Created
June 25, 2010 20:40
-
-
Save rsky/453412 to your computer and use it in GitHub Desktop.
php-5.3/ext/sqlite3をPHP 5.2で使うためのパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ur sqlite3-0.7-dev/php_sqlite3.h sqlite3-0.7-dev-php-5.2/php_sqlite3.h | |
--- sqlite3-0.7-dev/php_sqlite3.h 2010-01-03 18:23:27.000000000 +0900 | |
+++ sqlite3-0.7-dev-php-5.2/php_sqlite3.h 2010-06-26 05:58:21.000000000 +0900 | |
@@ -40,6 +40,17 @@ | |
#define PHP_SQLITE3_NUM 1<<1 | |
#define PHP_SQLITE3_BOTH (PHP_SQLITE3_ASSOC|PHP_SQLITE3_NUM) | |
+#define MAKE_COPY_ZVAL(ppzv, pzv) \ | |
+ *(pzv) = **(ppzv); \ | |
+ zval_copy_ctor((pzv)); \ | |
+ INIT_PZVAL((pzv)); | |
+ | |
+#define Z_ADDREF_P(pz) ++(pz)->refcount | |
+#define Z_DELREF_P(pz) --(pz)->refcount | |
+ | |
+#define zend_parse_parameters_none() \ | |
+ zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") | |
+ | |
#endif | |
/* | |
diff -ur sqlite3-0.7-dev/sqlite3.c sqlite3-0.7-dev-php-5.2/sqlite3.c | |
--- sqlite3-0.7-dev/sqlite3.c 2010-06-21 00:30:49.000000000 +0900 | |
+++ sqlite3-0.7-dev-php-5.2/sqlite3.c 2010-06-26 05:48:23.000000000 +0900 | |
@@ -98,17 +98,16 @@ | |
char *filename, *encryption_key, *fullpath; | |
int filename_len, encryption_key_len = 0; | |
long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; | |
- zend_error_handling error_handling; | |
db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); | |
- zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); | |
+ php_set_error_handling(EH_THROW, NULL TSRMLS_CC); | |
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) { | |
- zend_restore_error_handling(&error_handling TSRMLS_CC); | |
+ php_std_error_handling(); | |
return; | |
} | |
- zend_restore_error_handling(&error_handling TSRMLS_CC); | |
+ php_std_error_handling(); | |
if (db_obj->initialised) { | |
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Already initialised DB Object", 0 TSRMLS_CC); | |
@@ -696,7 +695,7 @@ | |
fc->fci.function_table = EG(function_table); | |
fc->fci.function_name = cb; | |
fc->fci.symbol_table = NULL; | |
- fc->fci.object_ptr = NULL; | |
+ fc->fci.object_pp = NULL; | |
fc->fci.retval_ptr_ptr = &retval; | |
fc->fci.param_count = fake_argc; | |
@@ -1462,14 +1461,13 @@ | |
zval *db_zval; | |
char *sql; | |
int sql_len, errcode; | |
- zend_error_handling error_handling; | |
php_sqlite3_free_list *free_item; | |
stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); | |
- zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); | |
+ php_set_error_handling(EH_THROW, NULL TSRMLS_CC); | |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &db_zval, php_sqlite3_sc_entry, &sql, &sql_len) == FAILURE) { | |
- zend_restore_error_handling(&error_handling TSRMLS_CC); | |
+ php_std_error_handling(); | |
return; | |
} | |
@@ -1477,7 +1475,7 @@ | |
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3) | |
- zend_restore_error_handling(&error_handling TSRMLS_CC); | |
+ php_std_error_handling(); | |
if (!sql_len) { | |
RETURN_FALSE; | |
@@ -1965,6 +1963,7 @@ | |
static zend_object_value php_sqlite3_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ | |
{ | |
+ zval *tmp; | |
zend_object_value retval; | |
php_sqlite3_db_object *intern; | |
@@ -1977,7 +1976,7 @@ | |
zend_llist_init(&(intern->free_list), sizeof(php_sqlite3_free_list *), (llist_dtor_func_t)php_sqlite3_free_list_dtor, 0); | |
zend_object_std_init(&intern->zo, class_type TSRMLS_CC); | |
- object_properties_init(&intern->zo, class_type); | |
+ zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); | |
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_sqlite3_object_free_storage, NULL TSRMLS_CC); | |
retval.handlers = (zend_object_handlers *) &sqlite3_object_handlers; | |
@@ -1988,6 +1987,7 @@ | |
static zend_object_value php_sqlite3_stmt_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ | |
{ | |
+ zval *tmp; | |
zend_object_value retval; | |
php_sqlite3_stmt *intern; | |
@@ -1998,7 +1998,7 @@ | |
intern->db_obj_zval = NULL; | |
zend_object_std_init(&intern->zo, class_type TSRMLS_CC); | |
- object_properties_init(&intern->zo, class_type); | |
+ zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); | |
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_sqlite3_stmt_object_free_storage, NULL TSRMLS_CC); | |
retval.handlers = (zend_object_handlers *) &sqlite3_stmt_object_handlers; | |
@@ -2009,6 +2009,7 @@ | |
static zend_object_value php_sqlite3_result_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ | |
{ | |
+ zval *tmp; | |
zend_object_value retval; | |
php_sqlite3_result *intern; | |
@@ -2021,7 +2022,7 @@ | |
intern->stmt_obj_zval = NULL; | |
zend_object_std_init(&intern->zo, class_type TSRMLS_CC); | |
- object_properties_init(&intern->zo, class_type); | |
+ zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *)); | |
retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_sqlite3_result_object_free_storage, NULL TSRMLS_CC); | |
retval.handlers = (zend_object_handlers *) &sqlite3_result_object_handlers; | |
diff -ur sqlite3-0.7-dev/tests/sqlite3_31_open.phpt sqlite3-0.7-dev-php-5.2/tests/sqlite3_31_open.phpt | |
--- sqlite3-0.7-dev/tests/sqlite3_31_open.phpt 2009-05-18 22:52:16.000000000 +0900 | |
+++ sqlite3-0.7-dev-php-5.2/tests/sqlite3_31_open.phpt 2010-06-26 06:00:23.000000000 +0900 | |
@@ -8,6 +8,7 @@ | |
--FILE-- | |
<?php | |
+define('__DIR__', realpath(dirname(__FILE__))); | |
try { | |
$db = new SQLite3(__DIR__ . '/db1.db'); | |
$db->open(__DIR__ . '/db1.db'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment