diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-08-20 08:34:35 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-08-20 08:34:35 +0200 |
commit | 45c0aa447e02c80bd21a23245574231a110cf5a1 (patch) | |
tree | b801de455f164afbf40fbbc995ab9751163eee84 /ext | |
parent | 3365f28adf90110ca7475df889720fc244820f4b (diff) | |
download | php-45c0aa447e02c80bd21a23245574231a110cf5a1.tar.gz |
Imported Upstream version 5.4.6upstream/5.4.6
Diffstat (limited to 'ext')
290 files changed, 2376 insertions, 338 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index b03f346b5..d7d5c51c4 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2177,7 +2177,7 @@ string_copy: convert_to_string_ex(zvalue); - if (!Z_STRLEN_PP(zvalue) || php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { + if (Z_STRLEN_PP(zvalue) && php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) { RETVAL_FALSE; return 1; } diff --git a/ext/curl/tests/bug61948.phpt b/ext/curl/tests/bug61948.phpt index 23bbda7d5..00df07d73 100644 --- a/ext/curl/tests/bug61948.phpt +++ b/ext/curl/tests/bug61948.phpt @@ -16,7 +16,7 @@ open_basedir="/tmp" curl_close($ch); ?> --EXPECTF-- -bool(false) +bool(true) bool(true) Warning: curl_setopt(): open_basedir restriction in effect. File(/xxx/bar) is not within the allowed path(s): (/tmp) in %sbug61948.php on line %d diff --git a/ext/date/php_date.c b/ext/date/php_date.c index cd48de273..13e7b753d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3430,10 +3430,19 @@ zval *date_interval_read_property(zval *object, zval *member, int type, const ze zval_copy_ctor(&tmp_member); convert_to_string(&tmp_member); member = &tmp_member; + key = NULL; } obj = (php_interval_obj *)zend_objects_get_address(object TSRMLS_CC); + if (!obj->initialized) { + retval = (zend_get_std_object_handlers())->read_property(object, member, type, key TSRMLS_CC); + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; + } + #define GET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ value = obj->diff->n; \ @@ -3482,9 +3491,19 @@ void date_interval_write_property(zval *object, zval *member, zval *value, const zval_copy_ctor(&tmp_member); convert_to_string(&tmp_member); member = &tmp_member; + key = NULL; } + obj = (php_interval_obj *)zend_objects_get_address(object TSRMLS_CC); + if (!obj->initialized) { + (zend_get_std_object_handlers())->write_property(object, member, value, key TSRMLS_CC); + if (member == &tmp_member) { + zval_dtor(member); + } + return; + } + #define SET_VALUE_FROM_STRUCT(n,m) \ if (strcmp(Z_STRVAL_P(member), m) == 0) { \ if (value->type != IS_LONG) { \ diff --git a/ext/date/tests/bug62500.phpt b/ext/date/tests/bug62500.phpt new file mode 100644 index 000000000..695233201 --- /dev/null +++ b/ext/date/tests/bug62500.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #62500 (Segfault in DateInterval class when extended) +--INI-- +date.timezone=GMT +--FILE-- +<?php +class Crasher extends DateInterval { + public $foo; + public function __construct($time_spec) { + var_dump($this->foo); + $this->foo = 3; + var_dump($this->foo); + var_dump($this->{2}); + parent::__construct($time_spec); + } +} +try { + $c = new Crasher('blah'); +} catch (Exception $e) { + var_dump($e->getMessage()); +} +--EXPECTF-- +NULL +int(3) + +Notice: Undefined property: Crasher::$2 in %sbug62500.php on line %d +NULL +string(%s) "DateInterval::__construct(): Unknown or bad format (blah)" diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 70e7aff69..342854654 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -321,6 +321,7 @@ int dom_xpath_document_read(dom_object *obj, zval **retval TSRMLS_DC) xmlDoc *docp = NULL; xmlXPathContextPtr ctx; int ret; + zval *tmp; ctx = (xmlXPathContextPtr) obj->ptr; @@ -329,10 +330,16 @@ int dom_xpath_document_read(dom_object *obj, zval **retval TSRMLS_DC) } ALLOC_ZVAL(*retval); + tmp = *retval; + if (NULL == (*retval = php_dom_create_object((xmlNodePtr) docp, &ret, *retval, obj TSRMLS_CC))) { + FREE_ZVAL(tmp); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); return FAILURE; } + if (tmp != *retval) { + FREE_ZVAL(tmp); + } return SUCCESS; } /* }}} */ diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index 757ba04ac..e5e52f099 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -270,7 +270,7 @@ ZEND_GET_MODULE(fileinfo) PHP_MINFO_FUNCTION(fileinfo) { php_info_print_table_start(); - php_info_print_table_header(2, "fileinfo support", "enabled"); + php_info_print_table_row(2, "fileinfo support", "enabled"); php_info_print_table_row(2, "version", PHP_FILEINFO_VERSION); php_info_print_table_end(); } diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 48a02360b..30364fb97 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ -diff -u libmagic.orig/apprentice.c libmagic/apprentice.c ---- libmagic.orig/apprentice.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/apprentice.c 2012-04-22 18:57:16.215980866 +0200 +diff -u libmagic.origin/apprentice.c libmagic/apprentice.c +--- libmagic.origin/apprentice.c 2012-07-15 18:17:24.802087661 +0800 ++++ libmagic/apprentice.c 2012-07-15 18:22:49.650087425 +0800 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -271,7 +271,9 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c + size_t lineno = 0; + + php_stream *stream; -+ + +- FILE *f = fopen(ms->file = fn, "r"); +- if (f == NULL) { + TSRMLS_FETCH(); + +#if PHP_API_VERSION < 20100412 @@ -279,9 +281,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c +#else + stream = php_stream_open_wrapper((char *)fn, "rb", REPORT_ERRORS, NULL); +#endif - -- FILE *f = fopen(ms->file = fn, "r"); -- if (f == NULL) { ++ + if (stream == NULL) { if (errno != ENOENT) file_error(ms, errno, "cannot read magic file `%s'", @@ -312,8 +312,12 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } /* -@@ -757,20 +756,16 @@ - int errs = 0; +@@ -754,23 +753,19 @@ + apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, + const char *fn, int action) + { +- int errs = 0; ++ int errs = 0, mflen = 0; struct magic_entry *marray; uint32_t marraycount, i, mentrycount = 0, starttest; - size_t slen, files = 0, maxfiles = 0; @@ -352,7 +356,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } while ((d = readdir(dir)) != NULL) { - if (asprintf(&mfn, "%s/%s", fn, d->d_name) < 0) { -+ if (snprintf(mfn, sizeof(mfn), "%s/%s", fn, d->d_name) < 0) { ++ if ((mflen = snprintf(mfn, sizeof(mfn), "%s/%s", fn, d->d_name)) < 0) { file_oomem(ms, strlen(fn) + strlen(d->d_name) + 2); errs++; @@ -364,7 +368,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c continue; } if (files >= maxfiles) { -@@ -803,7 +799,6 @@ +@@ -803,20 +799,19 @@ if ((filearr = CAST(char **, realloc(filearr, mlen))) == NULL) { file_oomem(ms, mlen); @@ -372,6 +376,21 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c closedir(dir); errs++; goto out; + } + } +- filearr[files++] = mfn; ++ filearr[files++] = estrndup(mfn, mflen); + } + closedir(dir); + qsort(filearr, files, sizeof(*filearr), cmpstrp); + for (i = 0; i < files; i++) { + load_1(ms, action, filearr[i], &errs, &marray, + &marraycount); +- free(filearr[i]); ++ efree(filearr[i]); + } + free(filearr); + } else @@ -882,12 +877,7 @@ for (i = 0; i < marraycount; i++) mentrycount += marray[i].cont_count; @@ -386,18 +405,31 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c mentrycount = 0; for (i = 0; i < marraycount; i++) { -@@ -897,8 +887,8 @@ +@@ -896,9 +886,14 @@ + mentrycount += marray[i].cont_count; } out: - for (i = 0; i < marraycount; i++) +- for (i = 0; i < marraycount; i++) - free(marray[i].mp); - free(marray); -+ efree(marray[i].mp); -+ efree(marray); ++ for (i = 0; i < marraycount; i++) { ++ if (marray[i].mp) { ++ efree(marray[i].mp); ++ } ++ } ++ if (marray) { ++ efree(marray); ++ } if (errs) { *magicp = NULL; *nmagicp = 0; -@@ -1178,11 +1168,7 @@ +@@ -1175,14 +1170,13 @@ + return -1; + } + me = &(*mentryp)[*nmentryp - 1]; ++ if (me->mp == NULL) { ++ return -1; ++ } if (me->cont_count == me->max_count) { struct magic *nm; size_t cnt = me->max_count + ALLOC_CHUNK; @@ -410,7 +442,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c me->mp = m = nm; me->max_count = CAST(uint32_t, cnt); } -@@ -1194,23 +1180,13 @@ +@@ -1194,23 +1188,13 @@ struct magic_entry *mp; maxmagic += ALLOC_INCR; @@ -437,7 +469,18 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c me->mp = m; me->max_count = ALLOC_CHUNK; } else -@@ -1361,7 +1337,7 @@ +@@ -1353,6 +1337,10 @@ + if (m->type == FILE_INVALID) { + if (ms->flags & MAGIC_CHECK) + file_magwarn(ms, "type `%s' invalid", l); ++ if (me->mp) { ++ efree(me->mp); ++ me->mp = NULL; ++ } + return -1; + } + +@@ -1361,7 +1349,7 @@ m->mask_op = 0; if (*l == '~') { @@ -446,7 +489,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c m->mask_op |= FILE_OPINVERSE; else if (ms->flags & MAGIC_CHECK) file_magwarn(ms, "'~' invalid for string types"); -@@ -1370,7 +1346,7 @@ +@@ -1370,7 +1358,7 @@ m->str_range = 0; m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0; if ((op = get_op(*l)) != -1) { @@ -455,7 +498,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c uint64_t val; ++l; m->mask_op |= op; -@@ -1558,11 +1534,6 @@ +@@ -1558,11 +1546,6 @@ if (check_format(ms, m) == -1) return -1; } @@ -467,7 +510,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c m->mimetype[0] = '\0'; /* initialise MIME type to none */ if (m->cont_level == 0) ++(*nmentryp); /* make room for next */ -@@ -2195,56 +2166,68 @@ +@@ -2195,56 +2178,69 @@ /* * handle a compiled file. @@ -542,6 +585,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c + mm = emalloc((size_t)st.sb.st_size); + if (php_stream_read(stream, mm, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) { file_badread(ms); ++ ret = 1; goto error1; } -#define RET 1 @@ -559,7 +603,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c ptr = (uint32_t *)(void *)*magicp; if (*ptr != MAGICNO) { if (swap4(*ptr) != MAGICNO) { -@@ -2259,35 +2242,55 @@ +@@ -2259,35 +2255,55 @@ else version = ptr[1]; if (version != VERSIONNO) { @@ -631,7 +675,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c return -1; } -@@ -2301,42 +2304,49 @@ +@@ -2301,42 +2317,49 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, const char *fn) { @@ -639,10 +683,10 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c char *dbname; int rv = -1; + php_stream *stream; ++ ++ TSRMLS_FETCH(); - dbname = mkdbname(ms, fn, 1); -+ TSRMLS_FETCH(); -+ + dbname = mkdbname(ms, fn, 0); if (dbname == NULL) @@ -692,7 +736,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c return rv; } -@@ -2349,6 +2359,7 @@ +@@ -2349,6 +2372,7 @@ { const char *p, *q; char *buf; @@ -700,7 +744,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c if (strip) { if ((p = strrchr(fn, '/')) != NULL) -@@ -2370,14 +2381,14 @@ +@@ -2370,14 +2394,14 @@ q++; /* Compatibility with old code that looked in .mime */ if (ms->flags & MAGIC_MIME) { @@ -719,7 +763,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c /* Compatibility with old code that looked in .mime */ if (strstr(p, ".mime") != NULL) -@@ -2467,7 +2478,7 @@ +@@ -2467,7 +2491,7 @@ m->offset = swap4((uint32_t)m->offset); m->in_offset = swap4((uint32_t)m->in_offset); m->lineno = swap4((uint32_t)m->lineno); @@ -728,9 +772,9 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c m->str_range = swap4(m->str_range); m->str_flags = swap4(m->str_flags); } -diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c ---- libmagic.orig/ascmagic.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/ascmagic.c 2012-04-22 18:57:16.215980866 +0200 +diff -u libmagic.origin/ascmagic.c libmagic/ascmagic.c +--- libmagic.origin/ascmagic.c 2012-07-15 18:17:24.762087659 +0800 ++++ libmagic/ascmagic.c 2012-07-15 18:20:42.730087520 +0800 @@ -139,10 +139,8 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -754,9 +798,9 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } -diff -u libmagic.orig/cdf.c libmagic/cdf.c ---- libmagic.orig/cdf.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/cdf.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/cdf.c libmagic/cdf.c +--- libmagic.origin/cdf.c 2012-07-15 18:17:24.822087659 +0800 ++++ libmagic/cdf.c 2012-07-15 18:20:42.730087520 +0800 @@ -43,7 +43,17 @@ #include <err.h> #endif @@ -818,9 +862,9 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c cdf_print_elapsed_time(buf, sizeof(buf), tp); (void)fprintf(stderr, "timestamp %s\n", buf); } else { -diff -u libmagic.orig/cdf.h libmagic/cdf.h ---- libmagic.orig/cdf.h 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/cdf.h 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/cdf.h libmagic/cdf.h +--- libmagic.origin/cdf.h 2012-07-15 18:17:25.046087660 +0800 ++++ libmagic/cdf.h 2012-07-15 18:20:42.730087520 +0800 @@ -35,7 +35,7 @@ #ifndef _H_CDF_ #define _H_CDF_ @@ -856,9 +900,9 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h int cdf_read_header(const cdf_info_t *, cdf_header_t *); void cdf_swap_header(cdf_header_t *); void cdf_unpack_header(cdf_header_t *, char *); -diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c ---- libmagic.orig/cdf_time.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/cdf_time.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/cdf_time.c libmagic/cdf_time.c +--- libmagic.origin/cdf_time.c 2012-07-15 18:17:24.734087660 +0800 ++++ libmagic/cdf_time.c 2012-07-15 18:20:42.734087519 +0800 @@ -96,7 +96,7 @@ } @@ -915,9 +959,9 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL; static const char *ref = "Sat Apr 23 01:30:00 1977"; char *p, *q; -diff -u libmagic.orig/compress.c libmagic/compress.c ---- libmagic.orig/compress.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/compress.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/compress.c libmagic/compress.c +--- libmagic.origin/compress.c 2012-07-15 18:17:24.730087657 +0800 ++++ libmagic/compress.c 2012-07-15 18:20:42.734087519 +0800 @@ -32,6 +32,7 @@ * uncompress(method, old, n, newch) - uncompress old into new, * using method, return sizeof new @@ -1078,9 +1122,9 @@ diff -u libmagic.orig/compress.c libmagic/compress.c } -#endif +#endif /* if PHP_FILEINFO_UNCOMPRESS */ -diff -u libmagic.orig/file.h libmagic/file.h ---- libmagic.orig/file.h 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/file.h 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/file.h libmagic/file.h +--- libmagic.origin/file.h 2012-07-15 18:17:25.046087660 +0800 ++++ libmagic/file.h 2012-07-15 18:20:42.734087519 +0800 @@ -33,11 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1251,9 +1295,9 @@ diff -u libmagic.orig/file.h libmagic/file.h +#endif + #endif /* __file_h__ */ -diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c ---- libmagic.orig/fsmagic.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/fsmagic.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/fsmagic.c libmagic/fsmagic.c +--- libmagic.origin/fsmagic.c 2012-07-15 18:17:24.730087657 +0800 ++++ libmagic/fsmagic.c 2012-07-15 18:20:42.734087519 +0800 @@ -59,27 +59,21 @@ # define minor(dev) ((dev) & 0xff) #endif @@ -1576,9 +1620,9 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c } /* -diff -u libmagic.orig/funcs.c libmagic/funcs.c ---- libmagic.orig/funcs.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/funcs.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/funcs.c libmagic/funcs.c +--- libmagic.origin/funcs.c 2012-07-15 18:17:25.046087660 +0800 ++++ libmagic/funcs.c 2012-07-15 18:20:42.734087519 +0800 @@ -41,52 +41,42 @@ #if defined(HAVE_WCTYPE_H) #include <wctype.h> @@ -1872,9 +1916,10 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c + return rep_cnt; } + -diff -u libmagic.orig/magic.c libmagic/magic.c ---- libmagic.orig/magic.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/magic.c 2012-04-22 18:57:16.219978162 +0200 +Common subdirectories: libmagic.origin/.libs and libmagic/.libs +diff -u libmagic.origin/magic.c libmagic/magic.c +--- libmagic.origin/magic.c 2012-07-15 18:17:25.046087660 +0800 ++++ libmagic/magic.c 2012-07-15 18:20:42.734087519 +0800 @@ -25,11 +25,6 @@ * SUCH DAMAGE. */ @@ -2250,9 +2295,9 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) -diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/magic.h 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/magic.h libmagic/magic.h +--- libmagic.origin/magic.h 2012-07-15 18:17:24.734087660 +0800 ++++ libmagic/magic.h 2012-07-15 18:20:42.734087519 +0800 @@ -85,6 +85,7 @@ const char *magic_getpath(const char *, int); @@ -2269,20 +2314,20 @@ diff -u libmagic.orig/magic.h libmagic/magic.h int magic_list(magic_t, const char *); int magic_errno(magic_t); -diff -u libmagic.orig/print.c libmagic/print.c ---- libmagic.orig/print.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/print.c 2012-05-29 14:34:03.770376387 +0200 +diff -u libmagic.origin/print.c libmagic/print.c +--- libmagic.origin/print.c 2012-07-15 18:21:02.846087501 +0800 ++++ libmagic/print.c 2012-07-15 18:20:42.734087519 +0800 @@ -29,6 +29,9 @@ * print.c - debugging printout routines */ ++#define _GNU_SOURCE +#include "php.h" -+#include "main/snprintf.h" + #include "file.h" #ifndef lint -@@ -45,174 +48,21 @@ +@@ -46,174 +49,21 @@ #define SZOF(a) (sizeof(a) / sizeof(a[0])) @@ -2464,9 +2509,206 @@ diff -u libmagic.orig/print.c libmagic/print.c } protected const char * -diff -u libmagic.orig/readcdf.c libmagic/readcdf.c ---- libmagic.orig/readcdf.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/readcdf.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/print.c.rej libmagic/print.c.rej +--- libmagic.origin/print.c.rej 2012-07-15 18:17:24.762087659 +0800 ++++ libmagic/print.c.rej 2012-07-15 18:20:27.186087168 +0800 +@@ -1,12 +1,184 @@ +---- libmagic/print.c 2012-05-29 14:34:03.770376387 +0200 +-+++ libmagic.orig/print.c 2012-05-29 14:40:41.710960045 +0200 +-@@ -29,9 +29,6 @@ +- * print.c - debugging printout routines +- */ ++--- libmagic.orig/print.c 2012-05-29 14:40:41.710960045 +0200 +++++ libmagic/print.c 2012-05-29 14:34:03.770376387 +0200 ++@@ -48,174 +51,21 @@ + +--#include "php.h" +--#include "main/snprintf.h" ++ #define SZOF(a) (sizeof(a) / sizeof(a[0])) ++ ++-#ifndef COMPILE_ONLY ++-protected void ++-file_mdump(struct magic *m) ++-{ ++- private const char optyp[] = { FILE_OPS }; ++- ++- (void) fprintf(stderr, "%u: %.*s %u", m->lineno, ++- (m->cont_level & 7) + 1, ">>>>>>>>", m->offset); ++- ++- if (m->flag & INDIR) { ++- (void) fprintf(stderr, "(%s,", ++- /* Note: type is unsigned */ ++- (m->in_type < file_nnames) ? ++- file_names[m->in_type] : "*bad*"); ++- if (m->in_op & FILE_OPINVERSE) ++- (void) fputc('~', stderr); ++- (void) fprintf(stderr, "%c%u),", ++- ((size_t)(m->in_op & FILE_OPS_MASK) < ++- SZOF(optyp)) ? ++- optyp[m->in_op & FILE_OPS_MASK] : '?', ++- m->in_offset); ++- } ++- (void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "", ++- /* Note: type is unsigned */ ++- (m->type < file_nnames) ? file_names[m->type] : "*bad*"); ++- if (m->mask_op & FILE_OPINVERSE) ++- (void) fputc('~', stderr); ++- ++- if (IS_STRING(m->type)) { ++- if (m->str_flags) { ++- (void) fputc('/', stderr); ++- if (m->str_flags & STRING_COMPACT_WHITESPACE) ++- (void) fputc(CHAR_COMPACT_WHITESPACE, stderr); ++- if (m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE) ++- (void) fputc(CHAR_COMPACT_OPTIONAL_WHITESPACE, ++- stderr); ++- if (m->str_flags & STRING_IGNORE_LOWERCASE) ++- (void) fputc(CHAR_IGNORE_LOWERCASE, stderr); ++- if (m->str_flags & STRING_IGNORE_UPPERCASE) ++- (void) fputc(CHAR_IGNORE_UPPERCASE, stderr); ++- if (m->str_flags & REGEX_OFFSET_START) ++- (void) fputc(CHAR_REGEX_OFFSET_START, stderr); ++- if (m->str_flags & STRING_TEXTTEST) ++- (void) fputc(CHAR_TEXTTEST, stderr); ++- if (m->str_flags & STRING_BINTEST) ++- (void) fputc(CHAR_BINTEST, stderr); ++- if (m->str_flags & PSTRING_1_BE) ++- (void) fputc(CHAR_PSTRING_1_BE, stderr); ++- if (m->str_flags & PSTRING_2_BE) ++- (void) fputc(CHAR_PSTRING_2_BE, stderr); ++- if (m->str_flags & PSTRING_2_LE) ++- (void) fputc(CHAR_PSTRING_2_LE, stderr); ++- if (m->str_flags & PSTRING_4_BE) ++- (void) fputc(CHAR_PSTRING_4_BE, stderr); ++- if (m->str_flags & PSTRING_4_LE) ++- (void) fputc(CHAR_PSTRING_4_LE, stderr); ++- if (m->str_flags & PSTRING_LENGTH_INCLUDES_ITSELF) ++- (void) fputc( ++- CHAR_PSTRING_LENGTH_INCLUDES_ITSELF, ++- stderr); ++- } ++- if (m->str_range) ++- (void) fprintf(stderr, "/%u", m->str_range); ++- } ++- else { ++- if ((size_t)(m->mask_op & FILE_OPS_MASK) < SZOF(optyp)) ++- (void) fputc(optyp[m->mask_op & FILE_OPS_MASK], stderr); ++- else ++- (void) fputc('?', stderr); ++- ++- if (m->num_mask) { ++- (void) fprintf(stderr, "%.8llx", ++- (unsigned long long)m->num_mask); ++- } ++- } ++- (void) fprintf(stderr, ",%c", m->reln); ++- ++- if (m->reln != 'x') { ++- switch (m->type) { ++- case FILE_BYTE: ++- case FILE_SHORT: ++- case FILE_LONG: ++- case FILE_LESHORT: ++- case FILE_LELONG: ++- case FILE_MELONG: ++- case FILE_BESHORT: ++- case FILE_BELONG: ++- (void) fprintf(stderr, "%d", m->value.l); ++- break; ++- case FILE_BEQUAD: ++- case FILE_LEQUAD: ++- case FILE_QUAD: ++- (void) fprintf(stderr, "%" INT64_T_FORMAT "d", ++- (unsigned long long)m->value.q); ++- break; ++- case FILE_PSTRING: ++- case FILE_STRING: ++- case FILE_REGEX: ++- case FILE_BESTRING16: ++- case FILE_LESTRING16: ++- case FILE_SEARCH: ++- file_showstr(stderr, m->value.s, (size_t)m->vallen); ++- break; ++- case FILE_DATE: ++- case FILE_LEDATE: ++- case FILE_BEDATE: ++- case FILE_MEDATE: ++- (void)fprintf(stderr, "%s,", ++- file_fmttime(m->value.l, 1)); ++- break; ++- case FILE_LDATE: ++- case FILE_LELDATE: ++- case FILE_BELDATE: ++- case FILE_MELDATE: ++- (void)fprintf(stderr, "%s,", ++- file_fmttime(m->value.l, 0)); ++- break; ++- case FILE_QDATE: ++- case FILE_LEQDATE: ++- case FILE_BEQDATE: ++- (void)fprintf(stderr, "%s,", ++- file_fmttime((uint32_t)m->value.q, 1)); ++- break; ++- case FILE_QLDATE: ++- case FILE_LEQLDATE: ++- case FILE_BEQLDATE: ++- (void)fprintf(stderr, "%s,", ++- file_fmttime((uint32_t)m->value.q, 0)); ++- break; ++- case FILE_FLOAT: ++- case FILE_BEFLOAT: ++- case FILE_LEFLOAT: ++- (void) fprintf(stderr, "%G", m->value.f); ++- break; ++- case FILE_DOUBLE: ++- case FILE_BEDOUBLE: ++- case FILE_LEDOUBLE: ++- (void) fprintf(stderr, "%G", m->value.d); ++- break; ++- case FILE_DEFAULT: ++- /* XXX - do anything here? */ ++- break; ++- default: ++- (void) fputs("*bad*", stderr); ++- break; ++- } ++- } ++- (void) fprintf(stderr, ",\"%s\"]\n", m->desc); ++-} ++-#endif ++- ++ /*VARARGS*/ ++ protected void ++ file_magwarn(struct magic_set *ms, const char *f, ...) ++ { ++ va_list va; +++ char *expanded_format; +++ TSRMLS_FETCH(); ++ ++- /* cuz we use stdout for most, stderr here */ ++- (void) fflush(stdout); + - +- #include "file.h" ++- if (ms->file) ++- (void) fprintf(stderr, "%s, %lu: ", ms->file, ++- (unsigned long)ms->line); ++- (void) fprintf(stderr, "Warning: "); ++ va_start(va, f); ++- (void) vfprintf(stderr, f, va); +++ vasprintf(&expanded_format, f, va); ++ va_end(va); ++- (void) fputc('\n', stderr); +++ +++ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format); +++ +++ free(expanded_format); ++ } + +- #ifndef lint ++ protected const char * +diff -u libmagic.origin/readcdf.c libmagic/readcdf.c +--- libmagic.origin/readcdf.c 2012-07-15 18:17:24.734087660 +0800 ++++ libmagic/readcdf.c 2012-07-15 18:20:42.734087519 +0800 @@ -30,7 +30,11 @@ #endif @@ -2512,9 +2754,9 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c c = cdf_ctime(&ts.tv_sec); if ((ec = strchr(c, '\n')) != NULL) *ec = '\0'; -diff -u libmagic.orig/readelf.c libmagic/readelf.c ---- libmagic.orig/readelf.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/readelf.c 2012-04-22 18:57:16.219978162 +0200 +diff -u libmagic.origin/readelf.c libmagic/readelf.c +--- libmagic.origin/readelf.c 2012-07-15 18:17:25.046087660 +0800 ++++ libmagic/readelf.c 2012-07-15 18:20:42.734087519 +0800 @@ -49,7 +49,7 @@ off_t, int *, int); private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, @@ -2669,9 +2911,9 @@ diff -u libmagic.orig/readelf.c libmagic/readelf.c fd = file_pipe2file(ms, fd, buf, nbytes); if (fstat(fd, &st) == -1) { -diff -u libmagic.orig/softmagic.c libmagic/softmagic.c ---- libmagic.orig/softmagic.c 2012-05-29 14:40:41.710960045 +0200 -+++ libmagic/softmagic.c 2012-05-29 14:34:31.900417647 +0200 +diff -u libmagic.origin/softmagic.c libmagic/softmagic.c +--- libmagic.origin/softmagic.c 2012-07-15 18:17:24.722087658 +0800 ++++ libmagic/softmagic.c 2012-07-15 18:20:42.734087519 +0800 @@ -41,6 +41,11 @@ #include <stdlib.h> #include <time.h> diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index 4a54849e0..98bde27a2 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -753,7 +753,7 @@ private int apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, const char *fn, int action) { - int errs = 0; + int errs = 0, mflen = 0; struct magic_entry *marray; uint32_t marraycount, i, mentrycount = 0, starttest; size_t files = 0, maxfiles = 0; @@ -782,7 +782,7 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, goto out; } while ((d = readdir(dir)) != NULL) { - if (snprintf(mfn, sizeof(mfn), "%s/%s", fn, d->d_name) < 0) { + if ((mflen = snprintf(mfn, sizeof(mfn), "%s/%s", fn, d->d_name)) < 0) { file_oomem(ms, strlen(fn) + strlen(d->d_name) + 2); errs++; @@ -804,14 +804,14 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, goto out; } } - filearr[files++] = mfn; + filearr[files++] = estrndup(mfn, mflen); } closedir(dir); qsort(filearr, files, sizeof(*filearr), cmpstrp); for (i = 0; i < files; i++) { load_1(ms, action, filearr[i], &errs, &marray, &marraycount); - free(filearr[i]); + efree(filearr[i]); } free(filearr); } else @@ -886,9 +886,14 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, mentrycount += marray[i].cont_count; } out: - for (i = 0; i < marraycount; i++) - efree(marray[i].mp); - efree(marray); + for (i = 0; i < marraycount; i++) { + if (marray[i].mp) { + efree(marray[i].mp); + } + } + if (marray) { + efree(marray); + } if (errs) { *magicp = NULL; *nmagicp = 0; @@ -1165,6 +1170,9 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp, return -1; } me = &(*mentryp)[*nmentryp - 1]; + if (me->mp == NULL) { + return -1; + } if (me->cont_count == me->max_count) { struct magic *nm; size_t cnt = me->max_count + ALLOC_CHUNK; @@ -1329,6 +1337,10 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp, if (m->type == FILE_INVALID) { if (ms->flags & MAGIC_CHECK) file_magwarn(ms, "type `%s' invalid", l); + if (me->mp) { + efree(me->mp); + me->mp = NULL; + } return -1; } @@ -2219,6 +2231,7 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, mm = emalloc((size_t)st.sb.st_size); if (php_stream_read(stream, mm, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) { file_badread(ms); + ret = 1; goto error1; } ret = 1; diff --git a/ext/fileinfo/tests/bug61964.phpt b/ext/fileinfo/tests/bug61964.phpt new file mode 100644 index 000000000..99c8fd2ae --- /dev/null +++ b/ext/fileinfo/tests/bug61964.phpt @@ -0,0 +1,69 @@ +--TEST-- +Bug #61964 (finfo_open with directory cause invalid free) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$magic_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic'; + +$ret = @finfo_open(FILEINFO_NONE, $magic_file . ".non-exits"); +var_dump($ret); + +$dir = __DIR__ . "/test-folder"; +@mkdir($dir); + +$magic_file_copy = $dir . "/magic.copy"; +$magic_file_copy2 = $magic_file_copy . "2"; +copy($magic_file, $magic_file_copy); +copy($magic_file, $magic_file_copy2); + +$ret = finfo_open(FILEINFO_NONE, $dir); +var_dump($ret); + +$ret = @finfo_open(FILEINFO_NONE, $dir); +var_dump($ret); + +$ret = @finfo_open(FILEINFO_NONE, $dir. "/non-exits-dir"); +var_dump($ret); + +// write some test files to test folder +file_put_contents($dir . "/test1.txt", "string\n> Core\n> Me"); +file_put_contents($dir . "/test2.txt", "a\nb\n"); +@mkdir($dir . "/test-inner-folder"); + +finfo_open(FILEINFO_NONE, $dir); +echo "DONE: testing dir with files\n"; + +rmdir($dir . "/test-inner-folder"); +unlink($dir . "/test1.txt"); +unlink($dir . "/test2.txt"); + +unlink($magic_file_copy); +unlink($magic_file_copy2); +rmdir($dir); +?> +===DONE=== +--EXPECTF-- +bool(false) +resource(%d) of type (file_info) +resource(%d) of type (file_info) +bool(false) + +Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964.php on line %d + +Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964.php on line %d + +Notice: finfo_open(): Warning: type `Core' invalid in %sbug61964.php on line %d + +Notice: finfo_open(): Warning: offset `a' invalid in %sbug61964.php on line %d + +Notice: finfo_open(): Warning: type `a' invalid in %sbug61964.php on line %d + +Notice: finfo_open(): Warning: offset `b' invalid in %sbug61964.php on line %d + +Notice: finfo_open(): Warning: type `b' invalid in %sbug61964.php on line %d + +Warning: finfo_open(): Failed to load magic database at '%stest-folder'. in %sbug61964.php on line %d +DONE: testing dir with files +===DONE=== diff --git a/ext/fileinfo/tests/finfo_open_error-win32.phpt b/ext/fileinfo/tests/finfo_open_error-win32.phpt index e168b7f7d..0260ca570 100644 --- a/ext/fileinfo/tests/finfo_open_error-win32.phpt +++ b/ext/fileinfo/tests/finfo_open_error-win32.phpt @@ -43,13 +43,7 @@ bool(false) Warning: finfo_open() expects at most 2 parameters, 3 given in %sfinfo_open_error-win32.php on line %d bool(false) - -Warning: finfo_open(%smagic): failed to open stream: No such file or directory in %sfinfo_open_error-win32.php on line %d - -Warning: finfo_open(%smagic): failed to open stream: No such file or directory in %sfinfo_open_error-win32.php on line %d - -Warning: finfo_open(): Failed to load magic database at '%smagic'. in %sfinfo_open_error-win32.php on line %d -bool(false) +resource(6) of type (file_info) Warning: finfo_open() expects parameter 1 to be long, string given in %sfinfo_open_error-win32.php on line %d bool(false) diff --git a/ext/intl/CREDITS b/ext/intl/CREDITS index 0e7fd55dc..0e7fd55dc 100755..100644 --- a/ext/intl/CREDITS +++ b/ext/intl/CREDITS diff --git a/ext/intl/TODO b/ext/intl/TODO index 6fd1b2781..6fd1b2781 100755..100644 --- a/ext/intl/TODO +++ b/ext/intl/TODO diff --git a/ext/intl/collator/collator.c b/ext/intl/collator/collator.c index 047a73802..047a73802 100755..100644 --- a/ext/intl/collator/collator.c +++ b/ext/intl/collator/collator.c diff --git a/ext/intl/collator/collator.h b/ext/intl/collator/collator.h index 96e7aa097..96e7aa097 100755..100644 --- a/ext/intl/collator/collator.h +++ b/ext/intl/collator/collator.h diff --git a/ext/intl/collator/collator_attr.c b/ext/intl/collator/collator_attr.c index 684e72cc5..684e72cc5 100755..100644 --- a/ext/intl/collator/collator_attr.c +++ b/ext/intl/collator/collator_attr.c diff --git a/ext/intl/collator/collator_attr.h b/ext/intl/collator/collator_attr.h index 85636cc48..85636cc48 100755..100644 --- a/ext/intl/collator/collator_attr.h +++ b/ext/intl/collator/collator_attr.h diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c index de744dcef..d1fa10ef2 100755..100644 --- a/ext/intl/collator/collator_class.c +++ b/ext/intl/collator/collator_class.c @@ -67,6 +67,7 @@ zend_object_value Collator_object_create( intern = ecalloc( 1, sizeof(Collator_object) ); intl_error_init( COLLATOR_ERROR_P( intern ) TSRMLS_CC ); zend_object_std_init( &intern->zo, ce TSRMLS_CC ); + object_properties_init(&intern->zo, ce); retval.handle = zend_objects_store_put( intern, diff --git a/ext/intl/collator/collator_class.h b/ext/intl/collator/collator_class.h index 835abd66c..835abd66c 100755..100644 --- a/ext/intl/collator/collator_class.h +++ b/ext/intl/collator/collator_class.h diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.c index 4384558ac..4384558ac 100755..100644 --- a/ext/intl/collator/collator_compare.c +++ b/ext/intl/collator/collator_compare.c diff --git a/ext/intl/collator/collator_compare.h b/ext/intl/collator/collator_compare.h index 4e38b7930..4e38b7930 100755..100644 --- a/ext/intl/collator/collator_compare.h +++ b/ext/intl/collator/collator_compare.h diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c index e989d4c65..e989d4c65 100755..100644 --- a/ext/intl/collator/collator_convert.c +++ b/ext/intl/collator/collator_convert.c diff --git a/ext/intl/collator/collator_convert.h b/ext/intl/collator/collator_convert.h index 8322ea998..8322ea998 100755..100644 --- a/ext/intl/collator/collator_convert.h +++ b/ext/intl/collator/collator_convert.h diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c index 0f0cc193e..0f0cc193e 100755..100644 --- a/ext/intl/collator/collator_create.c +++ b/ext/intl/collator/collator_create.c diff --git a/ext/intl/collator/collator_create.h b/ext/intl/collator/collator_create.h index b740e82d6..b740e82d6 100755..100644 --- a/ext/intl/collator/collator_create.h +++ b/ext/intl/collator/collator_create.h diff --git a/ext/intl/collator/collator_error.c b/ext/intl/collator/collator_error.c index c4e41250a..c4e41250a 100755..100644 --- a/ext/intl/collator/collator_error.c +++ b/ext/intl/collator/collator_error.c diff --git a/ext/intl/collator/collator_error.h b/ext/intl/collator/collator_error.h index b2f44ea2a..b2f44ea2a 100755..100644 --- a/ext/intl/collator/collator_error.h +++ b/ext/intl/collator/collator_error.h diff --git a/ext/intl/collator/collator_is_numeric.c b/ext/intl/collator/collator_is_numeric.c index a8abfac12..a8abfac12 100755..100644 --- a/ext/intl/collator/collator_is_numeric.c +++ b/ext/intl/collator/collator_is_numeric.c diff --git a/ext/intl/collator/collator_is_numeric.h b/ext/intl/collator/collator_is_numeric.h index 585d58917..585d58917 100755..100644 --- a/ext/intl/collator/collator_is_numeric.h +++ b/ext/intl/collator/collator_is_numeric.h diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c index b30b021ee..b30b021ee 100755..100644 --- a/ext/intl/collator/collator_locale.c +++ b/ext/intl/collator/collator_locale.c diff --git a/ext/intl/collator/collator_locale.h b/ext/intl/collator/collator_locale.h index bda90cd3b..bda90cd3b 100755..100644 --- a/ext/intl/collator/collator_locale.h +++ b/ext/intl/collator/collator_locale.h diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index 0785111c9..0785111c9 100755..100644 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c diff --git a/ext/intl/collator/collator_sort.h b/ext/intl/collator/collator_sort.h index a990cdf08..a990cdf08 100755..100644 --- a/ext/intl/collator/collator_sort.h +++ b/ext/intl/collator/collator_sort.h diff --git a/ext/intl/common/common_error.c b/ext/intl/common/common_error.c index a0ee7c145..a0ee7c145 100755..100644 --- a/ext/intl/common/common_error.c +++ b/ext/intl/common/common_error.c diff --git a/ext/intl/common/common_error.h b/ext/intl/common/common_error.h index 871622212..871622212 100755..100644 --- a/ext/intl/common/common_error.h +++ b/ext/intl/common/common_error.h diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 index 0477c7f59..0477c7f59 100755..100644 --- a/ext/intl/config.m4 +++ b/ext/intl/config.m4 diff --git a/ext/intl/config.w32 b/ext/intl/config.w32 index 437fedb7d..437fedb7d 100755..100644 --- a/ext/intl/config.w32 +++ b/ext/intl/config.w32 diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c index b399a39fc..b399a39fc 100755..100644 --- a/ext/intl/dateformat/dateformat.c +++ b/ext/intl/dateformat/dateformat.c diff --git a/ext/intl/dateformat/dateformat.h b/ext/intl/dateformat/dateformat.h index f11918b79..f11918b79 100755..100644 --- a/ext/intl/dateformat/dateformat.h +++ b/ext/intl/dateformat/dateformat.h diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c index 6131cedc9..6131cedc9 100755..100644 --- a/ext/intl/dateformat/dateformat_attr.c +++ b/ext/intl/dateformat/dateformat_attr.c diff --git a/ext/intl/dateformat/dateformat_attr.h b/ext/intl/dateformat/dateformat_attr.h index bf28824d6..bf28824d6 100755..100644 --- a/ext/intl/dateformat/dateformat_attr.h +++ b/ext/intl/dateformat/dateformat_attr.h diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index c66610f23..a9e06c147 100755..100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -63,6 +63,7 @@ zend_object_value IntlDateFormatter_object_create(zend_class_entry *ce TSRMLS_DC intern = ecalloc( 1, sizeof(IntlDateFormatter_object) ); dateformat_data_init( &intern->datef_data TSRMLS_CC ); zend_object_std_init( &intern->zo, ce TSRMLS_CC ); + object_properties_init(&intern->zo, ce); intern->date_type = 0; intern->time_type = 0; intern->calendar = 1; /* Gregorian calendar */ diff --git a/ext/intl/dateformat/dateformat_class.h b/ext/intl/dateformat/dateformat_class.h index 9ad83ee3d..9ad83ee3d 100755..100644 --- a/ext/intl/dateformat/dateformat_class.h +++ b/ext/intl/dateformat/dateformat_class.h diff --git a/ext/intl/dateformat/dateformat_data.c b/ext/intl/dateformat/dateformat_data.c index 33451e1c5..33451e1c5 100755..100644 --- a/ext/intl/dateformat/dateformat_data.c +++ b/ext/intl/dateformat/dateformat_data.c diff --git a/ext/intl/dateformat/dateformat_data.h b/ext/intl/dateformat/dateformat_data.h index cde9e363c..cde9e363c 100755..100644 --- a/ext/intl/dateformat/dateformat_data.h +++ b/ext/intl/dateformat/dateformat_data.h diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c index 4d03d924c..4d03d924c 100755..100644 --- a/ext/intl/dateformat/dateformat_format.c +++ b/ext/intl/dateformat/dateformat_format.c diff --git a/ext/intl/dateformat/dateformat_format.h b/ext/intl/dateformat/dateformat_format.h index 49f34c689..49f34c689 100755..100644 --- a/ext/intl/dateformat/dateformat_format.h +++ b/ext/intl/dateformat/dateformat_format.h diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c index 4193e8901..4193e8901 100755..100644 --- a/ext/intl/dateformat/dateformat_parse.c +++ b/ext/intl/dateformat/dateformat_parse.c diff --git a/ext/intl/dateformat/dateformat_parse.h b/ext/intl/dateformat/dateformat_parse.h index c74a3d5f1..c74a3d5f1 100755..100644 --- a/ext/intl/dateformat/dateformat_parse.h +++ b/ext/intl/dateformat/dateformat_parse.h diff --git a/ext/intl/doc/Tutorial.txt b/ext/intl/doc/Tutorial.txt index 4a66dc184..4a66dc184 100755..100644 --- a/ext/intl/doc/Tutorial.txt +++ b/ext/intl/doc/Tutorial.txt diff --git a/ext/intl/doc/collator_api.php b/ext/intl/doc/collator_api.php index ef7250243..ef7250243 100755..100644 --- a/ext/intl/doc/collator_api.php +++ b/ext/intl/doc/collator_api.php diff --git a/ext/intl/doc/common_api.php b/ext/intl/doc/common_api.php index 993dab180..993dab180 100755..100644 --- a/ext/intl/doc/common_api.php +++ b/ext/intl/doc/common_api.php diff --git a/ext/intl/doc/datefmt_api.php b/ext/intl/doc/datefmt_api.php index 272abdb57..272abdb57 100755..100644 --- a/ext/intl/doc/datefmt_api.php +++ b/ext/intl/doc/datefmt_api.php diff --git a/ext/intl/doc/formatter_api.php b/ext/intl/doc/formatter_api.php index 14d98db66..14d98db66 100755..100644 --- a/ext/intl/doc/formatter_api.php +++ b/ext/intl/doc/formatter_api.php diff --git a/ext/intl/doc/grapheme_api.php b/ext/intl/doc/grapheme_api.php index 465453fd3..465453fd3 100755..100644 --- a/ext/intl/doc/grapheme_api.php +++ b/ext/intl/doc/grapheme_api.php diff --git a/ext/intl/doc/locale_api.php b/ext/intl/doc/locale_api.php index c6c41ede0..c6c41ede0 100755..100644 --- a/ext/intl/doc/locale_api.php +++ b/ext/intl/doc/locale_api.php diff --git a/ext/intl/doc/msgfmt_api.php b/ext/intl/doc/msgfmt_api.php index e4d047b97..e4d047b97 100755..100644 --- a/ext/intl/doc/msgfmt_api.php +++ b/ext/intl/doc/msgfmt_api.php diff --git a/ext/intl/doc/normalizer_api.php b/ext/intl/doc/normalizer_api.php index a9bb566e6..a9bb566e6 100755..100644 --- a/ext/intl/doc/normalizer_api.php +++ b/ext/intl/doc/normalizer_api.php diff --git a/ext/intl/formatter/formatter.c b/ext/intl/formatter/formatter.c index 1b7922ce0..1b7922ce0 100755..100644 --- a/ext/intl/formatter/formatter.c +++ b/ext/intl/formatter/formatter.c diff --git a/ext/intl/formatter/formatter.h b/ext/intl/formatter/formatter.h index 1f9ebead8..1f9ebead8 100755..100644 --- a/ext/intl/formatter/formatter.h +++ b/ext/intl/formatter/formatter.h diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.c index 448a9db72..448a9db72 100755..100644 --- a/ext/intl/formatter/formatter_attr.c +++ b/ext/intl/formatter/formatter_attr.c diff --git a/ext/intl/formatter/formatter_attr.h b/ext/intl/formatter/formatter_attr.h index c4bc94ce5..c4bc94ce5 100755..100644 --- a/ext/intl/formatter/formatter_attr.h +++ b/ext/intl/formatter/formatter_attr.h diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index 8fcda643b..28af14e5d 100755..100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -62,6 +62,7 @@ zend_object_value NumberFormatter_object_create(zend_class_entry *ce TSRMLS_DC) intern = ecalloc( 1, sizeof(NumberFormatter_object) ); formatter_data_init( &intern->nf_data TSRMLS_CC ); zend_object_std_init( &intern->zo, ce TSRMLS_CC ); + object_properties_init(&intern->zo, ce); retval.handle = zend_objects_store_put( intern, diff --git a/ext/intl/formatter/formatter_class.h b/ext/intl/formatter/formatter_class.h index cf1cb060c..cf1cb060c 100755..100644 --- a/ext/intl/formatter/formatter_class.h +++ b/ext/intl/formatter/formatter_class.h diff --git a/ext/intl/formatter/formatter_data.c b/ext/intl/formatter/formatter_data.c index 88f122f7c..88f122f7c 100755..100644 --- a/ext/intl/formatter/formatter_data.c +++ b/ext/intl/formatter/formatter_data.c diff --git a/ext/intl/formatter/formatter_data.h b/ext/intl/formatter/formatter_data.h index adc4818af..adc4818af 100755..100644 --- a/ext/intl/formatter/formatter_data.h +++ b/ext/intl/formatter/formatter_data.h diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index ce1c941e1..ce1c941e1 100755..100644 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c diff --git a/ext/intl/formatter/formatter_format.h b/ext/intl/formatter/formatter_format.h index 35fafd1ed..35fafd1ed 100755..100644 --- a/ext/intl/formatter/formatter_format.h +++ b/ext/intl/formatter/formatter_format.h diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c index 8fa17560b..8fa17560b 100755..100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.c diff --git a/ext/intl/formatter/formatter_main.h b/ext/intl/formatter/formatter_main.h index 7669e684a..7669e684a 100755..100644 --- a/ext/intl/formatter/formatter_main.h +++ b/ext/intl/formatter/formatter_main.h diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index 6f3a3a12b..6f3a3a12b 100755..100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.c diff --git a/ext/intl/formatter/formatter_parse.h b/ext/intl/formatter/formatter_parse.h index cb96c72b5..cb96c72b5 100755..100644 --- a/ext/intl/formatter/formatter_parse.h +++ b/ext/intl/formatter/formatter_parse.h diff --git a/ext/intl/grapheme/grapheme.h b/ext/intl/grapheme/grapheme.h index c0e697ac1..c0e697ac1 100755..100644 --- a/ext/intl/grapheme/grapheme.h +++ b/ext/intl/grapheme/grapheme.h diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index 475bbe418..475bbe418 100755..100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c index 92008554d..92008554d 100755..100644 --- a/ext/intl/grapheme/grapheme_util.c +++ b/ext/intl/grapheme/grapheme_util.c diff --git a/ext/intl/grapheme/grapheme_util.h b/ext/intl/grapheme/grapheme_util.h index c91aeaff7..c91aeaff7 100755..100644 --- a/ext/intl/grapheme/grapheme_util.h +++ b/ext/intl/grapheme/grapheme_util.h diff --git a/ext/intl/intl_common.h b/ext/intl/intl_common.h index 9424571d0..9424571d0 100755..100644 --- a/ext/intl/intl_common.h +++ b/ext/intl/intl_common.h diff --git a/ext/intl/intl_convert.c b/ext/intl/intl_convert.c index 92cdc4cef..92cdc4cef 100755..100644 --- a/ext/intl/intl_convert.c +++ b/ext/intl/intl_convert.c diff --git a/ext/intl/intl_convert.h b/ext/intl/intl_convert.h index 3fc03f4bb..3fc03f4bb 100755..100644 --- a/ext/intl/intl_convert.h +++ b/ext/intl/intl_convert.h diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h index 66ca27ae7..66ca27ae7 100755..100644 --- a/ext/intl/intl_data.h +++ b/ext/intl/intl_data.h diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index 9c2e13dfd..9c2e13dfd 100755..100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 3adae8547..3adae8547 100755..100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h diff --git a/ext/intl/locale/locale.c b/ext/intl/locale/locale.c index ffc463f39..ffc463f39 100755..100644 --- a/ext/intl/locale/locale.c +++ b/ext/intl/locale/locale.c diff --git a/ext/intl/locale/locale.h b/ext/intl/locale/locale.h index f3859c7a2..f3859c7a2 100755..100644 --- a/ext/intl/locale/locale.h +++ b/ext/intl/locale/locale.h diff --git a/ext/intl/locale/locale_class.c b/ext/intl/locale/locale_class.c index 432cfb28f..432cfb28f 100755..100644 --- a/ext/intl/locale/locale_class.c +++ b/ext/intl/locale/locale_class.c diff --git a/ext/intl/locale/locale_class.h b/ext/intl/locale/locale_class.h index cbddccbe1..cbddccbe1 100755..100644 --- a/ext/intl/locale/locale_class.h +++ b/ext/intl/locale/locale_class.h diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 1707c69f9..1707c69f9 100755..100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c diff --git a/ext/intl/locale/locale_methods.h b/ext/intl/locale/locale_methods.h index e88fac64b..e88fac64b 100755..100644 --- a/ext/intl/locale/locale_methods.h +++ b/ext/intl/locale/locale_methods.h diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index 0a01204fa..0a01204fa 100755..100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c diff --git a/ext/intl/msgformat/msgformat.h b/ext/intl/msgformat/msgformat.h index 205c7066f..205c7066f 100755..100644 --- a/ext/intl/msgformat/msgformat.h +++ b/ext/intl/msgformat/msgformat.h diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c index ed2dae27d..ed2dae27d 100755..100644 --- a/ext/intl/msgformat/msgformat_attr.c +++ b/ext/intl/msgformat/msgformat_attr.c diff --git a/ext/intl/msgformat/msgformat_attr.h b/ext/intl/msgformat/msgformat_attr.h index 898c4451e..898c4451e 100755..100644 --- a/ext/intl/msgformat/msgformat_attr.h +++ b/ext/intl/msgformat/msgformat_attr.h diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index d0138854e..8145a46f1 100755..100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -60,6 +60,7 @@ zend_object_value MessageFormatter_object_create(zend_class_entry *ce TSRMLS_DC) intern = ecalloc( 1, sizeof(MessageFormatter_object) ); msgformat_data_init( &intern->mf_data TSRMLS_CC ); zend_object_std_init( &intern->zo, ce TSRMLS_CC ); + object_properties_init(&intern->zo, ce); retval.handle = zend_objects_store_put( intern, diff --git a/ext/intl/msgformat/msgformat_class.h b/ext/intl/msgformat/msgformat_class.h index b6b8e3322..b6b8e3322 100755..100644 --- a/ext/intl/msgformat/msgformat_class.h +++ b/ext/intl/msgformat/msgformat_class.h diff --git a/ext/intl/msgformat/msgformat_data.c b/ext/intl/msgformat/msgformat_data.c index 527c1d4d1..527c1d4d1 100755..100644 --- a/ext/intl/msgformat/msgformat_data.c +++ b/ext/intl/msgformat/msgformat_data.c diff --git a/ext/intl/msgformat/msgformat_data.h b/ext/intl/msgformat/msgformat_data.h index 6479888f8..6479888f8 100755..100644 --- a/ext/intl/msgformat/msgformat_data.h +++ b/ext/intl/msgformat/msgformat_data.h diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index 9a18ac0a7..9a18ac0a7 100755..100644 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c diff --git a/ext/intl/msgformat/msgformat_format.h b/ext/intl/msgformat/msgformat_format.h index b74deab8f..b74deab8f 100755..100644 --- a/ext/intl/msgformat/msgformat_format.h +++ b/ext/intl/msgformat/msgformat_format.h diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index 1895de2c8..1895de2c8 100755..100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp diff --git a/ext/intl/msgformat/msgformat_helpers.h b/ext/intl/msgformat/msgformat_helpers.h index 30c7e3930..30c7e3930 100755..100644 --- a/ext/intl/msgformat/msgformat_helpers.h +++ b/ext/intl/msgformat/msgformat_helpers.h diff --git a/ext/intl/msgformat/msgformat_parse.c b/ext/intl/msgformat/msgformat_parse.c index f540b1d0c..f540b1d0c 100755..100644 --- a/ext/intl/msgformat/msgformat_parse.c +++ b/ext/intl/msgformat/msgformat_parse.c diff --git a/ext/intl/msgformat/msgformat_parse.h b/ext/intl/msgformat/msgformat_parse.h index a93723583..a93723583 100755..100644 --- a/ext/intl/msgformat/msgformat_parse.h +++ b/ext/intl/msgformat/msgformat_parse.h diff --git a/ext/intl/normalizer/normalizer.c b/ext/intl/normalizer/normalizer.c index 033b05cd3..033b05cd3 100755..100644 --- a/ext/intl/normalizer/normalizer.c +++ b/ext/intl/normalizer/normalizer.c diff --git a/ext/intl/normalizer/normalizer.h b/ext/intl/normalizer/normalizer.h index eca9abe05..eca9abe05 100755..100644 --- a/ext/intl/normalizer/normalizer.h +++ b/ext/intl/normalizer/normalizer.h diff --git a/ext/intl/normalizer/normalizer_class.c b/ext/intl/normalizer/normalizer_class.c index 154d877e3..154d877e3 100755..100644 --- a/ext/intl/normalizer/normalizer_class.c +++ b/ext/intl/normalizer/normalizer_class.c diff --git a/ext/intl/normalizer/normalizer_class.h b/ext/intl/normalizer/normalizer_class.h index 4d3f7d234..4d3f7d234 100755..100644 --- a/ext/intl/normalizer/normalizer_class.h +++ b/ext/intl/normalizer/normalizer_class.h diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c index f46285e9d..f46285e9d 100755..100644 --- a/ext/intl/normalizer/normalizer_normalize.c +++ b/ext/intl/normalizer/normalizer_normalize.c diff --git a/ext/intl/normalizer/normalizer_normalize.h b/ext/intl/normalizer/normalizer_normalize.h index 41c31f794..41c31f794 100755..100644 --- a/ext/intl/normalizer/normalizer_normalize.h +++ b/ext/intl/normalizer/normalizer_normalize.h diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index efe0ddd24..efe0ddd24 100755..100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h index 4ede069e2..4ede069e2 100755..100644 --- a/ext/intl/php_intl.h +++ b/ext/intl/php_intl.h diff --git a/ext/intl/resourcebundle/TODO b/ext/intl/resourcebundle/TODO index ace4ceb25..ace4ceb25 100755..100644 --- a/ext/intl/resourcebundle/TODO +++ b/ext/intl/resourcebundle/TODO diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 1205450c4..23e9449a3 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -63,6 +63,7 @@ static zend_object_value ResourceBundle_object_create( zend_class_entry *ce TSRM rb = ecalloc( 1, sizeof(ResourceBundle_object) ); zend_object_std_init( (zend_object *) rb, ce TSRMLS_CC ); + object_properties_init((zend_object *) rb, ce); intl_error_init( INTL_DATA_ERROR_P(rb) TSRMLS_CC ); rb->me = NULL; diff --git a/ext/intl/spoofchecker/spoofchecker.c b/ext/intl/spoofchecker/spoofchecker.c index 42a014a90..42a014a90 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker.c +++ b/ext/intl/spoofchecker/spoofchecker.c diff --git a/ext/intl/spoofchecker/spoofchecker.h b/ext/intl/spoofchecker/spoofchecker.h index f976d639a..f976d639a 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker.h +++ b/ext/intl/spoofchecker/spoofchecker.h diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index 6c19fbb0f..507a2ca98 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c @@ -61,6 +61,7 @@ zend_object_value Spoofchecker_object_create( intern = ecalloc(1, sizeof(Spoofchecker_object)); intl_error_init(SPOOFCHECKER_ERROR_P(intern) TSRMLS_CC); zend_object_std_init(&intern->zo, ce TSRMLS_CC); + object_properties_init(&intern->zo, ce); retval.handle = zend_objects_store_put( intern, diff --git a/ext/intl/spoofchecker/spoofchecker_class.h b/ext/intl/spoofchecker/spoofchecker_class.h index 8db64680e..8db64680e 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_class.h +++ b/ext/intl/spoofchecker/spoofchecker_class.h diff --git a/ext/intl/spoofchecker/spoofchecker_create.c b/ext/intl/spoofchecker/spoofchecker_create.c index 3659551ed..3659551ed 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_create.c +++ b/ext/intl/spoofchecker/spoofchecker_create.c diff --git a/ext/intl/spoofchecker/spoofchecker_create.h b/ext/intl/spoofchecker/spoofchecker_create.h index 313faab8a..313faab8a 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_create.h +++ b/ext/intl/spoofchecker/spoofchecker_create.h diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c index c37b9186a..c37b9186a 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_main.c +++ b/ext/intl/spoofchecker/spoofchecker_main.c diff --git a/ext/intl/spoofchecker/spoofchecker_main.h b/ext/intl/spoofchecker/spoofchecker_main.h index fb920d784..fb920d784 100755..100644 --- a/ext/intl/spoofchecker/spoofchecker_main.h +++ b/ext/intl/spoofchecker/spoofchecker_main.h diff --git a/ext/intl/tests/_files/es-bundle.txt b/ext/intl/tests/_files/es-bundle.txt index 46399a771..46399a771 100755..100644 --- a/ext/intl/tests/_files/es-bundle.txt +++ b/ext/intl/tests/_files/es-bundle.txt diff --git a/ext/intl/tests/_files/res_index.txt b/ext/intl/tests/_files/res_index.txt index a39bea58e..a39bea58e 100755..100644 --- a/ext/intl/tests/_files/res_index.txt +++ b/ext/intl/tests/_files/res_index.txt diff --git a/ext/intl/tests/_files/resourcebundle.txt b/ext/intl/tests/_files/resourcebundle.txt index 5b081da6c..5b081da6c 100755..100644 --- a/ext/intl/tests/_files/resourcebundle.txt +++ b/ext/intl/tests/_files/resourcebundle.txt diff --git a/ext/intl/tests/_files/resourcebundle/es.res b/ext/intl/tests/_files/resourcebundle/es.res Binary files differindex f9d891d6b..f9d891d6b 100755..100644 --- a/ext/intl/tests/_files/resourcebundle/es.res +++ b/ext/intl/tests/_files/resourcebundle/es.res diff --git a/ext/intl/tests/_files/resourcebundle/res_index.res b/ext/intl/tests/_files/resourcebundle/res_index.res Binary files differindex 9dd3df2de..9dd3df2de 100755..100644 --- a/ext/intl/tests/_files/resourcebundle/res_index.res +++ b/ext/intl/tests/_files/resourcebundle/res_index.res diff --git a/ext/intl/tests/_files/resourcebundle/root.res b/ext/intl/tests/_files/resourcebundle/root.res Binary files differindex 62cb48c45..62cb48c45 100755..100644 --- a/ext/intl/tests/_files/resourcebundle/root.res +++ b/ext/intl/tests/_files/resourcebundle/root.res diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt index 9232bbf0c..9232bbf0c 100755..100644 --- a/ext/intl/tests/badargs.phpt +++ b/ext/intl/tests/badargs.phpt diff --git a/ext/intl/tests/bug12887.phpt b/ext/intl/tests/bug12887.phpt index e2fc19494..e2fc19494 100755..100644 --- a/ext/intl/tests/bug12887.phpt +++ b/ext/intl/tests/bug12887.phpt diff --git a/ext/intl/tests/bug14562.phpt b/ext/intl/tests/bug14562.phpt index 325626840..325626840 100755..100644 --- a/ext/intl/tests/bug14562.phpt +++ b/ext/intl/tests/bug14562.phpt diff --git a/ext/intl/tests/bug62070.phpt b/ext/intl/tests/bug62070.phpt index a466b05c2..3ab0078d7 100644 --- a/ext/intl/tests/bug62070.phpt +++ b/ext/intl/tests/bug62070.phpt @@ -4,6 +4,8 @@ Bug #62070: Collator::getSortKey() returns garbage <?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip ICU >= 49 only'); --FILE-- <?php $s1 = 'Hello'; diff --git a/ext/intl/tests/collation_customization.phpt b/ext/intl/tests/collation_customization.phpt index e38038063..e38038063 100755..100644 --- a/ext/intl/tests/collation_customization.phpt +++ b/ext/intl/tests/collation_customization.phpt diff --git a/ext/intl/tests/collator_asort.phpt b/ext/intl/tests/collator_asort.phpt index a614ddc3f..a614ddc3f 100755..100644 --- a/ext/intl/tests/collator_asort.phpt +++ b/ext/intl/tests/collator_asort.phpt diff --git a/ext/intl/tests/collator_compare.phpt b/ext/intl/tests/collator_compare.phpt index f10b5708f..f10b5708f 100755..100644 --- a/ext/intl/tests/collator_compare.phpt +++ b/ext/intl/tests/collator_compare.phpt diff --git a/ext/intl/tests/collator_create.phpt b/ext/intl/tests/collator_create.phpt index eed8cf1b2..eed8cf1b2 100755..100644 --- a/ext/intl/tests/collator_create.phpt +++ b/ext/intl/tests/collator_create.phpt diff --git a/ext/intl/tests/collator_get_error_code.phpt b/ext/intl/tests/collator_get_error_code.phpt index 45a8e710f..45a8e710f 100755..100644 --- a/ext/intl/tests/collator_get_error_code.phpt +++ b/ext/intl/tests/collator_get_error_code.phpt diff --git a/ext/intl/tests/collator_get_error_message.phpt b/ext/intl/tests/collator_get_error_message.phpt index af4b9c382..af4b9c382 100755..100644 --- a/ext/intl/tests/collator_get_error_message.phpt +++ b/ext/intl/tests/collator_get_error_message.phpt diff --git a/ext/intl/tests/collator_get_locale.phpt b/ext/intl/tests/collator_get_locale.phpt index 68440f3ee..68440f3ee 100755..100644 --- a/ext/intl/tests/collator_get_locale.phpt +++ b/ext/intl/tests/collator_get_locale.phpt diff --git a/ext/intl/tests/collator_get_set_attribute.phpt b/ext/intl/tests/collator_get_set_attribute.phpt index b234790f8..b234790f8 100755..100644 --- a/ext/intl/tests/collator_get_set_attribute.phpt +++ b/ext/intl/tests/collator_get_set_attribute.phpt diff --git a/ext/intl/tests/collator_get_set_strength.phpt b/ext/intl/tests/collator_get_set_strength.phpt index 1f779441f..1f779441f 100755..100644 --- a/ext/intl/tests/collator_get_set_strength.phpt +++ b/ext/intl/tests/collator_get_set_strength.phpt diff --git a/ext/intl/tests/collator_get_sort_key.phpt b/ext/intl/tests/collator_get_sort_key.phpt index a9c4d7134..a9c4d7134 100755..100644 --- a/ext/intl/tests/collator_get_sort_key.phpt +++ b/ext/intl/tests/collator_get_sort_key.phpt diff --git a/ext/intl/tests/collator_sort.phpt b/ext/intl/tests/collator_sort.phpt index 5cefe2fd7..5cefe2fd7 100755..100644 --- a/ext/intl/tests/collator_sort.phpt +++ b/ext/intl/tests/collator_sort.phpt diff --git a/ext/intl/tests/collator_sort_with_sort_keys.phpt b/ext/intl/tests/collator_sort_with_sort_keys.phpt index 2f489d745..2f489d745 100755..100644 --- a/ext/intl/tests/collator_sort_with_sort_keys.phpt +++ b/ext/intl/tests/collator_sort_with_sort_keys.phpt diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index e5548196d..e5548196d 100755..100644 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt index bd41d715b..bd41d715b 100755..100644 --- a/ext/intl/tests/dateformat_format_parse.phpt +++ b/ext/intl/tests/dateformat_format_parse.phpt diff --git a/ext/intl/tests/dateformat_get_datetype.phpt b/ext/intl/tests/dateformat_get_datetype.phpt index 24d03898e..24d03898e 100755..100644 --- a/ext/intl/tests/dateformat_get_datetype.phpt +++ b/ext/intl/tests/dateformat_get_datetype.phpt diff --git a/ext/intl/tests/dateformat_get_locale.phpt b/ext/intl/tests/dateformat_get_locale.phpt index 17fcca355..17fcca355 100755..100644 --- a/ext/intl/tests/dateformat_get_locale.phpt +++ b/ext/intl/tests/dateformat_get_locale.phpt diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt index bfd4e578e..bfd4e578e 100755..100644 --- a/ext/intl/tests/dateformat_get_set_calendar.phpt +++ b/ext/intl/tests/dateformat_get_set_calendar.phpt diff --git a/ext/intl/tests/dateformat_get_set_pattern.phpt b/ext/intl/tests/dateformat_get_set_pattern.phpt index bd541c1c9..bd541c1c9 100755..100644 --- a/ext/intl/tests/dateformat_get_set_pattern.phpt +++ b/ext/intl/tests/dateformat_get_set_pattern.phpt diff --git a/ext/intl/tests/dateformat_get_timetype.phpt b/ext/intl/tests/dateformat_get_timetype.phpt index 2ddc1172b..2ddc1172b 100755..100644 --- a/ext/intl/tests/dateformat_get_timetype.phpt +++ b/ext/intl/tests/dateformat_get_timetype.phpt diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt index 80cbdbbf0..80cbdbbf0 100755..100644 --- a/ext/intl/tests/dateformat_get_timezone_id.phpt +++ b/ext/intl/tests/dateformat_get_timezone_id.phpt diff --git a/ext/intl/tests/dateformat_is_set_lenient.phpt b/ext/intl/tests/dateformat_is_set_lenient.phpt index 8492a2e2a..8492a2e2a 100755..100644 --- a/ext/intl/tests/dateformat_is_set_lenient.phpt +++ b/ext/intl/tests/dateformat_is_set_lenient.phpt diff --git a/ext/intl/tests/dateformat_localtime.phpt b/ext/intl/tests/dateformat_localtime.phpt index 79f297db7..79f297db7 100755..100644 --- a/ext/intl/tests/dateformat_localtime.phpt +++ b/ext/intl/tests/dateformat_localtime.phpt diff --git a/ext/intl/tests/dateformat_parse.phpt b/ext/intl/tests/dateformat_parse.phpt index ff5977348..ff5977348 100755..100644 --- a/ext/intl/tests/dateformat_parse.phpt +++ b/ext/intl/tests/dateformat_parse.phpt diff --git a/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt b/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt index 03f99f1d9..03f99f1d9 100755..100644 --- a/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt +++ b/ext/intl/tests/dateformat_parse_localtime_parsepos.phpt diff --git a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt index 0f2664316..0f2664316 100755..100644 --- a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt +++ b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt diff --git a/ext/intl/tests/dateformat_set_timezone_id.phpt b/ext/intl/tests/dateformat_set_timezone_id.phpt index 72a9230bd..72a9230bd 100755..100644 --- a/ext/intl/tests/dateformat_set_timezone_id.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id.phpt diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 295f01100..295f01100 100755..100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt diff --git a/ext/intl/tests/formatter_format.phpt b/ext/intl/tests/formatter_format.phpt index 334ef4956..334ef4956 100755..100644 --- a/ext/intl/tests/formatter_format.phpt +++ b/ext/intl/tests/formatter_format.phpt diff --git a/ext/intl/tests/formatter_format_conv.phpt b/ext/intl/tests/formatter_format_conv.phpt index e1d25ef3d..e1d25ef3d 100755..100644 --- a/ext/intl/tests/formatter_format_conv.phpt +++ b/ext/intl/tests/formatter_format_conv.phpt diff --git a/ext/intl/tests/formatter_format_currency.phpt b/ext/intl/tests/formatter_format_currency.phpt index be219a5ba..be219a5ba 100755..100644 --- a/ext/intl/tests/formatter_format_currency.phpt +++ b/ext/intl/tests/formatter_format_currency.phpt diff --git a/ext/intl/tests/formatter_get_error.phpt b/ext/intl/tests/formatter_get_error.phpt index acb683e89..acb683e89 100755..100644 --- a/ext/intl/tests/formatter_get_error.phpt +++ b/ext/intl/tests/formatter_get_error.phpt diff --git a/ext/intl/tests/formatter_get_locale.phpt b/ext/intl/tests/formatter_get_locale.phpt index 3d4fb2ae4..3d4fb2ae4 100755..100644 --- a/ext/intl/tests/formatter_get_locale.phpt +++ b/ext/intl/tests/formatter_get_locale.phpt diff --git a/ext/intl/tests/formatter_get_set_attribute.phpt b/ext/intl/tests/formatter_get_set_attribute.phpt index 51c7d3658..51c7d3658 100755..100644 --- a/ext/intl/tests/formatter_get_set_attribute.phpt +++ b/ext/intl/tests/formatter_get_set_attribute.phpt diff --git a/ext/intl/tests/formatter_get_set_pattern.phpt b/ext/intl/tests/formatter_get_set_pattern.phpt index 0ae5b308b..0ae5b308b 100755..100644 --- a/ext/intl/tests/formatter_get_set_pattern.phpt +++ b/ext/intl/tests/formatter_get_set_pattern.phpt diff --git a/ext/intl/tests/formatter_get_set_symbol.phpt b/ext/intl/tests/formatter_get_set_symbol.phpt index 050e8cf9e..050e8cf9e 100755..100644 --- a/ext/intl/tests/formatter_get_set_symbol.phpt +++ b/ext/intl/tests/formatter_get_set_symbol.phpt diff --git a/ext/intl/tests/formatter_get_set_text_attribute.phpt b/ext/intl/tests/formatter_get_set_text_attribute.phpt index 539ff5232..539ff5232 100755..100644 --- a/ext/intl/tests/formatter_get_set_text_attribute.phpt +++ b/ext/intl/tests/formatter_get_set_text_attribute.phpt diff --git a/ext/intl/tests/formatter_parse.phpt b/ext/intl/tests/formatter_parse.phpt index 2ab9cce3b..2ab9cce3b 100755..100644 --- a/ext/intl/tests/formatter_parse.phpt +++ b/ext/intl/tests/formatter_parse.phpt diff --git a/ext/intl/tests/formatter_parse_currency.phpt b/ext/intl/tests/formatter_parse_currency.phpt index 4ebd1a417..4ebd1a417 100755..100644 --- a/ext/intl/tests/formatter_parse_currency.phpt +++ b/ext/intl/tests/formatter_parse_currency.phpt diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt index def9110d0..def9110d0 100755..100644 --- a/ext/intl/tests/grapheme.phpt +++ b/ext/intl/tests/grapheme.phpt diff --git a/ext/intl/tests/idn.phpt b/ext/intl/tests/idn.phpt index fde822a56..fde822a56 100755..100644 --- a/ext/intl/tests/idn.phpt +++ b/ext/intl/tests/idn.phpt diff --git a/ext/intl/tests/intl_error_name.phpt b/ext/intl/tests/intl_error_name.phpt index 8f5b2dc19..8f5b2dc19 100755..100644 --- a/ext/intl/tests/intl_error_name.phpt +++ b/ext/intl/tests/intl_error_name.phpt diff --git a/ext/intl/tests/intl_get_error_code.phpt b/ext/intl/tests/intl_get_error_code.phpt index 6cd361ba7..6cd361ba7 100755..100644 --- a/ext/intl/tests/intl_get_error_code.phpt +++ b/ext/intl/tests/intl_get_error_code.phpt diff --git a/ext/intl/tests/intl_get_error_message.phpt b/ext/intl/tests/intl_get_error_message.phpt index f81b5c03d..f81b5c03d 100755..100644 --- a/ext/intl/tests/intl_get_error_message.phpt +++ b/ext/intl/tests/intl_get_error_message.phpt diff --git a/ext/intl/tests/intl_is_failure.phpt b/ext/intl/tests/intl_is_failure.phpt index e07df8f2c..e07df8f2c 100755..100644 --- a/ext/intl/tests/intl_is_failure.phpt +++ b/ext/intl/tests/intl_is_failure.phpt diff --git a/ext/intl/tests/locale_accept.phpt b/ext/intl/tests/locale_accept.phpt index cf1dc6e67..cf1dc6e67 100755..100644 --- a/ext/intl/tests/locale_accept.phpt +++ b/ext/intl/tests/locale_accept.phpt diff --git a/ext/intl/tests/locale_compose_locale.phpt b/ext/intl/tests/locale_compose_locale.phpt index 2d0ca54e7..2d0ca54e7 100755..100644 --- a/ext/intl/tests/locale_compose_locale.phpt +++ b/ext/intl/tests/locale_compose_locale.phpt diff --git a/ext/intl/tests/locale_filter_matches.phpt b/ext/intl/tests/locale_filter_matches.phpt index cada499b9..cada499b9 100755..100644 --- a/ext/intl/tests/locale_filter_matches.phpt +++ b/ext/intl/tests/locale_filter_matches.phpt diff --git a/ext/intl/tests/locale_get_all_variants.phpt b/ext/intl/tests/locale_get_all_variants.phpt index 864b8a2e1..864b8a2e1 100755..100644 --- a/ext/intl/tests/locale_get_all_variants.phpt +++ b/ext/intl/tests/locale_get_all_variants.phpt diff --git a/ext/intl/tests/locale_get_default.phpt b/ext/intl/tests/locale_get_default.phpt index 57c46ccd2..57c46ccd2 100755..100644 --- a/ext/intl/tests/locale_get_default.phpt +++ b/ext/intl/tests/locale_get_default.phpt diff --git a/ext/intl/tests/locale_get_display_language.phpt b/ext/intl/tests/locale_get_display_language.phpt index 2e0005628..2e0005628 100755..100644 --- a/ext/intl/tests/locale_get_display_language.phpt +++ b/ext/intl/tests/locale_get_display_language.phpt diff --git a/ext/intl/tests/locale_get_display_name.phpt b/ext/intl/tests/locale_get_display_name.phpt index b12873427..b12873427 100755..100644 --- a/ext/intl/tests/locale_get_display_name.phpt +++ b/ext/intl/tests/locale_get_display_name.phpt diff --git a/ext/intl/tests/locale_get_display_region.phpt b/ext/intl/tests/locale_get_display_region.phpt index 9a6e75d94..9a6e75d94 100755..100644 --- a/ext/intl/tests/locale_get_display_region.phpt +++ b/ext/intl/tests/locale_get_display_region.phpt diff --git a/ext/intl/tests/locale_get_display_script.phpt b/ext/intl/tests/locale_get_display_script.phpt index 0440dfb20..0440dfb20 100755..100644 --- a/ext/intl/tests/locale_get_display_script.phpt +++ b/ext/intl/tests/locale_get_display_script.phpt diff --git a/ext/intl/tests/locale_get_display_script2.phpt b/ext/intl/tests/locale_get_display_script2.phpt index 92652bde9..2b9e037b7 100644 --- a/ext/intl/tests/locale_get_display_script2.phpt +++ b/ext/intl/tests/locale_get_display_script2.phpt @@ -1,8 +1,8 @@ --TEST-- -locale_get_display_script() icu >= 4.8 +locale_get_display_script() icu = 4.8 --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> -<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0 || version_compare(INTL_ICU_VERSION, '49') >= 0) print 'skip'; ?> --FILE-- <?php diff --git a/ext/intl/tests/locale_get_display_script3.phpt b/ext/intl/tests/locale_get_display_script3.phpt new file mode 100644 index 000000000..447766e6b --- /dev/null +++ b/ext/intl/tests/locale_get_display_script3.phpt @@ -0,0 +1,275 @@ +--TEST-- +locale_get_display_script() icu >= 49 +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '49') < 0) print 'skip'; ?> +--FILE-- +<?php + +/* + * Try getting the display_script for different locales + * with Procedural and Object methods. + */ + +function ut_main() +{ + $res_str = ''; + + $disp_locales=array('en','fr','de'); + + $locales = array( + 'uk-ua_CALIFORNIA@currency=;currency=GRN', + 'root', + 'uk@currency=EURO', + 'Hindi', +//Simple language subtag + 'de', + 'fr', + 'ja', + 'i-enochian', //(example of a grandfathered tag) +//Language subtag plus Script subtag: + 'zh-Hant', + 'zh-Hans', + 'sr-Cyrl', + 'sr-Latn', +//Language-Script-Region + 'zh-Hans-CN', + 'sr-Latn-CS', +//Language-Variant + 'sl-rozaj', + 'sl-nedis', +//Language-Region-Variant + 'de-CH-1901', + 'sl-IT-nedis', +//Language-Script-Region-Variant + 'sl-Latn-IT-nedis', +//Language-Region: + 'de-DE', + 'en-US', + 'es-419', +//Private use subtags: + 'de-CH-x-phonebk', + 'az-Arab-x-AZE-derbend', +//Extended language subtags + 'zh-min', + 'zh-min-nan-Hant-CN', +//Private use registry values + 'x-whatever', + 'qaa-Qaaa-QM-x-southern', + 'sr-Latn-QM', + 'sr-Qaaa-CS', +/*Tags that use extensions (examples ONLY: extensions MUST be defined + by revision or update to this document or by RFC): */ + 'en-US-u-islamCal', + 'zh-CN-a-myExt-x-private', + 'en-a-myExt-b-another', +//Some Invalid Tags: + 'de-419-DE', + 'a-DE', + 'ar-a-aaa-b-bbb-a-ccc' + ); + + + $res_str = ''; + + foreach( $locales as $locale ) + { + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_script( $locale ,$disp_locale ); + $res_str .= "disp_locale=$disp_locale : display_script=$scr"; + $res_str .= "\n"; + } + $res_str .= "-----------------\n"; + } + + return $res_str; + +} + +include_once( 'ut_common.inc' ); +ut_run(); + +?> +--EXPECT-- +locale='uk-ua_CALIFORNIA@currency=;currency=GRN' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='root' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='uk@currency=EURO' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='Hindi' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='fr' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='ja' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='i-enochian' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='zh-Hant' +disp_locale=en : display_script=Traditional Han +disp_locale=fr : display_script=chinois traditionnel +disp_locale=de : display_script=Traditionelles Chinesisch +----------------- +locale='zh-Hans' +disp_locale=en : display_script=Simplified Han +disp_locale=fr : display_script=chinois simplifié +disp_locale=de : display_script=Vereinfachtes Chinesisch +----------------- +locale='sr-Cyrl' +disp_locale=en : display_script=Cyrillic +disp_locale=fr : display_script=cyrillique +disp_locale=de : display_script=Kyrillisch +----------------- +locale='sr-Latn' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='zh-Hans-CN' +disp_locale=en : display_script=Simplified Han +disp_locale=fr : display_script=chinois simplifié +disp_locale=de : display_script=Vereinfachtes Chinesisch +----------------- +locale='sr-Latn-CS' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='sl-rozaj' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='sl-nedis' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de-CH-1901' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='sl-IT-nedis' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='sl-Latn-IT-nedis' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='de-DE' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='en-US' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='es-419' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de-CH-x-phonebk' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='az-Arab-x-AZE-derbend' +disp_locale=en : display_script=Arabic +disp_locale=fr : display_script=arabe +disp_locale=de : display_script=Arabisch +----------------- +locale='zh-min' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='zh-min-nan-Hant-CN' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='x-whatever' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='qaa-Qaaa-QM-x-southern' +disp_locale=en : display_script=Qaaa +disp_locale=fr : display_script=Qaaa +disp_locale=de : display_script=Qaaa +----------------- +locale='sr-Latn-QM' +disp_locale=en : display_script=Latin +disp_locale=fr : display_script=latin +disp_locale=de : display_script=Lateinisch +----------------- +locale='sr-Qaaa-CS' +disp_locale=en : display_script=Qaaa +disp_locale=fr : display_script=Qaaa +disp_locale=de : display_script=Qaaa +----------------- +locale='en-US-u-islamCal' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='zh-CN-a-myExt-x-private' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='en-a-myExt-b-another' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='de-419-DE' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='a-DE' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- +locale='ar-a-aaa-b-bbb-a-ccc' +disp_locale=en : display_script= +disp_locale=fr : display_script= +disp_locale=de : display_script= +----------------- diff --git a/ext/intl/tests/locale_get_display_variant.phpt b/ext/intl/tests/locale_get_display_variant.phpt index 9f72ee049..9f72ee049 100755..100644 --- a/ext/intl/tests/locale_get_display_variant.phpt +++ b/ext/intl/tests/locale_get_display_variant.phpt diff --git a/ext/intl/tests/locale_get_keywords.phpt b/ext/intl/tests/locale_get_keywords.phpt index 4a09f54d3..4a09f54d3 100755..100644 --- a/ext/intl/tests/locale_get_keywords.phpt +++ b/ext/intl/tests/locale_get_keywords.phpt diff --git a/ext/intl/tests/locale_get_primary_language.phpt b/ext/intl/tests/locale_get_primary_language.phpt index bc92e9266..bc92e9266 100755..100644 --- a/ext/intl/tests/locale_get_primary_language.phpt +++ b/ext/intl/tests/locale_get_primary_language.phpt diff --git a/ext/intl/tests/locale_get_region.phpt b/ext/intl/tests/locale_get_region.phpt index 0baae4993..0baae4993 100755..100644 --- a/ext/intl/tests/locale_get_region.phpt +++ b/ext/intl/tests/locale_get_region.phpt diff --git a/ext/intl/tests/locale_get_script.phpt b/ext/intl/tests/locale_get_script.phpt index 6a794fdb1..6a794fdb1 100755..100644 --- a/ext/intl/tests/locale_get_script.phpt +++ b/ext/intl/tests/locale_get_script.phpt diff --git a/ext/intl/tests/locale_lookup.phpt b/ext/intl/tests/locale_lookup.phpt index f0affafa6..f0affafa6 100755..100644 --- a/ext/intl/tests/locale_lookup.phpt +++ b/ext/intl/tests/locale_lookup.phpt diff --git a/ext/intl/tests/locale_parse_locale.phpt b/ext/intl/tests/locale_parse_locale.phpt index c8aa2f412..c8aa2f412 100755..100644 --- a/ext/intl/tests/locale_parse_locale.phpt +++ b/ext/intl/tests/locale_parse_locale.phpt diff --git a/ext/intl/tests/locale_set_default.phpt b/ext/intl/tests/locale_set_default.phpt index 7debf4d3d..7debf4d3d 100755..100644 --- a/ext/intl/tests/locale_set_default.phpt +++ b/ext/intl/tests/locale_set_default.phpt diff --git a/ext/intl/tests/msgfmt_fail.phpt b/ext/intl/tests/msgfmt_fail.phpt index bffb71c56..bffb71c56 100755..100644 --- a/ext/intl/tests/msgfmt_fail.phpt +++ b/ext/intl/tests/msgfmt_fail.phpt diff --git a/ext/intl/tests/msgfmt_format.phpt b/ext/intl/tests/msgfmt_format.phpt index c1bf5e9db..c1bf5e9db 100755..100644 --- a/ext/intl/tests/msgfmt_format.phpt +++ b/ext/intl/tests/msgfmt_format.phpt diff --git a/ext/intl/tests/msgfmt_get_error.phpt b/ext/intl/tests/msgfmt_get_error.phpt index 015c50d46..015c50d46 100755..100644 --- a/ext/intl/tests/msgfmt_get_error.phpt +++ b/ext/intl/tests/msgfmt_get_error.phpt diff --git a/ext/intl/tests/msgfmt_get_locale.phpt b/ext/intl/tests/msgfmt_get_locale.phpt index 4c2651fe2..4c2651fe2 100755..100644 --- a/ext/intl/tests/msgfmt_get_locale.phpt +++ b/ext/intl/tests/msgfmt_get_locale.phpt diff --git a/ext/intl/tests/msgfmt_get_set_pattern.phpt b/ext/intl/tests/msgfmt_get_set_pattern.phpt index 67b1aca45..67b1aca45 100755..100644 --- a/ext/intl/tests/msgfmt_get_set_pattern.phpt +++ b/ext/intl/tests/msgfmt_get_set_pattern.phpt diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt index b9ec36374..b9ec36374 100755..100644 --- a/ext/intl/tests/msgfmt_parse.phpt +++ b/ext/intl/tests/msgfmt_parse.phpt diff --git a/ext/intl/tests/normalizer_normalize.phpt b/ext/intl/tests/normalizer_normalize.phpt index 238b7423c..238b7423c 100755..100644 --- a/ext/intl/tests/normalizer_normalize.phpt +++ b/ext/intl/tests/normalizer_normalize.phpt diff --git a/ext/intl/tests/regression_sort_and_cow.phpt b/ext/intl/tests/regression_sort_and_cow.phpt index d7ff79770..d7ff79770 100755..100644 --- a/ext/intl/tests/regression_sort_and_cow.phpt +++ b/ext/intl/tests/regression_sort_and_cow.phpt diff --git a/ext/intl/tests/regression_sort_eq.phpt b/ext/intl/tests/regression_sort_eq.phpt index 8676c5c93..8676c5c93 100755..100644 --- a/ext/intl/tests/regression_sort_eq.phpt +++ b/ext/intl/tests/regression_sort_eq.phpt diff --git a/ext/intl/tests/regression_sortwsk_and_cow.phpt b/ext/intl/tests/regression_sortwsk_and_cow.phpt index a4953232e..a4953232e 100755..100644 --- a/ext/intl/tests/regression_sortwsk_and_cow.phpt +++ b/ext/intl/tests/regression_sortwsk_and_cow.phpt diff --git a/ext/intl/tests/regression_sortwsk_eq.phpt b/ext/intl/tests/regression_sortwsk_eq.phpt index 945bac300..945bac300 100755..100644 --- a/ext/intl/tests/regression_sortwsk_eq.phpt +++ b/ext/intl/tests/regression_sortwsk_eq.phpt diff --git a/ext/intl/tests/resourcebundle.build b/ext/intl/tests/resourcebundle.build index 6a7eeae5e..6a7eeae5e 100755..100644 --- a/ext/intl/tests/resourcebundle.build +++ b/ext/intl/tests/resourcebundle.build diff --git a/ext/intl/tests/resourcebundle_locales.phpt b/ext/intl/tests/resourcebundle_locales.phpt index e14a7e5aa..e14a7e5aa 100755..100644 --- a/ext/intl/tests/resourcebundle_locales.phpt +++ b/ext/intl/tests/resourcebundle_locales.phpt diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt index 8fde61bd2..17fab6d63 100644 --- a/ext/intl/tests/resourcebundle_null_mandatory_args.phpt +++ b/ext/intl/tests/resourcebundle_null_mandatory_args.phpt @@ -1,11 +1,13 @@ --TEST-- -IntlCalendar::setTime() basic test +ResourceBundle constructor bundle accepts NULL for first two arguments --INI-- date.timezone=Atlantic/Azores --SKIPIF-- <?php if (!extension_loaded('intl')) die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip ICU >= 4.8 only'); --FILE-- <?php ini_set("intl.error_level", E_WARNING); diff --git a/ext/intl/tests/spoofchecker_001.phpt b/ext/intl/tests/spoofchecker_001.phpt index 7904b3a4c..7904b3a4c 100755..100644 --- a/ext/intl/tests/spoofchecker_001.phpt +++ b/ext/intl/tests/spoofchecker_001.phpt diff --git a/ext/intl/tests/spoofchecker_002.phpt b/ext/intl/tests/spoofchecker_002.phpt index d57091735..d57091735 100755..100644 --- a/ext/intl/tests/spoofchecker_002.phpt +++ b/ext/intl/tests/spoofchecker_002.phpt diff --git a/ext/intl/tests/spoofchecker_003.phpt b/ext/intl/tests/spoofchecker_003.phpt index 0be9bfa40..0be9bfa40 100755..100644 --- a/ext/intl/tests/spoofchecker_003.phpt +++ b/ext/intl/tests/spoofchecker_003.phpt diff --git a/ext/intl/tests/spoofchecker_004.phpt b/ext/intl/tests/spoofchecker_004.phpt index b38c61d71..b38c61d71 100755..100644 --- a/ext/intl/tests/spoofchecker_004.phpt +++ b/ext/intl/tests/spoofchecker_004.phpt diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc index 09be22bf5..09be22bf5 100755..100644 --- a/ext/intl/tests/ut_common.inc +++ b/ext/intl/tests/ut_common.inc diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 4a63681fb..900f8207b 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -2184,7 +2184,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, change_user)(MYSQLND_CONN_DATA * const conn, } memcpy(conn->auth_plugin_data, plugin_data, plugin_data_len); - DBG_INF_FMT("salt=[%*s]", plugin_data_len - 1, plugin_data); + DBG_INF_FMT("salt=[%*.s]", plugin_data_len - 1, plugin_data); /* The data should be allocated with malloc() */ scrambled_data = diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index 5c77b4245..044a7d680 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -516,9 +516,11 @@ enum mysqlnd_debug_parser_state static void MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const mode) { - unsigned int mode_len = strlen(mode), i; + unsigned int mode_len, i; enum mysqlnd_debug_parser_state state = PARSER_WAIT_MODIFIER; + mode_len = mode? strlen(mode) : 0; + self->flags = 0; self->nest_level_limit = 0; if (self->file_name && self->file_name != mysqlnd_debug_default_trace_file) { diff --git a/ext/oci8/tests/pecl_bug10194.phpt b/ext/oci8/tests/pecl_bug10194.phpt index 9947e15db..3c1c7887c 100644 --- a/ext/oci8/tests/pecl_bug10194.phpt +++ b/ext/oci8/tests/pecl_bug10194.phpt @@ -5,6 +5,9 @@ PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs require(dirname(__FILE__).'/skipif.inc'); if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} ?> --INI-- memory_limit=10M diff --git a/ext/oci8/tests/pecl_bug10194_blob_64.phpt b/ext/oci8/tests/pecl_bug10194_blob_64.phpt index 45788a41b..e1a4cc034 100644 --- a/ext/oci8/tests/pecl_bug10194_blob_64.phpt +++ b/ext/oci8/tests/pecl_bug10194_blob_64.phpt @@ -6,6 +6,9 @@ $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on t require(dirname(__FILE__).'/skipif.inc'); if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} ?> --INI-- memory_limit=6M diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc index f2e076793..443c8dd82 100644 --- a/ext/pdo/tests/pdo_test.inc +++ b/ext/pdo/tests/pdo_test.inc @@ -66,13 +66,19 @@ class PDOTest { } static function test_factory($file) { - $data = file_get_contents($file); - $data = preg_replace('/^.*--REDIRECTTEST--/s', '', $data); - $config = eval($data); + $config = self::get_config($file); foreach ($config['ENV'] as $k => $v) { putenv("$k=$v"); } return self::factory(); } + + static function get_config($file) { + $data = file_get_contents($file); + $data = preg_replace('/^.*--REDIRECTTEST--/s', '', $data); + $config = eval($data); + + return $config; + } } ?> diff --git a/ext/pdo_firebird/tests/bug_47415.phpt b/ext/pdo_firebird/tests/bug_47415.phpt index cedc2c45b..12cd782f2 100644 --- a/ext/pdo_firebird/tests/bug_47415.phpt +++ b/ext/pdo_firebird/tests/bug_47415.phpt @@ -2,6 +2,7 @@ Bug #47415 PDO_Firebird segfaults when passing lowercased column name to bindColumn() --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php diff --git a/ext/pdo_firebird/tests/bug_48877.phpt b/ext/pdo_firebird/tests/bug_48877.phpt index 290cd7a3a..cbab84b37 100644 --- a/ext/pdo_firebird/tests/bug_48877.phpt +++ b/ext/pdo_firebird/tests/bug_48877.phpt @@ -2,6 +2,7 @@ PDO_Firebird: bug 48877 The "bindValue" and "bindParam" do not work for PDO Firebird if we use named parameters (:parameter). --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php diff --git a/ext/pdo_firebird/tests/bug_53280.phpt b/ext/pdo_firebird/tests/bug_53280.phpt index 1be4e8a82..3139867af 100644 --- a/ext/pdo_firebird/tests/bug_53280.phpt +++ b/ext/pdo_firebird/tests/bug_53280.phpt @@ -2,6 +2,7 @@ PDO_Firebird: bug 53280 segfaults if query column count is less than param count --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php diff --git a/ext/pdo_firebird/tests/connect.phpt b/ext/pdo_firebird/tests/connect.phpt index e4bb8ef54..cbe76e686 100644 --- a/ext/pdo_firebird/tests/connect.phpt +++ b/ext/pdo_firebird/tests/connect.phpt @@ -2,6 +2,7 @@ PDO_Firebird: connect/disconnect --SKIPIF-- <?php include("skipif.inc"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php /* $Id$ */ diff --git a/ext/pdo_firebird/tests/ddl.phpt b/ext/pdo_firebird/tests/ddl.phpt index 9a3ddd100..9d2a0953e 100644 --- a/ext/pdo_firebird/tests/ddl.phpt +++ b/ext/pdo_firebird/tests/ddl.phpt @@ -2,6 +2,7 @@ PDO_Firebird: DDL/transactions --SKIPIF-- <?php include("skipif.inc"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php /* $Id$ */ diff --git a/ext/pdo_firebird/tests/execute.phpt b/ext/pdo_firebird/tests/execute.phpt index 3a759fc51..896347e93 100644 --- a/ext/pdo_firebird/tests/execute.phpt +++ b/ext/pdo_firebird/tests/execute.phpt @@ -2,6 +2,7 @@ PDO_Firebird: prepare/execute/binding --SKIPIF-- <?php include("skipif.inc"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --INI-- ibase.timestampformat=%Y-%m-%d %H:%M:%S --FILE-- diff --git a/ext/pdo_firebird/tests/rowCount.phpt b/ext/pdo_firebird/tests/rowCount.phpt index 3d7f71c83..1a009508e 100644 --- a/ext/pdo_firebird/tests/rowCount.phpt +++ b/ext/pdo_firebird/tests/rowCount.phpt @@ -2,6 +2,7 @@ PDO_Firebird: rowCount --SKIPIF-- <?php extension_loaded("pdo_firebird") or die("skip"); ?> +<?php function_exists("ibase_query") or die("skip"); ?> --FILE-- <?php /* $Id$ */ diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 4e039d2a7..e700ef8c3 100755 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -633,58 +633,49 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned l } if (rc == SQL_SUCCESS_WITH_INFO) { - /* promote up to a bigger buffer */ - - if (C->fetched_len != SQL_NO_TOTAL) { - /* use size suggested by the driver, if it knows it */ - buf = emalloc(C->fetched_len + 1); - memcpy(buf, C->data, C->fetched_len); - buf[C->fetched_len] = 0; - used = C->fetched_len; - } else { - buf = estrndup(C->data, 256); - used = 255; /* not 256; the driver NUL terminated the buffer */ - } - + /* this is a 'long column' + + read the column in 255 byte blocks until the end of the column is reached, reassembling those blocks + in order into the output buffer + + this loop has to work whether or not SQLGetData() provides the total column length. + calling SQLDescribeCol() or other, specifically to get the column length, then doing a single read + for that size would be slower except maybe for extremely long columns.*/ + char *buf2; + + buf2 = emalloc(256); + buf = estrndup(C->data, 256); + used = 255; /* not 256; the driver NUL terminated the buffer */ + do { C->fetched_len = 0; - rc = SQLGetData(S->stmt, colno+1, SQL_C_CHAR, - buf + used, alloced - used, - &C->fetched_len); - - if (rc == SQL_NO_DATA) { - /* we got the lot */ - break; - } else if (rc != SQL_SUCCESS) { - pdo_odbc_stmt_error("SQLGetData"); - if (rc != SQL_SUCCESS_WITH_INFO) { - break; - } - } - - if (C->fetched_len == SQL_NO_TOTAL) { - used += alloced - used; + /* read block. 256 bytes => 255 bytes are actually read, the last 1 is NULL */ + rc = SQLGetData(S->stmt, colno+1, SQL_C_CHAR, buf2, 256, &C->fetched_len); + + /* resize output buffer and reassemble block */ + if (rc==SQL_SUCCESS_WITH_INFO) { + /* point 5, in section "Retrieving Data with SQLGetData" in http://msdn.microsoft.com/en-us/library/windows/desktop/ms715441(v=vs.85).aspx + states that if SQL_SUCCESS_WITH_INFO, fetched_len will be > 255 (greater than buf2's size) + (if a driver fails to follow that and wrote less than 255 bytes to buf2, this will AV or read garbage into buf) */ + buf = erealloc(buf, used + 255+1); + memcpy(buf + used, buf2, 255); + used = used + 255; + } else if (rc==SQL_SUCCESS) { + buf = erealloc(buf, used + C->fetched_len+1); + memcpy(buf + used, buf2, C->fetched_len); + used = used + C->fetched_len; } else { - used += C->fetched_len; - } - - if (rc == SQL_SUCCESS) { - /* this was the final fetch */ + /* includes SQL_NO_DATA */ break; } - - /* we need to fetch another chunk; resize the - * buffer */ - alloced *= 2; - buf = erealloc(buf, alloced); + } while (1); - - /* size down */ - if (used < alloced - 1024) { - alloced = used+1; - buf = erealloc(buf, used+1); - } + + efree(buf2); + + /* NULL terminate the buffer once, when finished, for use with the rest of PHP */ buf[used] = '\0'; + *ptr = buf; *caller_frees = 1; *len = used; diff --git a/ext/pdo_odbc/tests/common.phpt b/ext/pdo_odbc/tests/common.phpt index f64da1a43..276f2b78e 100644 --- a/ext/pdo_odbc/tests/common.phpt +++ b/ext/pdo_odbc/tests/common.phpt @@ -2,17 +2,40 @@ ODBC --SKIPIF-- <?php # vim:ft=php -if (!extension_loaded('pdo_odbc')) print 'skip'; ?> +if (!extension_loaded('pdo_odbc')) print 'skip'; +if (substr(PHP_OS, 0, 3) == 'WIN' && + false === getenv('PDOTEST_DSN') && + false === getenv('PDO_ODBC_TEST_DSN') && + !extension_loaded('com_dotnet')) { + die('skip - either PDOTEST_DSN or com_dotnet extension is needed to setup the connection'); +} --REDIRECTTEST-- # magic auto-configuration $config = array( - 'TESTS' => 'ext/pdo/tests' + 'TESTS' => 'ext/pdo/tests', + 'ENV' => array() ); - -if (false !== getenv('PDO_ODBC_TEST_DSN')) { - # user set them from their shell +// try loading PDO driver using ENV vars and if none given, and on Windows, try using MS Access +// and if not, skip the test +// +// try to use common PDO env vars, instead of PDO_ODBC specific +if (false !== getenv('PDOTEST_DSN')) { + // user should have to set PDOTEST_DSN so that: + // 1. test is skipped if user doesn't want to test it, even if they have MS Access installed + // 2. it detects if ODBC driver is not installed - to avoid test bug + // 3. it detects if ODBC driver is installed - so test will be run + // 4. so a specific ODBC driver can be tested - if system has multiple ODBC drivers + + $config['ENV']['PDOTEST_DSN'] = getenv('PDOTEST_DSN'); + $config['ENV']['PDOTEST_USER'] = getenv('PDOTEST_USER'); + $config['ENV']['PDOTEST_PASS'] = getenv('PDOTEST_PASS'); + if (false !== getenv('PDOTEST_ATTR')) { + $config['ENV']['PDOTEST_ATTR'] = getenv('PDOTEST_ATTR'); + } +} else if (false !== getenv('PDO_ODBC_TEST_DSN')) { + // user set these from their shell instead $config['ENV']['PDOTEST_DSN'] = getenv('PDO_ODBC_TEST_DSN'); $config['ENV']['PDOTEST_USER'] = getenv('PDO_ODBC_TEST_USER'); $config['ENV']['PDOTEST_PASS'] = getenv('PDO_ODBC_TEST_PASS'); @@ -20,10 +43,13 @@ if (false !== getenv('PDO_ODBC_TEST_DSN')) { $config['ENV']['PDOTEST_ATTR'] = getenv('PDO_ODBC_TEST_ATTR'); } } elseif (preg_match('/^WIN/i', PHP_OS)) { - # on windows, try to create a temporary MS access database + // on Windows and user didn't set PDOTEST_DSN, try this as a fallback: + // check if MS Access DB is installed, and if yes, try using it. create a temporary MS access database. + // $path = realpath(dirname(__FILE__)) . '\pdo_odbc.mdb'; if (!file_exists($path)) { try { + // try to create database $adox = new COM('ADOX.Catalog'); $adox->Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' . $path); $adox = null; @@ -32,9 +58,12 @@ if (false !== getenv('PDO_ODBC_TEST_DSN')) { } } if (file_exists($path)) { + // database was created and written to file system $config['ENV']['PDOTEST_DSN'] = "odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=$path;Uid=Admin"; - } -} + } // else: $config['ENV']['PDOTEST_DSN'] not set +} // else: $config['ENV']['PDOTEST_DSN'] not set +// test will be skipped. see SKIPIF section of long_columns.phpt + # other magic autodetection here, eg: for DB2 by inspecting env /* $USER = 'db2inst1'; diff --git a/ext/pdo_odbc/tests/long_columns.phpt b/ext/pdo_odbc/tests/long_columns.phpt index 65ec2f96e..e3430ded4 100644 --- a/ext/pdo_odbc/tests/long_columns.phpt +++ b/ext/pdo_odbc/tests/long_columns.phpt @@ -3,9 +3,44 @@ PDO ODBC "long" columns --SKIPIF-- <?php # vim:ft=php if (!extension_loaded('pdo_odbc')) print 'skip not loaded'; +// make sure there is an ODBC driver and a DSN, or the test will fail +include 'ext/pdo/tests/pdo_test.inc'; +$config = PDOTest::get_config('ext/pdo_odbc/tests/common.phpt'); +if (!isset($config['ENV']['PDOTEST_DSN']) || $config['ENV']['PDOTEST_DSN']===false) print 'skip'; ?> --FILE-- <?php +// setup: set PDOTEST_DSN environment variable +// for MyODBC (MySQL) and MS SQL Server, you need to also set PDOTEST_USER and PDOTEST_PASS +// +// can use MS SQL Server on Linux - using unixODBC +// -RHEL6.2 +// -download & instructions: http://www.microsoft.com/en-us/download/details.aspx?id=28160 +// -Linux6\sqlncli-11.0.1790.0.tar.gz (it calls RHEL6.x 'Linux6' for some reason) +// -follow instructions on web page and install script +// -may have to specify connection info in connection string without using a DSN (DSN-less connection) +// -for example: +// set PDOTEST_DSN='odbc:Driver=SQL Server Native Client 11.0;Server=10.200.51.179;Database=testdb' +// set PDOTEST_USER=sa +// set PDOTEST_PASS=Password01 +// +// on Windows, the easy way to do this: +// 1. install MS Access (part of MS Office) and include ODBC (Development tools feature) +// install the x86 build of the Drivers. You might not be able to load the x64 drivers. +// 2. in Control Panel, search for ODBC and open "Setup data sources (ODBC)" +// 3. click on System DSN tab +// 4. click Add and choose "Microsoft Access Driver (*.mdb, *.accdb)" driver +// 5. enter a DSN, ex: accdb12 +// 6. click 'Create' and select a file to save the database as +// -otherwise, you'll have to open MS Access, create a database, then load that file in this Window to map it to a DSN +// 7. set the environment variable PDOTEST_DSN="odbc:<system dsn from step 5>" ex: SET PDOTEST_DSN=odbc:accdb12 +// -note: on Windows, " is included in environment variable +// +// easy way to compile: +// configure --disable-all --enable-cli --enable-zts --enable-pdo --with-pdo-odbc --enable-debug +// configure --disable-all --eanble-cli --enable-pdo --with-pdo-odbc=unixODBC,/usr,/usr --with-unixODBC=/usr --enable-debug +// + require 'ext/pdo/tests/pdo_test.inc'; $db = PDOTest::test_factory('ext/pdo_odbc/tests/common.phpt'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); @@ -20,27 +55,86 @@ if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data CL $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$sizes = array(32, 64, 128, 253, 254, 255, 256, 257, 258, 512, 1024, 2048, 3998, 3999, 4000); +// the driver reads columns in blocks of 255 bytes and then reassembles those blocks into a single buffer. +// test sizes around 255 to make sure that the reassembly works (and that the column is split into 255 byte blocks by the database) +// also, test sizes below 255 to make sure that they work - and are not treated as a long column (should be read in a single read) +$sizes = array(32, 53, 64, 79, 128, 253, 254, 255, 256, 257, 258, 1022, 1023, 1024, 1025, 1026, 510, 511, 512, 513, 514, 1278, 1279, 1280, 1281, 1282, 2046, 2047, 2048, 2049, 2050, 1534, 1535, 1536, 1537, 1538, 3070, 3071, 3072, 3073, 3074, 3998, 3999, 4000); -$db->beginTransaction(); -$insert = $db->prepare('INSERT INTO TEST VALUES (?, ?)'); +function alpha_repeat($len) { + // use the alphabet instead of 'i' characters to make sure the blocks don't overlap when they are reassembled + $out = ""; + while (strlen($out) < $len) { + $out .= "abcdefghijklmnopqrstuvwxyz"; + } + return substr($out, 0, $len); +} + +// don't use Prepared Statements. that fails on MS SQL server (works with Access, MyODBC), which is a separate failure, feature/code-path from what +// this test does - nice to be able to test using MS SQL server foreach ($sizes as $num) { - $insert->execute(array($num, str_repeat('i', $num))); + $text = alpha_repeat($num); + $db->exec("INSERT INTO TEST VALUES($num, '$text')"); } -$insert = null; -$db->commit(); +// verify data foreach ($db->query('SELECT id, data from TEST') as $row) { - $expect = str_repeat('i', $row[0]); + $expect = alpha_repeat($row[0]); if (strcmp($expect, $row[1])) { echo "Failed on size $row[id]:\n"; printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); - echo bin2hex($expect) . "\n"; - echo bin2hex($row['data']) . "\n"; + echo ($expect) . "\n"; + echo ($row['data']) . "\n"; + } else { + echo "Passed on size $row[id]\n"; } } echo "Finished\n"; --EXPECT-- +Passed on size 32 +Passed on size 53 +Passed on size 64 +Passed on size 79 +Passed on size 128 +Passed on size 253 +Passed on size 254 +Passed on size 255 +Passed on size 256 +Passed on size 257 +Passed on size 258 +Passed on size 1022 +Passed on size 1023 +Passed on size 1024 +Passed on size 1025 +Passed on size 1026 +Passed on size 510 +Passed on size 511 +Passed on size 512 +Passed on size 513 +Passed on size 514 +Passed on size 1278 +Passed on size 1279 +Passed on size 1280 +Passed on size 1281 +Passed on size 1282 +Passed on size 2046 +Passed on size 2047 +Passed on size 2048 +Passed on size 2049 +Passed on size 2050 +Passed on size 1534 +Passed on size 1535 +Passed on size 1536 +Passed on size 1537 +Passed on size 1538 +Passed on size 3070 +Passed on size 3071 +Passed on size 3072 +Passed on size 3073 +Passed on size 3074 +Passed on size 3998 +Passed on size 3999 +Passed on size 4000 Finished + diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index ee76afbc0..bcdcdaeea 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -1457,6 +1457,54 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c } /* }}} */ +/* {{{ _reflection_param_get_default_param */ +static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTION_PARAMETERS) +{ + reflection_object *intern; + parameter_reference *param; + + intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + if (intern == NULL || intern->ptr == NULL) { + if (EG(exception) && Z_OBJCE_P(EG(exception)) == reflection_exception_ptr) { + return NULL; + } + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the reflection object"); + } + + param = intern->ptr; + if (param->fptr->type != ZEND_USER_FUNCTION) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions"); + return NULL; + } + + if (param->offset < param->required) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); + return NULL; + } + + return param; +} +/* }}} */ + +/* {{{ _reflection_param_get_default_precv */ +static zend_op *_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS, parameter_reference *param) +{ + zend_op *precv; + + if (param == NULL) { + return NULL; + } + + precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); + return NULL; + } + + return precv; +} +/* }}} */ + /* {{{ Preventing __clone from being called */ ZEND_METHOD(reflection, __clone) { @@ -2535,27 +2583,20 @@ ZEND_METHOD(reflection_parameter, isDefaultValueAvailable) Returns the default value of this parameter or throws an exception */ ZEND_METHOD(reflection_parameter, getDefaultValue) { - reflection_object *intern; parameter_reference *param; zend_op *precv; if (zend_parse_parameters_none() == FAILURE) { return; } - GET_REFLECTION_OBJECT_PTR(param); - if (param->fptr->type != ZEND_USER_FUNCTION) - { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions"); + param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (!param) { return; } - if (param->offset < param->required) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); - return; - } - precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); - if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); + + precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); + if (!precv) { return; } @@ -2569,6 +2610,54 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) } /* }}} */ +/* {{{ proto public bool ReflectionParameter::isDefaultValueConstant() + Returns whether the default value of this parameter is constant */ +ZEND_METHOD(reflection_parameter, isDefaultValueConstant) +{ + zend_op *precv; + parameter_reference *param; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (!param) { + RETURN_FALSE; + } + + precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); + if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { + RETURN_TRUE; + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto public mixed ReflectionParameter::getDefaultValueConstantName() + Returns the default value's constant name if default value is constant or null */ +ZEND_METHOD(reflection_parameter, getDefaultValueConstantName) +{ + zend_op *precv; + parameter_reference *param; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU); + if (!param) { + return; + } + + precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); + if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { + RETURN_STRINGL(Z_STRVAL_P(precv->op2.zv), Z_STRLEN_P(precv->op2.zv), 1); + } +} +/* }}} */ + /* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */ ZEND_METHOD(reflection_method, export) @@ -5912,6 +6001,8 @@ static const zend_function_entry reflection_parameter_functions[] = { ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isDefaultValueAvailable, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0) + ZEND_ME(reflection_parameter, isDefaultValueConstant, arginfo_reflection__void, 0) + ZEND_ME(reflection_parameter, getDefaultValueConstantName, arginfo_reflection__void, 0) PHP_FE_END }; diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt new file mode 100644 index 000000000..cdd00d262 --- /dev/null +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt @@ -0,0 +1,52 @@ +--TEST-- +ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() +--FILE-- +<?php + +define("CONST_TEST_1", "const1"); + +function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1) { + echo $test; +} +$reflect = new ReflectionFunction('ReflectionParameterTest'); +foreach($reflect->getParameters() as $param) { + if($param->getName() == 'test1') { + var_dump($param->isDefaultValueConstant()); + } + if($param->getName() == 'test2') { + var_dump($param->isDefaultValueConstant()); + } + if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { + var_dump($param->getDefaultValueConstantName()); + } +} + +class Foo2 { + const bar = 'Foo2::bar'; +} + +class Foo { + const bar = 'Foo::bar'; + + public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) { + } +} + +$method = new ReflectionMethod('Foo', 'baz'); +$params = $method->getParameters(); + +foreach ($params as $param) { + if ($param->isDefaultValueConstant()) { + var_dump($param->getDefaultValueConstantName()); + } +} +?> +==DONE== +--EXPECT-- +bool(false) +bool(true) +string(12) "CONST_TEST_1" +string(9) "self::bar" +string(9) "Foo2::bar" +string(12) "CONST_TEST_1" +==DONE== diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt new file mode 100644 index 000000000..1ee9e9373 --- /dev/null +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt @@ -0,0 +1,30 @@ +--TEST-- +ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() for namespace +--FILE-- +<?php + +namespace ReflectionTestNamespace { + CONST TEST_CONST_1 = "Test Const 1"; + + class TestClass { + const TEST_CONST_2 = "Test Const 2 in class"; + } +} + +namespace { + function ReflectionParameterTest($test=ReflectionTestNamespace\TestClass::TEST_CONST_2, $test2 = ReflectionTestNamespace\CONST_TEST_1) { + echo $test; + } + $reflect = new ReflectionFunction('ReflectionParameterTest'); + foreach($reflect->getParameters() as $param) { + if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { + echo $param->getDefaultValueConstantName() . "\n"; + } + } + echo "==DONE=="; +} +?> +--EXPECT-- +ReflectionTestNamespace\TestClass::TEST_CONST_2 +ReflectionTestNamespace\CONST_TEST_1 +==DONE== diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt new file mode 100644 index 000000000..984b06efe --- /dev/null +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt @@ -0,0 +1,25 @@ +--TEST-- +ReflectionParameter::getDefaultValueConstant() should raise exception on non optional parameter +--FILE-- +<?php + +define("CONST_TEST_1", "const1"); + +function ReflectionParameterTest($test, $test2 = CONST_TEST_1) { + echo $test; +} +$reflect = new ReflectionFunction('ReflectionParameterTest'); +foreach($reflect->getParameters() as $param) { + try { + echo $param->getDefaultValueConstantName() . "\n"; + } + catch(ReflectionException $e) { + echo $e->getMessage() . "\n"; + } +} +?> +==DONE== +--EXPECT-- +Parameter is not optional +CONST_TEST_1 +==DONE== diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 455280fc7..7236b8a1b 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1513,22 +1513,28 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node, } /* }}} */ -/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive]) +/* {{{ proto string SimpleXMLElement::getDocNamespaces([bool recursive [, bool from_root]) Return all namespaces registered with document */ SXE_METHOD(getDocNamespaces) { - zend_bool recursive = 0; + zend_bool recursive = 0, from_root = 1; php_sxe_object *sxe; + xmlNodePtr node; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &recursive) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &recursive, &from_root) == FAILURE) { return; } array_init(return_value); sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); + if(from_root){ + node = xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr); + }else{ + GET_NODE(sxe, node); + } - sxe_add_registered_namespaces(sxe, xmlDocGetRootElement((xmlDocPtr)sxe->document->ptr), recursive, return_value TSRMLS_CC); + sxe_add_registered_namespaces(sxe, node, recursive, return_value TSRMLS_CC); } /* }}} */ @@ -2518,6 +2524,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getnamespaces, 0, 0, 0) ZEND_ARG_INFO(0, recursve) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_getdocnamespaces, 0, 0, 0) + ZEND_ARG_INFO(0, recursve) + ZEND_ARG_INFO(0, from_root) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_simplexmlelement_children, 0, 0, 0) ZEND_ARG_INFO(0, ns) ZEND_ARG_INFO(0, is_prefix) @@ -2586,7 +2597,7 @@ static const zend_function_entry sxe_functions[] = { /* {{{ */ SXE_ME(attributes, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC) SXE_ME(children, arginfo_simplexmlelement_children, ZEND_ACC_PUBLIC) SXE_ME(getNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC) - SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getnamespaces, ZEND_ACC_PUBLIC) + SXE_ME(getDocNamespaces, arginfo_simplexmlelement_getdocnamespaces, ZEND_ACC_PUBLIC) SXE_ME(getName, arginfo_simplexmlelement__void, ZEND_ACC_PUBLIC) SXE_ME(addChild, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC) SXE_ME(addAttribute, arginfo_simplexmlelement_addchild, ZEND_ACC_PUBLIC) diff --git a/ext/simplexml/tests/feature55218.phpt b/ext/simplexml/tests/feature55218.phpt new file mode 100644 index 000000000..25ea53437 --- /dev/null +++ b/ext/simplexml/tests/feature55218.phpt @@ -0,0 +1,117 @@ +--TEST-- +Bug #55218 getDocNamespaces from current element and not root +--SKIPIF-- +<?php +if (!extension_loaded("simplexml")) print "skip SimpleXML not present"; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$x = new SimpleXMLElement( +'<?xml version="1.0" standalone="yes"?> +<people xmlns:p="http://example.org/p" > + <person id="1" xmlns:t="http://example.org/t" > + <t:name>John Doe</t:name> + </person> + <person id="2">Susie Q. Public</person> + <o> + <p:div>jdslkfjsldk jskdfjsmlkjfkldjkjflskj kljfslkjf sldk</p:div> + </o> +</people>'); + +echo "getDocNamespaces\n"; +echo "\nBackwards Compatibility:\n"; +echo "recursion:\n"; + +var_dump ( $x->getDocNamespaces(true) ) ; +var_dump( $x->person[0]->getDocNamespaces(true) ); +var_dump( $x->person[1]->getDocNamespaces(true) ); + +echo "\nnon recursive:\n"; + +var_dump( $x->getDocNamespaces(false) ); +var_dump( $x->person[0]->getDocNamespaces(false) ); +var_dump( $x->person[1]->getDocNamespaces(false) ); + +echo "\n\nUsing new 'from_root' bool set to false:\n"; +echo "recursion:\n"; + +var_dump ( $x->getDocNamespaces(true, false) ) ; +var_dump( $x->person[0]->getDocNamespaces(true, false) ); +var_dump( $x->person[1]->getDocNamespaces(true, false) ); + +echo "\nnon recursive:\n"; + +var_dump( $x->getDocNamespaces(false, false) ); +var_dump( $x->person[0]->getDocNamespaces(false, false) ); +var_dump( $x->person[1]->getDocNamespaces(false, false) ); + +?> +===DONE=== +--EXPECTF-- +getDocNamespaces + +Backwards Compatibility: +recursion: +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} + +non recursive: +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} + + +Using new 'from_root' bool set to false: +recursion: +array(2) { + ["p"]=> + string(20) "http://example.org/p" + ["t"]=> + string(20) "http://example.org/t" +} +array(1) { + ["t"]=> + string(20) "http://example.org/t" +} +array(0) { +} + +non recursive: +array(1) { + ["p"]=> + string(20) "http://example.org/p" +} +array(1) { + ["t"]=> + string(20) "http://example.org/t" +} +array(0) { +} +===DONE===
\ No newline at end of file diff --git a/ext/sockets/tests/socket_import_stream-4-win.phpt b/ext/sockets/tests/socket_import_stream-4-win.phpt index 68b6582b8..e2fc523ce 100644 --- a/ext/sockets/tests/socket_import_stream-4-win.phpt +++ b/ext/sockets/tests/socket_import_stream-4-win.phpt @@ -83,11 +83,11 @@ socket_set_block Warning: socket_set_block(): An operation was attempted on something that is not a socket. in %ssocket_import_stream-4-win.php on line %d -Warning: socket_set_block(): unable to set blocking mode [0]: The operation completed successfully. +Warning: socket_set_block(): unable to set blocking mode [%d]: An operation was attempted on something that is not a socket. in %ssocket_import_stream-4-win.php on line %d socket_get_option -Warning: socket_get_option(): unable to retrieve socket option [0]: An operation was attempted on something that is not a socket. +Warning: socket_get_option(): unable to retrieve socket option [%d]: An operation was attempted on something that is not a socket. in %ssocket_import_stream-4-win.php on line %d diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 84977c4b9..e2ea17a3f 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -650,6 +650,28 @@ static int spl_array_has_dimension(zval *object, zval *offset, int check_empty T return spl_array_has_dimension_ex(1, object, offset, check_empty TSRMLS_CC); } /* }}} */ +/* {{{ spl_array_object_verify_pos_ex */ +static inline int spl_array_object_verify_pos_ex(spl_array_object *object, HashTable *ht, const char *msg_prefix TSRMLS_DC) +{ + if (!ht) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%sArray was modified outside object and is no longer an array", msg_prefix); + return FAILURE; + } + + if (object->pos && (object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, ht TSRMLS_CC) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%sArray was modified outside object and internal position is no longer valid", msg_prefix); + return FAILURE; + } + + return SUCCESS; +} /* }}} */ + +/* {{{ spl_array_object_verify_pos */ +static inline int spl_array_object_verify_pos(spl_array_object *object, HashTable *ht TSRMLS_DC) +{ + return spl_array_object_verify_pos_ex(object, ht, "" TSRMLS_CC); +} /* }}} */ + /* {{{ proto bool ArrayObject::offsetExists(mixed $index) proto bool ArrayIterator::offsetExists(mixed $index) Returns whether the requested $index exists. */ @@ -963,17 +985,11 @@ static int spl_array_it_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */ if (object->ar_flags & SPL_ARRAY_OVERLOADED_VALID) { return zend_user_it_valid(iter TSRMLS_CC); } else { - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::valid(): Array was modified outside object and is no longer an array"); - return FAILURE; - } - - if (object->pos && (object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::valid(): Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos_ex(object, aht, "ArrayIterator::valid(): " TSRMLS_CC) == FAILURE) { return FAILURE; - } else { - return zend_hash_has_more_elements_ex(aht, &object->pos); } + + return zend_hash_has_more_elements_ex(aht, &object->pos); } } /* }}} */ @@ -1003,13 +1019,7 @@ static int spl_array_it_get_current_key(zend_object_iterator *iter, char **str_k if (object->ar_flags & SPL_ARRAY_OVERLOADED_KEY) { return zend_user_it_get_current_key(iter, str_key, str_key_len, int_key TSRMLS_CC); } else { - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::current(): Array was modified outside object and is no longer an array"); - return HASH_KEY_NON_EXISTANT; - } - - if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::current(): Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos_ex(object, aht, "ArrayIterator::current(): " TSRMLS_CC) == FAILURE) { return HASH_KEY_NON_EXISTANT; } @@ -1494,13 +1504,7 @@ SPL_METHOD(Array, current) return; } - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) { return; } @@ -1530,13 +1534,7 @@ void spl_array_iterator_key(zval *object, zval *return_value TSRMLS_DC) /* {{{ * ulong num_key; HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) { return; } @@ -1564,13 +1562,12 @@ SPL_METHOD(Array, next) if (zend_parse_parameters_none() == FAILURE) { return; } - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); + + if (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) { return; } - spl_array_next_ex(intern, aht TSRMLS_CC); + spl_array_next_no_verify(intern, aht TSRMLS_CC); } /* }}} */ @@ -1585,14 +1582,8 @@ SPL_METHOD(Array, valid) if (zend_parse_parameters_none() == FAILURE) { return; } - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - if (intern->pos && (intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) { RETURN_FALSE; } else { RETURN_BOOL(zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS); @@ -1611,14 +1602,8 @@ SPL_METHOD(Array, hasChildren) if (zend_parse_parameters_none() == FAILURE) { return; } - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - RETURN_FALSE; - } - if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) { RETURN_FALSE; } @@ -1642,13 +1627,7 @@ SPL_METHOD(Array, getChildren) return; } - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); + if (spl_array_object_verify_pos(intern, aht TSRMLS_CC) == FAILURE) { return; } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 19a68f637..e5dc03073 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1289,6 +1289,8 @@ static union _zend_function *spl_dual_it_get_method(zval **object_ptr, char *met *object_ptr = intern->inner.zobject; function_handler = Z_OBJ_HT_P(*object_ptr)->get_method(object_ptr, method, method_len, key TSRMLS_CC); } + } else { + *object_ptr = intern->inner.zobject; } } return function_handler; diff --git a/ext/spl/tests/SplFileObject_current_basic.phpt b/ext/spl/tests/SplFileObject_current_basic.phpt new file mode 100644 index 000000000..d3f4802a5 --- /dev/null +++ b/ext/spl/tests/SplFileObject_current_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +SPL: SplFileObject::current basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +echo $s->current(); + +?> +--EXPECT-- +<?php diff --git a/ext/spl/tests/SplFileObject_current_error001.phpt b/ext/spl/tests/SplFileObject_current_error001.phpt new file mode 100644 index 000000000..23c126648 --- /dev/null +++ b/ext/spl/tests/SplFileObject_current_error001.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::current variation error +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->seek(2); + +echo $s->current('foo'); +?> +--EXPECTF-- +Warning: SplFileObject::current() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_current_variation001.phpt b/ext/spl/tests/SplFileObject_current_variation001.phpt new file mode 100644 index 000000000..0cc588a7f --- /dev/null +++ b/ext/spl/tests/SplFileObject_current_variation001.phpt @@ -0,0 +1,21 @@ +--TEST-- +SPL: SplFileObject::current variation +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->seek(2); + +echo $s->current(); +echo $s->current(); +?> +--EXPECT-- +//line 3 +//line 3 diff --git a/ext/spl/tests/SplFileObject_getchildren_basic.phpt b/ext/spl/tests/SplFileObject_getchildren_basic.phpt new file mode 100644 index 000000000..065e8eae4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_basic.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::getchildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +var_dump($s->getChildren()); + +?> +--EXPECT-- +NULL diff --git a/ext/spl/tests/SplFileObject_getchildren_error001.phpt b/ext/spl/tests/SplFileObject_getchildren_error001.phpt new file mode 100644 index 000000000..9c17a8297 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getchildren_error001.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::getchildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->getChildren('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::getChildren() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_getflags_basic.phpt b/ext/spl/tests/SplFileObject_getflags_basic.phpt new file mode 100644 index 000000000..5addadf38 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::getFlags basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + +$fo = new SplFileObject('testdata.csv'); + +$fo->setFlags(SplFileObject::DROP_NEW_LINE); +var_dump($fo->getFlags()); +?> +--CLEAN-- +<?php +unlink('testdata.csv'); +?> +--EXPECT-- +int(1) diff --git a/ext/spl/tests/SplFileObject_getflags_error001.phpt b/ext/spl/tests/SplFileObject_getflags_error001.phpt new file mode 100644 index 000000000..1602f8888 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_error001.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::getFlags error 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + + +$fo = new SplFileObject('testdata.csv'); +$fo->setFlags(SplFileObject::READ_CSV); + +$fo->setFlags(SplFileObject::DROP_NEW_LINE); + +var_dump($fo->getFlags()); + +?> +--CLEAN-- +<?php +unlink('testdata.csv'); +?> +--EXPECT-- +int(1) diff --git a/ext/spl/tests/SplFileObject_getflags_error002.phpt b/ext/spl/tests/SplFileObject_getflags_error002.phpt new file mode 100644 index 000000000..e2c8255f4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_error002.phpt @@ -0,0 +1,21 @@ +--TEST-- +SPL: SplFileObject::getFlags error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze@gmail.com> +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + +$fo = new SplFileObject('testdata.csv'); +$fo->setFlags(SplFileObject::READ_CSV); + +$fo->getFlags('fake'); + +?> +--CLEAN-- +<?php +unlink('testdata.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::getFlags() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_getflags_variation001.phpt b/ext/spl/tests/SplFileObject_getflags_variation001.phpt new file mode 100644 index 000000000..640de0351 --- /dev/null +++ b/ext/spl/tests/SplFileObject_getflags_variation001.phpt @@ -0,0 +1,29 @@ +--TEST-- +SPL: SplFileObject::getFlags +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +$fo = new SplFileObject(__FILE__); + +$fo->setFlags(SplFileObject::DROP_NEW_LINE); +var_dump($fo->getFlags()); + +$fo->setFlags(SplFileObject::READ_AHEAD); +var_dump($fo->getFlags()); + +$fo->setFlags(SplFileObject::SKIP_EMPTY); +var_dump($fo->getFlags()); + +$fo->setFlags(SplFileObject::READ_CSV); +var_dump($fo->getFlags()); + +?> +--EXPECT-- +int(1) +int(2) +int(4) +int(8) diff --git a/ext/spl/tests/SplFileObject_haschildren_basic.phpt b/ext/spl/tests/SplFileObject_haschildren_basic.phpt new file mode 100644 index 000000000..1ce00bfd4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_basic.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::haschildren basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +var_dump($s->hasChildren()); + +?> +--EXPECT-- +bool(false) diff --git a/ext/spl/tests/SplFileObject_haschildren_error001.phpt b/ext/spl/tests/SplFileObject_haschildren_error001.phpt new file mode 100644 index 000000000..0c4e1de3b --- /dev/null +++ b/ext/spl/tests/SplFileObject_haschildren_error001.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::haschildren error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->hasChildren('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::hasChildren() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_key_basic.phpt b/ext/spl/tests/SplFileObject_key_basic.phpt new file mode 100644 index 000000000..4081d314e --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::key basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(3); +echo $s->key(); +?> +--EXPECT-- +3 diff --git a/ext/spl/tests/SplFileObject_key_error001.phpt b/ext/spl/tests/SplFileObject_key_error001.phpt new file mode 100644 index 000000000..b0834f002 --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_error001.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::key error +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(12); +$s->next(); +var_dump($s->key()); +var_dump($s->valid()); +?> +--EXPECT-- +int(13) +bool(false) diff --git a/ext/spl/tests/SplFileObject_key_error002.phpt b/ext/spl/tests/SplFileObject_key_error002.phpt new file mode 100644 index 000000000..8fc9b7fef --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_error002.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::key error +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(120); +$s->next(); +var_dump($s->key()); +var_dump($s->valid()); +?> +--EXPECT-- +int(13) +bool(false) diff --git a/ext/spl/tests/SplFileObject_key_error003.phpt b/ext/spl/tests/SplFileObject_key_error003.phpt new file mode 100644 index 000000000..7568cf55f --- /dev/null +++ b/ext/spl/tests/SplFileObject_key_error003.phpt @@ -0,0 +1,15 @@ +--TEST-- +SPL: SplFileObject::key error +--CREDITS-- +Erwin Poeze <erwin.poeze AT gmail.com> +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->key(3); +?> +--EXPECTF-- +Warning: SplFileObject::key() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_next_basic.phpt b/ext/spl/tests/SplFileObject_next_basic.phpt new file mode 100644 index 000000000..59dc7ab58 --- /dev/null +++ b/ext/spl/tests/SplFileObject_next_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +SPL: SplFileObject::next basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +echo $s->current(); +$s->next(); + +echo $s->current(); + +?> +--EXPECT-- +<?php +//line 2 diff --git a/ext/spl/tests/SplFileObject_next_variation001.phpt b/ext/spl/tests/SplFileObject_next_variation001.phpt new file mode 100644 index 000000000..34771dd52 --- /dev/null +++ b/ext/spl/tests/SplFileObject_next_variation001.phpt @@ -0,0 +1,24 @@ +--TEST-- +SPL: SplFileObject::next variation 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(13); +echo $s->current(); + +$s->next(); +echo $s->current(); +var_dump($s->valid()); +?> +--EXPECT-- +?> +bool(false) diff --git a/ext/spl/tests/SplFileObject_next_variation002.phpt b/ext/spl/tests/SplFileObject_next_variation002.phpt new file mode 100644 index 000000000..d48ff8c22 --- /dev/null +++ b/ext/spl/tests/SplFileObject_next_variation002.phpt @@ -0,0 +1,30 @@ +--TEST-- +SPL: SplFileObject::next variation 002, read ahead +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); +$s->seek(2); +echo $s->current(); +$s->next(); +echo $s->current(); + +$s->setFlags(SplFileObject::READ_AHEAD); + +$s->seek(2); +echo $s->current(); +$s->next(); +echo $s->current(); +?> +--EXPECT-- +//line 3 +//line 4 +//line 3 +//line 4 diff --git a/ext/spl/tests/SplFileObject_rewind_basic.phpt b/ext/spl/tests/SplFileObject_rewind_basic.phpt new file mode 100644 index 000000000..331c587e4 --- /dev/null +++ b/ext/spl/tests/SplFileObject_rewind_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +SPL: SplFileObject::rewind basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(3); + +$s->rewind(); +echo $s->current(); +?> +--EXPECT-- +<?php diff --git a/ext/spl/tests/SplFileObject_rewind_error001.phpt b/ext/spl/tests/SplFileObject_rewind_error001.phpt new file mode 100644 index 000000000..bdb3301e6 --- /dev/null +++ b/ext/spl/tests/SplFileObject_rewind_error001.phpt @@ -0,0 +1,18 @@ +--TEST-- +SPL: SplFileObject::rewind() with a parameter. +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php + +file_put_contents('testdata.csv', 'eerste;tweede;derde'); + +$fo = new SplFileObject('testdata.csv'); + +$fo->rewind( "invalid" ); + +?> +--EXPECTF-- +Warning: SplFileObject::rewind() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/SplFileObject_rewind_variation001.phpt b/ext/spl/tests/SplFileObject_rewind_variation001.phpt new file mode 100644 index 000000000..d835c443d --- /dev/null +++ b/ext/spl/tests/SplFileObject_rewind_variation001.phpt @@ -0,0 +1,28 @@ +--TEST-- +SPL: SplFileObject::rewind variation 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(15); +echo $s->current(); +$s->next(); +echo $s->current(); +var_dump($s->valid()); +$s->rewind(); +var_dump($s->valid()); +echo $s->current(); +?> +--EXPECT-- +?> +bool(false) +bool(true) +<?php diff --git a/ext/spl/tests/SplFileObject_seek_basic.phpt b/ext/spl/tests/SplFileObject_seek_basic.phpt new file mode 100644 index 000000000..7106f70cc --- /dev/null +++ b/ext/spl/tests/SplFileObject_seek_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL: SplFileObject::seek basic +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(2); +echo $s->current(); +?> +--EXPECT-- +//line 3 diff --git a/ext/spl/tests/SplFileObject_seek_error002.phpt b/ext/spl/tests/SplFileObject_seek_error002.phpt new file mode 100644 index 000000000..057c8d325 --- /dev/null +++ b/ext/spl/tests/SplFileObject_seek_error002.phpt @@ -0,0 +1,18 @@ +--TEST-- +SPL: SplFileObject::seek error 001 +--CREDITS-- +Ricardo Oedietram <ricardo@odracir.nl> +Erwin Poeze <erwin.poeze@gmail.com> +#PFZ June PHP TestFest 2012 +--FILE-- +<?php +//line 2 +//line 3 +//line 4 +//line 5 +$s = new SplFileObject(__FILE__); + +$s->seek(20); +echo $s->current(); +?> +--EXPECT-- diff --git a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt new file mode 100644 index 000000000..b2630606e --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +SPL: SplFileObject::setCsvControl basic +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('|', '\'', '/'); +foreach ($s as $row) { + list($fruit, $quantity) = $row; + echo "$fruit : $quantity\n"; +} +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECT-- +groene appelen : 10 +gele bananen : 20 +rode kersen : 30 + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt new file mode 100644 index 000000000..f582a4a89 --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt @@ -0,0 +1,24 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('||'); +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::setCsvControl(): delimiter must be a character in %s on line %d + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt new file mode 100644 index 000000000..bcfd9c4dd --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt @@ -0,0 +1,24 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 002 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('|', 'two'); +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::setCsvControl(): enclosure must be a character in %s on line %d + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt new file mode 100644 index 000000000..8b1f54d5a --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt @@ -0,0 +1,26 @@ +--TEST-- +SPL: SplFileObject::setCsvControl error 003 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +'groene appelen'|10 +'gele bananen'|20 +'rode kersen'|30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl('|', '\'', 'three'); +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECTF-- +Warning: SplFileObject::setCsvControl(): escape must be a character in %s on line %d + diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt new file mode 100644 index 000000000..7aaf8a3fe --- /dev/null +++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt @@ -0,0 +1,30 @@ +--TEST-- +SPL: SplFileObject::setCsvControl variation 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +file_put_contents('csv_control_data.csv', +<<<CDATA +"groene appelen",10 +"gele bananen",20 +"rode kersen",30 +CDATA +); +$s = new SplFileObject('csv_control_data.csv'); +$s->setFlags(SplFileObject::READ_CSV); +$s->setCsvControl(); +foreach ($s as $row) { + list($fruit, $quantity) = $row; + echo "$fruit : $quantity\n"; +} +?> +--CLEAN-- +<?php +unlink('csv_control_data.csv'); +?> +--EXPECT-- +groene appelen : 10 +gele bananen : 20 +rode kersen : 30 + diff --git a/ext/spl/tests/bug61527.phpt b/ext/spl/tests/bug61527.phpt new file mode 100644 index 000000000..ab13c6954 --- /dev/null +++ b/ext/spl/tests/bug61527.phpt @@ -0,0 +1,92 @@ +--TEST-- +Bug #61527 (Recursive/ArrayIterator gives misleading notice when array empty or moved to the end) +--FILE-- +<?php +$ao = new ArrayObject(array()); +$ai = $ao->getIterator(); + +/* testing empty array, should no notice at all */ +$ai->next(); +var_dump($ai->key()); +var_dump($ai->current()); + +/* testing array changing */ +$ao2 = new ArrayObject(array(1 => 1, 2, 3, 4, 5)); +$ai2 = $ao2->getIterator(); + +$ao2->offsetUnset($ai2->key()); +$ai2->next(); + +/* now point to 2 */ +$ao2->offsetUnset($ai2->key()); +var_dump($ai2->key()); + +/* now point to 3 */ +$ao2->offsetUnset($ai2->key()); +var_dump($ai2->current()); + +$ai2->next(); +var_dump($ai2->key()); +var_dump($ai2->current()); + +/* should be at the end and no notice */ +$ai2->next(); +var_dump($ai2->key()); +var_dump($ai2->current()); + +$ai2->rewind(); +$ai2->next(); +$ai2->next(); +/* should reached the end */ +var_dump($ai2->next()); +var_dump($ai2->key()); + +/* testing RecursiveArrayIterator */ +$ao3 = new ArrayObject(array(), NULL, 'RecursiveArrayIterator'); +$ai3 = $ao3->getIterator(); + +var_dump($ai3->getChildren()); + +$ao4 = new ArrayObject(array(1, 2), NULL, 'RecursiveArrayIterator'); +$ai4 = $ao4->getIterator(); + +$ai4->next(); +$ai4->next(); +$ai4->next(); +var_dump($ai4->hasChildren()); + +$ai4->rewind(); +$ao4->offsetUnset($ai4->key()); +var_dump($ai4->hasChildren()); + +$ao4->offsetUnset($ai4->key()); +var_dump($ai4->getChildren()); +?> +==DONE== +<?php exit(0); ?> +--EXPECTF-- +NULL +NULL + +Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d + +Notice: ArrayIterator::key(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +NULL + +Notice: ArrayIterator::current(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +NULL +int(5) +int(5) +NULL +NULL +NULL +NULL +NULL +bool(false) + +Notice: RecursiveArrayIterator::hasChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +bool(false) + +Notice: RecursiveArrayIterator::getChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d +NULL +==DONE== diff --git a/ext/spl/tests/bug62433.phpt b/ext/spl/tests/bug62433.phpt index 86b5df838..bfb3568ba 100644 --- a/ext/spl/tests/bug62433.phpt +++ b/ext/spl/tests/bug62433.phpt @@ -5,11 +5,11 @@ Bug #62433 Inconsistent behavior of RecursiveDirectoryIterator to dot files (. a $dots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__))); $ndots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS))); -var_dump(in_array(__DIR__ . '/.', $dots)); -var_dump(in_array(__DIR__ . '/..', $dots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $dots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $dots)); -var_dump(in_array(__DIR__ . '/.', $ndots)); -var_dump(in_array(__DIR__ . '/..', $ndots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $ndots)); +var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $ndots)); ?> --EXPECT-- bool(true) diff --git a/ext/spl/tests/bug62616.phpt b/ext/spl/tests/bug62616.phpt new file mode 100644 index 000000000..4e4be9449 --- /dev/null +++ b/ext/spl/tests/bug62616.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #62616 (ArrayIterator::count() from IteratorIterator instance gives Segmentation fault) +--FILE-- +<?php +$ai = new ArrayIterator(array(0,1)); + +var_dump($ai->count()); + +$ii = new IteratorIterator($ai); + +var_dump($ii->count()); +?> +--EXPECTF-- +int(2) +int(2) diff --git a/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt new file mode 100644 index 000000000..3c0c9eebd --- /dev/null +++ b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt @@ -0,0 +1,14 @@ +--TEST-- +SPL: SplFileObject::getMaxLineLen error 001 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--INI-- +include_path=. +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->getMaxLineLen('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::getMaxLineLen() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt new file mode 100644 index 000000000..6bfdfdcf5 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt @@ -0,0 +1,17 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 001() +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +try { + $s->setMaxLineLen(-1); +} +catch (DomainException $e) { + echo 'DomainException thrown'; +} + +?> +--EXPECT-- +DomainException thrown diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt new file mode 100644 index 000000000..dad59fca5 --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 002 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->setMaxLineLen(); + +?> +--EXPECTF-- +Warning: SplFileObject::setMaxLineLen() expects exactly 1 parameter, 0 given in %s on line %d diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt new file mode 100644 index 000000000..8dc50d5fc --- /dev/null +++ b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL: SplFileObject::setMaxLineLen error 003 +--CREDITS-- +Erwin Poeze <erwin.poeze at gmail.com> +--FILE-- +<?php +$s = new SplFileObject( __FILE__ ); +$s->setMaxLineLen('string'); + +?> +--EXPECTF-- +Warning: SplFileObject::setMaxLineLen() expects parameter 1 to be long, string given in %s on line %d diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index a5637db50..e6de34e5f 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3719,8 +3719,6 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ /* Default to global filters only */ FG(stream_filters) = NULL; - FG(wrapper_errors) = NULL; - return SUCCESS; } /* }}} */ diff --git a/ext/standard/file.c b/ext/standard/file.c index 7d01d3135..cce0143ff 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -161,6 +161,7 @@ static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC) FG(pclose_ret) = 0; FG(user_stream_current_filename) = NULL; FG(def_chunk_size) = PHP_SOCK_CHUNK_SIZE; + FG(wrapper_errors) = NULL; } static void file_globals_dtor(php_file_globals *file_globals_p TSRMLS_DC) diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 0ca2f04cf..f6d3750e2 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -109,6 +109,8 @@ static zend_object_value php_create_incomplete_object(zend_class_entry *class_ty value = zend_objects_new(&object, class_type TSRMLS_CC); value.handlers = &php_incomplete_object_handlers; + object_properties_init(object, class_type); + return value; } diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 36568c508..364f7fc39 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -39,6 +39,7 @@ #endif #endif +#include "php_syslog.h" #include "php_mail.h" #include "php_ini.h" #include "php_string.h" @@ -189,6 +190,37 @@ PHP_FUNCTION(mail) } /* }}} */ + +void php_mail_log_crlf_to_spaces(char *message) { + /* Find all instances of carriage returns or line feeds and + * replace them with spaces. Thus, a log line is always one line + * long + */ + char *p = message; + while ((p = strpbrk(p, "\r\n"))) { + *p = ' '; + } +} + +void php_mail_log_to_syslog(char *message) { + /* Write 'message' to syslog. */ +#ifdef HAVE_SYSLOG_H + php_syslog(LOG_NOTICE, "%s", message); +#endif +} + + +void php_mail_log_to_file(char *filename, char *message, size_t message_size TSRMLS_DC) { + /* Write 'message' to the given file. */ + uint flags = IGNORE_URL_WIN | REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR; + php_stream *stream = php_stream_open_wrapper(filename, "a", flags, NULL); + if (stream) { + php_stream_write(stream, message, message_size); + php_stream_close(stream); + } +} + + /* {{{ php_mail */ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC) @@ -216,19 +248,22 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char if (mail_log && *mail_log) { char *tmp; int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); - php_stream *stream = php_stream_open_wrapper(mail_log, "a", IGNORE_URL_WIN | REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR, NULL); - if (hdr) { /* find all \r\n instances and replace them with spaces, so a log line is always one line long */ - char *p = tmp; - while ((p = strpbrk(p, "\r\n"))) { - *p = ' '; - } - tmp[l - 1] = '\n'; + if (hdr) { + php_mail_log_crlf_to_spaces(tmp); } - if (stream) { - php_stream_write(stream, tmp, l); - php_stream_close(stream); + + if (!strcmp(mail_log, "syslog")) { + /* Drop the final space when logging to syslog. */ + tmp[l - 1] = 0; + php_mail_log_to_syslog(tmp); + } + else { + /* Convert the final space to a newline when logging to file. */ + tmp[l - 1] = '\n'; + php_mail_log_to_file(mail_log, tmp, l TSRMLS_CC); } + efree(tmp); } if (PG(mail_x_header)) { diff --git a/ext/standard/math.c b/ext/standard/math.c index 65187f6fa..6e934a385 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1097,7 +1097,9 @@ PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char tho return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1); } -PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len) +static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point, + size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len, + int *result_len) { char *tmpbuf = NULL, *resbuf; char *s, *t; /* source, target */ @@ -1118,6 +1120,10 @@ PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, size tmplen = spprintf(&tmpbuf, 0, "%.*F", dec, d); if (tmpbuf == NULL || !isdigit((int)tmpbuf[0])) { + if (result_len) { + *result_len = tmplen; + } + return tmpbuf; } @@ -1205,8 +1211,19 @@ PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, size efree(tmpbuf); + if (result_len) { + *result_len = reslen; + } + return resbuf; } + +PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point, + size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len) +{ + return _php_math_number_format_ex_len(d, dec, dec_point, dec_point_len, + thousand_sep, thousand_sep_len, NULL); +} /* }}} */ /* {{{ proto string number_format(float number [, int num_decimal_places [, string dec_seperator, string thousands_seperator]]) @@ -1241,7 +1258,10 @@ PHP_FUNCTION(number_format) thousand_sep_len = 1; } - RETURN_STRING(_php_math_number_format_ex(num, dec, dec_point, dec_point_len, thousand_sep, thousand_sep_len), 0); + Z_TYPE_P(return_value) = IS_STRING; + Z_STRVAL_P(return_value) = _php_math_number_format_ex_len(num, dec, + dec_point, dec_point_len, thousand_sep, thousand_sep_len, + &Z_STRLEN_P(return_value)); break; default: WRONG_PARAM_COUNT; diff --git a/ext/standard/string.c b/ext/standard/string.c index 5c33232f7..9a64376c2 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -131,8 +131,8 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t * register unsigned char *result = NULL; size_t i, j; - result = (unsigned char *) safe_emalloc(oldlen * 2, sizeof(char), 1); - + result = (unsigned char *) safe_emalloc(oldlen, 2 * sizeof(char), 1); + for (i = j = 0; i < oldlen; i++) { result[j++] = hexconvtab[old[i] >> 4]; result[j++] = hexconvtab[old[i] & 15]; @@ -4029,13 +4029,12 @@ PHP_FUNCTION(nl2br) RETURN_STRINGL(str, str_len, 1); } - if (is_xhtml) { - new_length = str_len + repl_cnt * (sizeof("<br />") - 1); - } else { - new_length = str_len + repl_cnt * (sizeof("<br>") - 1); - } + { + size_t repl_len = is_xhtml ? (sizeof("<br />") - 1) : (sizeof("<br>") - 1); - tmp = target = emalloc(new_length + 1); + new_length = str_len + repl_cnt * repl_len; + tmp = target = safe_emalloc(repl_cnt, repl_len, str_len + 1); + } while (str < end) { switch (*str) { diff --git a/ext/standard/tests/file/realpath_cache.phpt b/ext/standard/tests/file/realpath_cache.phpt index 92d6fc5b2..2dac21ec4 100644 --- a/ext/standard/tests/file/realpath_cache.phpt +++ b/ext/standard/tests/file/realpath_cache.phpt @@ -19,7 +19,7 @@ echo "Done\n"; int(%d) array(4) { ["key"]=> - %s(%d) + %s(%s) ["is_dir"]=> bool(true) ["realpath"]=> diff --git a/ext/standard/tests/general_functions/bug27678.phpt b/ext/standard/tests/general_functions/bug27678.phpt index 5db5890a1..6f95509e1 100644 --- a/ext/standard/tests/general_functions/bug27678.phpt +++ b/ext/standard/tests/general_functions/bug27678.phpt @@ -6,9 +6,11 @@ Bug #27678 (number_format() crashes with large numbers) number_format(1e80, 0, '', ' '); number_format(1e300, 0, '', ' '); number_format(1e320, 0, '', ' '); -number_format(1e1000, 0, '', ' '); +$num = number_format(1e1000, 0, '', ' '); +var_dump(strlen($num) == 3); // $num == 'inf' echo "Done\n"; ?> --EXPECT-- +bool(true) Done diff --git a/ext/standard/tests/general_functions/debug_zval_dump_o.phpt b/ext/standard/tests/general_functions/debug_zval_dump_o.phpt index dd4b5142a..78f0f0300 100644 --- a/ext/standard/tests/general_functions/debug_zval_dump_o.phpt +++ b/ext/standard/tests/general_functions/debug_zval_dump_o.phpt @@ -1,5 +1,7 @@ --TEST-- Test debug_zval_dump() function : working on objects +--SKIPIF-- +<?php if (PHP_ZTS) { print "skip only for no-zts build"; } --FILE-- <?php /* Prototype: void debug_zval_dump ( mixed $variable ); diff --git a/ext/standard/tests/general_functions/uniqid_basic.phpt b/ext/standard/tests/general_functions/uniqid_basic.phpt index 9a9c57332..2da832b8e 100644 --- a/ext/standard/tests/general_functions/uniqid_basic.phpt +++ b/ext/standard/tests/general_functions/uniqid_basic.phpt @@ -1,73 +1,72 @@ ---TEST--
-Test uniqid() function : basic functionality
---FILE--
-<?php
-/* Prototype : string uniqid ([ string $prefix= "" [, bool $more_entropy= false ]] )
- * Description: Gets a prefixed unique identifier based on the current time in microseconds.
- * Source code: ext/standard/uniqid.c
-*/
-echo "*** Testing uniqid() : basic functionality ***\n";
-
-echo "\nuniqid() without a prefix\n";
-var_dump(uniqid());
-var_dump(uniqid(null, true));
-var_dump(uniqid(null, false));
-echo "\n\n";
-
-echo "uniqid() with a prefix\n";
-
-// Use a fixed prefix so we can ensure length of o/p id is fixed
-$prefix = array (
- 99999,
- "99999",
- 10.5e2,
- null,
- true,
- false
- );
-
-for ($i = 0; $i < count($prefix); $i++) {
- var_dump(uniqid($prefix[$i]));
- var_dump(uniqid($prefix[$i], true));
- var_dump(uniqid($prefix[$i], false));
- echo "\n";
-}
-
-?>
-===DONE===
---EXPECTF--
-*** Testing uniqid() : basic functionality ***
-
-uniqid() without a prefix
-string(13) "%s"
-string(23) "%s.%s"
-string(13) "%s"
-
-
-uniqid() with a prefix
-string(18) "99999%s"
-string(28) "99999%s.%s"
-string(18) "99999%s"
-
-string(18) "999994%s"
-string(28) "999994%s.%s"
-string(18) "999994%s"
-
-string(17) "1050%s"
-string(27) "1050%s.%s"
-string(17) "1050%s"
-
-string(13) "%s"
-string(23) "%s.%s"
-string(13) "%s"
-
-string(14) "1%s"
-string(24) "1%s.%s"
-string(14) "1%s"
-
-string(13) "%s"
-string(23) "%s.%s"
-string(13) "%s"
-
-===DONE===
-
\ No newline at end of file +--TEST-- +Test uniqid() function : basic functionality +--FILE-- +<?php +/* Prototype : string uniqid ([ string $prefix= "" [, bool $more_entropy= false ]] ) + * Description: Gets a prefixed unique identifier based on the current time in microseconds. + * Source code: ext/standard/uniqid.c +*/ +echo "*** Testing uniqid() : basic functionality ***\n"; + +echo "\nuniqid() without a prefix\n"; +var_dump(uniqid()); +var_dump(uniqid(null, true)); +var_dump(uniqid(null, false)); +echo "\n\n"; + +echo "uniqid() with a prefix\n"; + +// Use a fixed prefix so we can ensure length of o/p id is fixed +$prefix = array ( + 99999, + "99999", + 10.5e2, + null, + true, + false + ); + +for ($i = 0; $i < count($prefix); $i++) { + var_dump(uniqid($prefix[$i])); + var_dump(uniqid($prefix[$i], true)); + var_dump(uniqid($prefix[$i], false)); + echo "\n"; +} + +?> +===DONE=== +--EXPECTF-- +*** Testing uniqid() : basic functionality *** + +uniqid() without a prefix +string(13) "%s" +string(23) "%s.%s" +string(13) "%s" + + +uniqid() with a prefix +string(18) "99999%s" +string(28) "99999%s.%s" +string(18) "99999%s" + +string(18) "99999%s" +string(28) "99999%s.%s" +string(18) "99999%s" + +string(17) "1050%s" +string(27) "1050%s.%s" +string(17) "1050%s" + +string(13) "%s" +string(23) "%s.%s" +string(13) "%s" + +string(14) "1%s" +string(24) "1%s.%s" +string(14) "1%s" + +string(13) "%s" +string(23) "%s.%s" +string(13) "%s" + +===DONE=== diff --git a/ext/standard/tests/math/bug62112.phpt b/ext/standard/tests/math/bug62112.phpt Binary files differnew file mode 100644 index 000000000..01de35a9c --- /dev/null +++ b/ext/standard/tests/math/bug62112.phpt diff --git a/ext/standard/tests/streams/bug61115-1.phpt b/ext/standard/tests/streams/bug61115-1.phpt index 89374e735..99e2f7929 100644 --- a/ext/standard/tests/streams/bug61115-1.phpt +++ b/ext/standard/tests/streams/bug61115-1.phpt @@ -1,5 +1,11 @@ --TEST-- Bug #61115: Stream related segfault on fatal error in php_stream_context_del_link - variation 1 +--SKIPIF-- +<?php +if (getenv("USE_ZEND_ALLOC") === "0") { + die("skip Zend MM disabled"); +} +?> --FILE-- <?php diff --git a/ext/standard/tests/strings/http_build_query_variation1.phpt b/ext/standard/tests/strings/http_build_query_variation1.phpt new file mode 100644 index 000000000..56d81c9fd --- /dev/null +++ b/ext/standard/tests/strings/http_build_query_variation1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test http_build_query() function: usage variations - first arguments as object +--CREDITS-- +Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com> +--FILE-- +<?php +/* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] ) + * Description: Generates a URL-encoded query string from the associative (or indexed) array provided. + * Source code: ext/standard/http.c +*/ + +class UrlBuilder +{ + public $name = 'homepage'; + public $page = 1; + protected $sort = 'desc,name'; + private $access = 'admin'; +} + +$obj = new stdClass; +$obj->name = 'homepage'; +$obj->page = 1; +$obj->sort = 'desc,name'; + +echo http_build_query($obj) . PHP_EOL; +echo http_build_query(new UrlBuilder()); +?> +--EXPECTF-- +name=homepage&page=1&sort=desc%2Cname +name=homepage&page=1 diff --git a/ext/standard/tests/strings/http_build_query_variation2.phpt b/ext/standard/tests/strings/http_build_query_variation2.phpt new file mode 100644 index 000000000..ca1d8f459 --- /dev/null +++ b/ext/standard/tests/strings/http_build_query_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test http_build_query() function: usage variations - first arguments as multidimensional array and second argument present/not present +--CREDITS-- +Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com> +--FILE-- +<?php +/* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] ) + * Description: Generates a URL-encoded query string from the associative (or indexed) array provided. + * Source code: ext/standard/http.c +*/ + +$mDimensional = array( + 20, + 5 => 13, + "9" => array( + 1 => "val1", + 3 => "val2", + "string" => "string" + ), + "name" => "homepage", + "page" => 10, + "sort" => array( + "desc", + "admin" => array( + "admin1", + "admin2" => array( + "who" => "admin2", + 2 => "test" + ) + ) + ) +); + +echo http_build_query($mDimensional) . PHP_EOL; +echo http_build_query($mDimensional, 'prefix_'); +?> +--EXPECTF-- +0=20&5=13&9%5B1%5D=val1&9%5B3%5D=val2&9%5Bstring%5D=string&name=homepage&page=10&sort%5B0%5D=desc&sort%5Badmin%5D%5B0%5D=admin1&sort%5Badmin%5D%5Badmin2%5D%5Bwho%5D=admin2&sort%5Badmin%5D%5Badmin2%5D%5B2%5D=test +prefix_0=20&prefix_5=13&prefix_9%5B1%5D=val1&prefix_9%5B3%5D=val2&prefix_9%5Bstring%5D=string&name=homepage&page=10&sort%5B0%5D=desc&sort%5Badmin%5D%5B0%5D=admin1&sort%5Badmin%5D%5Badmin2%5D%5Bwho%5D=admin2&sort%5Badmin%5D%5Badmin2%5D%5B2%5D=test diff --git a/ext/standard/tests/strings/http_build_query_variation3.phpt b/ext/standard/tests/strings/http_build_query_variation3.phpt new file mode 100644 index 000000000..107120e08 --- /dev/null +++ b/ext/standard/tests/strings/http_build_query_variation3.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test http_build_query() function: usage variations - testing four parameter added in PHP 5.4.0 +--CREDITS-- +Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com> +--SKIPIF-- +<?php + if (version_compare(PHP_VERSION, '5.4.0', '<')) die("skip this test if PHP_VERSION is less than 5.4.0"); +?> +--FILE-- +<?php +/* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] ) + * Description: Generates a URL-encoded query string from the associative (or indexed) array provided. + * Source code: ext/standard/http.c +*/ + +$oDimensional = array( + "name" => "main page", + "sort" => "desc,admin", + "equation" => "10 + 10 - 5" +); + +echo http_build_query($oDimensional, '', ini_get('arg_separator.output'), PHP_QUERY_RFC1738) . PHP_EOL; +echo http_build_query($oDimensional, '', ini_get('arg_separator.output'), PHP_QUERY_RFC3986); +?> +--EXPECTF-- +name=main+page&sort=desc%2Cadmin&equation=10+%2B+10+-+5 +name=main%20page&sort=desc%2Cadmin&equation=10%20%2B%2010%20-%205 diff --git a/ext/standard/tests/zend_logo_guid.phpt b/ext/standard/tests/zend_logo_guid.phpt index d26ed45e9..44e213b25 100644 --- a/ext/standard/tests/zend_logo_guid.phpt +++ b/ext/standard/tests/zend_logo_guid.phpt @@ -1,5 +1,5 @@ --TEST-- -Checking the zend_logo_guid() functio +Checking the zend_logo_guid() function --CREDITS-- Sebastian Schürmann sschuermann@chip.de diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 3d8c90cbf..e895e0e48 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -54,6 +54,8 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) long output_compression_level; char *output_handler; php_zlib_context *ob_gzhandler; + long output_compression_default; + zend_bool handler_registered; ZEND_END_MODULE_GLOBALS(zlib); php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); diff --git a/ext/zlib/tests/bug55544.phpt b/ext/zlib/tests/bug55544.phpt Binary files differnew file mode 100644 index 000000000..ca4214a46 --- /dev/null +++ b/ext/zlib/tests/bug55544.phpt diff --git a/ext/zlib/tests/bug_52944.phpt b/ext/zlib/tests/bug_52944.phpt index 850371190..c090fe6f5 100644 --- a/ext/zlib/tests/bug_52944.phpt +++ b/ext/zlib/tests/bug_52944.phpt @@ -2,6 +2,11 @@ Bug #52944 (segfault with zlib filter and corrupted data)
--SKIPIF--
<?php if (!extension_loaded("zlib")) print "skip"; ?>
+<?php
+include "func.inc";
+if (substr(PHP_OS, 0, 3) == 'WIN' && version_compare(get_zlib_version(), '1.2.7') < 0) {
+ die('skip - only for zlib >= 1.2.7 on windows');
+}
--INI--
allow_url_fopen=1
--FILE--
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index c6e2e0cf8..7ff2b30c4 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -263,6 +263,8 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name ZLIBG(output_compression) = chunk_size ? chunk_size : PHP_OUTPUT_HANDLER_DEFAULT_SIZE; } + ZLIBG(handler_registered) = 1; + if ((h = php_output_handler_create_internal(handler_name, handler_name_len, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) { php_output_handler_set_context(h, php_zlib_output_handler_context_init(TSRMLS_C), php_zlib_output_handler_context_dtor TSRMLS_CC); } @@ -690,6 +692,7 @@ PHP_ZLIB_ENCODE_FUNC(zlib_encode, 0); /* {{{ proto binary zlib_decode(binary data[, int max_decoded_len]) Uncompress any raw/gzip/zlib encoded data */ PHP_ZLIB_DECODE_FUNC(zlib_decode, PHP_ZLIB_ENCODING_ANY); +/* }}} */ /* NOTE: The naming of these userland functions was quite unlucky */ /* {{{ proto binary gzdeflate(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_RAW]) @@ -701,18 +704,22 @@ PHP_ZLIB_ENCODE_FUNC(gzdeflate, PHP_ZLIB_ENCODING_RAW); Encode data with the gzip encoding */ PHP_ZLIB_ENCODE_FUNC(gzencode, PHP_ZLIB_ENCODING_GZIP); /* }}} */ + /* {{{ proto binary gzcompress(binary data[, int level = -1[, int encoding = ZLIB_ENCODING_DEFLATE]) Encode data with the zlib encoding */ PHP_ZLIB_ENCODE_FUNC(gzcompress, PHP_ZLIB_ENCODING_DEFLATE); /* }}} */ + /* {{{ proto binary gzinflate(binary data[, int max_decoded_len]) Decode raw deflate encoded data */ PHP_ZLIB_DECODE_FUNC(gzinflate, PHP_ZLIB_ENCODING_RAW); /* }}} */ + /* {{{ proto binary gzdecode(binary data[, int max_decoded_len]) Decode gzip encoded data */ PHP_ZLIB_DECODE_FUNC(gzdecode, PHP_ZLIB_ENCODING_GZIP); /* }}} */ + /* {{{ proto binary gzuncompress(binary data[, int max_decoded_len]) Decode zlib encoded data */ PHP_ZLIB_DECODE_FUNC(gzuncompress, PHP_ZLIB_ENCODING_DEFLATE); @@ -890,6 +897,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) status = OnUpdateLong(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + ZLIBG(output_compression) = ZLIBG(output_compression_default); if (stage == PHP_INI_STAGE_RUNTIME && int_value) { if (!php_output_handler_started(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME) TSRMLS_CC)) { php_zlib_output_compression_start(TSRMLS_C); @@ -914,7 +922,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_handler) /* {{{ INI */ PHP_INI_BEGIN() - STD_PHP_INI_BOOLEAN("zlib.output_compression", "0", PHP_INI_ALL, OnUpdate_zlib_output_compression, output_compression, zend_zlib_globals, zlib_globals) + STD_PHP_INI_BOOLEAN("zlib.output_compression", "0", PHP_INI_ALL, OnUpdate_zlib_output_compression, output_compression_default, zend_zlib_globals, zlib_globals) STD_PHP_INI_ENTRY("zlib.output_compression_level", "-1", PHP_INI_ALL, OnUpdateLong, output_compression_level, zend_zlib_globals, zlib_globals) STD_PHP_INI_ENTRY("zlib.output_handler", "", PHP_INI_ALL, OnUpdate_zlib_output_handler, output_handler, zend_zlib_globals, zlib_globals) PHP_INI_END() @@ -958,19 +966,24 @@ static PHP_MSHUTDOWN_FUNCTION(zlib) static PHP_RINIT_FUNCTION(zlib) { ZLIBG(compression_coding) = 0; - - php_zlib_output_compression_start(TSRMLS_C); + if (!ZLIBG(handler_registered)) { + ZLIBG(output_compression) = ZLIBG(output_compression_default); + php_zlib_output_compression_start(TSRMLS_C); + } return SUCCESS; } /* }}} */ +/* {{{ PHP_RSHUTDOWN_FUNCTION */ static PHP_RSHUTDOWN_FUNCTION(zlib) { php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C); + ZLIBG(handler_registered) = 0; return SUCCESS; } +/* }}} */ /* {{{ PHP_MINFO_FUNCTION */ static PHP_MINFO_FUNCTION(zlib) @@ -991,6 +1004,7 @@ static PHP_MINFO_FUNCTION(zlib) static ZEND_MODULE_GLOBALS_CTOR_D(zlib) { zlib_globals->ob_gzhandler = NULL; + zlib_globals->handler_registered = 0; } /* }}} */ |