]> granicus.if.org Git - php/commitdiff
Fix bug #47678 - Allow loadExtension to be disabled in SQLite3
authorScott MacVicar <scottmac@php.net>
Tue, 17 Mar 2009 02:42:41 +0000 (02:42 +0000)
committerScott MacVicar <scottmac@php.net>
Tue, 17 Mar 2009 02:42:41 +0000 (02:42 +0000)
ext/sqlite3/config0.m4
ext/sqlite3/sqlite3.c
ext/sqlite3/tests/sqlite3_22_loadextension.phpt

index 006d536f06731a0bb0fa835033368007fea9bfc9..8b3623d6b0c6b7c310ebb2476250fa918704fa7f 100644 (file)
@@ -51,6 +51,10 @@ if test $PHP_SQLITE3 != "no"; then
       AC_DEFINE(HAVE_SQLITE3_KEY, 1, [have commercial sqlite3 with crypto support])
     ])
 
+    PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension,[
+      AC_DEFINE(SQLITE_OMIT_LOAD_EXTENSION, 1, [have sqlite3 with extension support])
+    ])
+
   else
     AC_MSG_CHECKING([bundled sqlite3 library])
     AC_MSG_RESULT([yes])
index da409a655de34f5c0d867e868fdd27ca5c561279..fb3b7f09862eccdde49d3390a28fdd3abf7988fe 100644 (file)
@@ -281,6 +281,7 @@ PHP_METHOD(sqlite3, lastErrorMsg)
 }
 /* }}} */
 
+#ifndef SQLITE_OMIT_LOAD_EXTENSION
 /* {{{ proto bool SQLite3::loadExtension(String Shared Library)
    Attempts to load an SQLite extension library */
 PHP_METHOD(sqlite3, loadExtension)
@@ -343,6 +344,7 @@ PHP_METHOD(sqlite3, loadExtension)
        RETURN_TRUE;
 }
 /* }}} */
+#endif
 
 /* {{{ proto int SQLite3::changes() U
   Returns the number of database rows that were changed (or inserted or deleted) by the most recent SQL statement. */
@@ -1636,9 +1638,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_open, 0)
        ZEND_ARG_INFO(0, encryption_key)
 ZEND_END_ARG_INFO()
 
+#ifndef SQLITE_OMIT_LOAD_EXTENSION
 ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_loadextension, 0)
        ZEND_ARG_INFO(0, shared_library)
 ZEND_END_ARG_INFO()
+#endif
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_escapestring, 0, 0, 1)
        ZEND_ARG_INFO(0, value)
@@ -1717,7 +1721,9 @@ static zend_function_entry php_sqlite3_class_methods[] = {
        PHP_ME(sqlite3,         lastInsertRowID,        arginfo_sqlite3_void, ZEND_ACC_PUBLIC)
        PHP_ME(sqlite3,         lastErrorCode,          arginfo_sqlite3_void, ZEND_ACC_PUBLIC)
        PHP_ME(sqlite3,         lastErrorMsg,           arginfo_sqlite3_void, ZEND_ACC_PUBLIC)
+#ifndef SQLITE_OMIT_LOAD_EXTENSION
        PHP_ME(sqlite3,         loadExtension,          arginfo_sqlite3_loadextension, ZEND_ACC_PUBLIC)
+#endif
        PHP_ME(sqlite3,         changes,                        arginfo_sqlite3_void, ZEND_ACC_PUBLIC)
        PHP_ME(sqlite3,         escapeString,           arginfo_sqlite3_escapestring, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_ME(sqlite3,         prepare,                        arginfo_sqlite3_query, ZEND_ACC_PUBLIC)
index 8020921a425b56f029eefdbb20d92f6226b31b8b..091dcd4a59661a3c00e59560130dff857102ce0a 100644 (file)
@@ -1,7 +1,13 @@
 --TEST--
 SQLite3 load extension
 --SKIPIF--
-<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+<?php
+require_once(dirname(__FILE__) . '/skipif.inc');
+$r = new ReflectionClass("sqlite3");
+if (!$r->hasMethod("loadExtension")) {
+       die("skip - sqlite3 doesn't have loadExtension enabled");
+}
+?>
 --INI--
 open_basedir=.
 sqlite3.extension_dir=.