summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2013-07-08 20:28:51 +0200
committerAndrey Hristov <andrey@php.net>2013-07-08 20:28:51 +0200
commit2c3f6dcdb6de8cd43371e91fb470e547aa217327 (patch)
tree6a51ff7f6c31d6e99a248eada3e2052d26ebc680
parent9fc38183b707341b6eddb8c196d0ea2b7c13d6a9 (diff)
parente4a28b7b7b972fecd01458364c0663195352891e (diff)
downloadphp-git-2c3f6dcdb6de8cd43371e91fb470e547aa217327.tar.gz
Merge branch 'PHP-5.4' of ssh://git.php.net/php-src into PHP-5.4
Conflicts: NEWS
-rw-r--r--NEWS32
-rwxr-xr-xUPGRADING3
-rw-r--r--Zend/acinclude.m42
-rw-r--r--Zend/zend_alloc.c4
-rw-r--r--ext/dba/tests/bug38698.phpt10
-rw-r--r--ext/imap/php_imap.c7
-rw-r--r--ext/intl/grapheme/grapheme_string.c18
-rw-r--r--ext/intl/grapheme/grapheme_util.c388
-rw-r--r--ext/intl/grapheme/grapheme_util.h24
-rw-r--r--ext/intl/tests/bug61860.phpt18
-rw-r--r--ext/mysqli/mysqli_nonapi.c4
-rw-r--r--ext/mysqlnd/mysqlnd.c4
-rw-r--r--ext/pdo_dblib/dblib_driver.c6
-rw-r--r--ext/pdo_mysql/tests/mysql_pdo_test.inc6
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt5
-rw-r--r--ext/phar/Makefile.frag4
-rw-r--r--ext/phar/config.m42
-rw-r--r--ext/phar/phar.1.in523
-rw-r--r--ext/phar/phar.phar.1.in1
-rw-r--r--ext/session/mod_files.sh67
-rw-r--r--ext/session/session.c29
-rw-r--r--ext/session/tests/session_name_error.phpt100
-rw-r--r--ext/session/tests/session_name_variation1.phpt12
-rw-r--r--ext/spl/spl_directory.c14
-rw-r--r--ext/spl/spl_fixedarray.c33
-rw-r--r--ext/spl/tests/SplFixedArray_serialize.phpt52
-rw-r--r--ext/standard/tests/array/array_walk_closure.phpt4
-rw-r--r--ext/xml/xml.c90
-rw-r--r--sapi/cgi/Makefile.frag3
-rw-r--r--sapi/cgi/config9.m42
-rw-r--r--sapi/cgi/php-cgi.1.in1
-rw-r--r--sapi/cli/php.1.in2
-rw-r--r--sapi/fpm/fpm/fpm_sockets.c13
33 files changed, 1038 insertions, 445 deletions
diff --git a/NEWS b/NEWS
index 04dc4828de..d20ec7ebbe 100644
--- a/NEWS
+++ b/NEWS
@@ -9,18 +9,30 @@ PHP NEWS
(Adam)
. Fixed bug #62964 (Possible XSS on "Registered stream filters" info).
(david at nnucomputerwhiz dot com)
- . Fixed bug #62672 (Error on serialize of ArrayObject).
- (lior dot k at zend dot com)
+ . Fixed bug #62672 (Error on serialize of ArrayObject). (Lior Kaplan)
. Fixed bug #62475 (variant_* functions causes crash when null given as an
argument). (Felipe)
. Fixed bug #60732 (php_error_docref links to invalid pages). (Jakub Vrana)
+- CGI:
+ . Fixed Bug #65143 (Missing php-cgi man page). (Remi)
+
- CLI server:
. Fixed bug #65066 (Cli server not responsive when responding with 422 http
status code). (Adam)
+
+- FPM:
+ . Fixed bug #63983 (enabling FPM borks compile on FreeBSD).
+ (chibisuke at web dot de, Felipe)
+
+- Imap:
+ . Fixed bug #64467 (Segmentation fault after imap_reopen failure).
+ (askalski at gmail dot com)
- Intl:
- . Fixed bug #62759: Buggy grapheme_substr() on edge case. (Stas)
+ . Fixed bug #62759 (Buggy grapheme_substr() on edge case). (Stas)
+ . Fixed bug #61860 (Offsets may be wrong for grapheme_stri* functions).
+ (Stas)
- mysqlnd:
. Fixed segfault in mysqlnd when doing long prepare. (Andrey)
@@ -33,13 +45,27 @@ PHP NEWS
. Allowed PDO_OCI to compile with Oracle Database 12c client libraries.
(Chris Jones)
+- Phar:
+ . Fixed Bug #65142 (Missing phar man page). (Remi)
+
+- Session
+ . Fixed bug #62535 ($_SESSION[$key]["cancel_upload"] doesn't work as
+ documented). (Arpad)
+ . Fixed bug #35703 (when session_name("123") consist only digits,
+ should warning). (Yasuo)
+ . Fixed bug #49175 (mod_files.sh does not support hash bits). Patch by
+ oorza2k5 at gmail dot com (Yasuo)
+
- Sockets:
. Implemented FR #63472 (Setting SO_BINDTODEVICE with socket_set_option).
(Damjan Cvetko)
- SPL:
+ . Fixed bug #65136 (RecursiveDirectoryIterator segfault). (Laruence)
. Fixed bug #61828 (Memleak when calling Directory(Recursive)Iterator
/Spl(Temp)FileObject ctor twice). (Laruence)
+ . Fixed bug #60560 (SplFixedArray un-/serialize, getSize(), count() return 0,
+ keys are strings). (Adam)
?? ??? 2013, PHP 5.4.17
diff --git a/UPGRADING b/UPGRADING
index 0293a6a660..e6f582a4a8 100755
--- a/UPGRADING
+++ b/UPGRADING
@@ -640,6 +640,9 @@ c. New functions
- SPL
- class_uses()
+ - SplFixedArray
+ - SplFixedArray::__wakeup() (5.4.18)
+
d. New global constants
- CURLOPT_MAX_RECV_SPEED_LARGE
diff --git a/Zend/acinclude.m4 b/Zend/acinclude.m4
index 136d2d8bef..77430aba79 100644
--- a/Zend/acinclude.m4
+++ b/Zend/acinclude.m4
@@ -4,7 +4,7 @@ dnl This file contains local autoconf functions.
AC_DEFUN([LIBZEND_BISON_CHECK],[
# we only support certain bison versions
- bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.5.1 2.6 2.6.1 2.6.2"
+ bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.5.1 2.6 2.6.1 2.6.2 2.6.4"
# for standalone build of Zend Engine
test -z "$SED" && SED=sed
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 0bbd59a357..596c2498bc 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -2461,7 +2461,7 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
size_t res = nmemb;
unsigned long overflow = 0;
- __asm__ ("mull %3\n\taddl %4,%0\n\tadcl %1,%1"
+ __asm__ ("mull %3\n\taddl %4,%0\n\tadcl $0,%1"
: "=&a"(res), "=&d" (overflow)
: "%0"(res),
"rm"(size),
@@ -2489,7 +2489,7 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
__asm__ ("mul" LP_SUFF " %3\n\t"
"add %4,%0\n\t"
- "adc %1,%1"
+ "adc $0,%1"
: "=&a"(res), "=&d" (overflow)
: "%0"(res),
"rm"(size),
diff --git a/ext/dba/tests/bug38698.phpt b/ext/dba/tests/bug38698.phpt
index 56dde85268..1d1ed674fe 100644
--- a/ext/dba/tests/bug38698.phpt
+++ b/ext/dba/tests/bug38698.phpt
@@ -8,10 +8,18 @@ Bug #38698 (Bug #38698 for some keys cdbmake creates corrupted db and cdb can't
--FILE--
<?php
+function isLittleEndian() {
+ return 0x00FF === current(unpack('v', pack('S',0x00FF)));
+}
+
$db_file = dirname(__FILE__) .'/129php.cdb';
if (($db_make=dba_open($db_file, "n", 'cdb_make'))!==FALSE) {
- dba_insert(pack('i',129), "Booo!", $db_make);
+ if (isLittleEndian() === FALSE) {
+ dba_insert(pack('V',129), "Booo!", $db_make);
+ } else{
+ dba_insert(pack('i',129), "Booo!", $db_make);
+ }
dba_close($db_make);
// write md5 checksum of generated database file
var_dump(md5_file($db_file));
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index b154cb86b0..d697fa7911 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -1270,7 +1270,6 @@ PHP_FUNCTION(imap_reopen)
int mailbox_len;
long options = 0, retries = 0;
pils *imap_le_struct;
- MAILSTREAM *imap_stream;
long flags=NIL;
long cl_flags=NIL;
@@ -1298,12 +1297,12 @@ PHP_FUNCTION(imap_reopen)
RETURN_FALSE;
}
- imap_stream = mail_open(imap_le_struct->imap_stream, mailbox, flags);
- if (imap_stream == NIL) {
+ imap_le_struct->imap_stream = mail_open(imap_le_struct->imap_stream, mailbox, flags);
+ if (imap_le_struct->imap_stream == NIL) {
+ zend_list_delete(Z_RESVAL_P(streamind));
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't re-open stream");
RETURN_FALSE;
}
- imap_le_struct->imap_stream = imap_stream;
RETURN_TRUE;
}
/* }}} */
diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c
index 1b7327e001..8a094e015e 100644
--- a/ext/intl/grapheme/grapheme_string.c
+++ b/ext/intl/grapheme/grapheme_string.c
@@ -113,7 +113,7 @@ PHP_FUNCTION(grapheme_strpos)
unsigned char *found;
long loffset = 0;
int32_t offset = 0;
- int ret_pos, uchar_pos;
+ int ret_pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) {
@@ -160,10 +160,10 @@ PHP_FUNCTION(grapheme_strpos)
}
/* do utf16 part of the strpos */
- ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, &uchar_pos, 0 /* fIgnoreCase */ TSRMLS_CC );
+ ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 0 /* fIgnoreCase */, 0 /* last */ TSRMLS_CC );
if ( ret_pos >= 0 ) {
- RETURN_LONG(ret_pos + offset);
+ RETURN_LONG(ret_pos);
} else {
RETURN_FALSE;
}
@@ -180,7 +180,7 @@ PHP_FUNCTION(grapheme_stripos)
unsigned char *found;
long loffset = 0;
int32_t offset = 0;
- int ret_pos, uchar_pos;
+ int ret_pos;
int is_ascii;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", (char **)&haystack, &haystack_len, (char **)&needle, &needle_len, &loffset) == FAILURE) {
@@ -235,10 +235,10 @@ PHP_FUNCTION(grapheme_stripos)
}
/* do utf16 part of the strpos */
- ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, &uchar_pos, 1 /* fIgnoreCase */ TSRMLS_CC );
+ ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 1 /* fIgnoreCase */, 0 /*last */ TSRMLS_CC );
if ( ret_pos >= 0 ) {
- RETURN_LONG(ret_pos + offset);
+ RETURN_LONG(ret_pos);
} else {
RETURN_FALSE;
}
@@ -304,7 +304,7 @@ PHP_FUNCTION(grapheme_strrpos)
/* else we need to continue via utf16 */
}
- ret_pos = grapheme_strrpos_utf16(haystack, haystack_len, needle, needle_len, offset, 0 /* f_ignore_case */ TSRMLS_CC);
+ ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 0 /* f_ignore_case */, 1/* last */ TSRMLS_CC);
if ( ret_pos >= 0 ) {
RETURN_LONG(ret_pos);
@@ -382,7 +382,7 @@ PHP_FUNCTION(grapheme_strripos)
/* else we need to continue via utf16 */
}
- ret_pos = grapheme_strrpos_utf16(haystack, haystack_len, needle, needle_len, offset, 1 /* f_ignore_case */ TSRMLS_CC);
+ ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, 1 /* f_ignore_case */, 1 /*last */ TSRMLS_CC);
if ( ret_pos >= 0 ) {
RETURN_LONG(ret_pos);
@@ -659,7 +659,7 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas
}
/* need to work in utf16 */
- ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, 0, &uchar_pos, f_ignore_case TSRMLS_CC );
+ ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, 0, &uchar_pos, f_ignore_case, 0 /*last */ TSRMLS_CC );
if ( ret_pos < 0 ) {
RETURN_FALSE;
diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c
index 92008554d4..883fa0391a 100644
--- a/ext/intl/grapheme/grapheme_util.c
+++ b/ext/intl/grapheme/grapheme_util.c
@@ -28,6 +28,7 @@
#include <unicode/ucol.h>
#include <unicode/ustring.h>
#include <unicode/ubrk.h>
+#include <unicode/usearch.h>
#include "ext/standard/php_string.h"
@@ -47,49 +48,8 @@ grapheme_close_global_iterator( TSRMLS_D )
}
/* }}} */
-/* {{{ grapheme_intl_case_fold: convert string to lowercase */
-void
-grapheme_intl_case_fold(UChar** ptr_to_free, UChar **str, int32_t *str_len, UErrorCode *pstatus )
-{
- UChar *dest;
- int32_t dest_len, size_required;
-
- /* allocate a destination string that is a bit larger than the src, hoping that is enough */
- dest_len = (*str_len) + ( *str_len / 10 );
- dest = (UChar*) eumalloc(dest_len);
-
- *pstatus = U_ZERO_ERROR;
- size_required = u_strFoldCase(dest, dest_len, *str, *str_len, U_FOLD_CASE_DEFAULT, pstatus);
-
- dest_len = size_required;
-
- if ( U_BUFFER_OVERFLOW_ERROR == *pstatus ) {
-
- dest = (UChar*) eurealloc(dest, dest_len);
-
- *pstatus = U_ZERO_ERROR;
- size_required = u_strFoldCase(dest, dest_len, *str, *str_len, U_FOLD_CASE_DEFAULT, pstatus);
- }
-
- if ( U_FAILURE(*pstatus) ) {
- return;
- }
-
- if ( NULL != ptr_to_free) {
- efree(*ptr_to_free);
- *ptr_to_free = dest;
- }
-
- *str = dest;
- *str_len = dest_len;
-
- return;
-}
-/* }}} */
-
/* {{{ grapheme_substr_ascii f='from' - starting point, l='length' */
-void
-grapheme_substr_ascii(char *str, int str_len, int f, int l, int argc, char **sub_str, int *sub_str_len)
+void grapheme_substr_ascii(char *str, int str_len, int f, int l, int argc, char **sub_str, int *sub_str_len)
{
*sub_str = NULL;
@@ -147,225 +107,101 @@ grapheme_substr_ascii(char *str, int str_len, int f, int l, int argc, char **sub
}
/* }}} */
-/* {{{ grapheme_strrpos_utf16 - strrpos using utf16 */
-int
-grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int f_ignore_case TSRMLS_DC)
-{
- UChar *uhaystack, *puhaystack, *uhaystack_end, *uneedle;
- int32_t uhaystack_len, uneedle_len;
- UErrorCode status;
- unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE];
- UBreakIterator* bi = NULL;
- int ret_pos, pos;
-
- /* convert the strings to UTF-16. */
- uhaystack = NULL;
- uhaystack_len = 0;
- status = U_ZERO_ERROR;
- intl_convert_utf8_to_utf16(&uhaystack, &uhaystack_len, (char *) haystack, haystack_len, &status );
-
- if ( U_FAILURE( status ) ) {
- /* Set global error code. */
- intl_error_set_code( NULL, status TSRMLS_CC );
-
- /* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
- if (uhaystack) {
- efree( uhaystack );
- }
- return -1;
- }
-
- if ( f_ignore_case ) {
- grapheme_intl_case_fold(&uhaystack, &uhaystack, &uhaystack_len, &status );
- }
-
- /* get a pointer to the haystack taking into account the offset */
- bi = NULL;
- status = U_ZERO_ERROR;
- bi = grapheme_get_break_iterator(u_break_iterator_buffer, &status TSRMLS_CC );
-
- puhaystack = grapheme_get_haystack_offset(bi, uhaystack, uhaystack_len, offset);
-
- if ( NULL == puhaystack ) {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC );
- if (uhaystack) {
- efree( uhaystack );
- }
- ubrk_close (bi);
- return -1;
- }
-
- uneedle = NULL;
- uneedle_len = 0;
- status = U_ZERO_ERROR;
- intl_convert_utf8_to_utf16(&uneedle, &uneedle_len, (char *) needle, needle_len, &status );
-
- if ( U_FAILURE( status ) ) {
- /* Set global error code. */
- intl_error_set_code( NULL, status TSRMLS_CC );
-
- /* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
- if (uhaystack) {
- efree( uhaystack );
- }
- if (uneedle) {
- efree( uneedle );
- }
- ubrk_close (bi);
- return -1;
- }
-
- if ( f_ignore_case ) {
- grapheme_intl_case_fold(&uneedle, &uneedle, &uneedle_len, &status );
- }
-
- ret_pos = -1; /* -1 represents 'not found' */
-
- /* back up until there's needle_len characters to compare */
-
- uhaystack_end = uhaystack + uhaystack_len;
- pos = ubrk_last(bi);
- puhaystack = uhaystack + pos;
-
- while ( uhaystack_end - puhaystack < uneedle_len ) {
-
- pos = ubrk_previous(bi);
-
- if ( UBRK_DONE == pos ) {
- break;
- }
-
- puhaystack = uhaystack + pos;
- }
-
- /* is there enough haystack left to hold the needle? */
- if ( ( uhaystack_end - puhaystack ) < uneedle_len ) {
- /* not enough, not found */
- goto exit;
- }
-
- while ( UBRK_DONE != pos ) {
-
- if (!u_memcmp(uneedle, puhaystack, uneedle_len)) { /* needle_len - 1 in zend memnstr? */
-
- /* does the grapheme in the haystack end at the same place as the last grapheme in the needle? */
-
- if ( ubrk_isBoundary(bi, pos + uneedle_len) ) {
-
- /* found it, get grapheme count offset */
- ret_pos = grapheme_count_graphemes(bi, uhaystack, pos);
- break;
- }
-
- /* set position back */
- ubrk_isBoundary(bi, pos);
- }
-
- pos = ubrk_previous(bi);
- puhaystack = uhaystack + pos;
- }
-
-exit:
- if (uhaystack) {
- efree( uhaystack );
- }
- if (uneedle) {
- efree( uneedle );
+#define STRPOS_CHECK_STATUS(status, error) \
+ if ( U_FAILURE( (status) ) ) { \
+ intl_error_set_code( NULL, (status) TSRMLS_CC ); \
+ intl_error_set_custom_msg( NULL, (error), 0 TSRMLS_CC ); \
+ if (uhaystack) { \
+ efree( uhaystack ); \
+ } \
+ if (uneedle) { \
+ efree( uneedle ); \
+ } \
+ if(bi) { \
+ ubrk_close (bi); \
+ } \
+ if(src) { \
+ usearch_close(src); \
+ } \
+ return -1; \
}
- ubrk_close (bi);
-
- return ret_pos;
-}
-/* }}} */
/* {{{ grapheme_strpos_utf16 - strrpos using utf16*/
-int
-grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case TSRMLS_DC)
+int grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last TSRMLS_DC)
{
- UChar *uhaystack, *puhaystack, *uneedle;
- int32_t uhaystack_len, uneedle_len;
- int ret_pos;
+ UChar *uhaystack = NULL, *puhaystack, *uneedle = NULL;
+ int32_t uhaystack_len = 0, uneedle_len = 0, char_pos, ret_pos, offset_pos = 0;
unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE];
- UBreakIterator* bi;
+ UBreakIterator* bi = NULL;
UErrorCode status;
+ UStringSearch* src = NULL;
+ UCollator *coll;
- *puchar_pos = -1;
-
+ if(puchar_pos) {
+ *puchar_pos = -1;
+ }
/* convert the strings to UTF-16. */
- uhaystack = NULL;
- uhaystack_len = 0;
status = U_ZERO_ERROR;
intl_convert_utf8_to_utf16(&uhaystack, &uhaystack_len, (char *) haystack, haystack_len, &status );
+ STRPOS_CHECK_STATUS(status, "Error converting input string to UTF-16");
- if ( U_FAILURE( status ) ) {
- /* Set global error code. */
- intl_error_set_code( NULL, status TSRMLS_CC );
-
- /* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
- if (uhaystack) {
- efree( uhaystack );
- }
- return -1;
- }
+ status = U_ZERO_ERROR;
+ intl_convert_utf8_to_utf16(&uneedle, &uneedle_len, (char *) needle, needle_len, &status );
+ STRPOS_CHECK_STATUS(status, "Error converting input string to UTF-16");
/* get a pointer to the haystack taking into account the offset */
- bi = NULL;
status = U_ZERO_ERROR;
bi = grapheme_get_break_iterator(u_break_iterator_buffer, &status TSRMLS_CC );
-
- puhaystack = grapheme_get_haystack_offset(bi, uhaystack, uhaystack_len, offset);
- uhaystack_len = (uhaystack_len - ( puhaystack - uhaystack));
+ STRPOS_CHECK_STATUS(status, "Failed to get iterator");
+ status = U_ZERO_ERROR;
+ ubrk_setText(bi, uhaystack, uhaystack_len, &status);
+ STRPOS_CHECK_STATUS(status, "Failed to set up iterator");
- if ( NULL == puhaystack ) {
-
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC );
- if (uhaystack) {
- efree( uhaystack );
- }
- ubrk_close (bi);
-
- return -1;
- }
+ status = U_ZERO_ERROR;
+ src = usearch_open(uneedle, uneedle_len, uhaystack, uhaystack_len, "", bi, &status);
+ STRPOS_CHECK_STATUS(status, "Error creating search object");
- if ( f_ignore_case ) {
- grapheme_intl_case_fold(&uhaystack, &puhaystack, &uhaystack_len, &status );
+ if(f_ignore_case) {
+ coll = usearch_getCollator(src);
+ status = U_ZERO_ERROR;
+ ucol_setAttribute(coll, UCOL_STRENGTH, UCOL_SECONDARY, &status);
+ STRPOS_CHECK_STATUS(status, "Error setting collation strength");
+ usearch_reset(src);
}
- uneedle = NULL;
- uneedle_len = 0;
- status = U_ZERO_ERROR;
- intl_convert_utf8_to_utf16(&uneedle, &uneedle_len, (char *) needle, needle_len, &status );
+ if(offset != 0) {
+ offset_pos = grapheme_get_haystack_offset(bi, offset);
+ if(offset_pos == -1) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ STRPOS_CHECK_STATUS(status, "Invalid search offset");
+ }
+ status = U_ZERO_ERROR;
+ usearch_setOffset(src, offset_pos, &status);
+ STRPOS_CHECK_STATUS(status, "Invalid search offset");
+ }
- if ( U_FAILURE( status ) ) {
- /* Set global error code. */
- intl_error_set_code( NULL, status TSRMLS_CC );
- /* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
- if (uhaystack) {
- efree( uhaystack );
+ if(last) {
+ char_pos = usearch_last(src, &status);
+ if(char_pos < offset_pos) {
+ /* last one is beyound our start offset */
+ char_pos = USEARCH_DONE;
}
- if (uneedle) {
- efree( uneedle );
- }
- ubrk_close (bi);
-
- return -1;
+ } else {
+ char_pos = usearch_next(src, &status);
}
-
- if ( f_ignore_case ) {
- grapheme_intl_case_fold(&uneedle, &uneedle, &uneedle_len, &status );
+ STRPOS_CHECK_STATUS(status, "Error looking up string");
+ if(char_pos != USEARCH_DONE && ubrk_isBoundary(bi, char_pos)) {
+ ret_pos = grapheme_count_graphemes(bi, uhaystack,char_pos);
+ if(puchar_pos) {
+ *puchar_pos = char_pos;
+ }
+ } else {
+ ret_pos = -1;
}
- ret_pos = grapheme_memnstr_grapheme(bi, puhaystack, uneedle, uneedle_len, puhaystack + uhaystack_len );
-
- *puchar_pos = ubrk_current(bi);
-
if (uhaystack) {
efree( uhaystack );
}
@@ -373,6 +209,7 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
efree( uneedle );
}
ubrk_close (bi);
+ usearch_close (src);
return ret_pos;
}
@@ -432,8 +269,7 @@ int grapheme_split_string(const UChar *text, int32_t text_length, int boundary_a
/* }}} */
/* {{{ grapheme_count_graphemes */
-int32_t
-grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len)
+int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len)
{
int ret_len = 0;
int pos = 0;
@@ -455,85 +291,16 @@ grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len)
}
/* }}} */
-/* {{{ grapheme_memnstr_grapheme: find needle in haystack using grapheme boundaries */
-int32_t
-grapheme_memnstr_grapheme(UBreakIterator *bi, UChar *haystack, UChar *needle, int32_t needle_len, UChar *end)
-{
- UChar *p = haystack;
- UChar ne = needle[needle_len-1];
- UErrorCode status;
- int32_t grapheme_offset;
-
- end -= needle_len;
-
- while (p <= end) {
-
- if ((p = u_memchr(p, *needle, (end-p+1))) && ne == p[needle_len-1]) {
-
- if (!u_memcmp(needle, p, needle_len - 1)) { /* needle_len - 1 works because if needle_len is 1, we've already tested the char */
-
- /* does the grapheme end here? */
-
- status = U_ZERO_ERROR;
- ubrk_setText (bi, haystack, (end - haystack) + needle_len, &status);
-
- if ( ubrk_isBoundary (bi, (p - haystack) + needle_len) ) {
-
- /* found it, get grapheme count offset */
- grapheme_offset = grapheme_count_graphemes(bi, haystack, (p - haystack));
-
- return grapheme_offset;
- }
- }
- }
-
- if (p == NULL) {
- return -1;
- }
-
- p++;
- }
-
- return -1;
-}
-
-/* }}} */
-
-/* {{{ grapheme_memrstr_grapheme: reverse find needle in haystack using grapheme boundaries */
-inline void *grapheme_memrchr_grapheme(const void *s, int c, int32_t n)
-{
- register unsigned char *e;
-
- if (n <= 0) {
- return NULL;
- }
-
- for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
- if (*e == (unsigned char)c) {
- return (void *)e;
- }
- }
-
- return NULL;
-}
-/* }}} */
/* {{{ grapheme_get_haystack_offset - bump the haystack pointer based on the grapheme count offset */
-UChar *
-grapheme_get_haystack_offset(UBreakIterator* bi, UChar *uhaystack, int32_t uhaystack_len, int32_t offset)
+int grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset)
{
- UErrorCode status;
int32_t pos;
int32_t (*iter_op)(UBreakIterator* bi);
int iter_incr;
- if ( NULL != bi ) {
- status = U_ZERO_ERROR;
- ubrk_setText (bi, uhaystack, uhaystack_len, &status);
- }
-
if ( 0 == offset ) {
- return uhaystack;
+ return 0;
}
if ( offset < 0 ) {
@@ -558,10 +325,10 @@ grapheme_get_haystack_offset(UBreakIterator* bi, UChar *uhaystack, int32_t uhays
}
if ( offset != 0 ) {
- return NULL;
+ return -1;
}
- return uhaystack + pos;
+ return pos;
}
/* }}} */
@@ -607,8 +374,7 @@ grapheme_strrpos_ascii(unsigned char *haystack, int32_t haystack_len, unsigned c
/* }}} */
/* {{{ grapheme_get_break_iterator: get a clone of the global character break iterator */
-UBreakIterator*
-grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC )
+UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC )
{
int32_t buffer_size;
diff --git a/ext/intl/grapheme/grapheme_util.h b/ext/intl/grapheme/grapheme_util.h
index c91aeaff7d..14f3f22c45 100644
--- a/ext/intl/grapheme/grapheme_util.h
+++ b/ext/intl/grapheme/grapheme_util.h
@@ -23,35 +23,25 @@
/* get_break_interator: get a break iterator from the global structure */
UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC );
-void
-grapheme_substr_ascii(char *str, int32_t str_len, int32_t f, int32_t l, int argc, char **sub_str, int *sub_str_len);
+void grapheme_substr_ascii(char *str, int32_t str_len, int32_t f, int32_t l, int argc, char **sub_str, int *sub_str_len);
-int
-grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int f_ignore_case TSRMLS_DC);
+int grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int f_ignore_case TSRMLS_DC);
-int
-grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int *puchar_pos, int f_ignore_case TSRMLS_DC);
+int grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int *puchar_pos, int f_ignore_case, int last TSRMLS_DC);
int grapheme_ascii_check(const unsigned char *day, int32_t len);
int grapheme_split_string(const UChar *text, int32_t text_length, int boundary_array[], int boundary_array_len TSRMLS_DC );
-int32_t
-grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len);
-
-int32_t
-grapheme_memnstr_grapheme(UBreakIterator *bi, UChar *haystack, UChar *needle, int32_t needle_len, UChar *end);
+int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len);
inline void *grapheme_memrchr_grapheme(const void *s, int c, int32_t n);
-UChar *
-grapheme_get_haystack_offset(UBreakIterator* bi, UChar *uhaystack, int32_t uhaystack_len, int32_t offset);
+int grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset);
-int32_t
-grapheme_strrpos_ascii(unsigned char *haystack, int32_t haystack_len, unsigned char *needle, int32_t needle_len, int32_t offset);
+int32_t grapheme_strrpos_ascii(unsigned char *haystack, int32_t haystack_len, unsigned char *needle, int32_t needle_len, int32_t offset);
-UBreakIterator*
-grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC );
+UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC );
/* OUTSIDE_STRING: check if (possibly negative) long offset is outside the string with int32_t length */
#define OUTSIDE_STRING(offset, max_len) ( offset <= INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (long) max_len : offset >= (long) max_len) )
diff --git a/ext/intl/tests/bug61860.phpt b/ext/intl/tests/bug61860.phpt
new file mode 100644
index 0000000000..123d9ff239
--- /dev/null
+++ b/ext/intl/tests/bug61860.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #61860: Offsets may be wrong for grapheme_stri* functions
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$haystack = 'Auf der Straße nach Paris habe ich mit dem Fahrer gesprochen';
+var_dump(
+ grapheme_stripos($haystack, 'pariS '),
+ grapheme_stristr($haystack, 'paRis '),
+ grapheme_substr($haystack, grapheme_stripos($haystack, 'Paris'))
+);
+
+?>
+--EXPECT--
+int(20)
+string(40) "Paris habe ich mit dem Fahrer gesprochen"
+string(40) "Paris habe ich mit dem Fahrer gesprochen"
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index 2ad1a20405..e1557efce1 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -564,7 +564,7 @@ PHP_FUNCTION(mysqli_query)
MY_MYSQL *mysql;
zval *mysql_link;
MYSQLI_RESOURCE *mysqli_resource;
- MYSQL_RES *result;
+ MYSQL_RES *result = NULL;
char *query = NULL;
int query_len;
long resultmode = MYSQLI_STORE_RESULT;
@@ -835,7 +835,7 @@ PHP_FUNCTION(mysqli_reap_async_query)
MY_MYSQL *mysql;
zval *mysql_link;
MYSQLI_RESOURCE *mysqli_resource;
- MYSQL_RES *result;
+ MYSQL_RES *result = NULL;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index d70582b7fb..8ed810d9d6 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -1061,7 +1061,7 @@ static enum_func_status
MYSQLND_METHOD(mysqlnd_conn_data, send_query)(MYSQLND_CONN_DATA * conn, const char * query, unsigned int query_len TSRMLS_DC)
{
size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, send_query);
- enum_func_status ret;
+ enum_func_status ret = FAIL;
DBG_ENTER("mysqlnd_conn_data::send_query");
DBG_INF_FMT("conn=%llu query=%s", conn->thread_id, query);
@@ -1468,7 +1468,7 @@ static ulong
MYSQLND_METHOD(mysqlnd_conn_data, escape_string)(MYSQLND_CONN_DATA * const conn, char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC)
{
size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, escape_string);
- ulong ret;
+ ulong ret = FAIL;
DBG_ENTER("mysqlnd_conn_data::escape_string");
DBG_INF_FMT("conn=%llu", conn->thread_id);
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 9ed5087369..c54cd73d84 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -274,9 +274,13 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
,{"5.0",DBVERSION_70} /* FIXME: This does not work with Sybase, but environ will */
,{"6.0",DBVERSION_70}
,{"7.0",DBVERSION_70}
+#ifdef DBVERSION_71
,{"7.1",DBVERSION_71}
+#endif
+#ifdef DBVERSION_72
,{"7.2",DBVERSION_72}
,{"8.0",DBVERSION_72}
+#endif
,{"10.0",DBVERSION_100}
,{"auto",0} /* Only works with FreeTDS. Other drivers will bork */
@@ -361,9 +365,11 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
/* allow double quoted indentifiers */
DBSETOPT(H->link, DBQUOTEDIDENT, "1");
+#ifdef DBSETLDBNAME
if (vars[3].optval) {
DBSETLDBNAME(H->login, vars[3].optval);
}
+#endif
ret = 1;
dbh->max_escaped_char_length = 2;
diff --git a/ext/pdo_mysql/tests/mysql_pdo_test.inc b/ext/pdo_mysql/tests/mysql_pdo_test.inc
index 115aeadc5a..7a97bb4630 100644
--- a/ext/pdo_mysql/tests/mysql_pdo_test.inc
+++ b/ext/pdo_mysql/tests/mysql_pdo_test.inc
@@ -162,8 +162,8 @@ class MySQLPDOTest extends PDOTest {
phpinfo();
$tmp = ob_get_contents();
ob_end_clean();
- $tmp = stristr($tmp, "PDO Driver for MySQL => enabled");
- return (bool)preg_match('/Client API version.*mysqlnd/', $tmp);
+ return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) &&
+ preg_match('/Client API version.*mysqlnd/', $tmp));
}
static function dropTestTable($db = NULL) {
@@ -174,4 +174,4 @@ class MySQLPDOTest extends PDOTest {
}
}
-?> \ No newline at end of file
+?>
diff --git a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt
index a570c1fd49..9674e85f5e 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt
@@ -18,10 +18,9 @@ $db = MySQLPDOTest::factory();
ob_end_clean();
/* PDO Driver for MySQL, client library version => 6.0.3-alpha */
- $expected = sprintf('Client API version => %s',
- $db->getAttribute(PDO::ATTR_CLIENT_VERSION));
+ $reg = 'Client API version.*' . pcre_quote($db->getAttribute(PDO::ATTR_CLIENT_VERSION), '/');
- if (false === stristr($tmp, $expected)) {
+ if (!preg_match("/$reg/", $tmp)) {
printf("[001] Cannot find MySQL PDO driver line in phpinfo() output\n");
}
diff --git a/ext/phar/Makefile.frag b/ext/phar/Makefile.frag
index b1c820f276..ed6de9fd67 100644
--- a/ext/phar/Makefile.frag
+++ b/ext/phar/Makefile.frag
@@ -40,3 +40,7 @@ install-pharcmd: pharcmd
$(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)
-@rm -f $(INSTALL_ROOT)$(bindir)/phar
$(LN_S) -f $(bindir)/phar.phar $(INSTALL_ROOT)$(bindir)/phar
+ @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1
+ @$(INSTALL_DATA) $(builddir)/phar.1 $(INSTALL_ROOT)$(mandir)/man1/phar.1
+ @$(INSTALL_DATA) $(builddir)/phar.phar.1 $(INSTALL_ROOT)$(mandir)/man1/phar.phar.1
+
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
index 2ac7f3dd81..d424060f2a 100644
--- a/ext/phar/config.m4
+++ b/ext/phar/config.m4
@@ -27,4 +27,6 @@ if test "$PHP_PHAR" != "no"; then
PHP_ADD_EXTENSION_DEP(phar, hash, true)
PHP_ADD_EXTENSION_DEP(phar, spl, true)
PHP_ADD_MAKEFILE_FRAGMENT
+
+ PHP_OUTPUT(ext/phar/phar.1 ext/phar/phar.phar.1)
fi
diff --git a/ext/phar/phar.1.in b/ext/phar/phar.1.in
new file mode 100644
index 0000000000..259a2bae86
--- /dev/null
+++ b/ext/phar/phar.1.in
@@ -0,0 +1,523 @@
+.TH PHAR 1 "2013" "The PHP Group" "User Commands"
+.SH NAME
+phar, phar.phar \- PHAR (PHP archive) command line tool
+.SH SYNOPSIS
+.B phar
+<command> [options] ...
+.LP
+.SH DESCRIPTION
+The \fBPHAR\fP file format provides a way to put entire PHP applications into a single
+file called a "phar" (PHP Archive) for easy distribution and installation.
+.P
+With the \fBphar\fP command you can create, update or extract PHP archives.
+.P
+Commands:
+add compress delete extract help help-list info list meta-del
+meta-get meta-set pack sign stub-get stub-set tree version
+
+.SH add command
+Add entries to a PHAR package.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.TP
+.PD
+.B ...
+Any number of input files and directories. If -i is in
+use then ONLY files and matching the given regular
+expression are being packed. If -x is given then files
+matching that regular expression are NOT being packed.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B \-a \fIalias\fP
+Provide an \fIalias\fP name for the phar file.
+.TP
+.PD
+.B \-c \fIalgo\fP
+Compression algorithm (see
+.SM
+.B COMPRESSION
+)
+.TP
+.PD
+.B \-i \fIregex\fP
+Specifies a regular expression for input files.
+.TP
+.PD
+.B \-l \fIlevel\fP
+Number of preceding subdirectories to strip from file entries
+.TP
+.PD
+.B \-x \fIregex\fP
+Regular expression for input files to exclude.
+
+.SH compress command
+Compress or uncompress all files or a selected entry.
+.P
+Required arguments:
+.TP 15
+.PD
+.B \-c \fIalgo\fP
+Compression algorithm (see
+.SM
+.B COMPRESSION
+)
+.TP
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -e \fIentry\fP
+Name of \fIentry\fP to work on (must include PHAR internal
+directory name if any).
+
+.SH delete command
+Delete entry from a PHAR archive
+.P
+Required arguments:
+.TP 15
+.PD
+.B \-e \fIentry\fP
+Name of \fIentry\fP to work on (must include PHAR internal
+directory name if any).
+.TP
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+
+.SH extract command
+Extract a PHAR package to a directory.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -i \fIregex\fP
+Specifies a regular expression for input files.
+.TP
+.PD
+.B -x \fIregex\fP
+Regular expression for input files to exclude.
+.TP
+.PD
+.B ...
+Directory to extract to (defaults to '.').
+
+
+.SH help command
+This help or help for a selected command.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B ...
+Optional command to retrieve help for.
+
+.SH help-list command
+Lists available commands.
+
+.SH info command
+Get information about a PHAR package.
+.P
+By using -k it is possible to return a single value.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -k \fIindex\fP
+Subscription \fIindex\fP to work on.
+
+.SH list command
+List contents of a PHAR archive.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -i \fIregex\fP
+Specifies a regular expression for input files.
+.TP
+.PD
+.B -x \fIregex\fP
+Regular expression for input files to exclude.
+
+
+.SH meta-del command
+Delete meta information of a PHAR entry or a PHAR package.
+.P
+If -k is given then the metadata is expected to be an array and the
+given index is being deleted.
+.P
+If something was deleted the return value is 0 otherwise it is 1.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -e \fIentry\fP
+Name of \fIentry\fP to work on (must include PHAR internal
+directory name if any).
+.TP
+.PD
+.B -k \fIindex\fP
+Subscription \fIindex\fP to work on.
+
+.SH meta-get command
+Get meta information of a PHAR entry or a PHAR package in serialized from. If
+no output file is specified for meta data then stdout is being used.
+You can also specify a particular index using -k. In that case the
+metadata is expected to be an array and the value of the given index
+is returned using echo rather than using serialize. If that index does
+not exist or no meta data is present then the return value is 1.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -e \fIentry\fP
+Name of \fIentry\fP to work on (must include PHAR internal
+directory name if any).
+.TP
+.PD
+.B -k \fIindex\fP
+Subscription \fIindex\fP to work on.
+
+.SH meta-set command
+Set meta data of a PHAR entry or a PHAR package using serialized input. If no
+input file is specified for meta data then stdin is being used. You can
+also specify a particular index using -k. In that case the metadata is
+expected to be an array and the value of the given index is being set.
+If the metadata is not present or empty a new array will be created.
+If the metadata is present and a flat value then the return value is
+1. Also using -k the input is been taken directly rather then being
+serialized.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.TP
+.PD
+.B -m \fImeta\fP
+Meta data to store with entry (serialized php data).
+.P
+Optional arguments:
+.TP 15
+.PD
+.B -e \fIentry\fP
+Name of \fIentry\fP to work on (must include PHAR internal
+directory name if any).
+.TP
+.PD
+.B -k \fIindex\fP
+Subscription \fIindex\fP to work on.
+
+.SH pack command
+Pack files into a PHAR archive.
+.P
+When using -s <stub>, then the stub file is being excluded from the
+list of input files/dirs.To create an archive that contains PEAR class
+PHP_Archive then point -p argument to PHP/Archive.php.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.TP
+.PD
+.B ...
+Any number of input files and directories. If -i is in
+use then ONLY files and matching the given regular
+expression are being packed. If -x is given then files
+matching that regular expression are NOT being packed.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B \-a \fIalias\fP
+Provide an \fIalias\fP name for the phar file.
+.TP
+.PD
+.B \-b \fIbang\fP
+Hash-bang line to start the archive (e.g. #!/usr/bin/php).
+The hash mark itself '#!' and the newline character are optional.
+.TP
+.PD
+.B \-c \fIalgo\fP
+Compression algorithm (see
+.SM
+.B COMPRESSION
+)
+.TP
+.PD
+.B \-h \fIhash\fP
+Selects the \fIhash\fP algorithm (see
+.SM
+.B HASH
+)
+.TP
+.PD
+.B \-i \fIregex\fP
+Specifies a regular expression for input files.
+.TP
+.PD
+.B \-l \fIlevel\fP
+Number of preceding subdirectories to strip from file entries
+.TP
+.PD
+.B \-p \fIloader\fP
+Location of PHP_Archive class file (pear list-files
+PHP_Archive).You can use '0' or '1' to locate it
+automatically using the mentioned pear command. When
+using '0' the command does not error out when the class
+file cannot be located. This switch also adds some code
+around the stub so that class PHP_Archive gets
+registered as phar:// stream wrapper if necessary. And
+finally this switch will add the file phar.inc from
+this package and load it to ensure class Phar is
+present.
+.TP
+.PD
+.B \-s \fIstub\fP
+Select the \fIstub\fP file.
+.TP
+.PD
+.B \-x \fIregex\fP
+Regular expression for input files to exclude.
+.TP
+.PD
+.B \-y \fIkey\fP
+Private \fIkey\fP for OpenSSL signing.
+
+.SH sign command
+Set signature hash algorithm.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.TP
+.PD
+.B \-h \fIhash\fP
+Selects the \fIhash\fP algorithm (see
+.SM
+.B HASH
+)
+.P
+Optional arguments:
+.TP 15
+.PD
+.B \-y \fIkey\fP
+Private \fIkey\fP for OpenSSL signing.
+
+.SH stub-get command
+Get the stub of a PHAR file. If no output file is specified as stub then stdout
+is being used.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B \-s \fIstub\fP
+Select the \fIstub\fP file.
+
+.SH stub-set command
+Set the stub of a PHAR file. If no input file is specified as stub then stdin
+is being used.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B \-b \fIbang\fP
+Hash-bang line to start the archive (e.g. #!/usr/bin/php).
+The hash mark itself '#!' and the newline character are optional.
+.TP
+.PD
+.B \-p \fIloader\fP
+Location of PHP_Archive class file (pear list-files
+PHP_Archive).You can use '0' or '1' to locate it
+automatically using the mentioned pear command. When
+using '0' the command does not error out when the class
+file cannot be located. This switch also adds some code
+around the stub so that class PHP_Archive gets
+registered as phar:// stream wrapper if necessary. And
+finally this switch will add the file phar.inc from
+this package and load it to ensure class Phar is
+present.
+.TP
+.PD
+.B \-s \fIstub\fP
+Select the \fIstub\fP file.
+
+
+.SH tree command
+Get a directory tree for a PHAR archive.
+.P
+Required arguments:
+.TP 15
+.PD
+.B -f \fIfile\fP
+Specifies the phar \fIfile\fP to work on.
+.P
+Optional arguments:
+.TP 15
+.PD
+.B \-i \fIregex\fP
+Specifies a regular expression for input files.
+.TP
+.PD
+.B \-x \fIregex\fP
+Regular expression for input files to exclude.
+
+.SH version command
+Get information about the PHAR environment and the tool version.
+
+
+.SH COMPRESSION
+Algorithms:
+.TP 15
+.PD
+.B 0
+No compression
+.TP
+.PD
+.B none
+No compression
+.TP
+.PD
+.B auto
+Automatically select compression algorithm
+.TP
+.PD
+.B gz
+GZip compression
+.TP
+.PD
+.B gzip
+GZip compression
+.TP
+.PD
+.B bz2
+BZip2 compression
+.TP
+.PD
+.B bzip2
+BZip2 compression
+
+.SH HASH
+Algorithms:
+.TP 15
+.PD
+.TP
+.PD
+.B md5
+MD5
+.TP
+.PD
+.B sha1
+SHA1
+.TP
+.PD
+.B sha256
+SHA256
+.TP
+.PD
+.B sha512
+SHA512
+.TP
+.PD
+.B openssl
+OpenSSL
+
+.SH SEE ALSO
+For a more or less complete description of PHAR look here:
+.PD 0
+.P
+.B http://php.net/phar
+.PD 1
+.P
+.SH BUGS
+You can view the list of known bugs or report any new bug you
+found at:
+.PD 0
+.P
+.B http://bugs.php.net
+.PD 1
+.SH AUTHORS
+The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
+.P
+Work for the PHP archive was done by Gregory Beaver, Marcus Boerger.
+.P
+A List of active developers can be found here:
+.PD 0
+.P
+.B http://www.php.net/credits.php
+.PD 1
+.P
+And last but not least PHP was developed with the help of a huge amount of
+contributors all around the world.
+.SH VERSION INFORMATION
+This manpage describes \fBphar\fP, version @PHP_VERSION@.
+.SH COPYRIGHT
+Copyright \(co 1997\-2013 The PHP Group
+.LP
+This source file is subject to version 3.01 of the PHP license,
+that is bundled with this package in the file LICENSE, and is
+available through the world-wide-web at the following url:
+.PD 0
+.P
+.B http://www.php.net/license/3_01.txt
+.PD 1
+.P
+If you did not receive a copy of the PHP license and are unable to
+obtain it through the world-wide-web, please send a note to
+.B license@php.net
+so we can mail you a copy immediately.
diff --git a/ext/phar/phar.phar.1.in b/ext/phar/phar.phar.1.in
new file mode 100644
index 0000000000..b5eecbfeba
--- /dev/null
+++ b/ext/phar/phar.phar.1.in
@@ -0,0 +1 @@
+.so man1/phar.1
diff --git a/ext/session/mod_files.sh b/ext/session/mod_files.sh
index 1d2672847c..4fc4f20f7f 100644
--- a/ext/session/mod_files.sh
+++ b/ext/session/mod_files.sh
@@ -1,24 +1,65 @@
#! /bin/sh
-if test "$2" = ""; then
- echo "usage: $0 basedir depth"
- exit 1
+if [[ "$2" = "" ]] || [[ "$3" = "" ]]; then
+ echo "Usage: $0 BASE_DIRECTORY DEPTH HASH_BITS"
+ echo "BASE_DIRECTORY will be created if it doesn't exist"
+ echo "DEPTH must be an integer number >0"
+ echo "HASH_BITS(session.hash_bits_per_charactor) should be one of 4, 5, or 6"
+ exit 1
fi
-if test "$2" = "0"; then
- exit 0
+if [[ "$2" = "0" ]] && [[ ! "$4" = "recurse" ]]; then
+ echo "Can't create a directory tree with depth of 0, exiting."
fi
+if [[ "$2" = "0" ]]; then
+ exit 0
+fi
+
+directory="$1"
+depth="$2"
+hashbits="$3"
+
hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f"
-if test "$3" -a "$3" -ge "5"; then
- hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
- if test "$3" -eq "6"; then
- hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ,"
- fi
+
+if [[ "$hashbits" -ge "5" ]]; then
+ hash_chars="$hash_chars g h i j k l m n o p q r s t u v"
fi
+if [[ "$hashbits" -ge "6" ]]; then
+ hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ,"
+fi
+
+while [[ -d $directory ]] && [[ $( ls $directory ) ]]; do
+ echo "Directory $directory is not empty! What would you like to do?"
+
+ options="\"Delete directory contents\" \"Choose another directory\" \"Quit\""
+ eval set $options
+ select opt in "$@"; do
+
+ if [[ $opt = "Delete directory contents" ]]; then
+ echo "Deleting $directory contents... "
+ rm -rf $directory/*
+ elif [[ $opt = "Choose another directory" ]]; then
+ echo "Which directory would you like to choose?"
+ read directory
+ elif [[ $opt = "Quit" ]]; then
+ exit 0
+ fi
+
+ break;
+ done
+done
+
+if [[ ! -d $directory ]]; then
+ mkdir -p $directory
+fi
+
+
+echo "Creating session path in $directory with a depth of $depth for session.hash_bits_per_character = $hashbits"
+
for i in $hash_chars; do
- newpath="$1/$i"
- mkdir $newpath || exit 1
- sh $0 $newpath `expr $2 - 1` $3
+ newpath="$directory/$i"
+ mkdir $newpath || exit 1
+ sh $0 $newpath `expr $depth - 1` $hashbits recurse
done
diff --git a/ext/session/session.c b/ext/session/session.c
index d9989ba753..3879edcce6 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -615,6 +615,31 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */
}
/* }}} */
+static PHP_INI_MH(OnUpdateName) /* {{{ */
+{
+ /* Numeric session.name won't work at all */
+ if (PG(modules_activated) &&
+ (!new_value_length || is_numeric_string(new_value, new_value_length, NULL, NULL, 0))) {
+ int err_type;
+
+ if (stage == ZEND_INI_STAGE_RUNTIME) {
+ err_type = E_WARNING;
+ } else {
+ err_type = E_ERROR;
+ }
+
+ /* Do not output error when restoring ini options. */
+ if (stage != ZEND_INI_STAGE_DEACTIVATE) {
+ php_error_docref(NULL TSRMLS_CC, err_type, "session.name cannot be a numeric or empty '%s'", new_value);
+ }
+ return FAILURE;
+ }
+
+ OnUpdateStringUnempty(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ return SUCCESS;
+}
+/* }}} */
+
static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */
{
long val;
@@ -706,7 +731,7 @@ static ZEND_INI_MH(OnUpdateSmartStr) /* {{{ */
*/
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals)
- STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateString, session_name, php_ps_globals, ps_globals)
+ STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateName, session_name, php_ps_globals, ps_globals)
PHP_INI_ENTRY("session.save_handler", "files", PHP_INI_ALL, OnUpdateSaveHandler)
STD_PHP_INI_BOOLEAN("session.auto_start", "0", PHP_INI_ALL, OnUpdateBool, auto_start, php_ps_globals, ps_globals)
STD_PHP_INI_ENTRY("session.gc_probability", "1", PHP_INI_ALL, OnUpdateLong, gc_probability, php_ps_globals, ps_globals)
@@ -2366,7 +2391,7 @@ static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, i
php_session_initialize(TSRMLS_C);
PS(session_status) = php_session_active;
IF_SESSION_VARS() {
- progress->cancel_upload = php_check_cancel_upload(progress TSRMLS_CC);
+ progress->cancel_upload |= php_check_cancel_upload(progress TSRMLS_CC);
ZEND_SET_SYMBOL_WITH_LENGTH(Z_ARRVAL_P(PS(http_session_vars)), progress->key.c, progress->key.len+1, progress->data, 2, 0);
}
php_session_flush(TSRMLS_C);
diff --git a/ext/session/tests/session_name_error.phpt b/ext/session/tests/session_name_error.phpt
index 2ed10d92a2..1b99d4ea35 100644
--- a/ext/session/tests/session_name_error.phpt
+++ b/ext/session/tests/session_name_error.phpt
@@ -86,7 +86,7 @@ $inputs = array(
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
- var_dump(session_name($input));
+ var_dump($input, session_name($input));
$iterator++;
};
@@ -98,77 +98,139 @@ ob_end_flush();
*** Testing session_name() : error functionality ***
-- Iteration 1 --
+
+Warning: session_name(): session.name cannot be a numeric or empty '0' in %s on line %d
+int(0)
string(9) "PHPSESSID"
-- Iteration 2 --
-string(1) "0"
+
+Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
+int(1)
+string(9) "PHPSESSID"
-- Iteration 3 --
-string(1) "1"
+
+Warning: session_name(): session.name cannot be a numeric or empty '12345' in %s on line %d
+int(12345)
+string(9) "PHPSESSID"
-- Iteration 4 --
-string(5) "12345"
+
+Warning: session_name(): session.name cannot be a numeric or empty '-2345' in %s on line %d
+int(-2345)
+string(9) "PHPSESSID"
-- Iteration 5 --
-string(5) "-2345"
+
+Warning: session_name(): session.name cannot be a numeric or empty '10.5' in %s on line %d
+float(10.5)
+string(9) "PHPSESSID"
-- Iteration 6 --
-string(4) "10.5"
+
+Warning: session_name(): session.name cannot be a numeric or empty '-10.5' in %s on line %d
+float(-10.5)
+string(9) "PHPSESSID"
-- Iteration 7 --
-string(5) "-10.5"
+
+Warning: session_name(): session.name cannot be a numeric or empty '123456789000' in %s on line %d
+float(123456789000)
+string(9) "PHPSESSID"
-- Iteration 8 --
-string(12) "123456789000"
+
+Warning: session_name(): session.name cannot be a numeric or empty '1.23456789E-9' in %s on line %d
+float(1.23456789E-9)
+string(9) "PHPSESSID"
-- Iteration 9 --
-string(13) "1.23456789E-9"
+
+Warning: session_name(): session.name cannot be a numeric or empty '0.5' in %s on line %d
+float(0.5)
+string(9) "PHPSESSID"
-- Iteration 10 --
-string(3) "0.5"
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+NULL
+string(9) "PHPSESSID"
-- Iteration 11 --
-string(0) ""
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+NULL
+string(9) "PHPSESSID"
-- Iteration 12 --
-string(0) ""
+
+Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
+bool(true)
+string(9) "PHPSESSID"
-- Iteration 13 --
-string(1) "1"
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+bool(false)
+string(9) "PHPSESSID"
-- Iteration 14 --
-string(0) ""
+
+Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
+bool(true)
+string(9) "PHPSESSID"
-- Iteration 15 --
-string(1) "1"
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+bool(false)
+string(9) "PHPSESSID"
-- Iteration 16 --
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
string(0) ""
+string(9) "PHPSESSID"
-- Iteration 17 --
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
string(0) ""
+string(9) "PHPSESSID"
-- Iteration 18 --
-string(0) ""
+string(7) "Nothing"
+string(9) "PHPSESSID"
-- Iteration 19 --
string(7) "Nothing"
+string(7) "Nothing"
-- Iteration 20 --
+string(12) "Hello World!"
string(7) "Nothing"
-- Iteration 21 --
+object(classA)#1 (0) {
+}
string(12) "Hello World!"
-- Iteration 22 --
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+NULL
string(12) "Hello World!"
-- Iteration 23 --
-string(0) ""
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+NULL
+string(12) "Hello World!"
-- Iteration 24 --
Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d
+resource(5) of type (stream)
NULL
-Done
-
+Done \ No newline at end of file
diff --git a/ext/session/tests/session_name_variation1.phpt b/ext/session/tests/session_name_variation1.phpt
index 16d6ad462c..b0de3ee361 100644
--- a/ext/session/tests/session_name_variation1.phpt
+++ b/ext/session/tests/session_name_variation1.phpt
@@ -43,18 +43,20 @@ ob_end_flush();
*** Testing session_name() : variation ***
string(9) "PHPSESSID"
bool(true)
-string(0) ""
+string(9) "PHPSESSID"
bool(true)
-string(0) ""
-string(0) ""
+string(9) "PHPSESSID"
+string(9) "PHPSESSID"
bool(true)
string(1) " "
bool(true)
string(1) " "
+
+Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
string(1) " "
bool(true)
-string(0) ""
+string(1) " "
bool(true)
-string(0) ""
+string(1) " "
Done
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 056e7e4f10..7f0ce631b1 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1510,7 +1510,7 @@ SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
Returns an iterator for the current entry if it is a directory */
SPL_METHOD(RecursiveDirectoryIterator, getChildren)
{
- zval zpath, zflags;
+ zval *zpath, *zflags;
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_filesystem_object *subdir;
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
@@ -1524,11 +1524,13 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
RETURN_STRINGL(intern->file_name, intern->file_name_len, 1);
} else {
- INIT_PZVAL(&zflags);
- INIT_PZVAL(&zpath);
- ZVAL_LONG(&zflags, intern->flags);
- ZVAL_STRINGL(&zpath, intern->file_name, intern->file_name_len, 0);
- spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, &zpath, &zflags TSRMLS_CC);
+ MAKE_STD_ZVAL(zflags);
+ MAKE_STD_ZVAL(zpath);
+ ZVAL_LONG(zflags, intern->flags);
+ ZVAL_STRINGL(zpath, intern->file_name, intern->file_name_len, 1);
+ spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, zpath, zflags TSRMLS_CC);
+ zval_ptr_dtor(&zpath);
+ zval_ptr_dtor(&zflags);
subdir = (spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
if (subdir) {
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index ebc4e341a6..fec7e2c4ac 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -604,6 +604,38 @@ SPL_METHOD(SplFixedArray, __construct)
}
/* }}} */
+/* {{{ proto void SplFixedArray::__wakeup()
+*/
+SPL_METHOD(SplFixedArray, __wakeup)
+{
+ spl_fixedarray_object *intern = (spl_fixedarray_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ HashPosition ptr;
+ HashTable *intern_ht = zend_std_get_properties(getThis() TSRMLS_CC);
+ zval **data;
+
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "")) {
+ return;
+ }
+
+ if (!intern->array) {
+ int index = 0;
+ int size = zend_hash_num_elements(intern_ht);
+
+ intern->array = emalloc(sizeof(spl_fixedarray));
+ spl_fixedarray_init(intern->array, size TSRMLS_CC);
+
+ for (zend_hash_internal_pointer_reset_ex(intern_ht, &ptr); zend_hash_get_current_data_ex(intern_ht, (void **) &data, &ptr) == SUCCESS; zend_hash_move_forward_ex(intern_ht, &ptr)) {
+ Z_ADDREF_PP(data);
+ intern->array->elements[index++] = *data;
+ }
+
+ /* Remove the unserialised properties, since we now have the elements
+ * within the spl_fixedarray_object structure. */
+ zend_hash_clean(intern_ht);
+ }
+}
+/* }}} */
+
/* {{{ proto int SplFixedArray::count(void)
*/
SPL_METHOD(SplFixedArray, count)
@@ -1086,6 +1118,7 @@ ZEND_END_ARG_INFO()
static zend_function_entry spl_funcs_SplFixedArray[] = { /* {{{ */
SPL_ME(SplFixedArray, __construct, arginfo_splfixedarray_construct,ZEND_ACC_PUBLIC)
+ SPL_ME(SplFixedArray, __wakeup, arginfo_splfixedarray_void, ZEND_ACC_PUBLIC)
SPL_ME(SplFixedArray, count, arginfo_splfixedarray_void, ZEND_ACC_PUBLIC)
SPL_ME(SplFixedArray, toArray, arginfo_splfixedarray_void, ZEND_ACC_PUBLIC)
SPL_ME(SplFixedArray, fromArray, arginfo_fixedarray_fromArray, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
diff --git a/ext/spl/tests/SplFixedArray_serialize.phpt b/ext/spl/tests/SplFixedArray_serialize.phpt
new file mode 100644
index 0000000000..f99812ecce
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_serialize.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SplFixedArray serialisation
+--FILE--
+<?php
+
+$array = new SplFixedArray(5);
+
+$obj = new stdClass;
+$obj->prop = 'value';
+
+$array[0] = 'foo';
+$array[2] = 42;
+$array[3] = $obj;
+$array[4] = range(1, 5);
+
+$ser = serialize($array);
+echo "$ser\n";
+$unser = unserialize($ser);
+
+printf("count: %d\n", count($unser));
+printf("getSize(): %d\n", $unser->getSize());
+
+var_dump($unser[0], $unser[1], $unser[2], $unser[3], $unser[4]);
+
+$unser[4] = 'quux';
+var_dump($unser[4]);
+
+?>
+--EXPECT--
+O:13:"SplFixedArray":5:{i:0;s:3:"foo";i:1;N;i:2;i:42;i:3;O:8:"stdClass":1:{s:4:"prop";s:5:"value";}i:4;a:5:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;}}
+count: 5
+getSize(): 5
+string(3) "foo"
+NULL
+int(42)
+object(stdClass)#4 (1) {
+ ["prop"]=>
+ string(5) "value"
+}
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
+string(4) "quux"
diff --git a/ext/standard/tests/array/array_walk_closure.phpt b/ext/standard/tests/array/array_walk_closure.phpt
index 7f6c8342e9..4e22bb8946 100644
--- a/ext/standard/tests/array/array_walk_closure.phpt
+++ b/ext/standard/tests/array/array_walk_closure.phpt
@@ -219,7 +219,7 @@ array(2) {
[1]=>
array(4) {
["file"]=>
- string(69) "%s"
+ string(%d) "%s"
["line"]=>
int(%d)
["function"]=>
@@ -248,4 +248,4 @@ array(2) {
}
}
}
-Done \ No newline at end of file
+Done
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 2fea4f8ab9..334938ab24 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -428,7 +428,7 @@ static void xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
}
if (parser->ltags) {
int inx;
- for (inx = 0; inx < parser->level; inx++)
+ for (inx = 0; ((inx < parser->level) && (inx < XML_MAXLEVEL)); inx++)
efree(parser->ltags[ inx ]);
efree(parser->ltags);
}
@@ -805,45 +805,50 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
}
if (parser->data) {
- zval *tag, *atr;
- int atcnt = 0;
+ if (parser->level <= XML_MAXLEVEL) {
+ zval *tag, *atr;
+ int atcnt = 0;
- MAKE_STD_ZVAL(tag);
- MAKE_STD_ZVAL(atr);
+ MAKE_STD_ZVAL(tag);
+ MAKE_STD_ZVAL(atr);
- array_init(tag);
- array_init(atr);
+ array_init(tag);
+ array_init(atr);
- _xml_add_to_info(parser,((char *) tag_name) + parser->toffset);
+ _xml_add_to_info(parser,((char *) tag_name) + parser->toffset);
- add_assoc_string(tag,"tag",((char *) tag_name) + parser->toffset,1); /* cast to avoid gcc-warning */
- add_assoc_string(tag,"type","open",1);
- add_assoc_long(tag,"level",parser->level);
+ add_assoc_string(tag,"tag",((char *) tag_name) + parser->toffset,1); /* cast to avoid gcc-warning */
+ add_assoc_string(tag,"type","open",1);
+ add_assoc_long(tag,"level",parser->level);
- parser->ltags[parser->level-1] = estrdup(tag_name);
- parser->lastwasopen = 1;
+ parser->ltags[parser->level-1] = estrdup(tag_name);
+ parser->lastwasopen = 1;
- attributes = (const XML_Char **) attrs;
+ attributes = (const XML_Char **) attrs;
- while (attributes && *attributes) {
- att = _xml_decode_tag(parser, attributes[0]);
- val = xml_utf8_decode(attributes[1], strlen(attributes[1]), &val_len, parser->target_encoding);
-
- add_assoc_stringl(atr,att,val,val_len,0);
+ while (attributes && *attributes) {
+ att = _xml_decode_tag(parser, attributes[0]);
+ val = xml_utf8_decode(attributes[1], strlen(attributes[1]), &val_len, parser->target_encoding);
- atcnt++;
- attributes += 2;
+ add_assoc_stringl(atr,att,val,val_len,0);
- efree(att);
- }
+ atcnt++;
+ attributes += 2;
- if (atcnt) {
- zend_hash_add(Z_ARRVAL_P(tag),"attributes",sizeof("attributes"),&atr,sizeof(zval*),NULL);
- } else {
- zval_ptr_dtor(&atr);
- }
+ efree(att);
+ }
+
+ if (atcnt) {
+ zend_hash_add(Z_ARRVAL_P(tag),"attributes",sizeof("attributes"),&atr,sizeof(zval*),NULL);
+ } else {
+ zval_ptr_dtor(&atr);
+ }
- zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),(void *) &parser->ctag);
+ zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),(void *) &parser->ctag);
+ } else if (parser->level == (XML_MAXLEVEL + 1)) {
+ TSRMLS_FETCH();
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Maximum depth exceeded - Results truncated");
+ }
}
efree(tag_name);
@@ -895,7 +900,7 @@ void _xml_endElementHandler(void *userData, const XML_Char *name)
efree(tag_name);
- if (parser->ltags) {
+ if ((parser->ltags) && (parser->level <= XML_MAXLEVEL)) {
efree(parser->ltags[parser->level-1]);
}
@@ -979,18 +984,23 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
}
}
- MAKE_STD_ZVAL(tag);
-
- array_init(tag);
-
- _xml_add_to_info(parser,parser->ltags[parser->level-1] + parser->toffset);
+ if (parser->level <= XML_MAXLEVEL) {
+ MAKE_STD_ZVAL(tag);
+
+ array_init(tag);
- add_assoc_string(tag,"tag",parser->ltags[parser->level-1] + parser->toffset,1);
- add_assoc_string(tag,"value",decoded_value,0);
- add_assoc_string(tag,"type","cdata",1);
- add_assoc_long(tag,"level",parser->level);
+ _xml_add_to_info(parser,parser->ltags[parser->level-1] + parser->toffset);
- zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),NULL);
+ add_assoc_string(tag,"tag",parser->ltags[parser->level-1] + parser->toffset,1);
+ add_assoc_string(tag,"value",decoded_value,0);
+ add_assoc_string(tag,"type","cdata",1);
+ add_assoc_long(tag,"level",parser->level);
+
+ zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),NULL);
+ } else if (parser->level == (XML_MAXLEVEL + 1)) {
+ TSRMLS_FETCH();
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Maximum depth exceeded - Results truncated");
+ }
}
} else {
efree(decoded_value);
diff --git a/sapi/cgi/Makefile.frag b/sapi/cgi/Makefile.frag
index 505119e572..d54dd40808 100644
--- a/sapi/cgi/Makefile.frag
+++ b/sapi/cgi/Makefile.frag
@@ -6,4 +6,7 @@ $(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_CGI_OBJS)
install-cgi: $(SAPI_CGI_PATH)
@echo "Installing PHP CGI binary: $(INSTALL_ROOT)$(bindir)/"
@$(INSTALL) -m 0755 $(SAPI_CGI_PATH) $(INSTALL_ROOT)$(bindir)/$(program_prefix)php-cgi$(program_suffix)$(EXEEXT)
+ @echo "Installing PHP CGI man page: $(INSTALL_ROOT)$(mandir)/man1/"
+ @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1
+ @$(INSTALL_DATA) sapi/cgi/php-cgi.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)php-cgi$(program_suffix).1
diff --git a/sapi/cgi/config9.m4 b/sapi/cgi/config9.m4
index 67251aeb58..49e61c83c3 100644
--- a/sapi/cgi/config9.m4
+++ b/sapi/cgi/config9.m4
@@ -71,6 +71,8 @@ if test "$PHP_CGI" != "no"; then
dnl Expose to Makefile
PHP_SUBST(SAPI_CGI_PATH)
PHP_SUBST(BUILD_CGI)
+
+ PHP_OUTPUT(sapi/cgi/php-cgi.1)
else
AC_MSG_RESULT(yes)
fi
diff --git a/sapi/cgi/php-cgi.1.in b/sapi/cgi/php-cgi.1.in
new file mode 100644
index 0000000000..340e6c5d60
--- /dev/null
+++ b/sapi/cgi/php-cgi.1.in
@@ -0,0 +1 @@
+.so man1/php.1
diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in
index 0e9d07ac77..749baa8a6b 100644
--- a/sapi/cli/php.1.in
+++ b/sapi/cli/php.1.in
@@ -1,6 +1,8 @@
.TH PHP 1 "2013" "The PHP Group" "Scripting Language"
.SH NAME
php \- PHP Command Line Interface 'CLI'
+.P
+php-cgi \- PHP Common Gateway Interface 'CGI' command
.SH SYNOPSIS
.B php
[options] [
diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c
index f959cf36d8..145b2550c3 100644
--- a/sapi/fpm/fpm/fpm_sockets.c
+++ b/sapi/fpm/fpm/fpm_sockets.c
@@ -405,7 +405,19 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
zlog(ZLOG_SYSERROR, "failed to retrieve TCP_INFO for socket");
return -1;
}
+#if defined(__FreeBSD__)
+ if (info.__tcpi_sacked == 0) {
+ return -1;
+ }
+
+ if (cur_lq) {
+ *cur_lq = info.__tcpi_unacked;
+ }
+ if (max_lq) {
+ *max_lq = info.__tcpi_sacked;
+ }
+#else
/* kernel >= 2.6.24 return non-zero here, that means operation is supported */
if (info.tcpi_sacked == 0) {
return -1;
@@ -418,6 +430,7 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
if (max_lq) {
*max_lq = info.tcpi_sacked;
}
+#endif
return 0;
}