helly Tue Jan 9 18:38:38 2007 UTC
Modified files:
/php-src/ext/spl php_spl.c spl_array.c
/php-src/ext/spl/tests bug40036.phpt
/php-src/main main.c php_main.h
Log:
- MFH (Ilia's changes)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.106&r2=1.107&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.106 php-src/ext/spl/php_spl.c:1.107
--- php-src/ext/spl/php_spl.c:1.106 Mon Jan 1 09:29:29 2007
+++ php-src/ext/spl/php_spl.c Tue Jan 9 18:38:38 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.106 2007/01/01 09:29:29 sebastian Exp $ */
+/* $Id: php_spl.c,v 1.107 2007/01/09 18:38:38 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -24,6 +24,7 @@
#include "php.h"
#include "php_ini.h"
+#include "php_main.h"
#include "ext/standard/info.h"
#include "php_spl.h"
#include "spl_functions.h"
@@ -212,24 +213,12 @@
zend_file_handle file_handle;
zend_op_array *new_op_array;
zval *result = NULL;
- zval err_mode;
int ret;
/* UTODO: Wewant the stream toacept a zstrfor opening */
class_file_len = spprintf(&class_file, 0, "%v%v", lc_name,
file_extension);
- ZVAL_LONG(&err_mode, EG(error_reporting));
- if (Z_LVAL(err_mode)) {
- php_alter_ini_entry("error_reporting",
sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
- }
-
- ret = zend_stream_open(class_file, &file_handle TSRMLS_CC);
-
- if (!EG(error_reporting) && Z_LVAL(err_mode) != EG(error_reporting)) {
- convert_to_string(&err_mode);
- zend_alter_ini_entry("error_reporting",
sizeof("error_reporting"), Z_STRVAL(err_mode), Z_STRLEN(err_mode),
ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
- zendi_zval_dtor(err_mode);
- }
+ ret = php_stream_open_for_zend_ex(class_file, &file_handle,
ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
if (ret == SUCCESS) {
if (!file_handle.opened_path) {
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.116&r2=1.117&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.116 php-src/ext/spl/spl_array.c:1.117
--- php-src/ext/spl/spl_array.c:1.116 Tue Jan 2 18:15:22 2007
+++ php-src/ext/spl/spl_array.c Tue Jan 9 18:38:38 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.116 2007/01/02 18:15:22 helly Exp $ */
+/* $Id: spl_array.c,v 1.117 2007/01/09 18:38:38 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -481,7 +481,16 @@
switch(Z_TYPE_P(offset)) {
case IS_STRING:
case IS_UNICODE:
- return zend_u_symtable_exists(spl_array_get_hash_table(intern,
0 TSRMLS_CC), Z_TYPE_P(offset), Z_UNIVAL_P(offset), Z_UNILEN_P(offset)+1);
+ if (check_empty) {
+ zval **tmp;
+ HashTable *ht = spl_array_get_hash_table(intern, 0
TSRMLS_CC);
+ if (zend_u_hash_find(ht, Z_TYPE_P(offset),
Z_UNIVAL_P(offset), Z_UNILEN_P(offset)+1, (void **) &tmp) != FAILURE &&
zend_is_true(*tmp)) {
+ return 1;
+ }
+ return 0;
+ } else {
+ return
zend_u_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC),
Z_TYPE_P(offset), Z_UNIVAL_P(offset), Z_UNILEN_P(offset)+1);
+ }
case IS_DOUBLE:
case IS_RESOURCE:
case IS_BOOL:
@@ -491,7 +500,16 @@
} else {
index = Z_LVAL_P(offset);
}
- return zend_hash_index_exists(spl_array_get_hash_table(intern,
0 TSRMLS_CC), index);
+ if (check_empty) {
+ zval **tmp;
+ HashTable *ht = spl_array_get_hash_table(intern, 0
TSRMLS_CC);
+ if (zend_hash_index_find(ht, index, (void **)&tmp) !=
FAILURE && zend_is_true(*tmp)) {
+ return 1;
+ }
+ return 0;
+ } else {
+ return
zend_hash_index_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index);
+ }
default:
zend_error(E_WARNING, "Illegal offset type");
}
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug40036.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/spl/tests/bug40036.phpt
diff -u /dev/null php-src/ext/spl/tests/bug40036.phpt:1.2
--- /dev/null Tue Jan 9 18:38:38 2007
+++ php-src/ext/spl/tests/bug40036.phpt Tue Jan 9 18:38:38 2007
@@ -0,0 +1,34 @@
+--TEST--
+Bug #40036 (empty() does not work correctly with ArrayObject when using
ARRAY_AS_PROPS)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+class View extends ArrayObject
+{
+ public function __construct(array $array = array())
+ {
+ parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
+ }
+}
+
+$view = new View();
+$view->foo = false;
+$view->bar = null;
+$view->baz = '';
+if (empty($view['foo']) || empty($view->foo)) {
+ echo "View::foo empty\n";
+}
+if (empty($view['bar']) || empty($view->bar)) {
+ echo "View::bar empty\n";
+}
+if (empty($view['baz']) || empty($view->baz)) {
+ echo "View::baz empty\n";
+}
+?>
+===DONE===
+--EXPECT--
+View::foo empty
+View::bar empty
+View::baz empty
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.718&r2=1.719&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.718 php-src/main/main.c:1.719
--- php-src/main/main.c:1.718 Mon Jan 1 09:29:35 2007
+++ php-src/main/main.c Tue Jan 9 18:38:38 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.718 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: main.c,v 1.719 2007/01/09 18:38:38 helly Exp $ */
/* {{{ includes
*/
@@ -106,7 +106,7 @@
return SUCCESS;
} else {
return FAILURE;
-}
+ }
}
/* }}} */
@@ -1013,9 +1013,14 @@
static int php_stream_open_for_zend(const char *filename, zend_file_handle
*handle TSRMLS_DC)
{
+ return php_stream_open_for_zend_ex(filename, handle,
ENFORCE_SAFE_MODE|USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
+}
+
+PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle
*handle, int mode TSRMLS_DC)
+{
php_stream *stream;
- stream = php_stream_open_wrapper((char *)filename, "rb",
USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, &handle->opened_path);
+ stream = php_stream_open_wrapper((char *)filename, "rb", mode,
&handle->opened_path);
if (stream) {
handle->type = ZEND_HANDLE_STREAM;
@@ -1034,7 +1039,6 @@
return FAILURE;
}
-
/* {{{ php_get_configuration_directive_for_zend
*/
static int php_get_configuration_directive_for_zend(char *name, uint
name_length, zval *contents)
http://cvs.php.net/viewvc.cgi/php-src/main/php_main.h?r1=1.38&r2=1.39&diff_format=u
Index: php-src/main/php_main.h
diff -u php-src/main/php_main.h:1.38 php-src/main/php_main.h:1.39
--- php-src/main/php_main.h:1.38 Mon Jan 1 09:29:35 2007
+++ php-src/main/php_main.h Tue Jan 9 18:38:38 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_main.h,v 1.38 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: php_main.h,v 1.39 2007/01/09 18:38:38 helly Exp $ */
#ifndef PHP_MAIN_H
#define PHP_MAIN_H
@@ -47,6 +47,7 @@
PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC);
PHPAPI void php_html_puts(const char *str, uint siz TSRMLS_DC);
+PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle
*handle, int mode TSRMLS_DC);
extern void php_call_shutdown_functions(TSRMLS_D);
extern void php_free_shutdown_functions(TSRMLS_D);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php