summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2013-02-25 16:29:09 +0100
committerOndřej Surý <ondrej@sury.org>2013-02-25 16:29:09 +0100
commit7ad1f708d5748e36de4b51088b377907e5ea01e7 (patch)
tree3f8a4c034747c921baf3b4118e2cc6ccc875fe43 /ext/spl
parent54098cf044025ec5965b8ea9c84750f9631d85b6 (diff)
downloadphp-7ad1f708d5748e36de4b51088b377907e5ea01e7.tar.gz
Imported Upstream version 5.5.0~alpha5upstream/5.5.0_alpha5
Diffstat (limited to 'ext/spl')
-rw-r--r--ext/spl/spl_array.c6
-rw-r--r--ext/spl/spl_directory.c4
-rw-r--r--ext/spl/spl_fixedarray.c6
-rw-r--r--ext/spl/tests/bug64023.phpt20
-rw-r--r--ext/spl/tests/bug64106.phpt15
-rw-r--r--ext/spl/tests/bug64228.phpt25
6 files changed, 74 insertions, 2 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 479c14839..40efc4391 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -381,7 +381,11 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
if (intern->fptr_offset_get) {
zval *rv;
- SEPARATE_ARG_IF_REF(offset);
+ if (!offset) {
+ ALLOC_INIT_ZVAL(offset);
+ } else {
+ SEPARATE_ARG_IF_REF(offset);
+ }
zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", &rv, offset);
zval_ptr_dtor(&offset);
if (rv) {
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 61d6324d5..f43a3709e 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1874,6 +1874,10 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(readobj TSRMLS_CC);
if (type == IS_STRING) {
+ if (Z_OBJCE_P(readobj)->__tostring) {
+ return std_object_handlers.cast_object(readobj, writeobj, type TSRMLS_CC);
+ }
+
switch (intern->type) {
case SPL_FS_INFO:
case SPL_FS_FILE:
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 1d51e0fb6..c9aec753c 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -378,7 +378,11 @@ static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, in
if (intern->fptr_offset_get) {
zval *rv;
- SEPARATE_ARG_IF_REF(offset);
+ if (!offset) {
+ ALLOC_INIT_ZVAL(offset);
+ } else {
+ SEPARATE_ARG_IF_REF(offset);
+ }
zend_call_method_with_1_params(&object, intern->std.ce, &intern->fptr_offset_get, "offsetGet", &rv, offset);
zval_ptr_dtor(&offset);
if (rv) {
diff --git a/ext/spl/tests/bug64023.phpt b/ext/spl/tests/bug64023.phpt
new file mode 100644
index 000000000..2c177f951
--- /dev/null
+++ b/ext/spl/tests/bug64023.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #64023: Overloading __toString() in SplFileInfo has no effect
+--FILE--
+<?php
+class A extends \SplFileInfo
+{
+ public function __toString() {return ' -expected- ';}
+}
+
+$a = new A('/');
+
+// Works
+echo $a, $a->__toString(), $a->__toString() . '', "\n";
+
+// Does not work - outputs parent::__toString()
+echo $a . '', "\n";
+
+--EXPECT--
+ -expected- -expected- -expected-
+ -expected-
diff --git a/ext/spl/tests/bug64106.phpt b/ext/spl/tests/bug64106.phpt
new file mode 100644
index 000000000..855caef21
--- /dev/null
+++ b/ext/spl/tests/bug64106.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #64106: Segfault on SplFixedArray[][x] = y when extended
+--FILE--
+<?php
+
+class MyFixedArray extends SplFixedArray {
+ public function offsetGet($offset) {}
+}
+
+$array = new MyFixedArray(10);
+$array[][1] = 10;
+
+?>
+--EXPECTF--
+Notice: Indirect modification of overloaded element of MyFixedArray has no effect in %s on line %d
diff --git a/ext/spl/tests/bug64228.phpt b/ext/spl/tests/bug64228.phpt
new file mode 100644
index 000000000..3f30dd2b2
--- /dev/null
+++ b/ext/spl/tests/bug64228.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS)
+--FILE--
+<?php
+$dirs = array();
+$empty_dir = __DIR__ . "/empty";
+@mkdir($empty_dir);
+
+$i = new RecursiveDirectoryIterator($empty_dir, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO); // Note the absence of FilesystemIterator::SKIP_DOTS
+foreach ($i as $key => $value) {
+ $dirs[] = $value->getFileName();
+}
+
+@rmdir($empty_dir);
+
+sort($dirs);
+print_r($dirs);
+?>
+--EXPECT--
+Array
+(
+ [0] => .
+ [1] => ..
+)
+