diff options
Diffstat (limited to 'ext')
347 files changed, 13321 insertions, 3875 deletions
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index abe84fc316..4adaa47fa9 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -192,7 +192,7 @@ php_stream_ops php_stream_bz2io_ops = { /* {{{ Bzip2 stream openers */ PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, - char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC) + const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC) { struct php_bz2_stream_data_t *self; @@ -205,8 +205,8 @@ PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, } PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, - char *path, - char *mode, + const char *path, + const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) diff --git a/ext/bz2/php_bz2.h b/ext/bz2/php_bz2.h index 8b12eca357..7bcffc1831 100644 --- a/ext/bz2/php_bz2.h +++ b/ext/bz2/php_bz2.h @@ -47,8 +47,8 @@ extern zend_module_entry bz2_module_entry; # define PHP_BZ2_API #endif -PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); -PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC); +PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC); #define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC TSRMLS_CC) #define php_stream_bz2open(wrapper, path, mode, options, opened_path) _php_stream_bz2open((wrapper), (path), (mode), (options), (opened_path), NULL STREAMS_CC TSRMLS_CC) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 9fdb57cc4e..591315973c 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1791,7 +1791,7 @@ static void alloc_curl_handle(php_curl **ch) zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0); zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0); - (*ch)->safe_upload = 0; /* for now, for BC reason we allow unsafe API */ + (*ch)->safe_upload = 1; /* for now, for BC reason we allow unsafe API */ (*ch)->to_free->slist = emalloc(sizeof(HashTable)); zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0); @@ -2504,6 +2504,7 @@ string_copy: case CURLOPT_FOLLOWLOCATION: convert_to_long_ex(zvalue); +#if LIBCURL_VERSION_NUM < 0x071304 if (PG(open_basedir) && *PG(open_basedir)) { if (Z_LVAL_PP(zvalue) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set"); @@ -2511,6 +2512,7 @@ string_copy: return 1; } } +#endif error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); break; diff --git a/ext/curl/tests/bug65646.phpt b/ext/curl/tests/bug65646.phpt new file mode 100644 index 0000000000..f244f7238f --- /dev/null +++ b/ext/curl/tests/bug65646.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #65646 (re-enable CURLOPT_FOLLOWLOCATION with open_basedir or safe_mode): open_basedir disabled +--SKIPIF-- +<?php +if (!extension_loaded('curl')) exit("skip curl extension not loaded"); +if (ini_get('open_basedir')) exit("skip open_basedir is set"); +?> +--FILE-- +<?php +$ch = curl_init(); +var_dump(curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)); +curl_close($ch); +?> +--EXPECT-- +bool(true) diff --git a/ext/curl/tests/bug65646_open_basedir_new.phpt b/ext/curl/tests/bug65646_open_basedir_new.phpt new file mode 100644 index 0000000000..991c4a2b8a --- /dev/null +++ b/ext/curl/tests/bug65646_open_basedir_new.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #65646 (re-enable CURLOPT_FOLLOWLOCATION with open_basedir or safe_mode): open_basedir enabled; curl >= 7.19.4 +--INI-- +open_basedir=. +--SKIPIF-- +<?php +if (!extension_loaded('curl')) exit("skip curl extension not loaded"); +if (version_compare(curl_version()['version'], '7.19.4', '<')) exit("skip curl version is too old"); +?> +--FILE-- +<?php +$ch = curl_init(); +var_dump(curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)); +var_dump(curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE)); +var_dump(curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_FILE)); +curl_close($ch); +?> +--EXPECTF-- +bool(true) + +Warning: curl_setopt(): CURLPROTO_FILE cannot be activated when an open_basedir is set in %s on line %d +bool(false) + +Warning: curl_setopt(): CURLPROTO_FILE cannot be activated when an open_basedir is set in %s on line %d +bool(false) diff --git a/ext/curl/tests/bug65646_open_basedir_old.phpt b/ext/curl/tests/bug65646_open_basedir_old.phpt new file mode 100644 index 0000000000..cf11d21a20 --- /dev/null +++ b/ext/curl/tests/bug65646_open_basedir_old.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #65646 (re-enable CURLOPT_FOLLOWLOCATION with open_basedir or safe_mode): open_basedir enabled; curl < 7.19.4 +--INI-- +open_basedir=. +--SKIPIF-- +<?php +if (!extension_loaded('curl')) exit("skip curl extension not loaded"); +if (version_compare(curl_version()['version'], '7.19.4', '>=')) exit("skip curl version is too new"); +?> +--FILE-- +<?php +$ch = curl_init(); +var_dump(curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)); +curl_close($ch); +?> +--EXPECTF-- +Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in %s on line %d +bool(false) diff --git a/ext/curl/tests/curl_setopt_CURLOPT_FOLLOWLOCATION_open_basedir.phpt b/ext/curl/tests/curl_setopt_CURLOPT_FOLLOWLOCATION_open_basedir.phpt deleted file mode 100644 index 7a778f3692..0000000000 --- a/ext/curl/tests/curl_setopt_CURLOPT_FOLLOWLOCATION_open_basedir.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -CURLOPT_FOLLOWLOCATION case check open_basedir ---CREDITS-- -WHITE new media architects - Dennis ---INI-- -open_basedir = DIRECTORY_SEPARATOR."tmp"; ---SKIPIF-- -<?php -if (!extension_loaded("curl")) print "skip cURL not loaded"; -?> ---FILE-- -<?php -print (ini_get("OPEN_BASEDIR")); -$ch = curl_init(); -$succes = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); -curl_close($ch); -var_dump($succes); -?> ---EXPECTF-- -Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in %s.php on line %d -bool(false) - diff --git a/ext/date/config0.m4 b/ext/date/config0.m4 index f403104a8a..0b46c6803a 100644 --- a/ext/date/config0.m4 +++ b/ext/date/config0.m4 @@ -22,4 +22,5 @@ cat > $ext_builddir/lib/timelib_config.h <<EOF #else # include <php_config.h> #endif +#include <php_stdint.h> EOF diff --git a/ext/date/lib/timelib_structs.h b/ext/date/lib/timelib_structs.h index a3d7793447..cc12eb38a6 100644 --- a/ext/date/lib/timelib_structs.h +++ b/ext/date/lib/timelib_structs.h @@ -23,37 +23,7 @@ #include "timelib_config.h" -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#if defined(HAVE_INTTYPES_H) -#include <inttypes.h> -#elif defined(HAVE_STDINT_H) -#include <stdint.h> -#endif - -#ifdef PHP_WIN32 -/* TODO: Remove these hacks/defs once we have the int definitions in main/ - rathen than in each 2nd extension and win32/ */ -# include "win32/php_stdint.h" -#else -# ifndef HAVE_INT32_T -# if SIZEOF_INT == 4 -typedef int int32_t; -# elif SIZEOF_LONG == 4 -typedef long int int32_t; -# endif -# endif - -# ifndef HAVE_UINT32_T -# if SIZEOF_INT == 4 -typedef unsigned int uint32_t; -# elif SIZEOF_LONG == 4 -typedef unsigned long int uint32_t; -# endif -# endif -#endif +#include "php_stdint.h" #include <stdio.h> diff --git a/ext/exif/exif.c b/ext/exif/exif.c index bd646d9adf..ec121a6c32 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -40,16 +40,6 @@ #include "php.h" #include "ext/standard/file.h" -#ifdef HAVE_STDINT_H -# include <stdint.h> -#endif -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> -#endif -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -#endif - #if HAVE_EXIF /* When EXIF_DEBUG is defined the module generates a lot of debug messages diff --git a/ext/ext_skel b/ext/ext_skel index 2492bf73da..061e78d649 100755 --- a/ext/ext_skel +++ b/ext/ext_skel @@ -12,7 +12,7 @@ echo "" echo " --extname=module module is the name of your extension" echo " --proto=file file contains prototypes of functions to create" echo " --stubs=file generate only function stubs in file" -echo " --xml generate xml documentation to be added to phpdoc-cvs" +echo " --xml generate xml documentation to be added to phpdoc-svn" echo " --skel=dir path to the skeleton directory" echo " --full-xml generate xml documentation for a self-contained extension" echo " (not yet implemented)" @@ -187,11 +187,43 @@ if (PHP_$EXTNAME != "no") { eof -$ECHO_N " .svnignore$ECHO_C" -cat >.svnignore <<eof +$ECHO_N " .gitignore$ECHO_C" +cat >.gitignore <<eof .deps *.lo *.la +.libs +acinclude.m4 +aclocal.m4 +autom4te.cache +build +config.guess +config.h +config.h.in +config.log +config.nice +config.status +config.sub +configure +configure.in +include +install-sh +libtool +ltmain.sh +Makefile +Makefile.fragments +Makefile.global +Makefile.objects +missing +mkinstalldirs +modules +run-tests.php +tests/*/*.diff +tests/*/*.out +tests/*/*.php +tests/*/*.exp +tests/*/*.log +tests/*/*.sh eof $ECHO_N " $extname.c$ECHO_C" diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index 353adb98b9..799891ed13 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -497,7 +497,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime case FILEINFO_MODE_FILE: { /* determine if the file is a local file or remote URL */ - char *tmp2; + const char *tmp2; php_stream_wrapper *wrap; php_stream_statbuf ssb; diff --git a/ext/gd/gd.c b/ext/gd/gd.c index fb258214a1..d8a90f5fb6 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -82,6 +82,10 @@ static void php_free_ps_enc(zend_rsrc_list_entry *rsrc TSRMLS_DC); # endif #endif +#if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED) +# include "X11/xpm.h" +#endif + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -92,6 +96,10 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int, int); #include "gd_ctx.c" +/* as it is not really public, duplicate declaration here to avoid + pointless warnings */ +int overflow2(int a, int b); + /* Section Filters Declarations */ /* IMPORTANT NOTE FOR NEW FILTER * Do not forget to update: @@ -2082,7 +2090,7 @@ PHP_FUNCTION(imagerotate) ZEND_FETCH_RESOURCE(im_src, gdImagePtr, &SIM, -1, "Image", le_gd); - im_dst = gdImageRotateInterpolated(im_src, (float)degrees, color); + im_dst = gdImageRotateInterpolated(im_src, (const float)degrees, color); if (im_dst != NULL) { ZEND_REGISTER_RESOURCE(return_value, im_dst, le_gd); @@ -5175,8 +5183,6 @@ PHP_FUNCTION(imageaffine) pRect = NULL; } - - //int gdTransformAffineGetImage(gdImagePtr *dst, const gdImagePtr src, gdRectPtr src_area, const double affine[6]); if (gdTransformAffineGetImage(&dst, src, pRect, affine) != GD_TRUE) { RETURN_FALSE; } diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h index 72515108d6..20156b97b5 100644 --- a/ext/gd/libgd/gd.h +++ b/ext/gd/libgd/gd.h @@ -849,8 +849,7 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, co gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int bgColor); gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const int bgColor); gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor); - - +gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor); typedef enum { GD_AFFINE_TRANSLATE = 0, diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 3643535f2e..e34242bb73 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -1,4 +1,5 @@ /* + * The two pass scaling function is based on: * Filtered Image Rescaling * Based on Gems III * - Schumacher general filtered image rescaling @@ -13,6 +14,7 @@ * * Initial sources code is avaibable in the Gems Source Code Packages: * http://www.acm.org/pubs/tog/GraphicsGems/GGemsIII.tar.gz + * */ /* @@ -816,10 +818,6 @@ int getPixelInterpolated(gdImagePtr im, const double x, const double y, const in return -1; } - /* Default to full alpha */ - if (bgColor == -1) { - } - if (im->interpolation_id == GD_WEIGHTED4) { return getPixelInterpolateWeight(im, x, y, bgColor); } @@ -1711,6 +1709,7 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, co gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor) { float _angle = ((float) (-degrees / 180.0f) * (float)M_PI); + const int angle_rounded = (int)floor(degrees * 100); const int src_w = gdImageSX(src); const int src_h = gdImageSY(src); const unsigned int new_width = (unsigned int)(abs((int)(src_w * cos(_angle))) + abs((int)(src_h * sin(_angle))) + 0.5f); @@ -1733,6 +1732,10 @@ gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int b : 0; + if (bgColor < 0) { + return NULL; + } + dst = gdImageCreateTrueColor(new_width, new_height); if (!dst) { return NULL; diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index e3a3563aac..8b5c131e76 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -24,6 +24,7 @@ #include "php_ini.h" #include "php_gmp.h" #include "ext/standard/info.h" +#include "zend_exceptions.h" #if HAVE_GMP @@ -34,9 +35,6 @@ #include "ext/standard/php_lcg.h" #define GMP_ABS(x) ((x) >= 0 ? (x) : -(x)) -/* True global resources - no need for thread safety here */ -static int le_gmp; - /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO_EX(arginfo_gmp_init, 0, 0, 1) ZEND_ARG_INFO(0, number) @@ -308,9 +306,18 @@ zend_module_entry gmp_module_entry = { ZEND_GET_MODULE(gmp) #endif -static void _php_gmpnum_free(zend_rsrc_list_entry *rsrc TSRMLS_DC); +zend_class_entry *gmp_ce; +static zend_object_handlers gmp_object_handlers; + +typedef struct _gmp_object { + zend_object std; + mpz_t num; +} gmp_object; -#define GMP_RESOURCE_NAME "GMP integer" +typedef struct _gmp_temp { + mpz_t num; + zend_bool is_used; +} gmp_temp_t; #define GMP_ROUND_ZERO 0 #define GMP_ROUND_PLUSINF 1 @@ -324,6 +331,123 @@ static void _php_gmpnum_free(zend_rsrc_list_entry *rsrc TSRMLS_DC); # define MAX_BASE 36 #endif +#define IS_GMP(zval) \ + (Z_TYPE_P(zval) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zval), gmp_ce TSRMLS_CC)) + +#define GET_GMP_FROM_ZVAL(zval) \ + (((gmp_object *) zend_object_store_get_object((zval) TSRMLS_CC))->num) + +/* The FETCH_GMP_ZVAL_* family of macros is used to fetch a gmp number + * (mpz_ptr) from a zval. If the zval is not a GMP instance, then we + * try to convert the value to a temporary gmp number using convert_to_gmp. + * This temporary number is stored in the temp argument, which is of type + * gmp_temp_t. This temporary value needs to be freed lateron using the + * FREE_GMP_TEMP macro. + * + * If the conversion to a gmp number fails, the macros return false. + * The _DEP / _DEP_DEP variants additionally free the temporary values + * passed in the last / last two arguments. + * + * If one zval can sometimes be fetched as a long you have to set the + * is_used member of the corresponding gmp_temp_t value to 0, otherwise + * the FREE_GMP_TEMP and *_DEP macros will not work properly. + * + * The three FETCH_GMP_ZVAL_* macros below are mostly copy & paste code + * as I couldn't find a way to combine them. + */ + +#define FREE_GMP_TEMP(temp) \ + if (temp.is_used) { \ + mpz_clear(temp.num); \ + } + +#define FETCH_GMP_ZVAL_DEP_DEP(gmpnumber, zval, temp, dep1, dep2) \ +if (IS_GMP(zval)) { \ + gmpnumber = GET_GMP_FROM_ZVAL(zval); \ + temp.is_used = 0; \ +} else { \ + mpz_init(temp.num); \ + if (convert_to_gmp(temp.num, zval, 0 TSRMLS_CC) == FAILURE) { \ + mpz_clear(temp.num); \ + FREE_GMP_TEMP(dep1); \ + FREE_GMP_TEMP(dep2); \ + RETURN_FALSE; \ + } \ + temp.is_used = 1; \ + gmpnumber = temp.num; \ +} + +#define FETCH_GMP_ZVAL_DEP(gmpnumber, zval, temp, dep) \ +if (IS_GMP(zval)) { \ + gmpnumber = GET_GMP_FROM_ZVAL(zval); \ + temp.is_used = 0; \ +} else { \ + mpz_init(temp.num); \ + if (convert_to_gmp(temp.num, zval, 0 TSRMLS_CC) == FAILURE) { \ + mpz_clear(temp.num); \ + FREE_GMP_TEMP(dep); \ + RETURN_FALSE; \ + } \ + temp.is_used = 1; \ + gmpnumber = temp.num; \ +} + +#define FETCH_GMP_ZVAL(gmpnumber, zval, temp) \ +if (IS_GMP(zval)) { \ + gmpnumber = GET_GMP_FROM_ZVAL(zval); \ + temp.is_used = 0; \ +} else { \ + mpz_init(temp.num); \ + if (convert_to_gmp(temp.num, zval, 0 TSRMLS_CC) == FAILURE) { \ + mpz_clear(temp.num); \ + RETURN_FALSE; \ + } \ + temp.is_used = 1; \ + gmpnumber = temp.num; \ +} + +#define INIT_GMP_RETVAL(gmpnumber) \ + gmp_create_ex(return_value, &gmpnumber TSRMLS_CC) + +static void gmp_strval(zval *result, mpz_t gmpnum, long base); +static int convert_to_gmp(mpz_t gmpnumber, zval *val, int base TSRMLS_DC); +static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg TSRMLS_DC); + +/* + * The gmp_*_op functions provide an implementation for several common types + * of GMP functions. The gmp_zval_(unary|binary)_*_op functions have to be manually + * passed zvals to work on, whereas the gmp_(unary|binary)_*_op macros already + * include parameter parsing. + */ +typedef void (*gmp_unary_op_t)(mpz_ptr, mpz_srcptr); +typedef int (*gmp_unary_opl_t)(mpz_srcptr); + +typedef void (*gmp_unary_ui_op_t)(mpz_ptr, unsigned long); + +typedef void (*gmp_binary_op_t)(mpz_ptr, mpz_srcptr, mpz_srcptr); +typedef int (*gmp_binary_opl_t)(mpz_srcptr, mpz_srcptr); + +typedef void (*gmp_binary_ui_op_t)(mpz_ptr, mpz_srcptr, unsigned long); +typedef void (*gmp_binary_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); +typedef void (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long); + +static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int check_b_zero TSRMLS_DC); +static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int check_b_zero TSRMLS_DC); +static inline void gmp_zval_unary_op(zval *return_value, zval *a_arg, gmp_unary_op_t gmp_op TSRMLS_DC); +static inline void gmp_zval_unary_ui_op(zval *return_value, zval *a_arg, gmp_unary_ui_op_t gmp_op TSRMLS_DC); + +/* Binary operations */ +#define gmp_binary_ui_op(op, uop) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, uop, 0) +#define gmp_binary_op(op) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, NULL, 0) +#define gmp_binary_opl(op) _gmp_binary_opl(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) +#define gmp_binary_ui_op_no_zero(op, uop) \ + _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, uop, 1) + +/* Unary operations */ +#define gmp_unary_op(op) _gmp_unary_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) +#define gmp_unary_opl(op) _gmp_unary_opl(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) +#define gmp_unary_ui_op(op) _gmp_unary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) + /* {{{ gmp_emalloc */ static void *gmp_emalloc(size_t size) @@ -348,6 +472,245 @@ static void gmp_efree(void *ptr, size_t size) } /* }}} */ +static inline long gmp_get_long(zval *zv) /* {{{ */ +{ + if (Z_TYPE_P(zv) == IS_LONG) { + return Z_LVAL_P(zv); + } else { + zval tmp_zv; + MAKE_COPY_ZVAL(&zv, &tmp_zv); + convert_to_long(&tmp_zv); + return Z_LVAL(tmp_zv); + } +} +/* }}} */ + +static void gmp_free_object_storage(gmp_object *intern TSRMLS_DC) /* {{{ */ +{ + mpz_clear(intern->num); + + zend_object_std_dtor(&intern->std TSRMLS_CC); + efree(intern); +} +/* }}} */ + +static inline zend_object_value gmp_create_object_ex(zend_class_entry *ce, mpz_ptr *gmpnum_target TSRMLS_DC) /* {{{ */ +{ + zend_object_value retval; + gmp_object *intern = emalloc(sizeof(gmp_object)); + + zend_object_std_init(&intern->std, ce TSRMLS_CC); + object_properties_init(&intern->std, ce); + + mpz_init(intern->num); + *gmpnum_target = intern->num; + + retval.handle = zend_objects_store_put( + intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, + (zend_objects_free_object_storage_t) gmp_free_object_storage, + NULL TSRMLS_CC + ); + retval.handlers = &gmp_object_handlers; + + return retval; +} +/* }}} */ + +static zend_object_value gmp_create_object(zend_class_entry *ce TSRMLS_DC) /* {{{ */ +{ + mpz_ptr gmpnum_dummy; + return gmp_create_object_ex(ce, &gmpnum_dummy TSRMLS_CC); +} +/* }}} */ + +static inline void gmp_create_ex(zval *target, mpz_ptr *gmpnum_target TSRMLS_DC) /* {{{ */ +{ + Z_TYPE_P(target) = IS_OBJECT; + Z_OBJVAL_P(target) = gmp_create_object_ex(gmp_ce, gmpnum_target TSRMLS_CC); +} +/* }}} */ + +static zval *gmp_create(mpz_ptr *gmpnum_target TSRMLS_DC) /* {{{ */ +{ + zval *obj; + MAKE_STD_ZVAL(obj); + gmp_create_ex(obj, gmpnum_target TSRMLS_CC); + return obj; +} +/* }}} */ + +static int gmp_cast_object(zval *readobj, zval *writeobj, int type TSRMLS_DC) /* {{{ */ +{ + mpz_ptr gmpnum; + switch (type) { + case IS_STRING: + gmpnum = GET_GMP_FROM_ZVAL(readobj); + INIT_PZVAL(writeobj); + gmp_strval(writeobj, gmpnum, 10); + return SUCCESS; + case IS_LONG: + gmpnum = GET_GMP_FROM_ZVAL(readobj); + INIT_PZVAL(writeobj); + ZVAL_LONG(writeobj, mpz_get_si(gmpnum)); + return SUCCESS; + case IS_DOUBLE: + gmpnum = GET_GMP_FROM_ZVAL(readobj); + INIT_PZVAL(writeobj); + ZVAL_DOUBLE(writeobj, mpz_get_d(gmpnum)); + return SUCCESS; + default: + return FAILURE; + } +} +/* }}} */ + +static HashTable *gmp_get_properties(zval *obj TSRMLS_DC) /* {{{ */ +{ + HashTable *ht = zend_std_get_properties(obj TSRMLS_CC); + mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(obj); + zval *zv; + + MAKE_STD_ZVAL(zv); + gmp_strval(zv, gmpnum, 10); + zend_hash_update(ht, "num", sizeof("num"), &zv, sizeof(zval *), NULL); + + return ht; +} +/* }}} */ + +static zend_object_value gmp_clone_obj(zval *obj TSRMLS_DC) /* {{{ */ +{ + gmp_object *old_object = zend_object_store_get_object(obj TSRMLS_CC); + zend_object_value new_object_val = gmp_create_object(Z_OBJCE_P(obj) TSRMLS_CC); + gmp_object *new_object = zend_object_store_get_object_by_handle( + new_object_val.handle TSRMLS_CC + ); + + zend_objects_clone_members( + &new_object->std, new_object_val, + &old_object->std, Z_OBJ_HANDLE_P(obj) TSRMLS_CC + ); + + mpz_set(new_object->num, old_object->num); + + return new_object_val; +} +/* }}} */ + +static void shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zval *op1, zval *op2 TSRMLS_DC) { + zval op2_copy; + if (Z_TYPE_P(op2) != IS_LONG) { + op2_copy = *op2; + zval_copy_ctor(&op2_copy); + convert_to_long(&op2_copy); + op2 = &op2_copy; + } + + if (Z_LVAL_P(op2) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Shift cannot be negative"); + RETVAL_FALSE; + } else { + mpz_ptr gmpnum_op, gmpnum_result; + gmp_temp_t temp; + + FETCH_GMP_ZVAL(gmpnum_op, op1, temp); + INIT_GMP_RETVAL(gmpnum_result); + op(gmpnum_result, gmpnum_op, (unsigned long) Z_LVAL_P(op2)); + FREE_GMP_TEMP(temp); + } +} + +#define DO_BINARY_UI_OP_EX(op, uop, check_b_zero) \ + gmp_zval_binary_ui_op( \ + result, op1, op2, op, (gmp_binary_ui_op_t) uop, \ + check_b_zero TSRMLS_CC \ + ); \ + return SUCCESS; + +#define DO_BINARY_UI_OP(op) DO_BINARY_UI_OP_EX(op, op ## _ui, 0) +#define DO_BINARY_OP(op) DO_BINARY_UI_OP_EX(op, NULL, 0) + +#define DO_UNARY_OP(op) \ + gmp_zval_unary_op(result, op1, op TSRMLS_CC); \ + return SUCCESS; + +static int gmp_do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ +{ + switch (opcode) { + case ZEND_ADD: + DO_BINARY_UI_OP(mpz_add); + case ZEND_SUB: + DO_BINARY_UI_OP(mpz_sub); + case ZEND_MUL: + DO_BINARY_UI_OP(mpz_mul); + case ZEND_DIV: + DO_BINARY_UI_OP_EX(mpz_tdiv_q, mpz_tdiv_q_ui, 1); + case ZEND_MOD: + DO_BINARY_UI_OP_EX(mpz_mod, mpz_mod_ui, 1); + case ZEND_SL: + shift_operator_helper(mpz_mul_2exp, result, op1, op2 TSRMLS_CC); + return SUCCESS; + case ZEND_SR: + shift_operator_helper(mpz_fdiv_q_2exp, result, op1, op2 TSRMLS_CC); + return SUCCESS; + case ZEND_BW_OR: + DO_BINARY_OP(mpz_ior); + case ZEND_BW_AND: + DO_BINARY_OP(mpz_and); + case ZEND_BW_XOR: + DO_BINARY_OP(mpz_xor); + case ZEND_BW_NOT: + DO_UNARY_OP(mpz_com); + + default: + return FAILURE; + } +} +/* }}} */ + +static int gmp_compare(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ +{ + gmp_cmp(result, op1, op2 TSRMLS_CC); + if (Z_TYPE_P(result) == IS_BOOL) { + ZVAL_LONG(result, 1); + } + return SUCCESS; +} +/* }}} */ + +PHP_METHOD(GMP, __wakeup) /* {{{ */ +{ + HashTable *props; + zval **num_zv; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + props = zend_std_get_properties(getThis() TSRMLS_CC); + if (zend_hash_find(props, "num", sizeof("num"), (void **) &num_zv) == SUCCESS + && Z_TYPE_PP(num_zv) == IS_STRING && Z_STRLEN_PP(num_zv) > 0 + ) { + mpz_ptr gmpnumber = GET_GMP_FROM_ZVAL(getThis()); + if (convert_to_gmp(gmpnumber, *num_zv, 10 TSRMLS_CC) == SUCCESS) { + return; + } + } + + zend_throw_exception( + NULL, "Invalid serialization data", 0 TSRMLS_CC + ); +} +/* }}} */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_wakeup, 0, 0, 0) +ZEND_END_ARG_INFO() + +const zend_function_entry gmp_methods[] = { + PHP_ME(GMP, __wakeup, arginfo_wakeup, ZEND_ACC_PUBLIC) + PHP_FE_END +}; + /* {{{ ZEND_GINIT_FUNCTION */ static ZEND_GINIT_FUNCTION(gmp) @@ -358,9 +721,20 @@ static ZEND_GINIT_FUNCTION(gmp) /* {{{ ZEND_MINIT_FUNCTION */ -ZEND_MODULE_STARTUP_D(gmp) +ZEND_MINIT_FUNCTION(gmp) { - le_gmp = zend_register_list_destructors_ex(_php_gmpnum_free, NULL, GMP_RESOURCE_NAME, module_number); + zend_class_entry tmp_ce; + INIT_CLASS_ENTRY(tmp_ce, "GMP", gmp_methods); /* No methods on the class for now */ + gmp_ce = zend_register_internal_class(&tmp_ce TSRMLS_CC); + gmp_ce->create_object = gmp_create_object; + + memcpy(&gmp_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + gmp_object_handlers.cast_object = gmp_cast_object; + gmp_object_handlers.get_properties = gmp_get_properties; + gmp_object_handlers.clone_obj = gmp_clone_obj; + gmp_object_handlers.do_operation = gmp_do_operation; + gmp_object_handlers.compare = gmp_compare; + REGISTER_LONG_CONSTANT("GMP_ROUND_ZERO", GMP_ROUND_ZERO, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GMP_ROUND_PLUSINF", GMP_ROUND_PLUSINF, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("GMP_ROUND_MINUSINF", GMP_ROUND_MINUSINF, CONST_CS | CONST_PERSISTENT); @@ -403,246 +777,211 @@ ZEND_MODULE_INFO_D(gmp) } /* }}} */ -/* Fetch zval to be GMP number. - Initially, zval can be also number or string */ -#define FETCH_GMP_ZVAL(gmpnumber, zval, tmp_resource) \ -if (Z_TYPE_PP(zval) == IS_RESOURCE) { \ - ZEND_FETCH_RESOURCE(gmpnumber, mpz_t *, zval, -1, GMP_RESOURCE_NAME, le_gmp); \ - tmp_resource = 0; \ -} else { \ - if (convert_to_gmp(&gmpnumber, zval, 0 TSRMLS_CC) == FAILURE) { \ - RETURN_FALSE; \ - } \ - tmp_resource = ZEND_REGISTER_RESOURCE(NULL, gmpnumber, le_gmp); \ -} - -#define FREE_GMP_TEMP(tmp_resource) \ - if(tmp_resource) { \ - zend_list_delete(tmp_resource); \ - } - - -/* create a new initialized GMP number */ -#define INIT_GMP_NUM(gmpnumber) { gmpnumber=emalloc(sizeof(mpz_t)); mpz_init(*gmpnumber); } -#define FREE_GMP_NUM(gmpnumber) { mpz_clear(*gmpnumber); efree(gmpnumber); } /* {{{ convert_to_gmp * Convert zval to be gmp number */ -static int convert_to_gmp(mpz_t * *gmpnumber, zval **val, int base TSRMLS_DC) +static int convert_to_gmp(mpz_t gmpnumber, zval *val, int base TSRMLS_DC) { - int ret = 0; - int skip_lead = 0; - - *gmpnumber = emalloc(sizeof(mpz_t)); - - switch (Z_TYPE_PP(val)) { + switch (Z_TYPE_P(val)) { case IS_LONG: case IS_BOOL: - case IS_CONSTANT: - { - convert_to_long_ex(val); - mpz_init_set_si(**gmpnumber, Z_LVAL_PP(val)); - } - break; - case IS_STRING: - { - char *numstr = Z_STRVAL_PP(val); - - if (Z_STRLEN_PP(val) > 2) { - if (numstr[0] == '0') { - if (numstr[1] == 'x' || numstr[1] == 'X') { - base = 16; - skip_lead = 1; - } else if (base != 16 && (numstr[1] == 'b' || numstr[1] == 'B')) { - base = 2; - skip_lead = 1; - } + case IS_CONSTANT: { + mpz_set_si(gmpnumber, gmp_get_long(val)); + return SUCCESS; + } + case IS_STRING: { + char *numstr = Z_STRVAL_P(val); + int skip_lead = 0; + + if (Z_STRLEN_P(val) > 2) { + if (numstr[0] == '0') { + if (numstr[1] == 'x' || numstr[1] == 'X') { + base = 16; + skip_lead = 1; + } else if (base != 16 && (numstr[1] == 'b' || numstr[1] == 'B')) { + base = 2; + skip_lead = 1; } } - ret = mpz_init_set_str(**gmpnumber, (skip_lead ? &numstr[2] : numstr), base); } - break; - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Unable to convert variable to GMP - wrong type"); - efree(*gmpnumber); - return FAILURE; - } - if (ret) { - FREE_GMP_NUM(*gmpnumber); + return mpz_set_str(gmpnumber, (skip_lead ? &numstr[2] : numstr), base); + } + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to convert variable to GMP - wrong type"); return FAILURE; } - - return SUCCESS; } /* }}} */ -/* {{{ typedefs - */ -typedef void (*gmp_unary_op_t)(mpz_ptr, mpz_srcptr); -typedef int (*gmp_unary_opl_t)(mpz_srcptr); +static void gmp_strval(zval *result, mpz_t gmpnum, long base) /* {{{ */ +{ + int num_len; + char *out_string; -typedef void (*gmp_unary_ui_op_t)(mpz_ptr, unsigned long); + num_len = mpz_sizeinbase(gmpnum, abs(base)); + if (mpz_sgn(gmpnum) < 0) { + num_len++; + } -typedef void (*gmp_binary_op_t)(mpz_ptr, mpz_srcptr, mpz_srcptr); -typedef int (*gmp_binary_opl_t)(mpz_srcptr, mpz_srcptr); + out_string = emalloc(num_len + 1); + mpz_get_str(out_string, base, gmpnum); + + /* + * From GMP documentation for mpz_sizeinbase(): + * The returned value will be exact or 1 too big. If base is a power of + * 2, the returned value will always be exact. + * + * So let's check to see if we already have a \0 byte... + */ + + if (out_string[num_len - 1] == '\0') { + num_len--; + } else { + out_string[num_len] = '\0'; + } -typedef unsigned long (*gmp_binary_ui_op_t)(mpz_ptr, mpz_srcptr, unsigned long); -typedef void (*gmp_binary_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); -typedef unsigned long (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long); + ZVAL_STRINGL(result, out_string, num_len, 0); +} /* }}} */ -#define gmp_zval_binary_ui_op(r, a, b, o, u) gmp_zval_binary_ui_op_ex(r, a, b, o, u, 0, 0, 0 TSRMLS_CC) -#define gmp_zval_binary_ui_op2(r, a, b, o, u) gmp_zval_binary_ui_op2_ex(r, a, b, o, u, 0, 0, 0 TSRMLS_CC) +static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg TSRMLS_DC) /* {{{ */ +{ + mpz_ptr gmpnum_a, gmpnum_b; + gmp_temp_t temp_a, temp_b; + zend_bool use_si = 0; + long res; -#define gmp_binary_ui_op(op, uop) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, uop) -#define gmp_binary_op(op) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, NULL) -#define gmp_binary_opl(op) _gmp_binary_opl(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) + FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); -/* Unary operations */ -#define gmp_unary_op(op) _gmp_unary_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) -#define gmp_unary_opl(op) _gmp_unary_opl(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) -#define gmp_unary_ui_op(op) _gmp_unary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op) + if (Z_TYPE_P(b_arg) == IS_LONG) { + use_si = 1; + temp_b.is_used = 0; + } else { + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); + } + + if (use_si) { + res = mpz_cmp_si(gmpnum_a, Z_LVAL_P(b_arg)); + } else { + res = mpz_cmp(gmpnum_a, gmpnum_b); + } + + FREE_GMP_TEMP(temp_a); + FREE_GMP_TEMP(temp_b); + + RETURN_LONG(res); +} +/* }}} */ -/* {{{ gmp_zval_binary_ui_op_ex +/* {{{ gmp_zval_binary_ui_op Execute GMP binary operation. - May return GMP resource or long if operation allows this */ -static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int allow_ui_return, int check_b_zero, int use_sign TSRMLS_DC) +static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int check_b_zero TSRMLS_DC) { - mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result; - unsigned long long_result = 0; + mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result; int use_ui = 0; - int arga_tmp = 0, argb_tmp = 0; + gmp_temp_t temp_a, temp_b; - FETCH_GMP_ZVAL(gmpnum_a, a_arg, arga_tmp); + FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - if (gmp_ui_op && Z_TYPE_PP(b_arg) == IS_LONG && Z_LVAL_PP(b_arg) >= 0) { + if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) { use_ui = 1; + temp_b.is_used = 0; } else { - FETCH_GMP_ZVAL(gmpnum_b, b_arg, argb_tmp); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); } - if(check_b_zero) { + if (check_b_zero) { int b_is_zero = 0; - if(use_ui) { - b_is_zero = (Z_LVAL_PP(b_arg) == 0); + if (use_ui) { + b_is_zero = (Z_LVAL_P(b_arg) == 0); } else { - b_is_zero = !mpz_cmp_ui(*gmpnum_b, 0); + b_is_zero = !mpz_cmp_ui(gmpnum_b, 0); } - if(b_is_zero) { + if (b_is_zero) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zero operand not allowed"); - FREE_GMP_TEMP(arga_tmp); - FREE_GMP_TEMP(argb_tmp); + FREE_GMP_TEMP(temp_a); + FREE_GMP_TEMP(temp_b); RETURN_FALSE; } } - INIT_GMP_NUM(gmpnum_result); + INIT_GMP_RETVAL(gmpnum_result); - if (use_ui && gmp_ui_op) { - if (allow_ui_return) { - long_result = gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg)); - if (use_sign && mpz_sgn(*gmpnum_a) == -1) { - long_result = -long_result; - } - } else { - gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg)); - } + if (use_ui) { + gmp_ui_op(gmpnum_result, gmpnum_a, (unsigned long) Z_LVAL_P(b_arg)); } else { - gmp_op(*gmpnum_result, *gmpnum_a, *gmpnum_b); + gmp_op(gmpnum_result, gmpnum_a, gmpnum_b); } - FREE_GMP_TEMP(arga_tmp); - FREE_GMP_TEMP(argb_tmp); - - if (use_ui && allow_ui_return) { - FREE_GMP_NUM(gmpnum_result); - RETURN_LONG((long)long_result); - } else { - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); - } + FREE_GMP_TEMP(temp_a); + FREE_GMP_TEMP(temp_b); } /* }}} */ -/* {{{ gmp_zval_binary_ui_op2_ex +/* {{{ gmp_zval_binary_ui_op2 Execute GMP binary operation which returns 2 values. - May return GMP resources or longs if operation allows this. */ -static inline void gmp_zval_binary_ui_op2_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int allow_ui_return, int check_b_zero TSRMLS_DC) +static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int check_b_zero TSRMLS_DC) { - mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result1, *gmpnum_result2; - zval r; + mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result1, gmpnum_result2; int use_ui = 0; - unsigned long long_result = 0; - int arga_tmp = 0, argb_tmp = 0; + gmp_temp_t temp_a, temp_b; - FETCH_GMP_ZVAL(gmpnum_a, a_arg, arga_tmp); + FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - if (gmp_ui_op && Z_TYPE_PP(b_arg) == IS_LONG && Z_LVAL_PP(b_arg) >= 0) { + if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) { /* use _ui function */ use_ui = 1; + temp_b.is_used = 0; } else { - FETCH_GMP_ZVAL(gmpnum_b, b_arg, argb_tmp); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); } - if(check_b_zero) { + if (check_b_zero) { int b_is_zero = 0; - if(use_ui) { - b_is_zero = (Z_LVAL_PP(b_arg) == 0); + if (use_ui) { + b_is_zero = (Z_LVAL_P(b_arg) == 0); } else { - b_is_zero = !mpz_cmp_ui(*gmpnum_b, 0); + b_is_zero = !mpz_cmp_ui(gmpnum_b, 0); } - if(b_is_zero) { + if (b_is_zero) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zero operand not allowed"); - FREE_GMP_TEMP(arga_tmp); - FREE_GMP_TEMP(argb_tmp); + FREE_GMP_TEMP(temp_a); + FREE_GMP_TEMP(temp_b); RETURN_FALSE; } } - INIT_GMP_NUM(gmpnum_result1); - INIT_GMP_NUM(gmpnum_result2); + array_init(return_value); + add_index_zval(return_value, 0, gmp_create(&gmpnum_result1 TSRMLS_CC)); + add_index_zval(return_value, 1, gmp_create(&gmpnum_result2 TSRMLS_CC)); - if (use_ui && gmp_ui_op) { - if (allow_ui_return) { - long_result = gmp_ui_op(*gmpnum_result1, *gmpnum_result2, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg)); - } else { - gmp_ui_op(*gmpnum_result1, *gmpnum_result2, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg)); - } + if (use_ui) { + gmp_ui_op(gmpnum_result1, gmpnum_result2, gmpnum_a, (unsigned long) Z_LVAL_P(b_arg)); } else { - gmp_op(*gmpnum_result1, *gmpnum_result2, *gmpnum_a, *gmpnum_b); + gmp_op(gmpnum_result1, gmpnum_result2, gmpnum_a, gmpnum_b); } - FREE_GMP_TEMP(arga_tmp); - FREE_GMP_TEMP(argb_tmp); - - array_init(return_value); - ZEND_REGISTER_RESOURCE(&r, gmpnum_result1, le_gmp); - add_index_resource(return_value, 0, Z_LVAL(r)); - if (use_ui && allow_ui_return) { - mpz_clear(*gmpnum_result2); - add_index_long(return_value, 1, long_result); - } else { - ZEND_REGISTER_RESOURCE(&r, gmpnum_result2, le_gmp); - add_index_resource(return_value, 1, Z_LVAL(r)); - } + FREE_GMP_TEMP(temp_a); + FREE_GMP_TEMP(temp_b); } /* }}} */ /* {{{ _gmp_binary_ui_op */ -static inline void _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op) +static inline void _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int check_b_zero) { - zval **a_arg, **b_arg; + zval *a_arg, *b_arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a_arg, &b_arg) == FAILURE){ return; } - gmp_zval_binary_ui_op(return_value, a_arg, b_arg, gmp_op, gmp_ui_op); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, gmp_op, gmp_ui_op, check_b_zero TSRMLS_CC); } /* }}} */ @@ -650,33 +989,28 @@ static inline void _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_op /* {{{ gmp_zval_unary_op */ -static inline void gmp_zval_unary_op(zval *return_value, zval **a_arg, gmp_unary_op_t gmp_op TSRMLS_DC) +static inline void gmp_zval_unary_op(zval *return_value, zval *a_arg, gmp_unary_op_t gmp_op TSRMLS_DC) { - mpz_t *gmpnum_a, *gmpnum_result; - int temp_a; + mpz_ptr gmpnum_a, gmpnum_result; + gmp_temp_t temp_a; FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - INIT_GMP_NUM(gmpnum_result); - gmp_op(*gmpnum_result, *gmpnum_a); + INIT_GMP_RETVAL(gmpnum_result); + gmp_op(gmpnum_result, gmpnum_a); FREE_GMP_TEMP(temp_a); - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); } /* }}} */ /* {{{ gmp_zval_unary_ui_op */ -static inline void gmp_zval_unary_ui_op(zval *return_value, zval **a_arg, gmp_unary_ui_op_t gmp_op TSRMLS_DC) +static inline void gmp_zval_unary_ui_op(zval *return_value, zval *a_arg, gmp_unary_ui_op_t gmp_op TSRMLS_DC) { - mpz_t *gmpnum_result; - - convert_to_long_ex(a_arg); + mpz_ptr gmpnum_result; - INIT_GMP_NUM(gmpnum_result); - gmp_op(*gmpnum_result, Z_LVAL_PP(a_arg)); - - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); + INIT_GMP_RETVAL(gmpnum_result); + gmp_op(gmpnum_result, gmp_get_long(a_arg)); } /* }}} */ @@ -685,9 +1019,9 @@ static inline void gmp_zval_unary_ui_op(zval *return_value, zval **a_arg, gmp_un */ static inline void _gmp_unary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_ui_op_t gmp_op) { - zval **a_arg; + zval *a_arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } @@ -699,9 +1033,9 @@ static inline void _gmp_unary_ui_op(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_ui_o */ static inline void _gmp_unary_op(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_op_t gmp_op) { - zval **a_arg; + zval *a_arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } @@ -713,16 +1047,16 @@ static inline void _gmp_unary_op(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_op_t gm */ static inline void _gmp_unary_opl(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_opl_t gmp_op) { - zval **a_arg; - mpz_t *gmpnum_a; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - RETVAL_LONG(gmp_op(*gmpnum_a)); + RETVAL_LONG(gmp_op(gmpnum_a)); FREE_GMP_TEMP(temp_a); } /* }}} */ @@ -731,33 +1065,33 @@ static inline void _gmp_unary_opl(INTERNAL_FUNCTION_PARAMETERS, gmp_unary_opl_t */ static inline void _gmp_binary_opl(INTERNAL_FUNCTION_PARAMETERS, gmp_binary_opl_t gmp_op) { - zval **a_arg, **b_arg; - mpz_t *gmpnum_a, *gmpnum_b; - int temp_a, temp_b; + zval *a_arg, *b_arg; + mpz_ptr gmpnum_a, gmpnum_b; + gmp_temp_t temp_a, temp_b; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a_arg, &b_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - FETCH_GMP_ZVAL(gmpnum_b, b_arg, temp_b); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); - RETVAL_LONG(gmp_op(*gmpnum_a, *gmpnum_b)); + RETVAL_LONG(gmp_op(gmpnum_a, gmpnum_b)); FREE_GMP_TEMP(temp_a); FREE_GMP_TEMP(temp_b); } /* }}} */ -/* {{{ proto resource gmp_init(mixed number [, int base]) +/* {{{ proto GMP gmp_init(mixed number [, int base]) Initializes GMP number */ ZEND_FUNCTION(gmp_init) { - zval **number_arg; - mpz_t * gmpnumber; - long base=0; + zval *number_arg; + mpz_ptr gmpnumber; + long base = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|l", &number_arg, &base) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &number_arg, &base) == FAILURE) { return; } @@ -766,48 +1100,42 @@ ZEND_FUNCTION(gmp_init) RETURN_FALSE; } - if (convert_to_gmp(&gmpnumber, number_arg, base TSRMLS_CC) == FAILURE) { + INIT_GMP_RETVAL(gmpnumber); + if (convert_to_gmp(gmpnumber, number_arg, base TSRMLS_CC) == FAILURE) { + zval_dtor(return_value); RETURN_FALSE; } - - /* Write your own code here to handle argument number. */ - ZEND_REGISTER_RESOURCE(return_value, gmpnumber, le_gmp); } /* }}} */ -/* {{{ proto int gmp_intval(resource gmpnumber) +/* {{{ proto int gmp_intval(mixed gmpnumber) Gets signed long value of GMP number */ ZEND_FUNCTION(gmp_intval) { - zval **gmpnumber_arg; - mpz_t * gmpnum; + zval *gmpnumber_arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &gmpnumber_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &gmpnumber_arg) == FAILURE){ return; } - if (Z_TYPE_PP(gmpnumber_arg) == IS_RESOURCE) { - ZEND_FETCH_RESOURCE(gmpnum, mpz_t *, gmpnumber_arg, -1, GMP_RESOURCE_NAME, le_gmp); - RETVAL_LONG(mpz_get_si(*gmpnum)); + if (IS_GMP(gmpnumber_arg)) { + RETVAL_LONG(mpz_get_si(GET_GMP_FROM_ZVAL(gmpnumber_arg))); } else { - convert_to_long_ex(gmpnumber_arg); - RETVAL_LONG(Z_LVAL_PP(gmpnumber_arg)); + RETVAL_LONG(gmp_get_long(gmpnumber_arg)); } } /* }}} */ -/* {{{ proto string gmp_strval(resource gmpnumber [, int base]) +/* {{{ proto string gmp_strval(mixed gmpnumber [, int base]) Gets string representation of GMP number */ ZEND_FUNCTION(gmp_strval) { - zval **gmpnumber_arg; - int num_len; + zval *gmpnumber_arg; long base = 10; - mpz_t * gmpnum; - char *out_string; - int temp_a; + mpz_ptr gmpnum; + gmp_temp_t temp_a; - if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "Z|l", &gmpnumber_arg, &base ) == FAILURE ) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &gmpnumber_arg, &base) == FAILURE) { return; } @@ -825,162 +1153,138 @@ ZEND_FUNCTION(gmp_strval) FETCH_GMP_ZVAL(gmpnum, gmpnumber_arg, temp_a); - num_len = mpz_sizeinbase(*gmpnum, abs(base)); - out_string = emalloc(num_len+2); - if (mpz_sgn(*gmpnum) < 0) { - num_len++; - } - mpz_get_str(out_string, base, *gmpnum); - - FREE_GMP_TEMP(temp_a); - - /* - From GMP documentation for mpz_sizeinbase(): - The returned value will be exact or 1 too big. If base is a power of - 2, the returned value will always be exact. - - So let's check to see if we already have a \0 byte... - */ + gmp_strval(return_value, gmpnum, base); - if (out_string[num_len-1] == '\0') { - num_len--; - } else { - out_string[num_len] = '\0'; - } - RETVAL_STRINGL(out_string, num_len, 0); + FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto resource gmp_add(resource a, resource b) +/* {{{ proto GMP gmp_add(mixed a, mixed b) Add a and b */ ZEND_FUNCTION(gmp_add) { - gmp_binary_ui_op(mpz_add, (gmp_binary_ui_op_t)mpz_add_ui); + gmp_binary_ui_op(mpz_add, mpz_add_ui); } /* }}} */ -/* {{{ proto resource gmp_sub(resource a, resource b) +/* {{{ proto GMP gmp_sub(mixed a, mixed b) Subtract b from a */ ZEND_FUNCTION(gmp_sub) { - gmp_binary_ui_op(mpz_sub, (gmp_binary_ui_op_t)mpz_sub_ui); + gmp_binary_ui_op(mpz_sub, mpz_sub_ui); } /* }}} */ -/* {{{ proto resource gmp_mul(resource a, resource b) +/* {{{ proto GMP gmp_mul(mixed a, mixed b) Multiply a and b */ ZEND_FUNCTION(gmp_mul) { - gmp_binary_ui_op(mpz_mul, (gmp_binary_ui_op_t)mpz_mul_ui); + gmp_binary_ui_op(mpz_mul, mpz_mul_ui); } /* }}} */ -/* {{{ proto array gmp_div_qr(resource a, resource b [, int round]) +/* {{{ proto array gmp_div_qr(mixed a, mixed b [, int round]) Divide a by b, returns quotient and reminder */ ZEND_FUNCTION(gmp_div_qr) { - zval **a_arg, **b_arg; + zval *a_arg, *b_arg; long round = GMP_ROUND_ZERO; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|l", &a_arg, &b_arg, &round) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &a_arg, &b_arg, &round) == FAILURE) { return; } switch (round) { case GMP_ROUND_ZERO: - gmp_zval_binary_ui_op2_ex(return_value, a_arg, b_arg, mpz_tdiv_qr, (gmp_binary_ui_op2_t)mpz_tdiv_qr_ui, 0, 1 TSRMLS_CC); + gmp_zval_binary_ui_op2(return_value, a_arg, b_arg, mpz_tdiv_qr, (gmp_binary_ui_op2_t) mpz_tdiv_qr_ui, 1 TSRMLS_CC); break; case GMP_ROUND_PLUSINF: - gmp_zval_binary_ui_op2_ex(return_value, a_arg, b_arg, mpz_cdiv_qr, (gmp_binary_ui_op2_t)mpz_cdiv_qr_ui, 0, 1 TSRMLS_CC); + gmp_zval_binary_ui_op2(return_value, a_arg, b_arg, mpz_cdiv_qr, (gmp_binary_ui_op2_t) mpz_cdiv_qr_ui, 1 TSRMLS_CC); break; case GMP_ROUND_MINUSINF: - gmp_zval_binary_ui_op2_ex(return_value, a_arg, b_arg, mpz_fdiv_qr, (gmp_binary_ui_op2_t)mpz_fdiv_qr_ui, 0, 1 TSRMLS_CC); + gmp_zval_binary_ui_op2(return_value, a_arg, b_arg, mpz_fdiv_qr, (gmp_binary_ui_op2_t) mpz_fdiv_qr_ui, 1 TSRMLS_CC); break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid rounding mode"); + RETURN_FALSE; } - } /* }}} */ -/* {{{ proto resource gmp_div_r(resource a, resource b [, int round]) +/* {{{ proto GMP gmp_div_r(mixed a, mixed b [, int round]) Divide a by b, returns reminder only */ ZEND_FUNCTION(gmp_div_r) { - zval **a_arg, **b_arg; + zval *a_arg, *b_arg; long round = GMP_ROUND_ZERO; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|l", &a_arg, &b_arg, &round) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &a_arg, &b_arg, &round) == FAILURE) { return; } switch (round) { case GMP_ROUND_ZERO: - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_r, (gmp_binary_ui_op_t)mpz_tdiv_r_ui, 1, 1, 1 TSRMLS_CC); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_tdiv_r, (gmp_binary_ui_op_t) mpz_tdiv_r_ui, 1 TSRMLS_CC); break; case GMP_ROUND_PLUSINF: - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_r, (gmp_binary_ui_op_t)mpz_cdiv_r_ui, 1, 1, 1 TSRMLS_CC); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_cdiv_r, (gmp_binary_ui_op_t) mpz_cdiv_r_ui, 1 TSRMLS_CC); break; case GMP_ROUND_MINUSINF: - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_r, (gmp_binary_ui_op_t)mpz_fdiv_r_ui, 1, 1, 1 TSRMLS_CC); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_fdiv_r, (gmp_binary_ui_op_t) mpz_fdiv_r_ui, 1 TSRMLS_CC); break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid rounding mode"); + RETURN_FALSE; } } /* }}} */ -/* {{{ proto resource gmp_div_q(resource a, resource b [, int round]) +/* {{{ proto GMP gmp_div_q(mixed a, mixed b [, int round]) Divide a by b, returns quotient only */ ZEND_FUNCTION(gmp_div_q) { - zval **a_arg, **b_arg; + zval *a_arg, *b_arg; long round = GMP_ROUND_ZERO; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|l", &a_arg, &b_arg, &round) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &a_arg, &b_arg, &round) == FAILURE) { return; } switch (round) { case GMP_ROUND_ZERO: - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_q, (gmp_binary_ui_op_t)mpz_tdiv_q_ui, 0, 1, 1 TSRMLS_CC); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_tdiv_q, (gmp_binary_ui_op_t) mpz_tdiv_q_ui, 1 TSRMLS_CC); break; case GMP_ROUND_PLUSINF: - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_q, (gmp_binary_ui_op_t)mpz_cdiv_q_ui, 0, 1, 1 TSRMLS_CC); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_cdiv_q, (gmp_binary_ui_op_t) mpz_cdiv_q_ui, 1 TSRMLS_CC); break; case GMP_ROUND_MINUSINF: - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_q, (gmp_binary_ui_op_t)mpz_fdiv_q_ui, 0, 1, 1 TSRMLS_CC); + gmp_zval_binary_ui_op(return_value, a_arg, b_arg, mpz_fdiv_q, (gmp_binary_ui_op_t) mpz_fdiv_q_ui, 1 TSRMLS_CC); break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid rounding mode"); + RETURN_FALSE; } } /* }}} */ -/* {{{ proto resource gmp_mod(resource a, resource b) +/* {{{ proto GMP gmp_mod(mixed a, mixed b) Computes a modulo b */ ZEND_FUNCTION(gmp_mod) { - zval **a_arg, **b_arg; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ - return; - } - - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_mod, (gmp_binary_ui_op_t)mpz_mod_ui, 1, 1, 0 TSRMLS_CC); + gmp_binary_ui_op_no_zero(mpz_mod, (gmp_binary_ui_op_t) mpz_mod_ui); } /* }}} */ -/* {{{ proto resource gmp_divexact(resource a, resource b) +/* {{{ proto GMP gmp_divexact(mixed a, mixed b) Divide a by b using exact division algorithm */ ZEND_FUNCTION(gmp_divexact) { - zval **a_arg, **b_arg; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ - return; - } - - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_divexact, NULL, 0, 1, 1 TSRMLS_CC); + gmp_binary_ui_op_no_zero(mpz_divexact, NULL); } /* }}} */ -/* {{{ proto resource gmp_neg(resource a) +/* {{{ proto GMP gmp_neg(mixed a) Negates a number */ ZEND_FUNCTION(gmp_neg) { @@ -988,7 +1292,7 @@ ZEND_FUNCTION(gmp_neg) } /* }}} */ -/* {{{ proto resource gmp_abs(resource a) +/* {{{ proto GMP gmp_abs(mixed a) Calculates absolute value */ ZEND_FUNCTION(gmp_abs) { @@ -996,99 +1300,92 @@ ZEND_FUNCTION(gmp_abs) } /* }}} */ -/* {{{ proto resource gmp_fact(int a) +/* {{{ proto GMP gmp_fact(int a) Calculates factorial function */ ZEND_FUNCTION(gmp_fact) { - zval **a_arg; - mpz_t *gmpnum_tmp; - int temp_a; + zval *a_arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } - if (Z_TYPE_PP(a_arg) == IS_RESOURCE) { - FETCH_GMP_ZVAL(gmpnum_tmp, a_arg, temp_a); /* no need to free this since it's IS_RESOURCE */ - if (mpz_sgn(*gmpnum_tmp) < 0) { + if (IS_GMP(a_arg)) { + mpz_ptr gmpnum_tmp = GET_GMP_FROM_ZVAL(a_arg); + if (mpz_sgn(gmpnum_tmp) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number has to be greater than or equal to 0"); RETURN_FALSE; } } else { - convert_to_long_ex(a_arg); - if (Z_LVAL_PP(a_arg) < 0) { + if (gmp_get_long(a_arg) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number has to be greater than or equal to 0"); RETURN_FALSE; } } - + gmp_zval_unary_ui_op(return_value, a_arg, mpz_fac_ui TSRMLS_CC); } /* }}} */ -/* {{{ proto resource gmp_pow(resource base, int exp) +/* {{{ proto GMP gmp_pow(mixed base, int exp) Raise base to power exp */ ZEND_FUNCTION(gmp_pow) { - zval **base_arg; - mpz_t *gmpnum_result, *gmpnum_base; - int use_ui = 0; - int temp_base; + zval *base_arg; + mpz_ptr gmpnum_result, gmpnum_base; + gmp_temp_t temp_base; long exp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &base_arg, &exp) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &base_arg, &exp) == FAILURE) { return; } - if (Z_TYPE_PP(base_arg) == IS_LONG && Z_LVAL_PP(base_arg) >= 0) { - use_ui = 1; - } else { - FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base); - } - if (exp < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Negative exponent not supported"); RETURN_FALSE; } - INIT_GMP_NUM(gmpnum_result); - if (use_ui) { - mpz_ui_pow_ui(*gmpnum_result, Z_LVAL_PP(base_arg), exp); + INIT_GMP_RETVAL(gmpnum_result); + if (Z_TYPE_P(base_arg) == IS_LONG && Z_LVAL_P(base_arg) >= 0) { + mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp); } else { - mpz_pow_ui(*gmpnum_result, *gmpnum_base, exp); + FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base); + mpz_pow_ui(gmpnum_result, gmpnum_base, exp); FREE_GMP_TEMP(temp_base); } - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); } /* }}} */ -/* {{{ proto resource gmp_powm(resource base, resource exp, resource mod) +/* {{{ proto GMP gmp_powm(mixed base, mixed exp, mixed mod) Raise base to power exp and take result modulo mod */ ZEND_FUNCTION(gmp_powm) { - zval **base_arg, **exp_arg, **mod_arg; - mpz_t *gmpnum_base, *gmpnum_exp, *gmpnum_mod, *gmpnum_result; + zval *base_arg, *exp_arg, *mod_arg; + mpz_ptr gmpnum_base, gmpnum_exp, gmpnum_mod, gmpnum_result; int use_ui = 0; - int temp_base = 0, temp_exp = 0, temp_mod; + gmp_temp_t temp_base = {0}, temp_exp = {0}, temp_mod; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ", &base_arg, &exp_arg, &mod_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &base_arg, &exp_arg, &mod_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base); - if (Z_TYPE_PP(exp_arg) == IS_LONG && Z_LVAL_PP(exp_arg) >= 0) { + if (Z_TYPE_P(exp_arg) == IS_LONG && Z_LVAL_P(exp_arg) >= 0) { use_ui = 1; + temp_exp.is_used = 0; } else { - FETCH_GMP_ZVAL(gmpnum_exp, exp_arg, temp_exp); - if (mpz_sgn(*gmpnum_exp) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Second parameter cannot be less than 0"); + FETCH_GMP_ZVAL_DEP(gmpnum_exp, exp_arg, temp_exp, temp_base); + if (mpz_sgn(gmpnum_exp) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Second parameter cannot be less than 0"); + FREE_GMP_TEMP(temp_base); + FREE_GMP_TEMP(temp_exp); RETURN_FALSE; } } - FETCH_GMP_ZVAL(gmpnum_mod, mod_arg, temp_mod); + FETCH_GMP_ZVAL_DEP_DEP(gmpnum_mod, mod_arg, temp_mod, temp_exp, temp_base); - if (!mpz_cmp_ui(*gmpnum_mod, 0)) { + if (!mpz_cmp_ui(gmpnum_mod, 0)) { FREE_GMP_TEMP(temp_base); if (use_ui) { FREE_GMP_TEMP(temp_exp); @@ -1097,202 +1394,175 @@ ZEND_FUNCTION(gmp_powm) RETURN_FALSE; } - INIT_GMP_NUM(gmpnum_result); + INIT_GMP_RETVAL(gmpnum_result); if (use_ui) { - mpz_powm_ui(*gmpnum_result, *gmpnum_base, (unsigned long)Z_LVAL_PP(exp_arg), *gmpnum_mod); + mpz_powm_ui(gmpnum_result, gmpnum_base, (unsigned long) Z_LVAL_P(exp_arg), gmpnum_mod); } else { - mpz_powm(*gmpnum_result, *gmpnum_base, *gmpnum_exp, *gmpnum_mod); + mpz_powm(gmpnum_result, gmpnum_base, gmpnum_exp, gmpnum_mod); FREE_GMP_TEMP(temp_exp); } FREE_GMP_TEMP(temp_base); FREE_GMP_TEMP(temp_mod); - - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); - } /* }}} */ -/* {{{ proto resource gmp_sqrt(resource a) +/* {{{ proto GMP gmp_sqrt(mixed a) Takes integer part of square root of a */ ZEND_FUNCTION(gmp_sqrt) { - zval **a_arg; - mpz_t *gmpnum_a, *gmpnum_result; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a, gmpnum_result; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - if (mpz_sgn(*gmpnum_a) < 0) { + if (mpz_sgn(gmpnum_a) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number has to be greater than or equal to 0"); FREE_GMP_TEMP(temp_a); RETURN_FALSE; } - - INIT_GMP_NUM(gmpnum_result); - mpz_sqrt(*gmpnum_result, *gmpnum_a); - FREE_GMP_TEMP(temp_a); - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); + INIT_GMP_RETVAL(gmpnum_result); + mpz_sqrt(gmpnum_result, gmpnum_a); + FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto array gmp_sqrtrem(resource a) +/* {{{ proto array gmp_sqrtrem(mixed a) Square root with remainder */ ZEND_FUNCTION(gmp_sqrtrem) { - zval **a_arg; - mpz_t *gmpnum_a, *gmpnum_result1, *gmpnum_result2; - zval r; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a, gmpnum_result1, gmpnum_result2; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - - if (mpz_sgn(*gmpnum_a) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Number has to be greater than or equal to 0"); + + if (mpz_sgn(gmpnum_a) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number has to be greater than or equal to 0"); + FREE_GMP_TEMP(temp_a); RETURN_FALSE; } - INIT_GMP_NUM(gmpnum_result1); - INIT_GMP_NUM(gmpnum_result2); + array_init(return_value); + add_index_zval(return_value, 0, gmp_create(&gmpnum_result1 TSRMLS_CC)); + add_index_zval(return_value, 1, gmp_create(&gmpnum_result2 TSRMLS_CC)); - mpz_sqrtrem(*gmpnum_result1, *gmpnum_result2, *gmpnum_a); + mpz_sqrtrem(gmpnum_result1, gmpnum_result2, gmpnum_a); FREE_GMP_TEMP(temp_a); - - array_init(return_value); - ZEND_REGISTER_RESOURCE(&r, gmpnum_result1, le_gmp); - add_index_resource(return_value, 0, Z_LVAL(r)); - ZEND_REGISTER_RESOURCE(&r, gmpnum_result2, le_gmp); - add_index_resource(return_value, 1, Z_LVAL(r)); } /* }}} */ -/* {{{ proto bool gmp_perfect_square(resource a) +/* {{{ proto bool gmp_perfect_square(mixed a) Checks if a is an exact square */ ZEND_FUNCTION(gmp_perfect_square) { - zval **a_arg; - mpz_t *gmpnum_a; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - RETVAL_BOOL((mpz_perfect_square_p(*gmpnum_a)!=0)); + RETVAL_BOOL((mpz_perfect_square_p(gmpnum_a) != 0)); FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto int gmp_prob_prime(resource a[, int reps]) +/* {{{ proto int gmp_prob_prime(mixed a[, int reps]) Checks if a is "probably prime" */ ZEND_FUNCTION(gmp_prob_prime) { - zval **gmpnumber_arg; - mpz_t *gmpnum_a; + zval *gmpnumber_arg; + mpz_ptr gmpnum_a; long reps = 10; - int temp_a; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|l", &gmpnumber_arg, &reps) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &gmpnumber_arg, &reps) == FAILURE) { return; } FETCH_GMP_ZVAL(gmpnum_a, gmpnumber_arg, temp_a); - RETVAL_LONG(mpz_probab_prime_p(*gmpnum_a, reps)); + RETVAL_LONG(mpz_probab_prime_p(gmpnum_a, reps)); FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto resource gmp_gcd(resource a, resource b) +/* {{{ proto GMP gmp_gcd(mixed a, mixed b) Computes greatest common denominator (gcd) of a and b */ ZEND_FUNCTION(gmp_gcd) { - zval **a_arg, **b_arg; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ - return; - } - - gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_gcd, (gmp_binary_ui_op_t)mpz_gcd_ui, 0, 0, 1 TSRMLS_CC); + gmp_binary_ui_op(mpz_gcd, (gmp_binary_ui_op_t) mpz_gcd_ui); } /* }}} */ -/* {{{ proto array gmp_gcdext(resource a, resource b) +/* {{{ proto array gmp_gcdext(mixed a, mixed b) Computes G, S, and T, such that AS + BT = G = `gcd' (A, B) */ ZEND_FUNCTION(gmp_gcdext) { - zval **a_arg, **b_arg; - mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_t, *gmpnum_s, *gmpnum_g; - zval r; - int temp_a, temp_b; + zval *a_arg, *b_arg; + mpz_ptr gmpnum_a, gmpnum_b, gmpnum_t, gmpnum_s, gmpnum_g; + gmp_temp_t temp_a, temp_b; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a_arg, &b_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - FETCH_GMP_ZVAL(gmpnum_b, b_arg, temp_b); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); - INIT_GMP_NUM(gmpnum_g); - INIT_GMP_NUM(gmpnum_s); - INIT_GMP_NUM(gmpnum_t); + array_init(return_value); + add_assoc_zval(return_value, "g", gmp_create(&gmpnum_g TSRMLS_CC)); + add_assoc_zval(return_value, "s", gmp_create(&gmpnum_s TSRMLS_CC)); + add_assoc_zval(return_value, "t", gmp_create(&gmpnum_t TSRMLS_CC)); - mpz_gcdext(*gmpnum_g, *gmpnum_s, *gmpnum_t, *gmpnum_a, *gmpnum_b); + mpz_gcdext(gmpnum_g, gmpnum_s, gmpnum_t, gmpnum_a, gmpnum_b); FREE_GMP_TEMP(temp_a); FREE_GMP_TEMP(temp_b); - - array_init(return_value); - - ZEND_REGISTER_RESOURCE(&r, gmpnum_g, le_gmp); - add_assoc_resource(return_value, "g", Z_LVAL(r)); - ZEND_REGISTER_RESOURCE(&r, gmpnum_s, le_gmp); - add_assoc_resource(return_value, "s", Z_LVAL(r)); - ZEND_REGISTER_RESOURCE(&r, gmpnum_t, le_gmp); - add_assoc_resource(return_value, "t", Z_LVAL(r)); } /* }}} */ -/* {{{ proto resource gmp_invert(resource a, resource b) +/* {{{ proto GMP gmp_invert(mixed a, mixed b) Computes the inverse of a modulo b */ ZEND_FUNCTION(gmp_invert) { - zval **a_arg, **b_arg; - mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result; - int temp_a, temp_b; + zval *a_arg, *b_arg; + mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result; + gmp_temp_t temp_a, temp_b; int res; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a_arg, &b_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - FETCH_GMP_ZVAL(gmpnum_b, b_arg, temp_b); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); - INIT_GMP_NUM(gmpnum_result); - res=mpz_invert(*gmpnum_result, *gmpnum_a, *gmpnum_b); + INIT_GMP_RETVAL(gmpnum_result); + res = mpz_invert(gmpnum_result, gmpnum_a, gmpnum_b); FREE_GMP_TEMP(temp_a); FREE_GMP_TEMP(temp_b); - if (res) { - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); - } else { - FREE_GMP_NUM(gmpnum_result); + if (!res) { + zval_dtor(return_value); RETURN_FALSE; } } /* }}} */ -/* {{{ proto int gmp_jacobi(resource a, resource b) +/* {{{ proto int gmp_jacobi(mixed a, mixed b) Computes Jacobi symbol */ ZEND_FUNCTION(gmp_jacobi) { @@ -1300,7 +1570,7 @@ ZEND_FUNCTION(gmp_jacobi) } /* }}} */ -/* {{{ proto int gmp_legendre(resource a, resource b) +/* {{{ proto int gmp_legendre(mixed a, mixed b) Computes Legendre symbol */ ZEND_FUNCTION(gmp_legendre) { @@ -1308,70 +1578,51 @@ ZEND_FUNCTION(gmp_legendre) } /* }}} */ -/* {{{ proto int gmp_cmp(resource a, resource b) +/* {{{ proto int gmp_cmp(mixed a, mixed b) Compares two numbers */ ZEND_FUNCTION(gmp_cmp) { - zval **a_arg, **b_arg; - mpz_t *gmpnum_a, *gmpnum_b; - int use_si = 0, res; - int temp_a, temp_b; + zval *a_arg, *b_arg; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a_arg, &b_arg) == FAILURE){ return; } - FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - - if (Z_TYPE_PP(b_arg) == IS_LONG) { - use_si = 1; - } else { - FETCH_GMP_ZVAL(gmpnum_b, b_arg, temp_b); - } - - if (use_si) { - res = mpz_cmp_si(*gmpnum_a, Z_LVAL_PP(b_arg)); - } else { - res = mpz_cmp(*gmpnum_a, *gmpnum_b); - FREE_GMP_TEMP(temp_b); - } - FREE_GMP_TEMP(temp_a); - - RETURN_LONG(res); + gmp_cmp(return_value, a_arg, b_arg TSRMLS_CC); } /* }}} */ -/* {{{ proto int gmp_sign(resource a) +/* {{{ proto int gmp_sign(mixed a) Gets the sign of the number */ ZEND_FUNCTION(gmp_sign) { - zval **a_arg; - mpz_t *gmpnum_a; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - RETVAL_LONG(mpz_sgn(*gmpnum_a)); + RETVAL_LONG(mpz_sgn(gmpnum_a)); FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto resource gmp_random([int limiter]) +/* {{{ proto GMP gmp_random([int limiter]) Gets random number */ ZEND_FUNCTION(gmp_random) { long limiter = 20; - mpz_t *gmpnum_result; + mpz_ptr gmpnum_result; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &limiter) == FAILURE) { return; } - INIT_GMP_NUM(gmpnum_result); + INIT_GMP_RETVAL(gmpnum_result); if (!GMPG(rand_initialized)) { /* Initialize */ @@ -1383,15 +1634,14 @@ ZEND_FUNCTION(gmp_random) GMPG(rand_initialized) = 1; } #ifdef GMP_LIMB_BITS - mpz_urandomb(*gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * GMP_LIMB_BITS); + mpz_urandomb(gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * GMP_LIMB_BITS); #else - mpz_urandomb(*gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * __GMP_BITS_PER_MP_LIMB); + mpz_urandomb(gmpnum_result, GMPG(rand_state), GMP_ABS (limiter) * __GMP_BITS_PER_MP_LIMB); #endif - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); } /* }}} */ -/* {{{ proto resource gmp_and(resource a, resource b) +/* {{{ proto GMP gmp_and(mixed a, mixed b) Calculates logical AND of a and b */ ZEND_FUNCTION(gmp_and) { @@ -1399,7 +1649,7 @@ ZEND_FUNCTION(gmp_and) } /* }}} */ -/* {{{ proto resource gmp_or(resource a, resource b) +/* {{{ proto GMP gmp_or(mixed a, mixed b) Calculates logical OR of a and b */ ZEND_FUNCTION(gmp_or) { @@ -1407,7 +1657,7 @@ ZEND_FUNCTION(gmp_or) } /* }}} */ -/* {{{ proto resource gmp_com(resource a) +/* {{{ proto GMP gmp_com(mixed a) Calculates one's complement of a */ ZEND_FUNCTION(gmp_com) { @@ -1415,7 +1665,7 @@ ZEND_FUNCTION(gmp_com) } /* }}} */ -/* {{{ proto resource gmp_nextprime(resource a) +/* {{{ proto GMP gmp_nextprime(mixed a) Finds next prime of a */ ZEND_FUNCTION(gmp_nextprime) { @@ -1423,21 +1673,22 @@ ZEND_FUNCTION(gmp_nextprime) } /* }}} */ -/* {{{ proto resource gmp_xor(resource a, resource b) +/* {{{ proto GMP gmp_xor(mixed a, mixed b) Calculates logical exclusive OR of a and b */ ZEND_FUNCTION(gmp_xor) { - /* use formula: a^b = (a|b)&^(a&b) */ - zval **a_arg, **b_arg; + gmp_binary_op(mpz_xor); + /* use formula: a^b = (a|b)&~(a&b) */ + /*zval **a_arg, **b_arg; mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result, *gmpnum_t; - int temp_a, temp_b; + gmp_temp_t temp_a, temp_b; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - FETCH_GMP_ZVAL(gmpnum_b, b_arg, temp_b); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); INIT_GMP_NUM(gmpnum_result); INIT_GMP_NUM(gmpnum_t); @@ -1452,183 +1703,169 @@ ZEND_FUNCTION(gmp_xor) FREE_GMP_TEMP(temp_a); FREE_GMP_TEMP(temp_b); - ZEND_REGISTER_RESOURCE(return_value, gmpnum_result, le_gmp); + RETVAL_GMP(gmpnum_result);*/ } /* }}} */ -/* {{{ proto void gmp_setbit(resource &a, int index[, bool set_clear]) +/* {{{ proto void gmp_setbit(GMP &a, int index[, bool set_clear]) Sets or clear bit in a */ ZEND_FUNCTION(gmp_setbit) { - zval **a_arg; + zval *a_arg; long index; zend_bool set = 1; - mpz_t *gmpnum_a; + mpz_ptr gmpnum_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl|b", &a_arg, &index, &set) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol|b", &a_arg, gmp_ce, &index, &set) == FAILURE) { return; } - ZEND_FETCH_RESOURCE(gmpnum_a, mpz_t *, a_arg, -1, GMP_RESOURCE_NAME, le_gmp); - if (index < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to zero"); return; } + gmpnum_a = GET_GMP_FROM_ZVAL(a_arg); + if (set) { - mpz_setbit(*gmpnum_a, index); + mpz_setbit(gmpnum_a, index); } else { - mpz_clrbit(*gmpnum_a, index); + mpz_clrbit(gmpnum_a, index); } } /* }}} */ -/* {{{ proto void gmp_clrbit(resource &a, int index) +/* {{{ proto void gmp_clrbit(GMP &a, int index) Clears bit in a */ ZEND_FUNCTION(gmp_clrbit) { - zval **a_arg; + zval *a_arg; long index; - mpz_t *gmpnum_a; + mpz_ptr gmpnum_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &index) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &a_arg, gmp_ce, &index) == FAILURE){ return; } - ZEND_FETCH_RESOURCE(gmpnum_a, mpz_t *, a_arg, -1, GMP_RESOURCE_NAME, le_gmp); - if (index < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to zero"); return; } - mpz_clrbit(*gmpnum_a, index); + gmpnum_a = GET_GMP_FROM_ZVAL(a_arg); + mpz_clrbit(gmpnum_a, index); } /* }}} */ -/* {{{ proto bool gmp_testbit(resource a, int index) +/* {{{ proto bool gmp_testbit(mixed a, int index) Tests if bit is set in a */ ZEND_FUNCTION(gmp_testbit) { - zval **a_arg; + zval *a_arg; long index; - mpz_t *gmpnum_a; + mpz_ptr gmpnum_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &index) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &a_arg, &index) == FAILURE){ return; } - ZEND_FETCH_RESOURCE(gmpnum_a, mpz_t *, a_arg, -1, GMP_RESOURCE_NAME, le_gmp); - if (index < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Index must be greater than or equal to zero"); RETURN_FALSE; } - if (mpz_tstbit(*gmpnum_a, index)) { - RETURN_TRUE; - } - RETURN_FALSE; + gmpnum_a = GET_GMP_FROM_ZVAL(a_arg); + RETURN_BOOL(mpz_tstbit(gmpnum_a, index)); } /* }}} */ -/* {{{ proto int gmp_popcount(resource a) +/* {{{ proto int gmp_popcount(mixed a) Calculates the population count of a */ ZEND_FUNCTION(gmp_popcount) { - zval **a_arg; - mpz_t *gmpnum_a; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a; + gmp_temp_t temp_a; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &a_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &a_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - RETVAL_LONG(mpz_popcount(*gmpnum_a)); + RETVAL_LONG(mpz_popcount(gmpnum_a)); FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto int gmp_hamdist(resource a, resource b) +/* {{{ proto int gmp_hamdist(mixed a, mixed b) Calculates hamming distance between a and b */ ZEND_FUNCTION(gmp_hamdist) { - zval **a_arg, **b_arg; - mpz_t *gmpnum_a, *gmpnum_b; - int temp_a, temp_b; + zval *a_arg, *b_arg; + mpz_ptr gmpnum_a, gmpnum_b; + gmp_temp_t temp_a, temp_b; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a_arg, &b_arg) == FAILURE){ return; } FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - FETCH_GMP_ZVAL(gmpnum_b, b_arg, temp_b); + FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); - RETVAL_LONG(mpz_hamdist(*gmpnum_a, *gmpnum_b)); + RETVAL_LONG(mpz_hamdist(gmpnum_a, gmpnum_b)); FREE_GMP_TEMP(temp_a); FREE_GMP_TEMP(temp_b); } /* }}} */ -/* {{{ proto int gmp_scan0(resource a, int start) +/* {{{ proto int gmp_scan0(mixed a, int start) Finds first zero bit */ ZEND_FUNCTION(gmp_scan0) { - zval **a_arg; - mpz_t *gmpnum_a; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a; + gmp_temp_t temp_a; long start; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &start) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &a_arg, &start) == FAILURE){ return; } - FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - if (start < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Starting index must be greater than or equal to zero"); RETURN_FALSE; } - RETVAL_LONG(mpz_scan0(*gmpnum_a, start)); + FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); + + RETVAL_LONG(mpz_scan0(gmpnum_a, start)); FREE_GMP_TEMP(temp_a); } /* }}} */ -/* {{{ proto int gmp_scan1(resource a, int start) +/* {{{ proto int gmp_scan1(mixed a, int start) Finds first non-zero bit */ ZEND_FUNCTION(gmp_scan1) { - zval **a_arg; - mpz_t *gmpnum_a; - int temp_a; + zval *a_arg; + mpz_ptr gmpnum_a; + gmp_temp_t temp_a; long start; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &a_arg, &start) == FAILURE){ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &a_arg, &start) == FAILURE){ return; } - FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); if (start < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Starting index must be greater than or equal to zero"); RETURN_FALSE; } - RETVAL_LONG(mpz_scan1(*gmpnum_a, start)); - FREE_GMP_TEMP(temp_a); -} -/* }}} */ - -/* {{{ _php_gmpnum_free - */ -static void _php_gmpnum_free(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - mpz_t *gmpnum = (mpz_t *)rsrc->ptr; + FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); - FREE_GMP_NUM(gmpnum); + RETVAL_LONG(mpz_scan1(gmpnum_a, start)); + FREE_GMP_TEMP(temp_a); } /* }}} */ diff --git a/ext/gmp/tests/004.phpt b/ext/gmp/tests/004.phpt index a0fa1cd133..088dd08fd8 100644 --- a/ext/gmp/tests/004.phpt +++ b/ext/gmp/tests/004.phpt @@ -38,8 +38,6 @@ int(2342344) Notice: Object of class stdClass could not be converted to int in %s on line %d int(1) int(0) - -Warning: gmp_intval(): supplied resource is not a valid GMP integer resource in %s on line %d -bool(false) +int(%d) int(12345678) Done diff --git a/ext/gmp/tests/005.phpt b/ext/gmp/tests/005.phpt index 7907ffbf53..4ae0cb750a 100644 --- a/ext/gmp/tests/005.phpt +++ b/ext/gmp/tests/005.phpt @@ -47,7 +47,7 @@ bool(false) Warning: gmp_strval() expects parameter 2 to be long, string given in %s on line %d NULL -Warning: gmp_strval(): supplied resource is not a valid GMP integer resource in %s on line %d +Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) string(7) "9765456" diff --git a/ext/gmp/tests/006.phpt b/ext/gmp/tests/006.phpt index dedbcd0472..740760631d 100644 --- a/ext/gmp/tests/006.phpt +++ b/ext/gmp/tests/006.phpt @@ -35,9 +35,15 @@ NULL Warning: gmp_sub(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(2) "-1" +} string(2) "-1" -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(5) "10001" +} string(5) "10001" Warning: gmp_sub(): Unable to convert variable to GMP - wrong type in %s on line %d diff --git a/ext/gmp/tests/007.phpt b/ext/gmp/tests/007.phpt index 4d4a993a17..e391c121f8 100644 --- a/ext/gmp/tests/007.phpt +++ b/ext/gmp/tests/007.phpt @@ -8,34 +8,16 @@ gmp_div_qr() tests var_dump(gmp_div_qr()); var_dump(gmp_div_qr("")); -var_dump($r = gmp_div_qr(0,1)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1,0)); -var_dump($r = gmp_div_qr(12653,23482734)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(12653,23482734, 10)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1123123,123)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1123123,123, 1)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1123123,123, 2)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1123123,123, GMP_ROUND_ZERO)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1123123,123, GMP_ROUND_PLUSINF)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); -var_dump($r = gmp_div_qr(1123123,123, GMP_ROUND_MINUSINF)); -var_dump(gmp_strval($r[0])); -var_dump(gmp_strval($r[1])); +var_dump(gmp_div_qr(0,1)); +var_dump(gmp_div_qr(1,0)); +var_dump(gmp_div_qr(12653,23482734)); +var_dump(gmp_div_qr(12653,23482734, 10)); +var_dump(gmp_div_qr(1123123,123)); +var_dump(gmp_div_qr(1123123,123, 1)); +var_dump(gmp_div_qr(1123123,123, 2)); +var_dump(gmp_div_qr(1123123,123, GMP_ROUND_ZERO)); +var_dump(gmp_div_qr(1123123,123, GMP_ROUND_PLUSINF)); +var_dump(gmp_div_qr(1123123,123, GMP_ROUND_MINUSINF)); $fp = fopen(__FILE__, 'r'); @@ -52,80 +34,108 @@ Warning: gmp_div_qr() expects at least 2 parameters, 1 given in %s on line %d NULL array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(1) "0" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(1) "0" + } } -string(1) "0" -string(1) "0" Warning: gmp_div_qr(): Zero operand not allowed in %s on line %d bool(false) array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(1) "0" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(5) "12653" + } } -string(1) "0" -string(5) "12653" -NULL - -Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d -bool(false) -Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d +Warning: gmp_div_qr(): Invalid rounding mode in %s on line %d bool(false) array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } } -string(4) "9131" -string(2) "10" array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "9132" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "-113" + } } -string(4) "9132" -string(4) "-113" array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } } -string(4) "9131" -string(2) "10" array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } } -string(4) "9131" -string(2) "10" array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "9132" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "-113" + } } -string(4) "9132" -string(4) "-113" array(2) { [0]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" + } [1]=> - resource(%d) of type (GMP integer) + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } } -string(4) "9131" -string(2) "10" -Warning: gmp_div_qr(): supplied resource is not a valid GMP integer resource in %s on line %d +Warning: gmp_div_qr(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) Warning: gmp_div_qr(): Unable to convert variable to GMP - wrong type in %s on line %d diff --git a/ext/gmp/tests/008.phpt b/ext/gmp/tests/008.phpt index 4e44ec10bf..c1874c86f9 100644 --- a/ext/gmp/tests/008.phpt +++ b/ext/gmp/tests/008.phpt @@ -9,24 +9,15 @@ var_dump(gmp_div_r()); var_dump(gmp_div_r("")); var_dump($r = gmp_div_r(0,1)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1,0)); var_dump($r = gmp_div_r(12653,23482734)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(12653,23482734, 10)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1123123,123)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1123123,123, 1)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1123123,123, 2)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1123123,123, GMP_ROUND_ZERO)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1123123,123, GMP_ROUND_PLUSINF)); -var_dump(gmp_strval($r)); var_dump($r = gmp_div_r(1123123,123, GMP_ROUND_MINUSINF)); -var_dump(gmp_strval($r)); $fp = fopen(__FILE__, 'r'); @@ -41,31 +32,46 @@ NULL Warning: gmp_div_r() expects at least 2 parameters, 1 given in %s on line %d NULL -int(0) -string(1) "0" +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} Warning: gmp_div_r(): Zero operand not allowed in %s on line %d bool(false) -int(12653) -string(5) "12653" -NULL +object(GMP)#%d (1) { + ["num"]=> + string(5) "12653" +} -Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d +Warning: gmp_div_r(): Invalid rounding mode in %s on line %d bool(false) -int(10) -string(2) "10" -int(113) -string(3) "113" -int(10) -string(2) "10" -int(10) -string(2) "10" -int(113) -string(3) "113" -int(10) -string(2) "10" +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "-113" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "-113" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} -Warning: gmp_div_r(): supplied resource is not a valid GMP integer resource in %s on line %d +Warning: gmp_div_r(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) Warning: gmp_div_r(): Unable to convert variable to GMP - wrong type in %s on line %d diff --git a/ext/gmp/tests/009.phpt b/ext/gmp/tests/009.phpt index 745a4ef638..3b75a48e18 100644 --- a/ext/gmp/tests/009.phpt +++ b/ext/gmp/tests/009.phpt @@ -8,25 +8,16 @@ gmp_div_q() tests var_dump(gmp_div_q()); var_dump(gmp_div_q("")); -var_dump($r = gmp_div_q(0,1)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1,0)); -var_dump($r = gmp_div_q(12653,23482734)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(12653,23482734, 10)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1123123,123)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1123123,123, 1)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1123123,123, 2)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1123123,123, GMP_ROUND_ZERO)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1123123,123, GMP_ROUND_PLUSINF)); -var_dump(gmp_strval($r)); -var_dump($r = gmp_div_q(1123123,123, GMP_ROUND_MINUSINF)); -var_dump(gmp_strval($r)); +var_dump(gmp_div_q(0,1)); +var_dump(gmp_div_q(1,0)); +var_dump(gmp_div_q(12653,23482734)); +var_dump(gmp_div_q(12653,23482734, 10)); +var_dump(gmp_div_q(1123123,123)); +var_dump(gmp_div_q(1123123,123, 1)); +var_dump(gmp_div_q(1123123,123, 2)); +var_dump(gmp_div_q(1123123,123, GMP_ROUND_ZERO)); +var_dump(gmp_div_q(1123123,123, GMP_ROUND_PLUSINF)); +var_dump(gmp_div_q(1123123,123, GMP_ROUND_MINUSINF)); $fp = fopen(__FILE__, 'r'); @@ -41,31 +32,46 @@ NULL Warning: gmp_div_q() expects at least 2 parameters, 1 given in %s on line %d NULL -resource(%d) of type (GMP integer) -string(1) "0" +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} Warning: gmp_div_q(): Zero operand not allowed in %s on line %d bool(false) -resource(%d) of type (GMP integer) -string(1) "0" -NULL +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} -Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d +Warning: gmp_div_q(): Invalid rounding mode %s on line %d bool(false) -resource(%d) of type (GMP integer) -string(4) "9131" -resource(%d) of type (GMP integer) -string(4) "9132" -resource(%d) of type (GMP integer) -string(4) "9131" -resource(%d) of type (GMP integer) -string(4) "9131" -resource(%d) of type (GMP integer) -string(4) "9132" -resource(%d) of type (GMP integer) -string(4) "9131" +object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "9132" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "9132" +} +object(GMP)#%d (1) { + ["num"]=> + string(4) "9131" +} -Warning: gmp_div_q(): supplied resource is not a valid GMP integer resource in %s on line %d +Warning: gmp_div_q(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) Warning: gmp_div_q(): Unable to convert variable to GMP - wrong type in %s on line %d diff --git a/ext/gmp/tests/010.phpt b/ext/gmp/tests/010.phpt index 293a2a0bf2..e3f85ec44f 100644 --- a/ext/gmp/tests/010.phpt +++ b/ext/gmp/tests/010.phpt @@ -28,13 +28,22 @@ NULL Warning: gmp_mod() expects exactly 2 parameters, 1 given in %s on line %d NULL bool(false) -int(0) -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} Warning: gmp_mod(): Zero operand not allowed in %s on line %d bool(false) Warning: gmp_mod(): Unable to convert variable to GMP - wrong type in %s on line %d bool(false) -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(5) "31161" +} Done diff --git a/ext/gmp/tests/014.phpt b/ext/gmp/tests/014.phpt index 40e10c6fbe..6afccaf936 100644 --- a/ext/gmp/tests/014.phpt +++ b/ext/gmp/tests/014.phpt @@ -43,7 +43,7 @@ string(19) "2432902008176640000" string(65) "30414093201713378043612608166064768844377641568960512000000000000" string(7) "3628800" string(1) "1" -string(11) "87178291200" +string(9) "479001600" Warning: gmp_fact(): Number has to be greater than or equal to 0 in %s on line %d string(1) "0" @@ -53,6 +53,9 @@ NULL Warning: gmp_fact() expects exactly 1 parameter, 2 given in %s on line %d NULL -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(1) "1" +} string(1) "1" Done diff --git a/ext/gmp/tests/016.phpt b/ext/gmp/tests/016.phpt index 44360865ca..8a0b34458f 100644 --- a/ext/gmp/tests/016.phpt +++ b/ext/gmp/tests/016.phpt @@ -69,5 +69,8 @@ NULL Warning: gmp_powm(): Second parameter cannot be less than 0 in %s on line %d bool(false) -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(1) "1" +} Done diff --git a/ext/gmp/tests/033.phpt b/ext/gmp/tests/033.phpt index 38ff5be5bf..99848959d5 100644 --- a/ext/gmp/tests/033.phpt +++ b/ext/gmp/tests/033.phpt @@ -52,13 +52,13 @@ string(12) "100008388608" string(12) "100000000000" string(12) "100000000008" -Warning: gmp_setbit(): supplied argument is not a valid GMP integer resource in %s on line %d +Warning: gmp_setbit() expects parameter 1 to be GMP, string given in %s on line %d Warning: gmp_setbit() expects at least 2 parameters, 1 given in %s on line %d Warning: gmp_setbit() expects at most 3 parameters, 4 given in %s on line %d -Warning: gmp_setbit() expects parameter 2 to be long, array given in %s on line %d +Warning: gmp_setbit() expects parameter 1 to be GMP, string given in %s on line %d -Warning: gmp_setbit() expects parameter 2 to be long, array given in %s on line %d +Warning: gmp_setbit() expects parameter 1 to be GMP, array given in %s on line %d Done diff --git a/ext/gmp/tests/034.phpt b/ext/gmp/tests/034.phpt index 6011029905..079d5d669f 100644 --- a/ext/gmp/tests/034.phpt +++ b/ext/gmp/tests/034.phpt @@ -46,7 +46,7 @@ string(7) "1000000" string(7) "1000000" string(30) "238462734628347239571822592658" -Warning: gmp_clrbit(): supplied argument is not a valid GMP integer resource in %s on line %d +Warning: gmp_clrbit() expects parameter 1 to be GMP, array given in %s on line %d Warning: gmp_clrbit() expects exactly 2 parameters, 3 given in %s on line %d diff --git a/ext/gmp/tests/040.phpt b/ext/gmp/tests/040.phpt index 3af18cce59..9cc497edc6 100644 --- a/ext/gmp/tests/040.phpt +++ b/ext/gmp/tests/040.phpt @@ -18,7 +18,10 @@ var_dump(gmp_strval(gmp_init("993247326237679187178",3))); echo "Done\n"; ?> --EXPECTF-- -resource(%d) of type (GMP integer) +object(GMP)#%d (1) { + ["num"]=> + string(8) "98765678" +} string(8) "98765678" Warning: gmp_init() expects at least 1 parameter, 0 given in %s on line %d diff --git a/ext/gmp/tests/cast.phpt b/ext/gmp/tests/cast.phpt new file mode 100644 index 0000000000..eb1832c4dd --- /dev/null +++ b/ext/gmp/tests/cast.phpt @@ -0,0 +1,22 @@ +--TEST-- +GMP casting using casting operators +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +$n = gmp_init(42); +echo $n, "\n"; +var_dump((string) $n); +var_dump((int) $n); +var_dump((float) $n); +var_dump((bool) $n); + +?> +--EXPECTF-- +42 +string(2) "42" +int(42) +float(42) + +Catchable fatal error: Object of class GMP could not be converted to boolean in %s on line %d diff --git a/ext/gmp/tests/clone.phpt b/ext/gmp/tests/clone.phpt new file mode 100644 index 0000000000..56b5ca3dfe --- /dev/null +++ b/ext/gmp/tests/clone.phpt @@ -0,0 +1,22 @@ +--TEST-- +Cloning GMP instances +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +$a = gmp_init(3); +$b = clone $a; +gmp_clrbit($a, 0); +var_dump($a, $b); // $b should be unaffected + +?> +--EXPECTF-- +object(GMP)#1 (1) { + ["num"]=> + string(1) "2" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "3" +} diff --git a/ext/gmp/tests/comparison.phpt b/ext/gmp/tests/comparison.phpt new file mode 100644 index 0000000000..1f3a423267 --- /dev/null +++ b/ext/gmp/tests/comparison.phpt @@ -0,0 +1,37 @@ +--TEST-- +Overloaded GMP comparison in sort() etc +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +$arr = [gmp_init(0), -3, gmp_init(2), 1]; +sort($arr); +var_dump($arr); + +var_dump(min(gmp_init(3), 4)); +var_dump(max(gmp_init(3), 4)); + +?> +--EXPECT-- +array(4) { + [0]=> + int(-3) + [1]=> + object(GMP)#1 (1) { + ["num"]=> + string(1) "0" + } + [2]=> + int(1) + [3]=> + object(GMP)#2 (1) { + ["num"]=> + string(1) "2" + } +} +object(GMP)#3 (1) { + ["num"]=> + string(1) "3" +} +int(4) diff --git a/ext/gmp/tests/overloading.phpt b/ext/gmp/tests/overloading.phpt new file mode 100644 index 0000000000..18e0bb2aa9 --- /dev/null +++ b/ext/gmp/tests/overloading.phpt @@ -0,0 +1,259 @@ +--TEST-- +GMP operator overloading +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +$a = gmp_init(42); +$b = gmp_init(17); + +var_dump($a + $b); +var_dump($a + 17); +var_dump(42 + $b); + +var_dump($a - $b); +var_dump($a - 17); +var_dump(42 - $b); + +var_dump($a / $b); +var_dump($a / 17); +var_dump(42 / $b); +var_dump($a / 0); + +var_dump($a % $b); +var_dump($a % 17); +var_dump(42 % $b); +var_dump($a % 0); + +// sl, sr + +var_dump($a | $b); +var_dump($a | 17); +var_dump(42 | $b); + +var_dump($a & $b); +var_dump($a & 17); +var_dump(42 & $b); + +var_dump($a ^ $b); +var_dump($a ^ 17); +var_dump(42 ^ $b); + +var_dump($a << $b); +var_dump($a << 17); +var_dump(42 << $b); + +var_dump($a >> 2); +var_dump(-$a >> 2); + +var_dump(~$a); +var_dump(-$a); +var_dump(+$a); + +var_dump($a == $b); +var_dump($a != $b); +var_dump($a < $b); +var_dump($a <= $b); +var_dump($a > $b); +var_dump($a >= $b); + +var_dump($a == $a); +var_dump($a != $a); + +var_dump($a == 42); +var_dump($a != 42); +var_dump($a < 42); +var_dump($a <= 42); +var_dump($a > 42); +var_dump($a >= 42); + +var_dump($a == new stdClass); + +$a += 1; +var_dump($a); +$a -= 1; +var_dump($a); + +var_dump(++$a); +var_dump($a++); +var_dump($a); + +var_dump(--$a); +var_dump($a--); +var_dump($a); + +?> +--EXPECTF-- +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "25" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "25" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "25" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "2" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "2" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "2" +} + +Warning: main(): Zero operand not allowed in %s on line %d +bool(false) +object(GMP)#%d (1) { + ["num"]=> + string(1) "8" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "8" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "8" +} + +Warning: main(): Zero operand not allowed in %s on line %d +bool(false) +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "59" +} +object(GMP)#%d (1) { + ["num"]=> + string(7) "5505024" +} +object(GMP)#%d (1) { + ["num"]=> + string(7) "5505024" +} +object(GMP)#%d (1) { + ["num"]=> + string(7) "5505024" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "-11" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "-43" +} +object(GMP)#%d (1) { + ["num"]=> + string(3) "-42" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "42" +} +bool(false) +bool(true) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(false) +bool(true) +bool(false) +bool(true) + +Warning: main(): Unable to convert variable to GMP - wrong type in %s on line %d +bool(false) +object(GMP)#%d (1) { + ["num"]=> + string(2) "43" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "42" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "43" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "43" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "44" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "43" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "43" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "42" +} + diff --git a/ext/gmp/tests/serialize.phpt b/ext/gmp/tests/serialize.phpt new file mode 100644 index 0000000000..26716b659c --- /dev/null +++ b/ext/gmp/tests/serialize.phpt @@ -0,0 +1,22 @@ +--TEST-- +GMP serialization and unserialization +--SKIPIF-- +<?php if (!extension_loaded("gmp")) print "skip"; ?> +--FILE-- +<?php + +var_dump($n = gmp_init(42)); +var_dump($s = serialize($n)); +var_dump(unserialize($s)); + +?> +--EXPECTF-- +object(GMP)#%d (1) { + ["num"]=> + string(2) "42" +} +string(33) "O:3:"GMP":1:{s:3:"num";s:2:"42";}" +object(GMP)#%d (1) { + ["num"]=> + string(2) "42" +} diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index 44c6d267bc..5174db3b71 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -31,7 +31,7 @@ if test "$PHP_HASH" != "no"; then EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \ php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \ php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h \ - php_hash_fnv.h php_hash_joaat.h php_hash_types.h" + php_hash_fnv.h php_hash_joaat.h" PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared) ifdef([PHP_INSTALL_HEADERS], [ diff --git a/ext/hash/config.w32 b/ext/hash/config.w32 index abe8675f30..8e9d4c3d48 100644 --- a/ext/hash/config.w32 +++ b/ext/hash/config.w32 @@ -19,7 +19,6 @@ if (PHP_HASH != "no") { PHP_INSTALL_HEADERS("ext/hash/", "php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h " + "php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h " + - "php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h " + - "php_hash_types.h"); + "php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h"); } diff --git a/ext/hash/package.xml b/ext/hash/package.xml index 119cdd673d..25a598a4a1 100644 --- a/ext/hash/package.xml +++ b/ext/hash/package.xml @@ -42,7 +42,6 @@ Supported Algorithms: <file role="src" name="config.w32"/> <file role="src" name="hash.c"/> <file role="src" name="php_hash.h"/> - <file role="src" name="php_hash_types.h"/> <file role="src" name="hash_md.c"/> <file role="src" name="php_hash_md.h"/> <file role="src" name="hash_sha.c"/> diff --git a/ext/hash/php_hash.h b/ext/hash/php_hash.h index 4bfddbacd9..3f5e7ced3a 100644 --- a/ext/hash/php_hash.h +++ b/ext/hash/php_hash.h @@ -22,7 +22,6 @@ #define PHP_HASH_H #include "php.h" -#include "php_hash_types.h" #define PHP_HASH_EXTNAME "hash" #define PHP_HASH_EXTVER "1.0" @@ -30,6 +29,12 @@ #define PHP_HASH_HMAC 0x0001 +#define L64 INT64_C +#define php_hash_int32 int32_t +#define php_hash_uint32 uint32_t +#define php_hash_int64 int64_t +#define php_hash_uint64 uint64_t + typedef void (*php_hash_init_func_t)(void *context); typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count); typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context); diff --git a/ext/hash/php_hash_types.h b/ext/hash/php_hash_types.h deleted file mode 100644 index 8793da55d6..0000000000 --- a/ext/hash/php_hash_types.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | - +----------------------------------------------------------------------+ - | 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: | - | http://www.php.net/license/3_01.txt | - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Michael Wallner <mike@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_HASH_TYPES_H -#define PHP_HASH_TYPES_H - -#ifdef HAVE_CONFIG_H -#include "config.h" -#else -#ifndef PHP_WIN32 -#include "php_config.h" -#endif -#endif - -#ifndef PHP_WIN32 -#if SIZEOF_LONG == 8 -#define L64(x) x -typedef unsigned long php_hash_uint64; -#if SIZEOF_INT == 4 -typedef unsigned int php_hash_uint32; -#elif SIZEOF_SHORT == 4 -typedef unsigned short php_hash_uint32; -#else -#error "Need a 32bit integer type" -#endif -#elif SIZEOF_LONG_LONG == 8 -#define L64(x) x##LL -typedef unsigned long long php_hash_uint64; -#if SIZEOF_INT == 4 -typedef unsigned int php_hash_uint32; -#elif SIZEOF_LONG == 4 -typedef unsigned long php_hash_uint32; -#else -#error "Need a 32bit integer type" -#endif -#else -#error "Need a 64bit integer type" -#endif -#else -#define L64(x) x##i64 -typedef unsigned __int64 php_hash_uint64; -typedef unsigned __int32 php_hash_uint32; -#endif - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/hash/tests/hash_file_basic.phpt b/ext/hash/tests/hash_file_basic.phpt index 9851c14b91..b16927d20e 100644 --- a/ext/hash/tests/hash_file_basic.phpt +++ b/ext/hash/tests/hash_file_basic.phpt @@ -15,7 +15,7 @@ Felix De Vliegher <felix.devliegher@gmail.com> echo "*** Testing hash_file() : basic functionality ***\n"; // Set up file -$filename = 'hash_file_example.txt'; +$filename = 'hash_file_basic_example.txt'; file_put_contents( $filename, 'The quick brown fox jumped over the lazy dog.' ); var_dump( hash_file( 'md5', $filename ) ); @@ -30,7 +30,7 @@ var_dump( base64_encode( hash_file( 'md5', $filename, true ) ) ); --CLEAN-- <?php -$filename = 'hash_file_example.txt'; +$filename = 'hash_file_basic_example.txt'; unlink( $filename ); ?> diff --git a/ext/hash/tests/hash_file_error.phpt b/ext/hash/tests/hash_file_error.phpt index de7ce55b10..96c41e6432 100644 --- a/ext/hash/tests/hash_file_error.phpt +++ b/ext/hash/tests/hash_file_error.phpt @@ -15,7 +15,7 @@ Felix De Vliegher <felix.devliegher@gmail.com> echo "*** Testing hash_file() : error conditions ***\n"; // Set up file -$filename = 'hash_file_example.txt'; +$filename = 'hash_file_error_example.txt'; file_put_contents( $filename, 'The quick brown fox jumped over the lazy dog.' ); @@ -38,7 +38,7 @@ var_dump( hash_file( 'md5', $filename, false, $extra_arg ) ); --CLEAN-- <?php -$filename = 'hash_file_example.txt'; +$filename = 'hash_file_error_example.txt'; unlink( $filename ); ?> diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 354cb548a7..05b8df4d0d 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -293,7 +293,8 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char php_stream_statbuf ssbuf; php_stream_context *context = NULL; php_stream_wrapper *wrapper = NULL; - char *resolved_path, *path_to_open = NULL; + char *resolved_path; + const char *path_to_open = NULL; void *ret_val = NULL; int isescaped=0; xmlURI *uri; diff --git a/ext/libxml/tests/bug61367-read.phpt b/ext/libxml/tests/bug61367-read.phpt index 75d0006a3f..b4ecaa0324 100644 --- a/ext/libxml/tests/bug61367-read.phpt +++ b/ext/libxml/tests/bug61367-read.phpt @@ -32,10 +32,10 @@ XML } } -var_dump(mkdir('test_bug_61367')); -var_dump(mkdir('test_bug_61367/base')); -var_dump(file_put_contents('test_bug_61367/bad', 'blah')); -var_dump(chdir('test_bug_61367/base')); +var_dump(mkdir('test_bug_61367-read')); +var_dump(mkdir('test_bug_61367-read/base')); +var_dump(file_put_contents('test_bug_61367-read/bad', 'blah')); +var_dump(chdir('test_bug_61367-read/base')); stream_wrapper_register( 'exploit', 'StreamExploiter' ); $s = fopen( 'exploit://', 'r' ); @@ -43,9 +43,9 @@ $s = fopen( 'exploit://', 'r' ); ?> --CLEAN-- <?php -unlink('test_bug_61367/bad'); -rmdir('test_bug_61367/base'); -rmdir('test_bug_61367'); +unlink('test_bug_61367-read/bad'); +rmdir('test_bug_61367-read/base'); +rmdir('test_bug_61367-read'); ?> --EXPECTF-- bool(true) @@ -53,7 +53,7 @@ bool(true) int(4) bool(true) -Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file:///%s/test_bug_61367/bad" in %s on line %d +Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file:///%s/test_bug_61367-read/bad" in %s on line %d Warning: DOMDocument::loadXML(): Failure to process entity file in Entity, line: 4 in %s on line %d diff --git a/ext/libxml/tests/bug61367-write.phpt b/ext/libxml/tests/bug61367-write.phpt index e18b07149a..63e99a8e50 100644 --- a/ext/libxml/tests/bug61367-write.phpt +++ b/ext/libxml/tests/bug61367-write.phpt @@ -19,10 +19,10 @@ class StreamExploiter { } } -var_dump(mkdir('test_bug_61367')); -var_dump(mkdir('test_bug_61367/base')); -var_dump(file_put_contents('test_bug_61367/bad', 'blah')); -var_dump(chdir('test_bug_61367/base')); +var_dump(mkdir('test_bug_61367-write')); +var_dump(mkdir('test_bug_61367-write/base')); +var_dump(file_put_contents('test_bug_61367-write/bad', 'blah')); +var_dump(chdir('test_bug_61367-write/base')); stream_wrapper_register( 'exploit', 'StreamExploiter' ); $s = fopen( 'exploit://', 'r' ); @@ -30,9 +30,9 @@ $s = fopen( 'exploit://', 'r' ); ?> --CLEAN-- <?php -@unlink('test_bug_61367/bad'); -rmdir('test_bug_61367/base'); -rmdir('test_bug_61367'); +@unlink('test_bug_61367-write/bad'); +rmdir('test_bug_61367-write/base'); +rmdir('test_bug_61367-write'); ?> --EXPECTF-- bool(true) diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c index 5ecc8f365e..30764dc807 100644 --- a/ext/mbstring/mb_gpc.c +++ b/ext/mbstring/mb_gpc.c @@ -364,6 +364,7 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler) { const mbfl_encoding *detected; php_mb_encoding_handler_info_t info; + char *post_data_str = NULL; MBSTRG(http_input_identify_post) = NULL; @@ -376,7 +377,10 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler) info.num_from_encodings = MBSTRG(http_input_list_size); info.from_language = MBSTRG(language); - detected = _php_mb_encoding_handler_ex(&info, arg, SG(request_info).post_data TSRMLS_CC); + php_stream_rewind(SG(request_info).request_body); + php_stream_copy_to_mem(SG(request_info).request_body, &post_data_str, PHP_STREAM_COPY_ALL, 0); + detected = _php_mb_encoding_handler_ex(&info, arg, post_data_str TSRMLS_CC); + STR_FREE(post_data_str); MBSTRG(http_input_identify) = detected; if (detected) { diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4 index 09aca5af8a..0e08b977af 100644 --- a/ext/mysqlnd/config9.m4 +++ b/ext/mysqlnd/config9.m4 @@ -48,16 +48,4 @@ fi if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then PHP_ADD_BUILD_DIR([ext/mysqlnd], 1) - - dnl This creates a file so it has to be after above macros - PHP_CHECK_TYPES([int8 uint8 int16 uint16 int32 uint32 uchar ulong int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t], [ - ext/mysqlnd/php_mysqlnd_config.h - ],[ -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif - ]) fi diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index 4ace69adcf..c9127ef93c 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -104,7 +104,7 @@ #define MYSQLND_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | \ CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | \ - CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | CLIENT_LOCAL_FILES | CLIENT_PLUGIN_AUTH) + CLIENT_MULTI_RESULTS | CLIENT_LOCAL_FILES | CLIENT_PLUGIN_AUTH) #define MYSQLND_NET_FLAG_USE_COMPRESSION 1 diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h index b9479150ae..72a156a795 100644 --- a/ext/mysqlnd/mysqlnd_portability.h +++ b/ext/mysqlnd/mysqlnd_portability.h @@ -36,8 +36,6 @@ This file is public domain and comes with NO WARRANTY of any kind */ #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) # include "ext/mysqlnd/config-win.h" -#else -# include <ext/mysqlnd/php_mysqlnd_config.h> #endif /* _WIN32... */ #if __STDC_VERSION__ < 199901L && !defined(atoll) @@ -45,14 +43,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define atoll atol #endif - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif +#include "php_stdint.h" #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG) #define _LONG_LONG 1 /* For AIX string library */ @@ -70,102 +61,6 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define HAVE_LONG_LONG 1 #endif - -/* Typdefs for easyier portability */ -#ifndef HAVE_INT8_T -#ifndef HAVE_INT8 -typedef signed char int8_t; /* Signed integer >= 8 bits */ -#else -typedef int8 int8_t; /* Signed integer >= 8 bits */ -#endif -#endif - -#ifndef HAVE_UINT8_T -#ifndef HAVE_UINT8 -typedef unsigned char uint8_t; /* Unsigned integer >= 8 bits */ -#else -typedef uint8 uint8_t; /* Signed integer >= 8 bits */ -#endif -#endif - -#ifndef HAVE_INT16_T -#ifndef HAVE_INT16 -typedef signed short int16_t; /* Signed integer >= 16 bits */ -#else -typedef int16 int16_t; /* Signed integer >= 16 bits */ -#endif -#endif - -#ifndef HAVE_UINT16_T -#ifndef HAVE_UINT16 -typedef unsigned short uint16_t; /* Signed integer >= 16 bits */ -#else -typedef uint16 uint16_t; /* Signed integer >= 16 bits */ -#endif -#endif - - -#ifndef HAVE_INT32_T -#ifdef HAVE_INT32 -typedef int32 int32_t; -#elif SIZEOF_INT == 4 -typedef signed int int32_t; -#elif SIZEOF_LONG == 4 -typedef signed long int32_t; -#else -error "Neither int nor long is of 4 bytes width" -#endif -#endif /* HAVE_INT32_T */ - -#ifndef HAVE_UINT32_T -#ifdef HAVE_UINT32 -typedef uint32 uint32_t; -#elif SIZEOF_INT == 4 -typedef unsigned int uint32_t; -#elif SIZEOF_LONG == 4 -typedef unsigned long uint32_t; -#else -#error "Neither int nor long is of 4 bytes width" -#endif -#endif /* HAVE_UINT32_T */ - -#ifndef HAVE_INT64_T -#ifdef HAVE_INT64 -typedef int64 int64_t; -#elif SIZEOF_INT == 8 -typedef signed int int64_t; -#elif SIZEOF_LONG == 8 -typedef signed long int64_t; -#elif SIZEOF_LONG_LONG == 8 -#ifdef PHP_WIN32 -typedef __int64 int64_t; -#else -typedef signed long long int64_t; -#endif -#else -#error "Neither int nor long nor long long is of 8 bytes width" -#endif -#endif /* HAVE_INT64_T */ - -#ifndef HAVE_UINT64_T -#ifdef HAVE_UINT64 -typedef uint64 uint64_t; -#elif SIZEOF_INT == 8 -typedef unsigned int uint64_t; -#elif SIZEOF_LONG == 8 -typedef unsigned long uint64_t; -#elif SIZEOF_LONG_LONG == 8 -#ifdef PHP_WIN32 -typedef unsigned __int64 uint64_t; -#else -typedef unsigned long long uint64_t; -#endif -#else -#error "Neither int nor long nor long long is of 8 bytes width" -#endif -#endif /* HAVE_INT64_T */ - - #ifdef PHP_WIN32 #define MYSQLND_LLU_SPEC "%I64u" #define MYSQLND_LL_SPEC "%I64d" diff --git a/ext/oci8/README b/ext/oci8/README index 420d5dac58..af5beeb5c0 100644 --- a/ext/oci8/README +++ b/ext/oci8/README @@ -6,8 +6,8 @@ Use the OCI8 extension to access Oracle Database. Documentation is at http://php.net/oci8 The extension can be built with PHP versions 4.3.9 to 5.x using Oracle -9.2, 10, or 11 client libraries. Oracle's standard cross-version -connectivity applies. For example PHP linked with Oracle 11.2 client -libraries can connect to Oracle Database 9.2 onwards. See Oracle's -note "Oracle Client / Server Interoperability Support" (ID 207303.1) -for details. +Database 9.2, 10, 11 or 12 client libraries. Oracle's standard +cross-version connectivity applies. For example PHP linked with +Oracle 11.2 client libraries can connect to Oracle Database 9.2 +onwards. See Oracle's note "Oracle Client / Server Interoperability +Support" (ID 207303.1) for details. diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4 index 39c037548a..49998d18f0 100644 --- a/ext/oci8/config.m4 +++ b/ext/oci8/config.m4 @@ -15,22 +15,6 @@ else PHP_OCI8_TAIL1="tail -1" fi -AC_DEFUN([PHP_OCI_IF_DEFINED],[ - old_CPPFLAGS=$CPPFLAGS - CPPFLAGS=$3 - AC_EGREP_CPP(yes,[ -#include <oci.h> -#if defined($1) - yes -#endif - ],[ - CPPFLAGS=$old_CPPFLAGS - $2 - ],[ - CPPFLAGS=$old_CPPFLAGS - ]) -]) - AC_DEFUN([AC_OCI8_CHECK_LIB_DIR],[ AC_MSG_CHECKING([ORACLE_HOME library validity]) if test ! -d "$OCI8_DIR"; then @@ -98,13 +82,99 @@ AC_DEFUN([AC_OCI8_ORACLE_VERSION],[ AC_MSG_RESULT($OCI8_ORACLE_VERSION) ]) +dnl +dnl OCI8_INIT_DTRACE(providerdesc, header-file, sources) +dnl This mimics PHP_INIT_DTRACE from PHP 5.4's acinclude.m4. It is +dnl necessarily different from PHP_INIT_DTRACE which doesn't currently +dnl support DTrace for extensions. Creating OCI8_INIT_DTRACE +dnl independently instead of using a refactored PHP_INIT_DTRACE allows +dnl OCI8 to be DTraced on versions of PHP where core PHP DTrace support +dnl isn't available. +dnl +AC_DEFUN([OCI8_INIT_DTRACE],[ + ac_srcdir=[]PHP_EXT_SRCDIR([oci8])/ + ac_bdir=[]PHP_EXT_BUILDDIR([oci8])/ + +dnl providerdesc + ac_provsrc=$1 + +dnl header-file + ac_hdrobj=$2 + +dnl DTrace objects + old_IFS=[$]IFS + for ac_src in $3; do + IFS=. + set $ac_src + ac_obj=[$]1 + IFS=$old_IFS + + OCI8_DTRACE_OBJS="[$]OCI8_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo" + done; + + for ac_lo in $OCI8_DTRACE_OBJS; do + dtrace_oci8_objs="[$]dtrace_oci8_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" + done; + +dnl Generate Makefile.objects entry +dnl The empty $ac_provsrc command stops an implicit circular dependency +dnl in GNU Make which causes the .d file to be overwritten (Bug 61268) + cat>>Makefile.objects<<EOF + +PHP_EXT_SRCDIR([oci8])/$ac_provsrc:; + +$ac_bdir[$]ac_hdrobj: $ac_srcdir[$]ac_provsrc + CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@ + +\$(OCI8_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj + +EOF + + case $host_alias in + *solaris*|*linux*) + dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o" + dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs" + dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o" + dtrace_nolib_objs='$(OCI8_DTRACE_OBJS:.lo=.o)' + for ac_lo in $OCI8_DTRACE_OBJS; do + dtrace_oci8_lib_objs="[$]dtrace_oci8_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`" + done; +dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692) + cat>>Makefile.objects<<EOF +$ac_bdir[$]ac_provsrc.lo: \$(OCI8_DTRACE_OBJS) + echo "[#] Generated by Makefile for libtool" > \$[]@ + @test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir + if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\] + echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\] + else [\\] + echo "pic_object='none'" >> \$[]@ [;\\] + fi + if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $ac_srcdir[$]ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\] + echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\] + else [\\] + echo "non_pic_object='none'" >> \$[]@ [;\\] + fi + +EOF + ;; + *) + AC_MSG_WARN([OCI8 extension: OCI8 DTrace support is not confirmed on this platform]) +cat>>Makefile.objects<<EOF +$ac_bdir[$]ac_provsrc.o: \$(OCI8_DTRACE_OBJS) + CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $ac_srcdir[$]ac_provsrc $dtrace_oci8_objs + +EOF + ;; + esac +]) + dnl --with-oci8=shared,instantclient,/path/to/client/dir/lib dnl or dnl --with-oci8=shared,/path/to/oracle/home PHP_ARG_WITH(oci8, for Oracle Database OCI8 support, -[ --with-oci8[=DIR] Include Oracle Database OCI8 support. DIR defaults to \$ORACLE_HOME. - Use --with-oci8=instantclient,/path/to/instant/client/lib +[ --with-oci8[=DIR] Include Oracle Database OCI8 support. DIR defaults to [$]ORACLE_HOME. + Use --with-oci8=instantclient,/path/to/instant/client/lib to use an Oracle Instant Client installation]) if test "$PHP_OCI8" != "no"; then @@ -140,12 +210,36 @@ if test "$PHP_OCI8" != "no"; then if test "$oci8_php_version" -lt "4003009"; then AC_MSG_ERROR([You need at least PHP 4.3.9 to be able to use this version of OCI8. PHP $php_version found]) - elif test "$oci8_php_version" -ge "6000000"; then - AC_MSG_ERROR([This version of OCI8 is not compatible with PHP 6 or higher]) else AC_MSG_RESULT([$php_version, ok]) fi + dnl Check whether --enable-dtrace was set. + dnl To use DTrace with a PECL install, extract the OCI8 archive, phpize it, and set + dnl PHP_DTRACE=yes before running configure + AC_MSG_CHECKING([OCI8 DTrace support]) + oci8_do_dtrace="`echo $PHP_OCI8 | cut -d, -f3`" + if test "$PHP_DTRACE" = "yes" -o "$oci8_do_dtrace" = "dtrace" ; then + AC_MSG_RESULT([yes]) + if test "$ext_shared" = "no"; then + AC_MSG_ERROR([For DTrace support OCI8 must be configured as a shared extension]) + else + AC_CHECK_HEADERS([sys/sdt.h], [ + OCI8_INIT_DTRACE([oci8_dtrace.d],[oci8_dtrace_gen.h],[oci8.c oci8_statement.c]) + + ], [ + AC_MSG_ERROR( + [Cannot find sys/sdt.h which is required for DTrace support]) + ]) + PHP_SUBST(OCI8_DTRACE_OBJS) + AC_DEFINE(HAVE_OCI8_DTRACE,1,[Defined to 1 if PHP OCI8 DTrace support was enabled during configuration]) + dnl Developer warning: hard coded extension is OK for the known supported environments + shared_objects_oci8="$shared_objects_oci8 PHP_EXT_BUILDDIR(oci8)/oci8_dtrace.d.lo" + fi + else + AC_MSG_RESULT([no]) + fi + dnl Set some port specific directory components for use later AC_CHECK_SIZEOF(long int, 4) @@ -255,14 +349,14 @@ if test "$PHP_OCI8" != "no"; then ;; *) - AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ]) + AC_DEFINE(HAVE_OCI_LOB_READ2,1,[Defined to 1 if OCI8 configuration located Oracle's OCILobRead2 function]) ;; esac PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD) PHP_ADD_LIBPATH($OCI8_DIR/$OCI8_LIB_DIR, OCI8_SHARED_LIBADD) PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared) - AC_DEFINE(HAVE_OCI8,1,[ ]) + AC_DEFINE(HAVE_OCI8,1,[Defined to 1 if the PHP OCI8 extension for Oracle Database is configured]) PHP_SUBST_OLD(OCI8_SHARED_LIBADD) PHP_SUBST_OLD(OCI8_DIR) @@ -330,11 +424,11 @@ if test "$PHP_OCI8" != "no"; then PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD) PHP_ADD_LIBPATH($PHP_OCI8_INSTANT_CLIENT, OCI8_SHARED_LIBADD) - AC_DEFINE(HAVE_OCI_INSTANT_CLIENT,1,[ ]) - AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ]) + AC_DEFINE(HAVE_OCI_INSTANT_CLIENT,1,[Defined to 1 if OCI8 configuration located Oracle's Instant Client libraries]) + AC_DEFINE(HAVE_OCI_LOB_READ2,1,[Defined to 1 if OCI8 configuration located Oracle's OCILobRead2 function]) PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared) - AC_DEFINE(HAVE_OCI8,1,[ ]) + AC_DEFINE(HAVE_OCI8,1,[Defined to 1 if the PHP OCI8 extension for Oracle Database is configured]) PHP_SUBST_OLD(OCI8_SHARED_LIBADD) PHP_SUBST_OLD(OCI8_DIR) diff --git a/ext/oci8/config.w32 b/ext/oci8/config.w32 index fdd7fa5e48..ac573a8af3 100644 --- a/ext/oci8/config.w32 +++ b/ext/oci8/config.w32 @@ -1,82 +1,38 @@ // $Id$ // vim:ft=javascript -if (PHP_OCI8 != "no" && PHP_OCI8_11G != "no") { - if (!PHP_OCI8_SHARED && !PHP_OCI8_11G_SHARED) { - WARNING("oci8 and oci8-11g provide the same extension and cannot both be built statically"); - PHP_OCI8 = "no" - PHP_OCI8_11G = "no" - } -} - -ARG_WITH("oci8", "OCI8 support", "no"); - -if (PHP_OCI8 != "no") { - - oci8_dirs = new Array( - PHP_OCI8 - ); - - oci8_lib_paths = ""; - oci8_inc_paths = ""; - - // find the Oracle install - for (i = 0; i < oci8_dirs.length; i++) { - oci8_lib_paths += oci8_dirs[i] + "\\lib;"; - oci8_lib_paths += oci8_dirs[i] + "\\lib\\msvc;"; - oci8_inc_paths += oci8_dirs[i] + "\\include;"; - } - - oci8_inc_paths += PHP_PHP_BUILD + "\\include\\instantclient;" - oci8_lib_paths += PHP_PHP_BUILD + "\\lib\\instantclient;"; - - if (CHECK_HEADER_ADD_INCLUDE("oci.h", "CFLAGS_OCI8", oci8_inc_paths) && - CHECK_LIB("oci.lib", "oci8", oci8_lib_paths)) - { - EXTENSION('oci8', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c'); - - AC_DEFINE('HAVE_OCI8', 1); - AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1); - AC_DEFINE('HAVE_OCI_LOB_READ2', 1); - - } else { - WARNING("oci8 not enabled: Oracle Database libraries or Oracle 10g Instant Client not found"); - PHP_OCI8 = "no" - } -} - -ARG_WITH("oci8-11g", "OCI8 support using Oracle 11g Instant Client", "no"); +ARG_WITH("oci8-12c", "OCI8 support using Oracle Database 12c Instant Client", "no"); -if (PHP_OCI8_11G != "no") { +if (PHP_OCI8_12C != "no") { - oci8_11g_dirs = new Array( - PHP_OCI8_11G + oci8_12c_dirs = new Array( + PHP_OCI8_12C ); - oci8_11g_lib_paths = ""; - oci8_11g_inc_paths = ""; + oci8_12c_lib_paths = ""; + oci8_12c_inc_paths = ""; // find the Oracle install - for (i = 0; i < oci8_11g_dirs.length; i++) { - oci8_11g_lib_paths += oci8_11g_dirs[i] + "\\lib;"; - oci8_11g_lib_paths += oci8_11g_dirs[i] + "\\lib\\msvc;"; - oci8_11g_inc_paths += oci8_11g_dirs[i] + "\\include;"; + for (i = 0; i < oci8_12c_dirs.length; i++) { + oci8_12c_lib_paths += oci8_12c_dirs[i] + "\\lib;"; + oci8_12c_lib_paths += oci8_12c_dirs[i] + "\\lib\\msvc;"; + oci8_12c_inc_paths += oci8_12c_dirs[i] + "\\include;"; } - oci8_11g_inc_paths += PHP_PHP_BUILD + "\\include\\instantclient_11;" - oci8_11g_lib_paths += PHP_PHP_BUILD + "\\lib\\instantclient_11;"; + oci8_12c_inc_paths += PHP_PHP_BUILD + "\\include\\instantclient_12;" + oci8_12c_lib_paths += PHP_PHP_BUILD + "\\lib\\instantclient_12;"; - if (CHECK_HEADER_ADD_INCLUDE("oci.h", "CFLAGS_OCI8_11G", oci8_11g_inc_paths) && - CHECK_LIB("oci.lib", "oci8_11g", oci8_11g_lib_paths)) + if (CHECK_HEADER_ADD_INCLUDE("oci.h", "CFLAGS_OCI8_12C", oci8_12c_inc_paths) && + CHECK_LIB("oci.lib", "oci8_12c", oci8_12c_lib_paths)) { - EXTENSION('oci8_11g', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c', null, null, null, "ext\\oci8_11g") + EXTENSION('oci8_12c', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c', null, null, null, "ext\\oci8_12c") AC_DEFINE('HAVE_OCI8', 1); AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1); AC_DEFINE('HAVE_OCI_LOB_READ2', 1); } else { - WARNING("oci8-11g not enabled: Oracle Database libraries or Oracle 11g Instant Client not found"); - PHP_OCI8_11G = "no" + WARNING("oci8-12c not enabled: Oracle Database client libraries or Oracle Database 12c Instant Client not found"); + PHP_OCI8_12C = "no" } } diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 44bfa71398..bccaa529b0 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -12,7 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Stig Sæther Bakken <ssb@php.net> | + | Authors: Stig S�ther Bakken <ssb@php.net> | | Thies C. Arntzen <thies@thieso.net> | | Maxim Maletsky <maxim@maxim.cx> | | | @@ -37,13 +37,6 @@ #include "php_ini.h" #include "ext/standard/php_smart_str.h" -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif -#ifdef PHP_WIN32 -#include "win32/php_stdint.h" -#endif - #if HAVE_OCI8 #if PHP_MAJOR_VERSION > 5 @@ -58,11 +51,17 @@ #include "php_oci8_int.h" #include "zend_hash.h" -#if defined(HAVE_STDINT_H) || defined(PHP_WIN32) -#define OCI8_INT_TO_PTR(I) ((void *)(intptr_t)(I)) +#if defined(__PTRDIFF_TYPE__) +# define OCI8_INT_TO_PTR(I) ((void*)(__PTRDIFF_TYPE__)(I)) +# define OCI8_PTR_TO_INT(P) ((int)(__PTRDIFF_TYPE__)(P)) +#elif !defined(__GNUC__) +#define OCI8_INT_TO_PTR(I) ((void*)&((char*)0)[I]) +#define OCI8_PTR_TO_INT(P) ((int)(((char*)P)-(char*)0)) +#elif defined(HAVE_STDINT_H) +#define OCI8_INT_TO_PTR(I) ((void*)(intptr_t)(I)) #define OCI8_PTR_TO_INT(P) ((int)(intptr_t)(P)) #else -#define OCI8_INT_TO_PTR(I) ((void *)(I)) +#define OCI8_INT_TO_PTR(I) ((void*)(I)) #define OCI8_PTR_TO_INT(P) ((int)(P)) #endif @@ -128,7 +127,7 @@ zend_class_entry *oci_coll_class_entry_ptr; #define PHP_OCI_INIT_MODE (OCI_DEFAULT | OCI_OBJECT) #endif -/* static protos {{{ */ +/* {{{ static protos */ static void php_oci_connection_list_dtor (zend_rsrc_list_entry * TSRMLS_DC); static void php_oci_pconnection_list_dtor (zend_rsrc_list_entry * TSRMLS_DC); static void php_oci_pconnection_list_np_dtor (zend_rsrc_list_entry * TSRMLS_DC); @@ -425,6 +424,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_parse, 0, 0, 2) ZEND_ARG_INFO(0, sql_text) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_get_implicit_resultset, 0, 0, 1) +ZEND_ARG_INFO(0, statement_resource) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_prefetch, 0, 0, 2) ZEND_ARG_INFO(0, statement_resource) ZEND_ARG_INFO(0, number_of_rows) @@ -698,6 +701,7 @@ static unsigned char arginfo_oci_bind_array_by_name[] = { 3, BYREF_NONE, BYREF_N #define arginfo_oci_error NULL #define arginfo_oci_num_fields NULL #define arginfo_oci_parse NULL +#define arginfo_oci_get_implicit_resultset NULL #define arginfo_oci_set_prefetch NULL #define arginfo_oci_set_client_identifier NULL #define arginfo_oci_set_edition NULL @@ -786,6 +790,7 @@ PHP_FUNCTION(oci_rollback); PHP_FUNCTION(oci_new_descriptor); PHP_FUNCTION(oci_num_fields); PHP_FUNCTION(oci_parse); +PHP_FUNCTION(oci_get_implicit_resultset); PHP_FUNCTION(oci_new_cursor); PHP_FUNCTION(oci_result); PHP_FUNCTION(oci_client_version); @@ -862,6 +867,7 @@ zend_function_entry php_oci_functions[] = { PHP_FE(oci_internal_debug, arginfo_oci_internal_debug) PHP_FE(oci_num_fields, arginfo_oci_num_fields) PHP_FE(oci_parse, arginfo_oci_parse) + PHP_FE(oci_get_implicit_resultset, arginfo_oci_get_implicit_resultset) PHP_FE(oci_new_cursor, arginfo_oci_new_cursor) PHP_FE(oci_result, arginfo_oci_result) PHP_FE(oci_client_version, arginfo_oci_client_version) @@ -1055,8 +1061,12 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY( "oci8.statement_cache_size", "20", PHP_INI_SYSTEM, ONUPDATELONGFUNC, statement_cache_size, zend_oci_globals, oci_globals) STD_PHP_INI_ENTRY( "oci8.default_prefetch", "100", PHP_INI_SYSTEM, ONUPDATELONGFUNC, default_prefetch, zend_oci_globals, oci_globals) STD_PHP_INI_BOOLEAN("oci8.old_oci_close_semantics", "0", PHP_INI_SYSTEM, OnUpdateBool, old_oci_close_semantics,zend_oci_globals, oci_globals) +#if (OCI_MAJOR_VERSION >= 11) STD_PHP_INI_ENTRY( "oci8.connection_class", "", PHP_INI_ALL, OnUpdateString, connection_class, zend_oci_globals, oci_globals) +#endif +#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) STD_PHP_INI_BOOLEAN("oci8.events", "0", PHP_INI_SYSTEM, OnUpdateBool, events, zend_oci_globals, oci_globals) +#endif PHP_INI_END() /* }}} */ @@ -1132,7 +1142,8 @@ static void php_oci_init_global_handles(TSRMLS_D) } } } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_cleanup_global_handles() * @@ -1149,7 +1160,8 @@ static void php_oci_cleanup_global_handles(TSRMLS_D) PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(env), OCI_HTYPE_ENV)); OCI_G(env) = NULL; } -} /* }}} */ +} +/* }}} */ /* {{{ PHP_GINIT_FUNCTION * @@ -1294,7 +1306,6 @@ PHP_MINIT_FUNCTION(oci) PHP_RINIT_FUNCTION(oci) { - OCI_G(debug_mode) = 0; /* start "fresh" */ OCI_G(num_links) = OCI_G(num_persistent); OCI_G(errcode) = 0; OCI_G(edition) = NULL; @@ -1336,22 +1347,26 @@ PHP_RSHUTDOWN_FUNCTION(oci) PHP_MINFO_FUNCTION(oci) { char buf[32]; +#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) char *ver; +#endif php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); - php_info_print_table_row(2, "Version", PHP_OCI8_VERSION); +#if defined(HAVE_OCI8_DTRACE) + php_info_print_table_row(2, "OCI8 DTrace Support", "enabled"); +#else + php_info_print_table_row(2, "OCI8 DTrace Support", "disabled"); +#endif + php_info_print_table_row(2, "OCI8 Version", PHP_OCI8_VERSION); php_info_print_table_row(2, "Revision", "$Id$"); - snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); - php_info_print_table_row(2, "Active Persistent Connections", buf); - snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links)); - php_info_print_table_row(2, "Active Connections", buf); - #if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) php_oci_client_get_version(&ver TSRMLS_CC); php_info_print_table_row(2, "Oracle Run-time Client Library Version", ver); efree(ver); +#else + php_info_print_table_row(2, "Oracle Run-time Client Library Version", "Unknown"); #endif #if defined(OCI_MAJOR_VERSION) && defined(OCI_MINOR_VERSION) snprintf(buf, sizeof(buf), "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION); @@ -1361,9 +1376,9 @@ PHP_MINFO_FUNCTION(oci) snprintf(buf, sizeof(buf), "Unknown"); #endif #if defined(HAVE_OCI_INSTANT_CLIENT) - php_info_print_table_row(2, "Oracle Instant Client Version", buf); + php_info_print_table_row(2, "Oracle Compile-time Instant Client Version", buf); #else - php_info_print_table_row(2, "Oracle Version", buf); + php_info_print_table_row(2, "Oracle Compile-time Version", buf); #endif #if !defined(PHP_WIN32) && !defined(HAVE_OCI_INSTANT_CLIENT) @@ -1375,14 +1390,22 @@ PHP_MINFO_FUNCTION(oci) #endif #endif - php_info_print_table_row(2, "Temporary Lob support", "enabled"); - php_info_print_table_row(2, "Collections support", "enabled"); + php_info_print_table_end(); + DISPLAY_INI_ENTRIES(); + + php_info_print_table_start(); + php_info_print_table_header(2, "Statistics", ""); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); + php_info_print_table_row(2, "Active Persistent Connections", buf); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links)); + php_info_print_table_row(2, "Active Connections", buf); + php_info_print_table_end(); } /* }}} */ -/* list destructors {{{ */ +/* {{{ list destructors */ /* {{{ php_oci_connection_list_dtor() * @@ -1396,7 +1419,8 @@ static void php_oci_connection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) php_oci_connection_close(connection TSRMLS_CC); OCI_G(num_links)--; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_pconnection_list_dtor() * @@ -1411,7 +1435,8 @@ static void php_oci_pconnection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) OCI_G(num_persistent)--; OCI_G(num_links)--; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_pconnection_list_np_dtor() * @@ -1449,11 +1474,12 @@ static void php_oci_pconnection_list_np_dtor(zend_rsrc_list_entry *entry TSRMLS_ OCI_G(num_persistent)--; } - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: np_dtor cleaning up: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_P_DTOR_CLOSE_ENABLED()) { + DTRACE_OCI8_CONNECT_P_DTOR_CLOSE(connection); } - } - else { +#endif /* HAVE_OCI8_DTRACE */ + } else { /* * Release the connection to underlying pool. We do this unconditionally so that * out-of-scope pconnects are now consistent with oci_close and out-of-scope new connect @@ -1465,11 +1491,14 @@ static void php_oci_pconnection_list_np_dtor(zend_rsrc_list_entry *entry TSRMLS_ */ php_oci_connection_release(connection TSRMLS_CC); - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: np_dtor releasing: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_P_DTOR_RELEASE_ENABLED()) { + DTRACE_OCI8_CONNECT_P_DTOR_RELEASE(connection); } +#endif /* HAVE_OCI8_DTRACE */ } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_list_dtor() * @@ -1479,7 +1508,8 @@ static void php_oci_statement_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) { php_oci_statement *statement = (php_oci_statement *)entry->ptr; php_oci_statement_free(statement TSRMLS_CC); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_descriptor_list_dtor() * @@ -1489,7 +1519,8 @@ static void php_oci_descriptor_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) { php_oci_descriptor *descriptor = (php_oci_descriptor *)entry->ptr; php_oci_lob_free(descriptor TSRMLS_CC); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_list_dtor() * @@ -1499,11 +1530,12 @@ static void php_oci_collection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) { php_oci_collection *collection = (php_oci_collection *)entry->ptr; php_oci_collection_close(collection TSRMLS_CC); -} /* }}} */ +} +/* }}} */ /* }}} */ -/* Hash Destructors {{{ */ +/* {{{ Hash Destructors */ /* {{{ php_oci_define_hash_dtor() * @@ -1605,18 +1637,17 @@ void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_D } /* }}} */ - /* {{{ php_oci_error() * * Fetch & print out error message if we get an error * Returns an Oracle error number */ -sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC) +sb4 php_oci_error(OCIError *err_p, sword errstatus TSRMLS_DC) { text *errbuf = (text *)NULL; - sb4 errcode = 0; + sb4 errcode = 0; /* Oracle error number */ - switch (status) { + switch (errstatus) { case OCI_SUCCESS: break; case OCI_SUCCESS_WITH_INFO: @@ -1659,9 +1690,16 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC) php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI_CONTINUE"); break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown OCI error code: %d", status); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown OCI error code: %d", errstatus); break; } + +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_ERROR_ENABLED()) { + DTRACE_OCI8_ERROR((int)errstatus, (long)errcode); + } +#endif /* HAVE_OCI8_DTRACE */ + return errcode; } /* }}} */ @@ -1690,7 +1728,8 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC) } } return error_code; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_fetch_sqltext_offset() * @@ -1718,7 +1757,8 @@ int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, u return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_do_connect() * @@ -1738,18 +1778,32 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus return; } +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_ENTRY_ENABLED()) { + DTRACE_OCI8_CONNECT_ENTRY(username, dbname, charset, session_mode, persistent, exclusive); + } +#endif /* HAVE_OCI8_DTRACE */ + if (!charset_len) { charset = NULL; } connection = php_oci_do_connect_ex(username, username_len, password, password_len, NULL, 0, dbname, dbname_len, charset, session_mode, persistent, exclusive TSRMLS_CC); +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_RETURN_ENABLED()) { + DTRACE_OCI8_CONNECT_RETURN(connection); + } +#endif /* HAVE_OCI8_DTRACE */ + + if (!connection) { RETURN_FALSE; } - RETURN_RESOURCE(connection->rsrc_id); + RETURN_RESOURCE(connection->id); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_do_connect_ex() * @@ -1908,16 +1962,11 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } } - /* Debug statements {{{ */ - if (OCI_G(debug_mode)) { - if (connection && connection->is_stub) { - php_printf ("OCI8 DEBUG L1: Got a cached stub: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } else if (connection) { - php_printf ("OCI8 DEBUG L1: Got a cached connection: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } else { - php_printf ("OCI8 DEBUG L1: Got NO cached connection at (%s:%d) \n", __FILE__, __LINE__); - } - } /* }}} */ +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_LOOKUP_ENABLED()) { + DTRACE_OCI8_CONNECT_LOOKUP(connection, connection && connection->is_stub ? 1 : 0); + } +#endif /* HAVE_OCI8_DTRACE */ /* If we got a pconnection stub, then 'load'(OCISessionGet) the real connection from its * private spool A connection is a stub if it is only a cached structure and the real @@ -1963,24 +2012,20 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* okay, the connection is open and the server is still alive */ connection->used_this_request = 1; - tmp = (php_oci_connection *)zend_list_find(connection->rsrc_id, &rsrc_type); + tmp = (php_oci_connection *)zend_list_find(connection->id, &rsrc_type); if (tmp != NULL && rsrc_type == le_pconnection && strlen(tmp->hash_key) == hashed_details.len && - memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->rsrc_id) == SUCCESS) { + memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->id) == SUCCESS) { /* do nothing */ } else { -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_pconnection); -#endif + PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection); /* Persistent connections: For old close semantics we artificially * bump up the refcount to prevent the non-persistent destructor * from getting called until request shutdown. The refcount is * decremented in the persistent helper */ if (OCI_G(old_oci_close_semantics)) { - zend_list_addref(connection->rsrc_id); + zend_list_addref(connection->id); } } smart_str_free_ex(&hashed_details, 0); @@ -1991,7 +2036,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } else { /* we do not ping non-persistent connections */ smart_str_free_ex(&hashed_details, 0); - zend_list_addref(connection->rsrc_id); + zend_list_addref(connection->id); return connection; } } /* is_open is true? */ @@ -2008,7 +2053,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* We have to do a hash_del but need to preserve the resource if there is a positive * refcount. Set the data pointer in the list entry to NULL */ - if (connection == zend_list_find(connection->rsrc_id, &rsrc_type) && rsrc_type == le_pconnection) { + if (connection == zend_list_find(connection->id, &rsrc_type) && rsrc_type == le_pconnection) { le->ptr = NULL; } @@ -2085,7 +2130,8 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char smart_str_free_ex(&hashed_details, 0); return NULL; } - } /* }}} */ + } + /* }}} */ connection->idle_expiry = (OCI_G(persistent_timeout) > 0) ? (timestamp + OCI_G(persistent_timeout)) : 0; @@ -2124,50 +2170,34 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char new_le.ptr = connection; new_le.type = le_pconnection; connection->used_this_request = 1; -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_pconnection); -#endif + PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection); /* Persistent connections: For old close semantics we artificially bump up the refcount to * prevent the non-persistent destructor from getting called until request shutdown. The * refcount is decremented in the persistent helper */ if (OCI_G(old_oci_close_semantics)) { - zend_list_addref(connection->rsrc_id); + zend_list_addref(connection->id); } zend_hash_update(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); OCI_G(num_persistent)++; OCI_G(num_links)++; } else if (!exclusive) { -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_connection); -#endif - new_le.ptr = OCI8_INT_TO_PTR(connection->rsrc_id); + PHP_OCI_REGISTER_RESOURCE(connection, le_connection); + new_le.ptr = OCI8_INT_TO_PTR(connection->id); new_le.type = le_index_ptr; zend_hash_update(&EG(regular_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); OCI_G(num_links)++; } else { -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_connection); -#endif + PHP_OCI_REGISTER_RESOURCE(connection, le_connection); OCI_G(num_links)++; } - /* Debug statements {{{ */ - if (OCI_G(debug_mode)) { - if (connection->is_persistent) { - php_printf ("OCI8 DEBUG L1: New Persistent Connection address: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } else { - php_printf ("OCI8 DEBUG L1: New Non-Persistent Connection address: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } - php_printf ("OCI8 DEBUG L1: num_persistent=(%ld), num_links=(%ld) at (%s:%d) \n", OCI_G(num_persistent), OCI_G(num_links), __FILE__, __LINE__); - } /* }}} */ +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_TYPE_ENABLED()) { + DTRACE_OCI8_CONNECT_TYPE(connection->is_persistent ? 1 : 0, exclusive ? 1 : 0, connection, OCI_G(num_persistent), OCI_G(num_links)); + } +#endif /* HAVE_OCI8_DTRACE */ return connection; } @@ -2179,20 +2209,24 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char */ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC) { + sword errstatus; + + OCI_G(errcode) = 0; /* assume ping is successful */ + /* Use OCIPing instead of OCIServerVersion. If OCIPing returns ORA-1010 (invalid OCI operation) * such as from Pre-10.1 servers, the error is still from the server and we would have * successfully performed a roundtrip and validated the connection. Use OCIServerVersion for * Pre-10.2 clients */ #if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIPing available 10.2 onwards */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIPing, (connection->svc, OCI_G(err), OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(errstatus, OCIPing, (connection->svc, OCI_G(err), OCI_DEFAULT)); #else char version[256]; /* use good old OCIServerVersion() */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIServerVersion, (connection->svc, OCI_G(err), (text *)version, sizeof(version), OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL_RETURN(errstatus, OCIServerVersion, (connection->svc, OCI_G(err), (text *)version, sizeof(version), OCI_HTYPE_SVCCTX)); #endif - if (OCI_G(errcode) == OCI_SUCCESS) { + if (errstatus == OCI_SUCCESS) { return 1; } else { sb4 error_code = 0; @@ -2203,10 +2237,9 @@ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC) if (error_code == 1010) { return 1; } + OCI_G(errcode) = error_code; } - /* ignore errors here, just return failure - * php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); */ return 0; } /* }}} */ @@ -2217,17 +2250,17 @@ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC) */ static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC) { - ub4 ss = 0; + ub4 ss = OCI_SERVER_NOT_CONNECTED; + sword errstatus; /* get OCI_ATTR_SERVER_STATUS */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->server, OCI_HTYPE_SERVER, (dvoid *)&ss, (ub4 *)0, OCI_ATTR_SERVER_STATUS, OCI_G(err))); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)connection->server, OCI_HTYPE_SERVER, (dvoid *)&ss, (ub4 *)0, OCI_ATTR_SERVER_STATUS, OCI_G(err))); - if (OCI_G(errcode) == OCI_SUCCESS && ss == OCI_SERVER_NORMAL) { + if (errstatus == OCI_SUCCESS && ss == OCI_SERVER_NORMAL) { return 1; } - /* ignore errors here, just return failure - * php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); */ + /* ignore errors here, just return failure */ return 0; } /* }}} */ @@ -2238,16 +2271,20 @@ static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC) */ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC) { - PHP_OCI_CALL_RETURN(connection->errcode, OCITransRollback, (connection->svc, connection->err, (ub4) 0)); - connection->needs_commit = 0; + sword errstatus; + + PHP_OCI_CALL_RETURN(errstatus, OCITransRollback, (connection->svc, connection->err, (ub4) 0)); + connection->rb_on_disconnect = 0; - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_connection_commit() * @@ -2255,16 +2292,20 @@ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC) */ int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC) { - PHP_OCI_CALL_RETURN(connection->errcode, OCITransCommit, (connection->svc, connection->err, (ub4) 0)); - connection->needs_commit = 0; + sword errstatus; + + PHP_OCI_CALL_RETURN(errstatus, OCITransCommit, (connection->svc, connection->err, (ub4) 0)); + connection->rb_on_disconnect = 0; - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_connection_close() * @@ -2275,13 +2316,19 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC) int result = 0; zend_bool in_call_save = OCI_G(in_call); +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECTION_CLOSE_ENABLED()) { + DTRACE_OCI8_CONNECTION_CLOSE(connection); + } +#endif /* HAVE_OCI8_DTRACE */ + if (!connection->is_stub) { /* Release resources associated with connection */ php_oci_connection_release(connection TSRMLS_CC); } if (!connection->using_spool && connection->svc) { - PHP_OCI_CALL(OCISessionEnd, (connection->svc, connection->err, connection->session, (ub4) 0)); + PHP_OCI_CALL(OCISessionEnd, (connection->svc, connection->err, connection->session, (ub4) 0)); } if (connection->err) { @@ -2302,7 +2349,7 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC) } if (connection->svc) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX)); } if (connection->server) { @@ -2333,7 +2380,8 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC) connection = NULL; OCI_G(in_call) = in_call_save; return result; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_connection_release() * @@ -2357,7 +2405,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) if (connection->svc) { /* rollback outstanding transactions */ - if (connection->needs_commit) { + if (connection->rb_on_disconnect) { if (php_oci_connection_rollback(connection TSRMLS_CC)) { /* rollback failed */ result = 1; @@ -2408,7 +2456,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) connection->server = NULL; connection->session = NULL; - connection->is_attached = connection->is_open = connection->needs_commit = connection->used_this_request = 0; + connection->is_attached = connection->is_open = connection->rb_on_disconnect = connection->used_this_request = 0; connection->is_stub = 1; /* Cut the link between the connection structure and the time_t structure allocated within @@ -2419,7 +2467,8 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) OCI_G(in_call) = in_call_save; return result; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_password_change() * @@ -2427,17 +2476,20 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) */ int php_oci_password_change(php_oci_connection *connection, char *user, int user_len, char *pass_old, int pass_old_len, char *pass_new, int pass_new_len TSRMLS_DC) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIPasswordChange, (connection->svc, connection->err, (text *)user, user_len, (text *)pass_old, pass_old_len, (text *)pass_new, pass_new_len, OCI_DEFAULT)); + sword errstatus; + + PHP_OCI_CALL_RETURN(errstatus, OCIPasswordChange, (connection->svc, connection->err, (text *)user, user_len, (text *)pass_old, pass_old_len, (text *)pass_new, pass_new_len, OCI_DEFAULT)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ connection->passwd_changed = 1; return 0; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_client_get_version() * @@ -2446,21 +2498,21 @@ int php_oci_password_change(php_oci_connection *connection, char *user, int user void php_oci_client_get_version(char **version TSRMLS_DC) { char version_buff[256]; +#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIClientVersion only available 10.2 onwards */ sword major_version = 0; sword minor_version = 0; sword update_num = 0; sword patch_num = 0; sword port_update_num = 0; -#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIClientVersion only available 10.2 onwards */ PHP_OCI_CALL(OCIClientVersion, (&major_version, &minor_version, &update_num, &patch_num, &port_update_num)); snprintf(version_buff, sizeof(version_buff), "%d.%d.%d.%d.%d", major_version, minor_version, update_num, patch_num, port_update_num); #else memcpy(version_buff, "Unknown", sizeof("Unknown")); #endif *version = estrdup(version_buff); -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_server_get_version() * @@ -2468,19 +2520,21 @@ void php_oci_client_get_version(char **version TSRMLS_DC) */ int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC) { + sword errstatus; char version_buff[256]; - PHP_OCI_CALL_RETURN(connection->errcode, OCIServerVersion, (connection->svc, connection->err, (text *)version_buff, sizeof(version_buff), OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL_RETURN(errstatus, OCIServerVersion, (connection->svc, connection->err, (text *)version_buff, sizeof(version_buff), OCI_HTYPE_SVCCTX)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } *version = estrdup(version_buff); return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_column_to_zval() * @@ -2564,14 +2618,19 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSR } /* }}} */ + /* {{{ php_oci_fetch_row() * * Fetch the next row from the given statement + * Has logic for Oracle 12c Implicit Result Sets */ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args) { zval *z_statement, *array; - php_oci_statement *statement; + php_oci_statement *statement; /* statement that will be fetched from */ +#if (OCI_MAJOR_VERSION >= 12) + php_oci_statement *invokedstatement; /* statement this function was invoked with */ +#endif /* OCI_MAJOR_VERSION */ php_oci_out_column *column; ub4 nrows = 1; int i; @@ -2617,11 +2676,63 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg } } +#if (OCI_MAJOR_VERSION < 12) PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { - RETURN_FALSE; + RETURN_FALSE; /* end of fetch */ } +#else /* OCI_MAJOR_VERSION */ + PHP_OCI_ZVAL_TO_STATEMENT(z_statement, invokedstatement); + + if (invokedstatement->impres_flag == PHP_OCI_IMPRES_NO_CHILDREN) { + /* Already know there are no Implicit Result Sets */ + statement = invokedstatement; + } else if (invokedstatement->impres_flag == PHP_OCI_IMPRES_HAS_CHILDREN) { + /* Previously saw an Implicit Result Set in an earlier invocation of php_oci_fetch_row */ + statement = (php_oci_statement *)invokedstatement->impres_child_stmt; + } else { + sword errstatus; + + /* Check for an Implicit Result Set on this statement handle */ + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)invokedstatement->stmt, OCI_HTYPE_STMT, + (dvoid *) &invokedstatement->impres_count, + (ub4 *)NULL, OCI_ATTR_IMPLICIT_RESULT_COUNT, invokedstatement->err)); + if (errstatus) { + RETURN_FALSE; + } + if (invokedstatement->impres_count > 0) { + /* Make it so the fetch occurs on the first Implicit Result Set */ + statement = php_oci_get_implicit_resultset(invokedstatement TSRMLS_CC); + if (!statement || php_oci_statement_execute(statement, (ub4)OCI_DEFAULT TSRMLS_CC)) + RETURN_FALSE; + invokedstatement->impres_count--; + invokedstatement->impres_child_stmt = (struct php_oci_statement *)statement; + invokedstatement->impres_flag = PHP_OCI_IMPRES_HAS_CHILDREN; + } else { + statement = invokedstatement; /* didn't find Implicit Result Sets */ + invokedstatement->impres_flag = PHP_OCI_IMPRES_NO_CHILDREN; /* Don't bother checking again */ + } + } + + if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { + /* End of fetch */ + if (invokedstatement->impres_count > 0) { + /* Check next Implicit Result Set */ + statement = php_oci_get_implicit_resultset(invokedstatement TSRMLS_CC); + if (!statement || php_oci_statement_execute(statement, (ub4)OCI_DEFAULT TSRMLS_CC)) + RETURN_FALSE; + invokedstatement->impres_count--; + invokedstatement->impres_child_stmt = (struct php_oci_statement *)statement; + if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { + /* End of all fetches */ + RETURN_FALSE; + } + } else { + RETURN_FALSE; + } + } +#endif /* OCI_MAJOR_VERSION */ array_init(return_value); @@ -2688,9 +2799,11 @@ static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC) connection = (php_oci_connection *)le->ptr; if (!connection->used_this_request && OCI_G(persistent_timeout) != -1) { - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: persistent_helper processing for timeout: (%p stub=%d) at (%s:%d) \n", connection, connection->is_stub, __FILE__, __LINE__); +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CONNECT_EXPIRY_ENABLED()) { + DTRACE_OCI8_CONNECT_EXPIRY(connection, connection->is_stub ? 1 : 0, (long)connection->idle_expiry, (long)timestamp); } +#endif /* HAVE_OCI8_DTRACE */ if (connection->idle_expiry < timestamp) { /* connection has timed out */ return ZEND_HASH_APPLY_REMOVE; @@ -2698,7 +2811,8 @@ static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC) } } return ZEND_HASH_APPLY_KEEP; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_create_spool() * @@ -2710,6 +2824,7 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha zend_bool iserror = 0; ub4 poolmode = OCI_DEFAULT; /* Mode to be passed to OCISessionPoolCreate */ OCIAuthInfo *spoolAuth = NULL; + sword errstatus; /* Allocate sessionpool out of persistent memory */ session_pool = (php_oci_spool *) calloc(1, sizeof(php_oci_spool)); @@ -2734,10 +2849,10 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha } /* Allocate the pool handle */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **) &session_pool->poolh, OCI_HTYPE_SPOOL, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(errstatus, OCIHandleAlloc, (session_pool->env, (dvoid **) &session_pool->poolh, OCI_HTYPE_SPOOL, (size_t) 0, (dvoid **) 0)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; goto exit_create_spool; } @@ -2746,10 +2861,10 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha * generic bug which can free up the OCI_G(err) variable before destroying connections. We * cannot use this for other roundtrip calls as there is no way the user can access this error */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, ((dvoid *) session_pool->env, (dvoid **)&(session_pool->err), (ub4) OCI_HTYPE_ERROR,(size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(errstatus, OCIHandleAlloc, ((dvoid *) session_pool->env, (dvoid **)&(session_pool->err), (ub4) OCI_HTYPE_ERROR,(size_t) 0, (dvoid **) 0)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; goto exit_create_spool; } @@ -2762,52 +2877,56 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha #endif #if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2))) - /* Allocate auth handle for session pool {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **)&(spoolAuth), OCI_HTYPE_AUTHINFO, 0, NULL)); + /* {{{ Allocate auth handle for session pool */ + PHP_OCI_CALL_RETURN(errstatus, OCIHandleAlloc, (session_pool->env, (dvoid **)&(spoolAuth), OCI_HTYPE_AUTHINFO, 0, NULL)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; goto exit_create_spool; - } /* }}} */ + } + /* }}} */ - /* Set the edition attribute on the auth handle {{{ */ + /* {{{ Set the edition attribute on the auth handle */ if (OCI_G(edition)) { - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) OCI_G(edition), (ub4)(strlen(OCI_G(edition))), (ub4)OCI_ATTR_EDITION, OCI_G(err))); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) OCI_G(edition), (ub4)(strlen(OCI_G(edition))), (ub4)OCI_ATTR_EDITION, OCI_G(err))); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; goto exit_create_spool; } - } /* }}} */ + } + /* }}} */ - /* Set the driver name attribute on the auth handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); + /* {{{ Set the driver name attribute on the auth handle */ + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; goto exit_create_spool; - } /* }}} */ + } + /* }}} */ - /* Set the auth handle on the session pool {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) (session_pool->poolh),(ub4) OCI_HTYPE_SPOOL, (dvoid *) spoolAuth, (ub4)0, (ub4)OCI_ATTR_SPOOL_AUTH, OCI_G(err))); + /* {{{ Set the auth handle on the session pool */ + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) (session_pool->poolh),(ub4) OCI_HTYPE_SPOOL, (dvoid *) spoolAuth, (ub4)0, (ub4)OCI_ATTR_SPOOL_AUTH, OCI_G(err))); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; goto exit_create_spool; - } /* }}} */ + } + /* }}} */ #endif /* Create the homogeneous session pool - We have different session pools for every different * username, password, charset and dbname. */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCISessionPoolCreate,(session_pool->env, OCI_G(err), session_pool->poolh, (OraText **)&session_pool->poolname, &session_pool->poolname_len, (OraText *)dbname, (ub4)dbname_len, 0, UB4MAXVAL, 1,(OraText *)username, (ub4)username_len, (OraText *)password,(ub4)password_len, poolmode)); + PHP_OCI_CALL_RETURN(errstatus, OCISessionPoolCreate,(session_pool->env, OCI_G(err), session_pool->poolh, (OraText **)&session_pool->poolname, &session_pool->poolname_len, (OraText *)dbname, (ub4)dbname_len, 0, UB4MAXVAL, 1,(OraText *)username, (ub4)username_len, (OraText *)password,(ub4)password_len, poolmode)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); iserror = 1; } @@ -2821,12 +2940,15 @@ exit_create_spool: PHP_OCI_CALL(OCIHandleFree, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO)); } - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: create_spool: (%p) at (%s:%d) \n", session_pool, __FILE__, __LINE__); +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_SESSPOOL_CREATE_ENABLED()) { + DTRACE_OCI8_SESSPOOL_CREATE(session_pool); } +#endif /* HAVE_OCI8_DTRACE */ return session_pool; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_get_spool() * @@ -2841,7 +2963,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char * zend_rsrc_list_entry *spool_out_le = NULL; zend_bool iserror = 0; - /* Create the spool hash key {{{ */ + /* {{{ Create the spool hash key */ smart_str_appendl_ex(&spool_hashed_details, "oci8spool***", sizeof("oci8spool***") - 1, 0); smart_str_appendl_ex(&spool_hashed_details, username, username_len, 0); smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0); @@ -2880,11 +3002,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char * } spool_le.ptr = session_pool; spool_le.type = le_psessionpool; -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - zend_list_insert(session_pool, le_psessionpool TSRMLS_CC); -#else - zend_list_insert(session_pool, le_psessionpool); -#endif + PHP_OCI_REGISTER_RESOURCE(session_pool, le_psessionpool); zend_hash_update(&EG(persistent_list), session_pool->spool_hash_key, strlen(session_pool->spool_hash_key)+1,(void *)&spool_le, sizeof(zend_rsrc_list_entry),NULL); } else if (spool_out_le->type == le_psessionpool && strlen(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == spool_hashed_details.len && @@ -2902,7 +3020,8 @@ exit_get_spool: return session_pool; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_create_env() * @@ -2933,7 +3052,8 @@ static OCIEnv *php_oci_create_env(ub2 charsetid TSRMLS_DC) return NULL; } return retenv; -}/* }}} */ +} +/* }}} */ /* {{{ php_oci_old_create_session() * @@ -2944,57 +3064,58 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna { ub4 statement_cache_size = (OCI_G(statement_cache_size) > 0) ? OCI_G(statement_cache_size) : 0; - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG: Bypassing client-side session pool for session create at (%s:%d) \n", __FILE__, __LINE__); - } - /* Create the OCI environment separate for each connection */ if (!(connection->env = php_oci_create_env(connection->charset TSRMLS_CC))) { return 1; } - /* Allocate our server handle {{{ */ + /* {{{ Allocate our server handle */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->server), OCI_HTYPE_SERVER, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Attach to the server {{{ */ + /* {{{ Attach to the server */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIServerAttach, (connection->server, OCI_G(err), (text *)dbname, dbname_len, (ub4) OCI_DEFAULT)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ connection->is_attached = 1; - /* Allocate our session handle {{{ */ + /* {{{ Allocate our session handle */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->session), OCI_HTYPE_SESSION, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Allocate our private error-handle {{{ */ + /* {{{ Allocate our private error-handle */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->err), OCI_HTYPE_ERROR, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Allocate our service-context {{{ */ + /* {{{ Allocate our service-context */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->svc), OCI_HTYPE_SVCCTX, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Set the username {{{ */ + /* {{{ Set the username */ if (username) { PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) username, (ub4) username_len, (ub4) OCI_ATTR_USERNAME, OCI_G(err))); @@ -3002,9 +3123,10 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } - }/* }}} */ + } + /* }}} */ - /* Set the password {{{ */ + /* {{{ Set the password */ if (password) { PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) password, (ub4) password_len, (ub4) OCI_ATTR_PASSWORD, OCI_G(err))); @@ -3012,9 +3134,10 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } - }/* }}} */ + } + /* }}} */ - /* Set the edition attribute on the session handle {{{ */ + /* {{{ Set the edition attribute on the session handle */ #if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2))) if (OCI_G(edition)) { PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(edition), (ub4) (strlen(OCI_G(edition))), (ub4) OCI_ATTR_EDITION, OCI_G(err))); @@ -3024,9 +3147,10 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna return 1; } } -#endif /* }}} */ +#endif +/* }}} */ - /* Set the driver name attribute on the session handle {{{ */ + /* {{{ Set the driver name attribute on the session handle */ #if (OCI_MAJOR_VERSION >= 11) PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); @@ -3034,26 +3158,29 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } -#endif /* }}} */ +#endif +/* }}} */ - /* Set the server handle in the service handle {{{ */ + /* {{{ Set the server handle in the service handle */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->server, 0, OCI_ATTR_SERVER, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Set the authentication handle in the service handle {{{ */ + /* {{{ Set the authentication handle in the service handle */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->session, 0, OCI_ATTR_SESSION, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ if (new_password) { - /* Try to change password if new one was provided {{{ */ + /* {{{ Try to change password if new one was provided */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIPasswordChange, (connection->svc, OCI_G(err), (text *)username, username_len, (text *)password, password_len, (text *)new_password, new_password_len, OCI_AUTH)); if (OCI_G(errcode) != OCI_SUCCESS) { @@ -3066,9 +3193,10 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ } else { - /* start the session {{{ */ + /* {{{ start the session */ ub4 cred_type = OCI_CRED_RDBMS; /* Extract the overloaded session_mode parameter into valid Oracle credential and session mode values */ @@ -3089,7 +3217,8 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna if (OCI_G(errcode) != OCI_SUCCESS_WITH_INFO) { return 1; } - } /* }}} */ + } + /* }}} */ } /* Brand new connection: Init and update the next_ping in the connection */ @@ -3107,7 +3236,8 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna /* Successfully created session */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_create_session() * @@ -3138,13 +3268,11 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool connection->using_spool = 1; } - if (OCI_G(debug_mode)) { - if (session_pool) { - php_printf ("OCI8 DEBUG L1: using shared pool: (%p) at (%s:%d) \n", session_pool, __FILE__, __LINE__); - } else { - php_printf ("OCI8 DEBUG L1: using private pool: (%p) at (%s:%d) \n", connection->private_spool, __FILE__, __LINE__); - } +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_SESSPOOL_TYPE_ENABLED()) { + DTRACE_OCI8_SESSPOOL_TYPE(session_pool ? 1 : 0, session_pool ? session_pool : connection->private_spool); } +#endif /* HAVE_OCI8_DTRACE */ /* The passed in "connection" can be a cached stub from plist or freshly created. In the former * case, we do not have to allocate any handles @@ -3170,7 +3298,7 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool /* Set the Connection class and purity if OCI client version >= 11g */ #if (OCI_MAJOR_VERSION > 10) - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) connection->authinfo,(ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(connection_class), (ub4)(strlen(OCI_G(connection_class))), (ub4)OCI_ATTR_CONNECTION_CLASS, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->authinfo,(ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(connection_class), (ub4)(strlen(OCI_G(connection_class))), (ub4)OCI_ATTR_CONNECTION_CLASS, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3189,16 +3317,20 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool return 1; } #endif - } /* }}} */ + } + /* }}} */ - /* Debug statements {{{ */ - if (OCI_G(debug_mode)) { + /* {{{ Debug statements */ +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_SESSPOOL_STATS_ENABLED()) { ub4 numfree = 0, numbusy = 0, numopen = 0; PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)actual_spool->poolh, OCI_HTYPE_SPOOL, (dvoid *)&numopen, (ub4 *)0, OCI_ATTR_SPOOL_OPEN_COUNT, OCI_G(err))); PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)actual_spool->poolh, OCI_HTYPE_SPOOL, (dvoid *)&numbusy, (ub4 *)0, OCI_ATTR_SPOOL_BUSY_COUNT, OCI_G(err))); numfree = numopen - numbusy; /* number of free connections in the pool */ - php_printf ("OCI8 DEBUG L1: (numopen=%d)(numbusy=%d)(numfree=%d) at (%s:%d) \n", numopen, numbusy, numfree, __FILE__, __LINE__); - } /* }}} */ + DTRACE_OCI8_SESSPOOL_STATS(numfree, numbusy, numopen); + } +#endif /* HAVE_OCI8_DTRACE */ + /* }}} */ /* Ping loop: Ping and loop till we get a good connection. When a database instance goes * down, it can leave several bad connections that need to be flushed out before getting a @@ -3225,7 +3357,8 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool /* {{{ Populate the session and server fields of the connection */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->server), (ub4 *)0, OCI_ATTR_SERVER, OCI_G(err))); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->session), (ub4 *)0, OCI_ATTR_SESSION, OCI_G(err))); /* }}} */ + PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->session), (ub4 *)0, OCI_ATTR_SESSION, OCI_G(err))); + /* }}} */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIContextGetValue, (connection->session, OCI_G(err), (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), (void **)&(connection->next_pingp))); if (OCI_G(errcode) != OCI_SUCCESS) { @@ -3265,7 +3398,8 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool connection->is_attached = connection->is_open = 1; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_spool_list_dtor() * @@ -3280,7 +3414,8 @@ static void php_oci_spool_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) } return; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_spool_close() * @@ -3310,7 +3445,8 @@ static void php_oci_spool_close(php_oci_spool *session_pool TSRMLS_DC) } free(session_pool); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_ping_init() * @@ -3353,7 +3489,22 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS connection->next_pingp = next_pingp; return OCI_SUCCESS; -} /* }}} */ +} +/* }}} */ + +/* {{{ php_oci_dtrace_check_connection() + * + * DTrace output for connections that may have become invalid and marked for reopening + */ +void php_oci_dtrace_check_connection(php_oci_connection *connection, sb4 errcode, ub4 serverStatus) +{ +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_CHECK_CONNECTION_ENABLED()) { + DTRACE_OCI8_CHECK_CONNECTION(connection, connection && connection->is_open ? 1 : 0, (long)errcode, (unsigned long)serverStatus); + } +#endif /* HAVE_OCI8_DTRACE */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index 763e12e924..320e90a5b8 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -44,21 +44,22 @@ /* {{{ php_oci_collection_create() Create and return connection handle */ -php_oci_collection * php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC) +php_oci_collection *php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC) { dvoid *dschp1 = NULL; dvoid *parmp1; dvoid *parmp2; php_oci_collection *collection; + sword errstatus; collection = emalloc(sizeof(php_oci_collection)); collection->connection = connection; collection->collection = NULL; - zend_list_addref(collection->connection->rsrc_id); + zend_list_addref(collection->connection->id); /* get type handle by name */ - PHP_OCI_CALL_RETURN(connection->errcode, OCITypeByName, + PHP_OCI_CALL_RETURN(errstatus, OCITypeByName, ( connection->env, connection->err, @@ -75,19 +76,19 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* allocate describe handle */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIHandleAlloc, (connection->env, (dvoid **) &dschp1, (ub4) OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(errstatus, OCIHandleAlloc, (connection->env, (dvoid **) &dschp1, (ub4) OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0)); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* describe TDO */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIDescribeAny, + PHP_OCI_CALL_RETURN(errstatus, OCIDescribeAny, ( connection->svc, connection->err, @@ -100,19 +101,19 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* get first parameter handle */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, ((dvoid *) dschp1, (ub4) OCI_HTYPE_DESCRIBE, (dvoid *)&parmp1, (ub4 *)0, (ub4)OCI_ATTR_PARAM, connection->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *) dschp1, (ub4) OCI_HTYPE_DESCRIBE, (dvoid *)&parmp1, (ub4 *)0, (ub4)OCI_ATTR_PARAM, connection->err)); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* get the collection type code of the attribute */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ( (dvoid*) parmp1, (ub4) OCI_DTYPE_PARAM, @@ -123,7 +124,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } @@ -131,7 +132,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c case OCI_TYPECODE_TABLE: case OCI_TYPECODE_VARRAY: /* get collection element handle */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ( (dvoid*) parmp1, (ub4) OCI_DTYPE_PARAM, @@ -142,12 +143,12 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* get REF of the TDO for the type */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ( (dvoid*) parmp2, (ub4) OCI_DTYPE_PARAM, @@ -158,12 +159,12 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* get the TDO (only header) */ - PHP_OCI_CALL_RETURN(connection->errcode, OCITypeByRef, + PHP_OCI_CALL_RETURN(errstatus, OCITypeByRef, ( connection->env, connection->err, @@ -174,12 +175,12 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* get typecode */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ( (dvoid*) parmp2, (ub4) OCI_DTYPE_PARAM, @@ -190,7 +191,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } break; @@ -201,7 +202,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* Create object to hold return table */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIObjectNew, + PHP_OCI_CALL_RETURN(errstatus, OCIObjectNew, ( connection->env, connection->err, @@ -215,13 +216,14 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c ) ); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { goto CLEANUP; } /* free the describe handle (Bug #44113) */ PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE)); PHP_OCI_REGISTER_RESOURCE(collection, le_collection); + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return collection; CLEANUP: @@ -230,27 +232,31 @@ CLEANUP: /* free the describe handle (Bug #44113) */ PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE)); } - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); php_oci_collection_close(collection TSRMLS_CC); return NULL; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_size() Return size of the collection */ int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC) { php_oci_connection *connection = collection->connection; + sword errstatus; - PHP_OCI_CALL_RETURN(connection->errcode, OCICollSize, (connection->env, connection->err, collection->collection, (sb4 *)size)); + PHP_OCI_CALL_RETURN(errstatus, OCICollSize, (connection->env, connection->err, collection->collection, (sb4 *)size)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_max() Return max number of elements in the collection */ @@ -262,23 +268,27 @@ int php_oci_collection_max(php_oci_collection *collection, long *max TSRMLS_DC) /* error handling is not necessary here? */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_trim() Trim collection to the given number of elements */ int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRMLS_DC) { php_oci_connection *connection = collection->connection; - - PHP_OCI_CALL_RETURN(connection->errcode, OCICollTrim, (connection->env, connection->err, trim_size, collection->collection)); + sword errstatus; + + PHP_OCI_CALL_RETURN(errstatus, OCICollTrim, (connection->env, connection->err, trim_size, collection->collection)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + errstatus = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_null() Append NULL element to the end of the collection */ @@ -286,17 +296,20 @@ int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC) { OCIInd null_index = OCI_IND_NULL; php_oci_connection *connection = collection->connection; + sword errstatus; /* append NULL element */ - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, (connection->env, connection->err, (dvoid *)0, &null_index, collection->collection)); + PHP_OCI_CALL_RETURN(errstatus, OCICollAppend, (connection->env, connection->err, (dvoid *)0, &null_index, collection->collection)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + errstatus = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_date() Append DATE element to the end of the collection (use "DD-MON-YY" format) */ @@ -305,18 +318,19 @@ int php_oci_collection_append_date(php_oci_collection *collection, char *date, i OCIInd new_index = OCI_IND_NOTNULL; OCIDate oci_date; php_oci_connection *connection = collection->connection; + sword errstatus; /* format and language are NULLs, so format is "DD-MON-YY" and language is the default language of the session */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { /* failed to convert string to date */ - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, + PHP_OCI_CALL_RETURN(errstatus, OCICollAppend, ( connection->env, connection->err, @@ -326,14 +340,16 @@ int php_oci_collection_append_date(php_oci_collection *collection, char *date, i ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_number() Append NUMBER to the end of the collection */ @@ -343,6 +359,7 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe double element_double; OCINumber oci_number; php_oci_connection *connection = collection->connection; + sword errstatus; #if (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10) /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */ @@ -352,15 +369,15 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe element_double = zend_strtod(number, NULL); #endif - PHP_OCI_CALL_RETURN(connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); + PHP_OCI_CALL_RETURN(errstatus, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, + PHP_OCI_CALL_RETURN(errstatus, OCICollAppend, ( connection->env, connection->err, @@ -370,14 +387,16 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_string() Append STRING to the end of the collection */ @@ -386,16 +405,17 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme OCIInd new_index = OCI_IND_NOTNULL; OCIString *ocistr = (OCIString *)0; php_oci_connection *connection = collection->connection; + sword errstatus; - PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); + PHP_OCI_CALL_RETURN(errstatus, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, + PHP_OCI_CALL_RETURN(errstatus, OCICollAppend, ( connection->env, connection->err, @@ -405,14 +425,16 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append() Append wrapper. Appends any supported element to the end of the collection */ @@ -452,7 +474,8 @@ int php_oci_collection_append(php_oci_collection *collection, char *element, int } /* never reached */ return 1; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_get() Get the element with the given index */ @@ -464,11 +487,14 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z boolean exists; oratext buff[1024]; ub4 buff_len = 1024; + sword errstatus; MAKE_STD_ZVAL(*result_element); ZVAL_NULL(*result_element); - PHP_OCI_CALL_RETURN(connection->errcode, OCICollGetElem, + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ + + PHP_OCI_CALL_RETURN(errstatus, OCICollGetElem, ( connection->env, connection->err, @@ -480,8 +506,8 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); FREE_ZVAL(*result_element); return 1; @@ -500,10 +526,10 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z switch (collection->element_typecode) { case OCI_TYPECODE_DATE: - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, element, 0, 0, 0, 0, &buff_len, buff)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateToText, (connection->err, element, 0, 0, 0, 0, &buff_len, buff)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); FREE_ZVAL(*result_element); return 1; @@ -543,10 +569,10 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z { double double_number; - PHP_OCI_CALL_RETURN(connection->errcode, OCINumberToReal, (connection->err, (CONST OCINumber *) element, (uword) sizeof(double), (dvoid *) &double_number)); + PHP_OCI_CALL_RETURN(errstatus, OCINumberToReal, (connection->err, (CONST OCINumber *) element, (uword) sizeof(double), (dvoid *) &double_number)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); FREE_ZVAL(*result_element); return 1; @@ -565,7 +591,8 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z } /* never reached */ return 1; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_null() Set the element with the given index to NULL */ @@ -573,17 +600,20 @@ int php_oci_collection_element_set_null(php_oci_collection *collection, long ind { OCIInd null_index = OCI_IND_NULL; php_oci_connection *connection = collection->connection; + sword errstatus; /* set NULL element */ - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, (connection->env, connection->err, (ub4) index, (dvoid *)"", &null_index, collection->collection)); + PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem, (connection->env, connection->err, (ub4) index, (dvoid *)"", &null_index, collection->collection)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_date() Change element's value to the given DATE */ @@ -592,18 +622,19 @@ int php_oci_collection_element_set_date(php_oci_collection *collection, long ind OCIInd new_index = OCI_IND_NOTNULL; OCIDate oci_date; php_oci_connection *connection = collection->connection; + sword errstatus; /* format and language are NULLs, so format is "DD-MON-YY" and language is the default language of the session */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { /* failed to convert string to date */ - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, + PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem, ( connection->env, connection->err, @@ -614,14 +645,16 @@ int php_oci_collection_element_set_date(php_oci_collection *collection, long ind ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_number() Change element's value to the given NUMBER */ @@ -631,6 +664,7 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i double element_double; OCINumber oci_number; php_oci_connection *connection = collection->connection; + sword errstatus; #if (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10) /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */ @@ -640,15 +674,15 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i element_double = zend_strtod(number, NULL); #endif - PHP_OCI_CALL_RETURN(connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); + PHP_OCI_CALL_RETURN(errstatus, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, + PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem, ( connection->env, connection->err, @@ -659,14 +693,16 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_string() Change element's value to the given string */ @@ -675,16 +711,17 @@ int php_oci_collection_element_set_string(php_oci_collection *collection, long i OCIInd new_index = OCI_IND_NOTNULL; OCIString *ocistr = (OCIString *)0; php_oci_connection *connection = collection->connection; + sword errstatus; - PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); + PHP_OCI_CALL_RETURN(errstatus, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, + PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem, ( connection->env, connection->err, @@ -695,14 +732,16 @@ int php_oci_collection_element_set_string(php_oci_collection *collection, long i ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set() Collection element setter */ @@ -742,44 +781,51 @@ int php_oci_collection_element_set(php_oci_collection *collection, long index, c } /* never reached */ return 1; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_assign() Assigns a value to the collection from another collection */ int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_collection *collection_from TSRMLS_DC) { php_oci_connection *connection = collection_dest->connection; + sword errstatus; - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssign, (connection->env, connection->err, collection_from->collection, collection_dest->collection)); + PHP_OCI_CALL_RETURN(errstatus, OCICollAssign, (connection->env, connection->err, collection_from->collection, collection_dest->collection)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_close() Destroy collection and all associated resources */ void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC) { php_oci_connection *connection = collection->connection; + sword errstatus; if (collection->collection) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIObjectFree, (connection->env, connection->err, (dvoid *)collection->collection, (ub2)OCI_OBJECTFREE_FORCE)); + PHP_OCI_CALL_RETURN(errstatus, OCIObjectFree, (connection->env, connection->err, (dvoid *)collection->collection, (ub2)OCI_OBJECTFREE_FORCE)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); + } else { + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } } - zend_list_delete(collection->connection->rsrc_id); - + zend_list_delete(collection->connection->id); efree(collection); return; -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_dtrace.d b/ext/oci8/oci8_dtrace.d new file mode 100644 index 0000000000..8ac94105c1 --- /dev/null +++ b/ext/oci8/oci8_dtrace.d @@ -0,0 +1,36 @@ +/* + +----------------------------------------------------------------------+ + | Zend Engine | + +----------------------------------------------------------------------+ + | Copyright (c) 2013 Zend Technologies Ltd. (http://www.zend.com) | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the Zend license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.zend.com/license/3_01.txt. | + | If you did not receive a copy of the Zend license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@zend.com so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Christopher Jones <christopher.jones@oracle.com> | + +----------------------------------------------------------------------+ +*/ + +provider php { + probe oci8__check__connection(void *connection, int is_open, long errcode, unsigned long server_status); + probe oci8__connect__entry(char *username, char *dbname, char *charset, long session_mode, int persistent, int exclusive); + probe oci8__connect__return(void *connection); + probe oci8__connection__close(void *connection); + probe oci8__error(int status, long errcode); + probe oci8__execute__mode(void *connection, unsigned int mode); + probe oci8__sqltext(void *connection, char *sql); + + probe oci8__connect__p__dtor__close(void *connection); + probe oci8__connect__p__dtor__release(void *connection); + probe oci8__connect__lookup(void *connection, int is_stub); + probe oci8__connect__expiry(void *connection, int is_stub, long idle_expiry, long timestamp); + probe oci8__connect__type(int persistent, int exclusive, void *connection, long num_persistent, long num_connections); + probe oci8__sesspool__create(void *session_pool); + probe oci8__sesspool__stats(unsigned long free, unsigned long busy, unsigned long open); + probe oci8__sesspool__type(int type, void *session_pool); +}; diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index e51d3c92f5..8d70aff9c2 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -1308,12 +1308,7 @@ PHP_FUNCTION(oci_field_is_null) Toggle internal debugging output for the OCI extension */ PHP_FUNCTION(oci_internal_debug) { - zend_bool on_off; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &on_off) == FAILURE) { - return; - } - OCI_G(debug_mode) = on_off; + /* NOP in OCI8 2.0. Obsoleted by DTrace probes */ } /* }}} */ @@ -1583,7 +1578,7 @@ PHP_FUNCTION(oci_close) } PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - zend_list_delete(connection->rsrc_id); + zend_list_delete(connection->id); ZVAL_NULL(z_connection); @@ -1591,7 +1586,7 @@ PHP_FUNCTION(oci_close) } /* }}} */ -/* {{{ proto resource oci_new_connect(string user, string pass [, string db]) +/* {{{ proto resource oci_new_connect(string user, string pass [, string db, string charset [, int session_mode ]]) Connect to an Oracle database and log on. Returns a new session. */ PHP_FUNCTION(oci_new_connect) { @@ -1607,7 +1602,7 @@ PHP_FUNCTION(oci_connect) } /* }}} */ -/* {{{ proto resource oci_pconnect(string user, string pass [, string db [, string charset ]]) +/* {{{ proto resource oci_pconnect(string user, string pass [, string db [, string charset [, int session_mode ]]) Connect to an Oracle database using a persistent connection and log on. Returns a new session. */ PHP_FUNCTION(oci_pconnect) { @@ -1624,7 +1619,6 @@ PHP_FUNCTION(oci_error) php_oci_connection *connection; text *errbuf; sb4 errcode = 0; - sword error = OCI_SUCCESS; dvoid *errh = NULL; ub2 error_offset = 0; text *sqltext = NULL; @@ -1635,10 +1629,9 @@ PHP_FUNCTION(oci_error) if (ZEND_NUM_ARGS() > 0) { statement = (php_oci_statement *) zend_fetch_resource(&arg TSRMLS_CC, -1, NULL, NULL, 1, le_statement); - if (statement) { errh = statement->err; - error = statement->errcode; + errcode = statement->errcode; if (php_oci_fetch_sqltext_offset(statement, &sqltext, &error_offset TSRMLS_CC)) { RETURN_FALSE; @@ -1649,23 +1642,23 @@ PHP_FUNCTION(oci_error) connection = (php_oci_connection *) zend_fetch_resource(&arg TSRMLS_CC, -1, NULL, NULL, 1, le_connection); if (connection) { errh = connection->err; - error = connection->errcode; + errcode = connection->errcode; goto go_out; } connection = (php_oci_connection *) zend_fetch_resource(&arg TSRMLS_CC, -1, NULL, NULL, 1, le_pconnection); if (connection) { errh = connection->err; - error = connection->errcode; + errcode = connection->errcode; goto go_out; } } else { errh = OCI_G(err); - error = OCI_G(errcode); + errcode = OCI_G(errcode); } go_out: - if (error == OCI_SUCCESS) { /* no error set in the handle */ + if (errcode == 0) { /* no error set in the handle */ RETURN_FALSE; } @@ -1744,7 +1737,12 @@ PHP_FUNCTION(oci_set_prefetch) PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); - if (php_oci_statement_set_prefetch(statement, size TSRMLS_CC)) { + if (size < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows to be prefetched has to be greater than or equal to 0"); + return; + } + + if (php_oci_statement_set_prefetch(statement, (ub4)size TSRMLS_CC)) { RETURN_FALSE; } RETURN_TRUE; @@ -1759,6 +1757,7 @@ PHP_FUNCTION(oci_set_client_identifier) php_oci_connection *connection; char *client_id; int client_id_len; + sword errstatus; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_id, &client_id_len) == FAILURE) { return; @@ -1766,10 +1765,10 @@ PHP_FUNCTION(oci_set_client_identifier) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, OCI_G(err))); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, connection->err)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); RETURN_FALSE; } @@ -1809,7 +1808,7 @@ PHP_FUNCTION(oci_set_edition) /* }}} */ /* {{{ proto bool oci_set_module_name(resource connection, string value) - Sets the module attribute on the connection */ + Sets the module attribute on the connection for end-to-end tracing */ PHP_FUNCTION(oci_set_module_name) { #if (OCI_MAJOR_VERSION >= 10) @@ -1817,6 +1816,7 @@ PHP_FUNCTION(oci_set_module_name) php_oci_connection *connection; char *module; int module_len; + sword errstatus; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &module, &module_len) == FAILURE) { return; @@ -1824,10 +1824,10 @@ PHP_FUNCTION(oci_set_module_name) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, OCI_G(err))); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, connection->err)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); RETURN_FALSE; } @@ -1840,7 +1840,7 @@ PHP_FUNCTION(oci_set_module_name) /* }}} */ /* {{{ proto bool oci_set_action(resource connection, string value) - Sets the action attribute on the connection */ + Sets the action attribute on the connection for end-to-end tracing */ PHP_FUNCTION(oci_set_action) { #if (OCI_MAJOR_VERSION >= 10) @@ -1848,6 +1848,7 @@ PHP_FUNCTION(oci_set_action) php_oci_connection *connection; char *action; int action_len; + sword errstatus; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &action, &action_len) == FAILURE) { return; @@ -1855,10 +1856,10 @@ PHP_FUNCTION(oci_set_action) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, OCI_G(err))); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, connection->err)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); RETURN_FALSE; } @@ -1871,7 +1872,7 @@ PHP_FUNCTION(oci_set_action) /* }}} */ /* {{{ proto bool oci_set_client_info(resource connection, string value) - Sets the client info attribute on the connection */ + Sets the client info attribute on the connection for end-to-end tracing */ PHP_FUNCTION(oci_set_client_info) { #if (OCI_MAJOR_VERSION >= 10) @@ -1879,6 +1880,7 @@ PHP_FUNCTION(oci_set_client_info) php_oci_connection *connection; char *client_info; int client_info_len; + sword errstatus; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_info, &client_info_len) == FAILURE) { return; @@ -1886,10 +1888,10 @@ PHP_FUNCTION(oci_set_client_info) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, OCI_G(err))); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, connection->err)); - if (OCI_G(errcode) != OCI_SUCCESS) { - php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); RETURN_FALSE; } @@ -1957,7 +1959,7 @@ PHP_FUNCTION(oci_password_change) if (!connection) { RETURN_FALSE; } - RETURN_RESOURCE(connection->rsrc_id); + RETURN_RESOURCE(connection->id); } WRONG_PARAM_COUNT; } @@ -2395,6 +2397,32 @@ PHP_FUNCTION(oci_new_collection) } /* }}} */ +/* {{{ proto bool oci_get_implicit(resource stmt) + Get the next statement resource from an Oracle 12c PL/SQL Implicit Result Set */ +PHP_FUNCTION(oci_get_implicit_resultset) +{ + zval *z_statement; + php_oci_statement *statement; + php_oci_statement *imp_statement; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) { + return; + } + + PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); + + imp_statement = php_oci_get_implicit_resultset(statement TSRMLS_CC); + + if (imp_statement) { + if (php_oci_statement_execute(imp_statement, (ub4)OCI_DEFAULT TSRMLS_CC)) + RETURN_FALSE; + RETURN_RESOURCE(imp_statement->id); + } + RETURN_FALSE; +} + +/* }}} */ + #endif /* HAVE_OCI8 */ /* diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index d05e053919..8d14dc3f50 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -54,6 +54,7 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long type TSRMLS_DC) { php_oci_descriptor *descriptor; + sword errstatus; switch (type) { case OCI_DTYPE_FILE: @@ -70,15 +71,17 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ descriptor = ecalloc(1, sizeof(php_oci_descriptor)); descriptor->type = type; descriptor->connection = connection; - zend_list_addref(descriptor->connection->rsrc_id); + zend_list_addref(descriptor->connection->id); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(errstatus, OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0)); - if (OCI_G(errcode) != OCI_SUCCESS) { - OCI_G(errcode) = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + OCI_G(errcode) = php_oci_error(OCI_G(err), errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, OCI_G(errcode)); efree(descriptor); return NULL; + } else { + OCI_G(errcode) = 0; /* retain backwards compat with OCI8 1.4 */ } PHP_OCI_REGISTER_RESOURCE(descriptor, le_descriptor); @@ -109,13 +112,15 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ } return descriptor; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_get_length() Get length of the LOB. The length is cached so we don't need to ask Oracle every time */ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; + sword errstatus; *length = 0; @@ -124,18 +129,18 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D return 0; } else { if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + PHP_OCI_CALL_RETURN(errstatus, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length)); + PHP_OCI_CALL_RETURN(errstatus, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } @@ -143,17 +148,20 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D descriptor->lob_size = *length; if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(errstatus, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } } + + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_callback() Append LOB portion to a memory buffer */ @@ -203,25 +211,28 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece) } /* }}} */ -/* {{{ php_oci_lob_calculate_buffer() */ +/* {{{ php_oci_lob_calculate_buffer() + Work out the size for LOB buffering */ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, long read_length TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; ub4 chunk_size; + sword errstatus; if (descriptor->type == OCI_DTYPE_FILE) { return read_length; } if (!descriptor->chunk_size) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size)); + PHP_OCI_CALL_RETURN(errstatus, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return read_length; /* we have to return original length here */ } descriptor->chunk_size = chunk_size; + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } if ((read_length % descriptor->chunk_size) != 0) { @@ -250,6 +261,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini #endif int is_clob = 0; sb4 bytes_per_char = 1; + sword errstatus; *data_len = 0; *data = NULL; @@ -286,20 +298,20 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini offset = initial_offset; if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); + PHP_OCI_CALL_RETURN(errstatus, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } } else { ub2 charset_id = 0; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); + PHP_OCI_CALL_RETURN(errstatus, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } @@ -310,10 +322,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } if (is_clob) { - PHP_OCI_CALL_RETURN(connection->errcode, OCINlsNumericInfoGet, (connection->env, connection->err, &bytes_per_char, OCI_NLS_CHARSET_MAXBYTESZ)); + PHP_OCI_CALL_RETURN(errstatus, OCINlsNumericInfoGet, (connection->env, connection->err, &bytes_per_char, OCI_NLS_CHARSET_MAXBYTESZ)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } @@ -337,7 +349,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */ bufp = (ub1 *) ecalloc(1, buffer_size); - PHP_OCI_CALL_RETURN(connection->errcode, OCILobRead2, + PHP_OCI_CALL_RETURN(errstatus, OCILobRead2, ( connection->svc, connection->err, @@ -370,7 +382,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */ bufp = (ub1 *) ecalloc(1, buffer_size); - PHP_OCI_CALL_RETURN(connection->errcode, OCILobRead, + PHP_OCI_CALL_RETURN(errstatus, OCILobRead, ( connection->svc, connection->err, @@ -391,8 +403,8 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini #endif - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); if (*data) { efree(*data); @@ -405,10 +417,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini descriptor->lob_current_position = (int)offset; if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(errstatus, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); if (*data) { efree(*data); @@ -419,8 +431,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_write() Write data to the LOB */ @@ -429,6 +443,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i OCILobLocator *lob = (OCILobLocator *) descriptor->descriptor; php_oci_connection *connection = (php_oci_connection *) descriptor->connection; ub4 lob_length; + sword errstatus; *bytes_written = 0; if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) { @@ -447,7 +462,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i offset = descriptor->lob_current_position; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobWrite, + PHP_OCI_CALL_RETURN(errstatus, OCILobWrite, ( connection->svc, connection->err, @@ -464,8 +479,8 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i ) ); - if (connection->errcode) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); *bytes_written = 0; return 1; @@ -482,14 +497,17 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i descriptor->buffering = PHP_OCI_LOB_BUFFER_USED; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_set_buffering() Turn buffering off/onn for this particular LOB */ int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; + sword errstatus; if (!on_off && descriptor->buffering == PHP_OCI_LOB_BUFFER_DISABLED) { /* disabling when it's already off */ @@ -502,19 +520,21 @@ int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS } if (on_off) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobEnableBuffering, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(errstatus, OCILobEnableBuffering, (connection->svc, connection->err, descriptor->descriptor)); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(errstatus, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor)); } - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } descriptor->buffering = on_off ? PHP_OCI_LOB_BUFFER_ENABLED : PHP_OCI_LOB_BUFFER_DISABLED; + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_get_buffering() Return current buffering state for the LOB */ @@ -525,7 +545,8 @@ int php_oci_lob_get_buffering (php_oci_descriptor *descriptor) } else { return 0; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_copy() Copy one LOB (or its part) to another one */ @@ -533,6 +554,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d { php_oci_connection *connection = descriptor_dest->connection; ub4 length_dest, length_from, copy_len; + sword errstatus; if (php_oci_lob_get_length(descriptor_dest, &length_dest TSRMLS_CC)) { return 1; @@ -553,7 +575,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCopy, + PHP_OCI_CALL_RETURN(errstatus, OCILobCopy, ( connection->svc, connection->err, @@ -565,29 +587,33 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_close() Close LOB */ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; - + sword errstatus; + if (descriptor->is_open) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); - } + PHP_OCI_CALL_RETURN(errstatus, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); - PHP_OCI_HANDLE_ERROR(connection, connection->errcode); - return 1; + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); + PHP_OCI_HANDLE_ERROR(connection, connection->errcode); + return 1; + } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } if (php_oci_temp_lob_close(descriptor TSRMLS_CC)) { @@ -595,7 +621,8 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_temp_lob_close() Close Temporary LOB */ @@ -603,27 +630,29 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; int is_temporary; + sword errstatus; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary)); + PHP_OCI_CALL_RETURN(errstatus, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } if (is_temporary) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(errstatus, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_lob_flush() Flush buffers for the LOB (only if they have been used) */ @@ -631,7 +660,8 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC) { OCILobLocator *lob = descriptor->descriptor; php_oci_connection *connection = descriptor->connection; - + sword errstatus; + if (!lob) { return 1; } @@ -654,18 +684,20 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC) return 0; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag)); + PHP_OCI_CALL_RETURN(errstatus, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } /* marking buffer as enabled and not used */ descriptor->buffering = PHP_OCI_LOB_BUFFER_ENABLED; + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_free() Close LOB descriptor and free associated resources */ @@ -709,9 +741,10 @@ void php_oci_lob_free (php_oci_descriptor *descriptor TSRMLS_DC) PHP_OCI_CALL(OCIDescriptorFree, (descriptor->descriptor, descriptor->type)); - zend_list_delete(descriptor->connection->rsrc_id); + zend_list_delete(descriptor->connection->id); efree(descriptor); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_import() Import LOB contents from the given file */ @@ -723,6 +756,7 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC php_oci_connection *connection = descriptor->connection; char buf[8192]; ub4 offset = 1; + sword errstatus; #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) /* Safe mode has been removed in PHP 5.4 */ @@ -739,7 +773,7 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC } while ((loblen = read(fp, &buf, sizeof(buf))) > 0) { - PHP_OCI_CALL_RETURN(connection->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCILobWrite, ( connection->svc, @@ -757,18 +791,21 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); close(fp); return 1; + } else { + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } offset += loblen; } close(fp); return 0; -} /* }}} */ +} + /* }}} */ /* {{{ php_oci_lob_append() Append data to the end of the LOB */ @@ -778,6 +815,7 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor OCILobLocator *lob_dest = descriptor_dest->descriptor; OCILobLocator *lob_from = descriptor_from->descriptor; ub4 dest_len, from_len; + sword errstatus; if (php_oci_lob_get_length(descriptor_dest, &dest_len TSRMLS_CC)) { return 1; @@ -791,15 +829,17 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor return 0; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobAppend, (connection->svc, connection->err, lob_dest, lob_from)); + PHP_OCI_CALL_RETURN(errstatus, OCILobAppend, (connection->svc, connection->err, lob_dest, lob_from)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_truncate() Truncate LOB to the given length */ @@ -808,6 +848,7 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS php_oci_connection *connection = descriptor->connection; OCILobLocator *lob = descriptor->descriptor; ub4 lob_length; + sword errstatus; if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) { return 1; @@ -827,17 +868,20 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length)); + PHP_OCI_CALL_RETURN(errstatus, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } descriptor->lob_size = new_lob_length; + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ + return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_erase() Erase (or fill with whitespaces, depending on LOB type) the LOB (or its part) */ @@ -846,6 +890,7 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length, php_oci_connection *connection = descriptor->connection; OCILobLocator *lob = descriptor->descriptor; ub4 lob_length; + sword errstatus; *bytes_erased = 0; @@ -861,17 +906,19 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length, length = lob_length; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1)); + PHP_OCI_CALL_RETURN(errstatus, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } *bytes_erased = length; + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_is_equal() Compare two LOB descriptors and figure out if they are pointing to the same LOB */ @@ -880,16 +927,19 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript php_oci_connection *connection = descriptor_first->connection; OCILobLocator *first_lob = descriptor_first->descriptor; OCILobLocator *second_lob = descriptor_second->descriptor; + sword errstatus; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsEqual, (connection->env, first_lob, second_lob, result)); + PHP_OCI_CALL_RETURN(errstatus, OCILobIsEqual, (connection->env, first_lob, second_lob, result)); - if (connection->errcode) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_write_tmp() Create temporary LOB and write data to it */ @@ -898,6 +948,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data php_oci_connection *connection = descriptor->connection; OCILobLocator *lob = descriptor->descriptor; ub4 bytes_written = 0; + sword errstatus; switch (type) { case OCI_TEMP_BLOB: @@ -914,7 +965,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCreateTemporary, + PHP_OCI_CALL_RETURN(errstatus, OCILobCreateTemporary, ( connection->svc, connection->err, @@ -927,24 +978,26 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data ) ); - if (connection->errcode) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE)); + PHP_OCI_CALL_RETURN(errstatus, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE)); - if (connection->errcode) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } descriptor->is_open = 1; + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return php_oci_lob_write(descriptor, 0, data, data_len, &bytes_written TSRMLS_CC); -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 89facb0703..274c4e9e33 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -43,21 +43,30 @@ /* {{{ php_oci_statement_create() Create statemend handle and allocate necessary resources */ -php_oci_statement *php_oci_statement_create (php_oci_connection *connection, char *query, int query_len TSRMLS_DC) +php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char *query, int query_len TSRMLS_DC) { php_oci_statement *statement; - + sword errstatus; + + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ + statement = ecalloc(1,sizeof(php_oci_statement)); if (!query_len) { /* do not allocate stmt handle for refcursors, we'll get it from OCIStmtPrepare2() */ PHP_OCI_CALL(OCIHandleAlloc, (connection->env, (dvoid **)&(statement->stmt), OCI_HTYPE_STMT, 0, NULL)); + } else { +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_SQLTEXT_ENABLED()) { + DTRACE_OCI8_SQLTEXT(connection, query); + } +#endif /* HAVE_OCI8_DTRACE */ } PHP_OCI_CALL(OCIHandleAlloc, (connection->env, (dvoid **)&(statement->err), OCI_HTYPE_ERROR, 0, NULL)); if (query_len > 0) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIStmtPrepare2, + PHP_OCI_CALL_RETURN(errstatus, OCIStmtPrepare2, ( connection->svc, &(statement->stmt), @@ -70,14 +79,13 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha OCI_DEFAULT ) ); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); - PHP_OCI_CALL(OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, statement->errcode ? OCI_STRLS_CACHE_DELETE : OCI_DEFAULT)); + PHP_OCI_CALL(OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, OCI_STRLS_CACHE_DELETE)); PHP_OCI_CALL(OCIHandleFree,(statement->err, OCI_HTYPE_ERROR)); - - efree(statement); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); + efree(statement); return NULL; } } @@ -95,10 +103,15 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha statement->has_data = 0; statement->has_descr = 0; statement->parent_stmtid = 0; - zend_list_addref(statement->connection->rsrc_id); + statement->impres_child_stmt = NULL; + statement->impres_count = 0; + statement->impres_flag = PHP_OCI_IMPRES_UNKNOWN; /* may or may not have Implicit Result Set children */ + zend_list_addref(statement->connection->id); if (OCI_G(default_prefetch) >= 0) { - php_oci_statement_set_prefetch(statement, OCI_G(default_prefetch) TSRMLS_CC); + php_oci_statement_set_prefetch(statement, (ub4)OCI_G(default_prefetch) TSRMLS_CC); + } else { + php_oci_statement_set_prefetch(statement, (ub4)100 TSRMLS_CC); /* semi-arbitrary, "sensible default" */ } PHP_OCI_REGISTER_RESOURCE(statement, le_statement); @@ -109,25 +122,85 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha } /* }}} */ +/* {{{ php_oci_get_implicit_resultset() + Fetch implicit result set statement resource */ +php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement TSRMLS_DC) +{ +#if (OCI_MAJOR_VERSION < 12) + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Implicit results are available in Oracle Database 12c onwards"); + return NULL; +#else + void *result; + ub4 rtype; + php_oci_statement *statement2; /* implicit result set statement handle */ + sword errstatus; + + PHP_OCI_CALL_RETURN(errstatus, OCIStmtGetNextResult, (statement->stmt, statement->err, &result, &rtype, OCI_DEFAULT)); + if (errstatus == OCI_NO_DATA) { + return NULL; + } + + if (rtype != OCI_RESULT_TYPE_SELECT) { + /* Only OCI_RESULT_TYPE_SELECT is supported by Oracle DB 12cR1 */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unexpected implicit result type returned from Oracle Database"); + return NULL; + } else { + statement2 = ecalloc(1,sizeof(php_oci_statement)); + + PHP_OCI_CALL(OCIHandleAlloc, (statement->connection->env, (dvoid **)&(statement2->err), OCI_HTYPE_ERROR, 0, NULL)); + statement2->stmt = (OCIStmt *)result; + statement2->parent_stmtid = statement->id; + statement2->impres_child_stmt = NULL; + statement2->impres_count = 0; + statement2->impres_flag = PHP_OCI_IMPRES_IS_CHILD; + statement2->connection = statement->connection; + statement2->errcode = 0; + statement2->last_query = NULL; + statement2->last_query_len = 0; + statement2->columns = NULL; + statement2->binds = NULL; + statement2->defines = NULL; + statement2->ncolumns = 0; + statement2->executed = 0; + statement2->has_data = 0; + statement2->has_descr = 0; + statement2->stmttype = 0; + + zend_list_addref(statement->id); + zend_list_addref(statement2->connection->id); + + php_oci_statement_set_prefetch(statement2, statement->prefetch_count TSRMLS_CC); + + PHP_OCI_REGISTER_RESOURCE(statement2, le_statement); + + OCI_G(num_statements)++; + + return statement2; + } +#endif /* OCI_MAJOR_VERSION < 12 */ +} +/* }}} */ + /* {{{ php_oci_statement_set_prefetch() - Set prefetch buffer size for the statement (we're assuming that one row is ~1K sized) */ -int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRMLS_DC) + Set prefetch buffer size for the statement */ +int php_oci_statement_set_prefetch(php_oci_statement *statement, ub4 prefetch TSRMLS_DC) { - ub4 prefetch = size; + sword errstatus; - if (size < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows to be prefetched has to be greater than or equal to 0"); - return 1; + if (prefetch > 20000) { + prefetch = 20000; /* keep it somewhat sane */ } + + PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, (statement->stmt, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, statement->err)); - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrSet, (statement->stmt, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, statement->err)); - - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); + statement->prefetch_count = 0; return 1; } - + statement->prefetch_count = prefetch; + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; } /* }}} */ @@ -163,8 +236,8 @@ int php_oci_cleanup_pre_fetch(void *data TSRMLS_DC) } return ZEND_HASH_APPLY_KEEP; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_statement_fetch() Fetch a row from the statement */ @@ -175,16 +248,18 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) ub4 typep, iterp, idxp; ub1 in_outp, piecep; zend_bool piecewisecols = 0; - php_oci_out_column *column; + sword errstatus; + + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ if (statement->has_descr && statement->columns) { zend_hash_apply(statement->columns, (apply_func_t) php_oci_cleanup_pre_fetch TSRMLS_CC); } - PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(errstatus, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); - if ( statement->errcode == OCI_NO_DATA || nrows == 0 ) { + if (errstatus == OCI_NO_DATA || nrows == 0) { if (statement->last_query == NULL) { /* reset define-list for refcursors */ if (statement->columns) { @@ -196,7 +271,6 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) statement->executed = 0; } - statement->errcode = 0; /* OCI_NO_DATA is NO error for us!!! */ statement->has_data = 0; if (nrows == 0) { @@ -209,15 +283,15 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) /* reset length for all piecewise columns */ for (i = 0; i < statement->ncolumns; i++) { column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); - if (column->piecewise) { + if (column && column->piecewise) { column->retlen4 = 0; piecewisecols = 1; } } - while (statement->errcode == OCI_NEED_DATA) { + while (errstatus == OCI_NEED_DATA) { if (piecewisecols) { - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCIStmtGetPieceInfo, ( statement->stmt, @@ -234,7 +308,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) /* scan through our columns for a piecewise column with a matching handle */ for (i = 0; i < statement->ncolumns; i++) { column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); - if (column->piecewise && handlepp == column->oci_define) { + if (column && column->piecewise && handlepp == column->oci_define) { if (!column->data) { column->data = (text *) ecalloc(1, PHP_OCI_PIECE_SIZE + 1); } else { @@ -259,7 +333,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) } } - PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(errstatus, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); if (piecewisecols) { for (i = 0; i < statement->ncolumns; i++) { @@ -271,7 +345,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) } } - if (statement->errcode == OCI_SUCCESS_WITH_INFO || statement->errcode == OCI_SUCCESS) { + if (errstatus == OCI_SUCCESS_WITH_INFO || errstatus == OCI_SUCCESS) { statement->has_data = 1; /* do the stuff needed for OCIDefineByName */ @@ -292,7 +366,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) return 0; } - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); statement->has_data = 0; @@ -332,7 +406,7 @@ php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, l } /* }}} */ -/* php_oci_define_callback() {{{ */ +/* {{{ php_oci_define_callback() */ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcpp) { php_oci_out_column *outcol = (php_oci_out_column *)ctx; @@ -415,12 +489,18 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) ub4 colcount; ub2 dynamic; dvoid *buf; + sword errstatus; switch (mode) { case OCI_COMMIT_ON_SUCCESS: case OCI_DESCRIBE_ONLY: case OCI_DEFAULT: /* only these are allowed */ +#ifdef HAVE_OCI8_DTRACE + if (DTRACE_OCI8_EXECUTE_MODE_ENABLED()) { + DTRACE_OCI8_EXECUTE_MODE(statement->connection, mode); + } +#endif /* HAVE_OCI8_DTRACE */ break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid execute mode given: %d", mode); @@ -430,12 +510,14 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) if (!statement->stmttype) { /* get statement type */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement->stmttype, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement->stmttype, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; + } else { + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } } @@ -445,9 +527,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) iters = 1; } - if (statement->last_query) { - /* if we execute refcursors we don't have a query and - we don't want to execute!!! */ + if (statement->last_query) { /* Don't execute REFCURSORS or Implicit Result Set handles */ if (statement->binds) { int result = 0; @@ -458,10 +538,10 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } /* execute statement */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtExecute, (statement->connection->svc, statement->stmt, statement->err, iters, 0, NULL, NULL, mode)); + PHP_OCI_CALL_RETURN(errstatus, OCIStmtExecute, (statement->connection->svc, statement->stmt, statement->err, iters, 0, NULL, NULL, mode)); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } @@ -471,10 +551,20 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } if (mode & OCI_COMMIT_ON_SUCCESS) { - statement->connection->needs_commit = 0; - } else { - statement->connection->needs_commit = 1; + /* No need to rollback on disconnect */ + statement->connection->rb_on_disconnect = 0; + } else if (statement->stmttype != OCI_STMT_SELECT) { + /* Assume some uncommitted DML occurred */ + statement->connection->rb_on_disconnect = 1; } + /* else for SELECT with OCI_NO_AUTO_COMMIT, leave + * "rb_on_disconnect" at its previous value. SELECT can't + * initiate uncommitted DML. (An AUTONOMOUS_TRANSACTION in + * invoked PL/SQL must explicitly rollback/commit else the + * SELECT fails). + */ + + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } if (statement->stmttype == OCI_STMT_SELECT && statement->executed == 0) { @@ -487,10 +577,10 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) counter = 1; /* get number of columns */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *)&colcount, (ub4 *)0, OCI_ATTR_PARAM_COUNT, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *)&colcount, (ub4 *)0, OCI_ATTR_PARAM_COUNT, statement->err)); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } @@ -507,50 +597,50 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } /* get column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)¶m, counter)); + PHP_OCI_CALL_RETURN(errstatus, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)¶m, counter)); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get column datatype */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_type, (ub4 *)0, OCI_ATTR_DATA_TYPE, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_type, (ub4 *)0, OCI_ATTR_DATA_TYPE, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get character set form */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_form, (ub4 *)0, OCI_ATTR_CHARSET_FORM, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_form, (ub4 *)0, OCI_ATTR_CHARSET_FORM, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get character set id */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_id, (ub4 *)0, OCI_ATTR_CHARSET_ID, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_id, (ub4 *)0, OCI_ATTR_CHARSET_ID, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get size of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_size, (dvoid *)0, OCI_ATTR_DATA_SIZE, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_size, (dvoid *)0, OCI_ATTR_DATA_SIZE, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } @@ -559,31 +649,31 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) outcol->retlen = outcol->data_size; /* get scale of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->scale, (dvoid *)0, OCI_ATTR_SCALE, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->scale, (dvoid *)0, OCI_ATTR_SCALE, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get precision of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->precision, (dvoid *)0, OCI_ATTR_PRECISION, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->precision, (dvoid *)0, OCI_ATTR_PRECISION, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get name of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid **)&colname, (ub4 *)&outcol->name_len, (ub4)OCI_ATTR_NAME, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid **)&colname, (ub4 *)&outcol->name_len, (ub4)OCI_ATTR_NAME, statement->err)); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } @@ -591,7 +681,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) outcol->name = estrndup((char*) colname, outcol->name_len); - /* find a user-setted define */ + /* find a user-set define */ if (statement->defines) { if (zend_hash_find(statement->defines,outcol->name,outcol->name_len,(void **) &outcol->define) == SUCCESS) { if (outcol->define->type) { @@ -679,7 +769,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } if (dynamic == OCI_DYNAMIC_FETCH) { - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCIDefineByPos, ( statement->stmt, /* IN/OUT handle to the requested SQL query */ @@ -697,7 +787,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) ); } else { - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCIDefineByPos, ( statement->stmt, /* IN/OUT handle to the requested SQL query */ @@ -716,10 +806,10 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); - return 0; + return 1; } /* additional OCIDefineDynamic() call */ @@ -729,7 +819,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) case SQLT_BLOB: case SQLT_CLOB: case SQLT_BFILE: - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCIDefineDynamic, ( outcol->oci_define, @@ -739,9 +829,15 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) ) ); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); + PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); + return 1; + } break; } } + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } return 0; @@ -752,10 +848,9 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) Cancel statement */ int php_oci_statement_cancel(php_oci_statement *statement TSRMLS_DC) { - return php_oci_statement_fetch(statement, 0 TSRMLS_CC); - -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_free() Destroy statement handle and free associated resources */ @@ -764,15 +859,15 @@ void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC) if (statement->stmt) { if (statement->last_query_len) { /* FIXME: magical */ PHP_OCI_CALL(OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, statement->errcode ? OCI_STRLS_CACHE_DELETE : OCI_DEFAULT)); - } else { + } else if (statement->impres_flag != PHP_OCI_IMPRES_IS_CHILD) { /* Oracle doc says don't free Implicit Result Set handles */ PHP_OCI_CALL(OCIHandleFree, (statement->stmt, OCI_HTYPE_STMT)); } - statement->stmt = 0; + statement->stmt = NULL; } if (statement->err) { PHP_OCI_CALL(OCIHandleFree, (statement->err, OCI_HTYPE_ERROR)); - statement->err = 0; + statement->err = NULL; } if (statement->last_query) { @@ -798,11 +893,12 @@ void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC) zend_list_delete(statement->parent_stmtid); } - zend_list_delete(statement->connection->rsrc_id); + zend_list_delete(statement->connection->id); efree(statement); OCI_G(num_statements)--; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_pre_exec() Helper function */ @@ -872,6 +968,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) { php_oci_bind *bind = (php_oci_bind *) data; php_oci_connection *connection = bind->parent_statement->connection; + sword errstatus; if (bind->indicator == -1) { /* NULL */ zval *val = bind->zval; @@ -931,24 +1028,26 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) memset((void*)buff,0,sizeof(buff)); if ((i < bind->array.old_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); zval_dtor(*entry); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); ZVAL_NULL(*entry); } else { + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ ZVAL_STRINGL(*entry, (char *)buff, buff_len, 1); } zend_hash_move_forward(hash); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); - if (connection->errcode != OCI_SUCCESS) { - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + PHP_OCI_CALL_RETURN(errstatus, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); + if (errstatus != OCI_SUCCESS) { + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); add_next_index_null(bind->zval); } else { + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ add_next_index_stringl(bind->zval, (char *)buff, buff_len, 1); } } @@ -982,7 +1081,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) /* {{{ php_oci_bind_by_name() Bind zval to the given placeholder */ -int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long maxlength, ub2 type TSRMLS_DC) +int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, long maxlength, ub2 type TSRMLS_DC) { php_oci_collection *bind_collection = NULL; php_oci_descriptor *bind_descriptor = NULL; @@ -994,6 +1093,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, php_oci_bind bind, *old_bind, *bindp; int mode = OCI_DATA_AT_EXEC; sb4 value_sz = -1; + sword errstatus; switch (type) { case SQLT_NTY: @@ -1117,7 +1217,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, bindp->type = type; zval_add_ref(&var); - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCIBindByName, ( statement->stmt, /* statement handle */ @@ -1137,14 +1237,14 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, ) ); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } if (mode == OCI_DATA_AT_EXEC) { - PHP_OCI_CALL_RETURN(statement->errcode, OCIBindDynamic, + PHP_OCI_CALL_RETURN(errstatus, OCIBindDynamic, ( bindp->bind, statement->err, @@ -1155,8 +1255,8 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, ) ); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } @@ -1164,7 +1264,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, if (type == SQLT_NTY) { /* Bind object */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIBindObject, + PHP_OCI_CALL_RETURN(errstatus, OCIBindObject, ( bindp->bind, statement->err, @@ -1176,15 +1276,17 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, ) ); - if (statement->errcode) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } } + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_in_callback() Callback used when binding LOBs and VARCHARs */ @@ -1235,7 +1337,8 @@ sb4 php_oci_bind_in_callback( *piecep = OCI_ONE_PIECE; /* pass all data in one go */ return OCI_CONTINUE; -}/* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_out_callback() Callback used when binding LOBs and VARCHARs */ @@ -1358,55 +1461,61 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME zval_dtor(&tmp); } return column; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_get_type() Return type of the statement */ int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type TSRMLS_DC) { ub2 statement_type; + sword errstatus; *type = 0; - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement_type, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement_type, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } - + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ *type = statement_type; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_get_numrows() Get the number of rows fetched to the clientside (NOT the number of rows in the result set) */ int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSRMLS_DC) { ub4 statement_numrows; + sword errstatus; *numrows = 0; - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub4 *)&statement_numrows, (ub4 *)0, OCI_ATTR_ROW_COUNT, statement->err)); + PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub4 *)&statement_numrows, (ub4 *)0, OCI_ATTR_ROW_COUNT, statement->err)); - if (statement->errcode != OCI_SUCCESS) { - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + if (errstatus != OCI_SUCCESS) { + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } - + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ *numrows = statement_numrows; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_by_name() Bind arrays to PL/SQL types */ -int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long max_table_length, long maxlength, long type TSRMLS_DC) +int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, long max_table_length, long maxlength, long type TSRMLS_DC) { php_oci_bind *bind, *bindp; + sword errstatus; convert_to_array(var); @@ -1470,7 +1579,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam zval_add_ref(&var); - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(errstatus, OCIBindByName, ( statement->stmt, @@ -1491,19 +1600,21 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam ); - if (statement->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { efree(bind); - statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); + statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } + statement->errcode = 0; /* retain backwards compat with OCI8 1.4 */ efree(bind); return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_string() Bind arrays to PL/SQL types */ -php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, long maxlength TSRMLS_DC) +php_oci_bind *php_oci_bind_array_helper_string(zval *var, long max_table_length, long maxlength TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1568,11 +1679,12 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_number() Bind arrays to PL/SQL types */ -php_oci_bind *php_oci_bind_array_helper_number(zval* var, long max_table_length TSRMLS_DC) +php_oci_bind *php_oci_bind_array_helper_number(zval *var, long max_table_length TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1606,11 +1718,12 @@ php_oci_bind *php_oci_bind_array_helper_number(zval* var, long max_table_length zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_double() Bind arrays to PL/SQL types */ -php_oci_bind *php_oci_bind_array_helper_double(zval* var, long max_table_length TSRMLS_DC) +php_oci_bind *php_oci_bind_array_helper_double(zval *var, long max_table_length TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1644,16 +1757,18 @@ php_oci_bind *php_oci_bind_array_helper_double(zval* var, long max_table_length zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_date() Bind arrays to PL/SQL types */ -php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, php_oci_connection *connection TSRMLS_DC) +php_oci_bind *php_oci_bind_array_helper_date(zval *var, long max_table_length, php_oci_connection *connection TSRMLS_DC) { php_oci_bind *bind; ub4 i; HashTable *hash; zval **entry; + sword errstatus; hash = HASH_OF(var); @@ -1675,14 +1790,14 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { convert_to_string_ex(entry); - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (CONST text *)Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date)); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { /* failed to convert string to date */ efree(bind->array.element_lengths); efree(bind->array.elements); efree(bind); - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return NULL; } @@ -1690,25 +1805,27 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p ((OCIDate *)bind->array.elements)[i] = oci_date; zend_hash_move_forward(hash); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (CONST text *)"01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)"01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date)); - if (connection->errcode != OCI_SUCCESS) { + if (errstatus != OCI_SUCCESS) { /* failed to convert string to date */ efree(bind->array.element_lengths); efree(bind->array.elements); efree(bind); - connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); + connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return NULL; } ((OCIDate *)bind->array.elements)[i] = oci_date; } + connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */ } zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml index feadf1907b..fcab20cc45 100644 --- a/ext/oci8/package.xml +++ b/ext/oci8/package.xml @@ -6,7 +6,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> <name>oci8</name> <channel>pecl.php.net</channel> <summary>Extension for Oracle Database</summary> - <description>This extension allows you to access Oracle databases. It can be built with PHP 4.3.9 to 5.x. It can be linked with Oracle 9.2, 10, 11, or 12.1 client libraries. + + <description> + This extension allows you to access Oracle Database. OCI8 2.0 can + be built with PHP 4.3.9 onwards. OCI8 can be linked with Oracle + Database 9.2, 10, 11, or 12.1 client libraries. Oracle's standard + cross-version connectivity applies. For example PHP linked with + Oracle Database 11.2 client libraries can connect to Oracle + Database 9.2 onwards. </description> <lead> <name>Christopher Jones</name> @@ -18,7 +25,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> <name>Antony Dovgal</name> <user>tony2001</user> <email>tony2001@php.net</email> - <active>yes</active> + <active>no</active> </lead> <lead> <name>Wez Furlong</name> @@ -33,21 +40,24 @@ http://pear.php.net/dtd/package-2.0.xsd"> <active>no</active> </lead> - <date>2013-07-08</date> + <date>2013-09-06</date> <time>12:00:00</time> - <version> - <release>1.4.10</release> - <api>1.4.10</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <license uri="http://www.php.net/license">PHP</license> - <notes> - Bump PECL package info version check to allow PECL installs with PHP 5.5+ - </notes> + <version> + <release>2.0.2</release> + <api>2.0.2</api> + </version> + <stability> + <release>devel</release> + <api>devel</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes> +Review and improve error handling code and data types. +Fix oci_set_*($connection, ...) error handling so oci_error($connection) works. +Add DTrace oci8-connection-close probe +Add the connection handle to several DTrace probes. + </notes> <contents> <dir name="/"> <dir name="tests"> @@ -94,6 +104,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="bind_misccoltypes.phpt" role="test" /> <file name="bind_number.phpt" role="test" /> <file name="bind_query.phpt" role="test" /> + <file name="bind_raw_2.phpt" role="test" /> <file name="bind_raw.phpt" role="test" /> <file name="bind_rowid.phpt" role="test" /> <file name="bind_sqltafc.phpt" role="test" /> @@ -287,6 +298,38 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="field_funcs_old.phpt" role="test" /> <file name="field_funcs.phpt" role="test" /> <file name="function_aliases.phpt" role="test" /> + <file name="imp_res_1.phpt" role="test" /> + <file name="imp_res_2.phpt" role="test" /> + <file name="imp_res_3.phpt" role="test" /> + <file name="imp_res_4.phpt" role="test" /> + <file name="imp_res_5.phpt" role="test" /> + <file name="imp_res_6.phpt" role="test" /> + <file name="imp_res_7.phpt" role="test" /> + <file name="imp_res_call_error.phpt" role="test" /> + <file name="imp_res_cancel.phpt" role="test" /> + <file name="imp_res_close.phpt" role="test" /> + <file name="imp_res_cursor.phpt" role="test" /> + <file name="imp_res_dbmsoutput.phpt" role="test" /> + <file name="imp_res_field.phpt" role="test" /> + <file name="imp_res_func_error.phpt" role="test" /> + <file name="imp_res_get_1.phpt" role="test" /> + <file name="imp_res_get_2.phpt" role="test" /> + <file name="imp_res_get_3.phpt" role="test" /> + <file name="imp_res_get_4.phpt" role="test" /> + <file name="imp_res_get_5.phpt" role="test" /> + <file name="imp_res_get_all.phpt" role="test" /> + <file name="imp_res_get_cancel.phpt" role="test" /> + <file name="imp_res_get_close_1.phpt" role="test" /> + <file name="imp_res_get_close_2.phpt" role="test" /> + <file name="imp_res_get_close_3.phpt" role="test" /> + <file name="imp_res_get_cursor.phpt" role="test" /> + <file name="imp_res_get_dbmsoutput.phpt" role="test" /> + <file name="imp_res_get_exec.phpt" role="test" /> + <file name="imp_res_get_none.phpt" role="test" /> + <file name="imp_res_insert.phpt" role="test" /> + <file name="imp_res_lob.phpt" role="test" /> + <file name="imp_res_prefetch.phpt" role="test" /> + <file name="ini_1.phpt" role="test" /> <file name="lob_001.phpt" role="test" /> <file name="lob_002.phpt" role="test" /> <file name="lob_003.phpt" role="test" /> @@ -335,6 +378,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="lob_aliases.phpt" role="test" /> <file name="lob_null.phpt" role="test" /> <file name="lob_temp1.phpt" role="test" /> + <file name="lob_temp2.phpt" role="test" /> <file name="lob_temp.phpt" role="test" /> <file name="minfo.phpt" role="test" /> <file name="null_byte_1.phpt" role="test" /> @@ -383,13 +427,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="config.w32" role="src" /> <file name="CREDITS" role="doc" /> <file name="oci8.c" role="src" /> - <file name="oci8.dsp" role="src" /> + <file name="oci8_dtrace.d" role="src" /> <file name="oci8_collection.c" role="src" /> <file name="oci8_interface.c" role="src" /> <file name="oci8_lob.c" role="src" /> <file name="oci8_statement.c" role="src" /> <file name="php_oci8.h" role="src" /> <file name="php_oci8_int.h" role="src" /> + <file name="oci8.dsp" role="src" /> <file name="README" role="doc" /> </dir> <!-- / --> </contents> @@ -411,6 +456,116 @@ http://pear.php.net/dtd/package-2.0.xsd"> <changelog> <release> + <version> + <release>2.0.1</release> + <api>2.0.1</api> + </version> + <stability> + <release>devel</release> + <api>devel</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes> +Fixed --enable-maintainer-zts mode. +Allow Implicit Result Set statement resources to inherit the parent's current prefetch count. +Allow OCI8 to be DTrace-enabled independently from core PHP. +Require OCI8 to be configured 'shared' when enabling DTrace support. + </notes> +</release> + +<release> + <version> + <release>2.0.0</release> + <api>2.0.0</api> + </version> + <stability> + <release>devel</release> + <api>devel</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes> +- NEW FUNCTIONALITY: + + - Added Implicit Result Set support for Oracle Database 12c. + Streaming of all IRS's returned from a PL/SQL block is available + via oci_fetch_array, oci_fetch_assoc, oci_fetch_object and + oci_fetch_row (but not oci_fetch or oci_fetch_all). + Alternatively individual IRS statement resources can be obtained + with the new function 'oci_get_implicit_resultset' and passed to + any oci_fetch_* function. + + - Added DTrace probes enabled with PHP's generic --enable-dtrace + +- IMPROVED FUNCTIONALITY: + + - Using 'oci_execute($s, OCI_NO_AUTO_COMMIT)' for a SELECT no + longer unnecessarily initiates an internal ROLLBACK during + connection close. This can improve overall scalability by + reducing "round trips" between PHP and the database. + +- CHANGED FUNCTIONALITY: + + - PHPINFO() CHANGES: + + - The oci8.event and oci8.connection_class values are now shown + only when the Oracle client libraries support the respective + functionality. + + - Connection statistics are now in a separate phpinfo() table. + + - Temporary LOB and Collection support status lines in + phpinfo() were removed. These features have always been + enabled since 2007. + + - OCI_INTERNAL_DEBUG() CHANGES: + + - The oci_internal_debug() function is now a no-op. Use PHP's + --enable-dtrace functionality with DTrace or SystemTap instead. + +- INTERNAL CHANGES: + + - Fixed a potential NULL pointer dereference flagged by Parfait + static code analysis. + + - Extended testing of existing OCI8 functionality. + + - Improved test output portability when using the PHP development + web server to run tests. + + - Removed no-longer necessary Unicode patterns from tests + (vestiges of PHP's previous PHP 6 project) + + - Improved build portability by removing compilation type cast + warnings with some compilers. + + - Fixed compilation warnings when building with Oracle 9.2 + client libraries. + + - Updated code to use internal macro PHP_OCI_REGISTER_RESOURCE. + + - Regularized code prototypes and fixed some in-line documentation + prototypes. + + - Fixed code folding. + </notes> +</release> + +<release> + <version> + <release>1.4.10</release> + <api>1.4.10</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes> + Bump PECL package info version check to allow PECL installs with PHP 5.5+ + </notes> +</release> + +<release> <version> <release>1.4.9</release> <api>1.4.9</api> @@ -457,7 +612,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> Fixed OCI8 part of bug #55748 (CVE-2011-4153: multiple NULL pointer dereferences with zend_strndup) Fixed OCI8 part of bug #55301 (multiple null pointer dereferences with calloc) Increased maximum Oracle error message buffer length for new Oracle 11.2.0.3 size - Improve internal initalization failure error messages + Improve internal initialization failure error messages </notes> </release> @@ -472,7 +627,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> </stability> <license uri="http://www.php.net/license">PHP</license> <notes> - Added oci_client_version() returning the runtime Oracle client library version + Added oci_client_version() returning the run time Oracle client library version Made OCI8 extension buildable with PHP 5.4-development code </notes> </release> @@ -846,7 +1001,7 @@ Fixed bug #36820 (Privileged connection with an Oracle password file fails) <date>2006-03-16</date> <license uri="http://www.php.net/license">PHP</license> <notes>Changed OCI8 code to use OCIServerVersion() instead of OCIPing(), which may crash Oracle server of version < 10.2 -Fixed bug #36235 (ocicolumnname returns false before a successfull fetch) +Fixed bug #36235 (ocicolumnname returns false before a successful fetch) Fixed bug #36096 (oci_result() returns garbage after oci_fetch() failed) Fixed bug #36055 (possible OCI8 crash in multithreaded environment) Fixed bug #36010 (Segfault when re-creating and re-executing statements with bound parameters) diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h index f1079526f6..8c5fba9ab0 100644 --- a/ext/oci8/php_oci8.h +++ b/ext/oci8/php_oci8.h @@ -46,7 +46,7 @@ */ #undef PHP_OCI8_VERSION #endif -#define PHP_OCI8_VERSION "1.4.10" +#define PHP_OCI8_VERSION "2.0.2-dev" extern zend_module_entry oci8_module_entry; #define phpext_oci8_ptr &oci8_module_entry diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index 155e57d2cd..6155a883b0 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -31,7 +31,7 @@ # ifndef PHP_OCI8_INT_H # define PHP_OCI8_INT_H -/* misc defines {{{ */ +/* {{{ misc defines */ # if (defined(__osf__) && defined(__alpha)) # ifndef A_OSF # define A_OSF @@ -44,6 +44,10 @@ # endif # endif /* osf alpha */ +#ifdef HAVE_OCI8_DTRACE +#include "oci8_dtrace_gen.h" +#endif + #if defined(min) #undef min #endif @@ -66,7 +70,7 @@ extern int le_session; extern zend_class_entry *oci_lob_class_entry_ptr; extern zend_class_entry *oci_coll_class_entry_ptr; -/* constants {{{ */ +/* {{{ constants */ #define PHP_OCI_SEEK_SET 0 #define PHP_OCI_SEEK_CUR 1 #define PHP_OCI_SEEK_END 2 @@ -101,6 +105,11 @@ extern zend_class_entry *oci_coll_class_entry_ptr; #error Invalid value for PHP_OCI_CRED_EXT #endif +#define PHP_OCI_IMPRES_UNKNOWN 0 +#define PHP_OCI_IMPRES_NO_CHILDREN 1 +#define PHP_OCI_IMPRES_HAS_CHILDREN 2 +#define PHP_OCI_IMPRES_IS_CHILD 3 + /* * Name passed to Oracle for tracing. Note some DB views only show * the first nine characters of the driver name. @@ -109,16 +118,21 @@ extern zend_class_entry *oci_coll_class_entry_ptr; /* }}} */ -typedef struct { /* php_oci_spool {{{ */ - OCIEnv *env; /*env of this session pool */ +/* {{{ php_oci_spool */ +typedef struct { + int id; /* resource id */ + OCIEnv *env; /* env of this session pool */ OCIError *err; /* pool's error handle */ OCISPool *poolh; /* pool handle */ void *poolname; /* session pool name */ unsigned int poolname_len; /* length of session pool name */ char *spool_hash_key; /* Hash key for session pool in plist */ -} php_oci_spool; /* }}} */ +} php_oci_spool; +/* }}} */ -typedef struct { /* php_oci_connection {{{ */ +/* {{{ php_oci_connection */ +typedef struct { + int id; /* resource ID */ OCIEnv *env; /* private env handle */ ub2 charset; /* charset ID */ OCIServer *server; /* private server handle */ @@ -127,7 +141,7 @@ typedef struct { /* php_oci_connection {{{ */ OCIAuthInfo *authinfo; /* Cached authinfo handle for OCISessionGet */ OCIError *err; /* private error handle */ php_oci_spool *private_spool; /* private session pool (for persistent) */ - sword errcode; /* last errcode */ + sb4 errcode; /* last ORA- error number */ HashTable *descriptors; /* descriptors hash, used to flush all the LOBs using this connection on commit */ ulong descriptor_count; /* used to index the descriptors hash table. Not an accurate count */ @@ -135,17 +149,18 @@ typedef struct { /* php_oci_connection {{{ */ unsigned is_attached:1; /* hels to determine if we should detach from the server when closing/freeing the connection */ unsigned is_persistent:1; /* self-descriptive */ unsigned used_this_request:1; /* helps to determine if we should reset connection's next ping time and check its timeout */ - unsigned needs_commit:1; /* helps to determine if we should rollback this connection on close/shutdown */ + unsigned rb_on_disconnect:1; /* helps to determine if we should rollback this connection on close/shutdown */ unsigned passwd_changed:1; /* helps determine if a persistent connection hash should be invalidated after a password change */ unsigned is_stub:1; /* flag to keep track whether the connection structure has a real OCI connection associated */ unsigned using_spool:1; /* Is this connection from session pool? */ - int rsrc_id; /* resource ID */ time_t idle_expiry; /* time when the connection will be considered as expired */ time_t *next_pingp; /* (pointer to) time of the next ping */ char *hash_key; /* hashed details of the connection */ -} php_oci_connection; /* }}} */ +} php_oci_connection; +/* }}} */ -typedef struct { /* php_oci_descriptor {{{ */ +/* {{{ php_oci_descriptor */ +typedef struct { int id; ulong index; /* descriptors hash table index */ php_oci_connection *connection; /* parent connection handle */ @@ -158,15 +173,19 @@ typedef struct { /* php_oci_descriptor {{{ */ ub1 charset_form; /* charset form, required for NCLOBs */ ub2 charset_id; /* charset ID */ unsigned is_open:1; /* helps to determine if lob is open or not */ -} php_oci_descriptor; /* }}} */ +} php_oci_descriptor; +/* }}} */ -typedef struct { /* php_oci_lob_ctx {{{ */ +/* {{{ php_oci_lob_ctx */ +typedef struct { char **lob_data; /* address of pointer to LOB data */ ub4 *lob_len; /* address of LOB length variable (bytes) */ ub4 alloc_len; -} php_oci_lob_ctx; /* }}} */ +} php_oci_lob_ctx; +/* }}} */ -typedef struct { /* php_oci_collection {{{ */ +/* {{{ php_oci_collection */ +typedef struct { int id; php_oci_connection *connection; /* parent connection handle */ OCIType *tdo; /* collection's type handle */ @@ -175,23 +194,30 @@ typedef struct { /* php_oci_collection {{{ */ OCIType *element_type; /* element's type handle */ OCITypeCode element_typecode; /* element's typecode handle */ OCIColl *collection; /* collection handle */ -} php_oci_collection; /* }}} */ +} php_oci_collection; +/* }}} */ -typedef struct { /* php_oci_define {{{ */ +/* {{{ php_oci_define */ +typedef struct { zval *zval; /* zval used in define */ text *name; /* placeholder's name */ ub4 name_len; /* placeholder's name length */ ub4 type; /* define type */ -} php_oci_define; /* }}} */ +} php_oci_define; +/* }}} */ -typedef struct { /* php_oci_statement {{{ */ +/* {{{ php_oci_statement */ +typedef struct { int id; int parent_stmtid; /* parent statement id */ + struct php_oci_statement *impres_child_stmt;/* child of current Implicit Result Set statement handle */ + ub4 impres_count; /* count of remaining Implicit Result children on parent statement handle */ php_oci_connection *connection; /* parent connection handle */ - sword errcode; /* last errcode*/ + sb4 errcode; /* last ORA- error number */ OCIError *err; /* private error handle */ OCIStmt *stmt; /* statement handle */ - char *last_query; /* last query issued. also used to determine if this is a statement or a refcursor received from Oracle */ + char *last_query; /* last query issued. also used to determine if this is a statement or a refcursor recieved from Oracle */ + char impres_flag; /* PHP_OCI_IMPRES_*_ */ long last_query_len; /* last query length */ HashTable *columns; /* hash containing all the result columns */ HashTable *binds; /* binds hash */ @@ -201,9 +227,12 @@ typedef struct { /* php_oci_statement {{{ */ unsigned has_data:1; /* statement has more data flag */ unsigned has_descr:1; /* statement has at least one descriptor or cursor column */ ub2 stmttype; /* statement type */ -} php_oci_statement; /* }}} */ + ub4 prefetch_count; /* current prefetch count */ +} php_oci_statement; +/* }}} */ -typedef struct { /* php_oci_bind {{{ */ +/* {{{ php_oci_bind */ +typedef struct { OCIBind *bind; /* bind handle */ zval *zval; /* value */ dvoid *descriptor; /* used for binding of LOBS etc */ @@ -222,9 +251,11 @@ typedef struct { /* php_oci_bind {{{ */ sb2 indicator; /* -1 means NULL */ ub2 retcode; ub4 dummy_len; /* a dummy var to store alenpp value in bind OUT callback */ -} php_oci_bind; /* }}} */ +} php_oci_bind; +/* }}} */ -typedef struct { /* php_oci_out_column {{{ */ +/* {{{ php_oci_out_column */ +typedef struct { php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ php_oci_statement *nested_statement; /* statement handle. used when fetching REFCURSORS */ OCIDefine *oci_define; /* define handle */ @@ -249,28 +280,23 @@ typedef struct { /* php_oci_out_column {{{ */ sb2 precision; /* column precision */ ub1 charset_form; /* charset form, required for NCLOBs */ ub2 charset_id; /* charset ID */ -} php_oci_out_column; /* }}} */ +} php_oci_out_column; +/* }}} */ /* {{{ macros */ -#define PHP_OCI_CALL(func, params) \ - do { \ - if (OCI_G(debug_mode)) { \ - php_printf ("OCI8 DEBUG: " #func " at (%s:%d) \n", __FILE__, __LINE__); \ - } \ - OCI_G(in_call) = 1; \ - func params; \ - OCI_G(in_call) = 0; \ +#define PHP_OCI_CALL(func, params) \ + do { \ + OCI_G(in_call) = 1; \ + func params; \ + OCI_G(in_call) = 0; \ } while (0) -#define PHP_OCI_CALL_RETURN(__retval, func, params) \ - do { \ - if (OCI_G(debug_mode)) { \ - php_printf ("OCI8 DEBUG: " #func " at (%s:%d) \n", __FILE__, __LINE__); \ - } \ - OCI_G(in_call) = 1; \ - __retval = func params; \ - OCI_G(in_call) = 0; \ +#define PHP_OCI_CALL_RETURN(__retval, func, params) \ + do { \ + OCI_G(in_call) = 1; \ + __retval = func params; \ + OCI_G(in_call) = 0; \ } while (0) /* Check for errors that indicate the connection to the DB is no @@ -284,6 +310,7 @@ typedef struct { /* php_oci_out_column {{{ */ */ #define PHP_OCI_HANDLE_ERROR(connection, errcode) \ do { \ + ub4 serverStatus = OCI_SERVER_NORMAL; \ switch (errcode) { \ case 1013: \ zend_bailout(); \ @@ -313,7 +340,6 @@ typedef struct { /* php_oci_out_column {{{ */ break; \ default: \ { \ - ub4 serverStatus = OCI_SERVER_NORMAL; \ PHP_OCI_CALL(OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \ (ub4 *)0, OCI_ATTR_SERVER_STATUS, (connection)->err)); \ if (serverStatus != OCI_SERVER_NORMAL) { \ @@ -322,6 +348,7 @@ typedef struct { /* php_oci_out_column {{{ */ } \ break; \ } \ + php_oci_dtrace_check_connection(connection, errcode, serverStatus); \ } while (0) #define PHP_OCI_REGISTER_RESOURCE(resource, le_resource) \ @@ -365,117 +392,110 @@ typedef struct { /* php_oci_out_column {{{ */ /* PROTOS */ -/* main prototypes {{{ */ - -void php_oci_column_hash_dtor (void *data); -void php_oci_define_hash_dtor (void *data); -void php_oci_bind_hash_dtor (void *data); -void php_oci_descriptor_flush_hash_dtor (void *data); +/* {{{ main prototypes */ +void php_oci_column_hash_dtor(void *data); +void php_oci_define_hash_dtor(void *data); +void php_oci_bind_hash_dtor(void *data); +void php_oci_descriptor_flush_hash_dtor(void *data); void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_DC); - -sb4 php_oci_error (OCIError *, sword TSRMLS_DC); -sb4 php_oci_fetch_errmsg(OCIError *, text ** TSRMLS_DC); -int php_oci_fetch_sqltext_offset(php_oci_statement *, text **, ub2 * TSRMLS_DC); - -void php_oci_do_connect (INTERNAL_FUNCTION_PARAMETERS, int , int); +sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC); +sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC); +int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, ub2 *error_offset TSRMLS_DC); +void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclusive); php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, long session_mode, int persistent, int exclusive TSRMLS_DC); - -int php_oci_connection_rollback(php_oci_connection * TSRMLS_DC); -int php_oci_connection_commit(php_oci_connection * TSRMLS_DC); +int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC); +int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC); int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC); - -int php_oci_password_change(php_oci_connection *, char *, int, char *, int, char *, int TSRMLS_DC); -void php_oci_client_get_version(char ** TSRMLS_DC); -int php_oci_server_get_version(php_oci_connection *, char ** TSRMLS_DC); - -void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int, int); -int php_oci_column_to_zval(php_oci_out_column *, zval *, int TSRMLS_DC); +int php_oci_password_change(php_oci_connection *connection, char *user, int user_len, char *pass_old, int pass_old_len, char *pass_new, int pass_new_len TSRMLS_DC); +void php_oci_client_get_version(char **version TSRMLS_DC); +int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC); +void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args); +int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSRMLS_DC); +void php_oci_dtrace_check_connection(php_oci_connection *connection, sb4 errcode, ub4 serverStatus); /* }}} */ -/* lob related prototypes {{{ */ - -php_oci_descriptor * php_oci_lob_create (php_oci_connection *, long TSRMLS_DC); -int php_oci_lob_get_length (php_oci_descriptor *, ub4 * TSRMLS_DC); -int php_oci_lob_read (php_oci_descriptor *, long, long, char **, ub4 * TSRMLS_DC); -int php_oci_lob_write (php_oci_descriptor *, ub4, char *, int, ub4 * TSRMLS_DC); -int php_oci_lob_flush (php_oci_descriptor *, long TSRMLS_DC); -int php_oci_lob_set_buffering (php_oci_descriptor *, int TSRMLS_DC); -int php_oci_lob_get_buffering (php_oci_descriptor *); -int php_oci_lob_copy (php_oci_descriptor *, php_oci_descriptor *, long TSRMLS_DC); -int php_oci_lob_close (php_oci_descriptor * TSRMLS_DC); -int php_oci_temp_lob_close (php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_write_tmp (php_oci_descriptor *, long, char *, int TSRMLS_DC); -void php_oci_lob_free(php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_import(php_oci_descriptor *descriptor, char * TSRMLS_DC); -int php_oci_lob_append (php_oci_descriptor *, php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_truncate (php_oci_descriptor *, long TSRMLS_DC); -int php_oci_lob_erase (php_oci_descriptor *, long, ub4, ub4 * TSRMLS_DC); -int php_oci_lob_is_equal (php_oci_descriptor *, php_oci_descriptor *, boolean * TSRMLS_DC); +/* {{{ lob related prototypes */ + +php_oci_descriptor *php_oci_lob_create(php_oci_connection *connection, long type TSRMLS_DC); +int php_oci_lob_get_length(php_oci_descriptor *descriptor, ub4 *length TSRMLS_DC); +int php_oci_lob_read(php_oci_descriptor *descriptor, long read_length, long inital_offset, char **data, ub4 *data_len TSRMLS_DC); +int php_oci_lob_write(php_oci_descriptor *descriptor, ub4 offset, char *data, int data_len, ub4 *bytes_written TSRMLS_DC); +int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC); +int php_oci_lob_set_buffering(php_oci_descriptor *descriptor, int on_off TSRMLS_DC); +int php_oci_lob_get_buffering(php_oci_descriptor *descriptor); +int php_oci_lob_copy(php_oci_descriptor *descriptor, php_oci_descriptor *descriptor_from, long length TSRMLS_DC); +int php_oci_lob_close(php_oci_descriptor *descriptor TSRMLS_DC); +int php_oci_temp_lob_close(php_oci_descriptor *descriptor TSRMLS_DC); +int php_oci_lob_write_tmp(php_oci_descriptor *descriptor, long type, char *data, int data_len TSRMLS_DC); +void php_oci_lob_free(php_oci_descriptor *descriptor TSRMLS_DC); +int php_oci_lob_import(php_oci_descriptor *descriptor, char *filename TSRMLS_DC); +int php_oci_lob_append(php_oci_descriptor *descriptor_dest, php_oci_descriptor *descriptor_from TSRMLS_DC); +int php_oci_lob_truncate(php_oci_descriptor *descriptor, long new_lob_length TSRMLS_DC); +int php_oci_lob_erase(php_oci_descriptor *descriptor, long offset, ub4 length, ub4 *bytes_erased TSRMLS_DC); +int php_oci_lob_is_equal(php_oci_descriptor *descriptor_first, php_oci_descriptor *descriptor_second, boolean *result TSRMLS_DC); #if defined(HAVE_OCI_LOB_READ2) -sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp); +sb4 php_oci_lob_callback(dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp); #else -sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece); +sb4 php_oci_lob_callback(dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece); #endif /* }}} */ -/* collection related prototypes {{{ */ - -php_oci_collection * php_oci_collection_create(php_oci_connection *, char *, int, char *, int TSRMLS_DC); -int php_oci_collection_size(php_oci_collection *, sb4 * TSRMLS_DC); -int php_oci_collection_max(php_oci_collection *, long * TSRMLS_DC); -int php_oci_collection_trim(php_oci_collection *, long TSRMLS_DC); -int php_oci_collection_append(php_oci_collection *, char *, int TSRMLS_DC); -int php_oci_collection_element_get(php_oci_collection *, long, zval** TSRMLS_DC); -int php_oci_collection_element_set(php_oci_collection *, long, char *, int TSRMLS_DC); -int php_oci_collection_element_set_null(php_oci_collection *, long TSRMLS_DC); -int php_oci_collection_element_set_date(php_oci_collection *, long, char *, int TSRMLS_DC); -int php_oci_collection_element_set_number(php_oci_collection *, long, char *, int TSRMLS_DC); -int php_oci_collection_element_set_string(php_oci_collection *, long, char *, int TSRMLS_DC); -int php_oci_collection_assign(php_oci_collection *, php_oci_collection * TSRMLS_DC); -void php_oci_collection_close(php_oci_collection * TSRMLS_DC); -int php_oci_collection_append_null(php_oci_collection * TSRMLS_DC); -int php_oci_collection_append_date(php_oci_collection *, char *, int TSRMLS_DC); -int php_oci_collection_append_number(php_oci_collection *, char *, int TSRMLS_DC); -int php_oci_collection_append_string(php_oci_collection *, char *, int TSRMLS_DC); +/* {{{ collection related prototypes */ + +php_oci_collection *php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC); +int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC); +int php_oci_collection_max(php_oci_collection *collection, long *max TSRMLS_DC); +int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRMLS_DC); +int php_oci_collection_append(php_oci_collection *collection, char *element, int element_len TSRMLS_DC); +int php_oci_collection_element_get(php_oci_collection *collection, long index, zval **result_element TSRMLS_DC); +int php_oci_collection_element_set(php_oci_collection *collection, long index, char *value, int value_len TSRMLS_DC); +int php_oci_collection_element_set_null(php_oci_collection *collection, long index TSRMLS_DC); +int php_oci_collection_element_set_date(php_oci_collection *collection, long index, char *date, int date_len TSRMLS_DC); +int php_oci_collection_element_set_number(php_oci_collection *collection, long index, char *number, int number_len TSRMLS_DC); +int php_oci_collection_element_set_string(php_oci_collection *collection, long index, char *element, int element_len TSRMLS_DC); +int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_collection *collection_from TSRMLS_DC); +void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC); +int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC); +int php_oci_collection_append_date(php_oci_collection *collection, char *date, int date_len TSRMLS_DC); +int php_oci_collection_append_number(php_oci_collection *collection, char *number, int number_len TSRMLS_DC); +int php_oci_collection_append_string(php_oci_collection *collection, char *element, int element_len TSRMLS_DC); /* }}} */ -/* statement related prototypes {{{ */ +/* {{{ statement related prototypes */ -php_oci_statement * php_oci_statement_create (php_oci_connection *, char *, int TSRMLS_DC); -int php_oci_statement_set_prefetch (php_oci_statement *, long TSRMLS_DC); -int php_oci_statement_fetch (php_oci_statement *, ub4 TSRMLS_DC); -php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, char *, int TSRMLS_DC); -int php_oci_statement_execute (php_oci_statement *, ub4 TSRMLS_DC); -int php_oci_statement_cancel (php_oci_statement * TSRMLS_DC); -void php_oci_statement_free (php_oci_statement * TSRMLS_DC); +php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char *query, int query_len TSRMLS_DC); +php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement TSRMLS_DC); +int php_oci_statement_set_prefetch(php_oci_statement *statement, ub4 prefetch TSRMLS_DC); +int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC); +php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, long column_index, char *column_name, int column_name_len TSRMLS_DC); +int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC); +int php_oci_statement_cancel(php_oci_statement *statement TSRMLS_DC); +void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC); int php_oci_bind_pre_exec(void *data, void *result TSRMLS_DC); int php_oci_bind_post_exec(void *data TSRMLS_DC); -int php_oci_bind_by_name(php_oci_statement *, char *, int, zval*, long, ub2 TSRMLS_DC); -sb4 php_oci_bind_in_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 *, ub1 *, dvoid **); -sb4 php_oci_bind_out_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 **, ub1 *, dvoid **, ub2 **); +int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, long maxlength, ub2 type TSRMLS_DC); +sb4 php_oci_bind_in_callback(dvoid *ictxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 *alenp, ub1 *piecep, dvoid **indpp); +sb4 php_oci_bind_out_callback(dvoid *octxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcodepp); php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data); int php_oci_cleanup_pre_fetch(void *data TSRMLS_DC); - -int php_oci_statement_get_type(php_oci_statement *, ub2 * TSRMLS_DC); -int php_oci_statement_get_numrows(php_oci_statement *, ub4 * TSRMLS_DC); -int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long max_table_length, long maxlength, long type TSRMLS_DC); -php_oci_bind *php_oci_bind_array_helper_number(zval* var, long max_table_length TSRMLS_DC); -php_oci_bind *php_oci_bind_array_helper_double(zval* var, long max_table_length TSRMLS_DC); -php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, long maxlength TSRMLS_DC); -php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, php_oci_connection *connection TSRMLS_DC); +int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type TSRMLS_DC); +int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSRMLS_DC); +int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, long max_table_length, long maxlength, long type TSRMLS_DC); +php_oci_bind *php_oci_bind_array_helper_number(zval *var, long max_table_length TSRMLS_DC); +php_oci_bind *php_oci_bind_array_helper_double(zval *var, long max_table_length TSRMLS_DC); +php_oci_bind *php_oci_bind_array_helper_string(zval *var, long max_table_length, long maxlength TSRMLS_DC); +php_oci_bind *php_oci_bind_array_helper_date(zval *var, long max_table_length, php_oci_connection *connection TSRMLS_DC); /* }}} */ -ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ */ - sword errcode; /* global last error code (used when connect fails, for example) */ +ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ Module globals */ + sb4 errcode; /* global last ORA- error number. Used when connect fails, for example */ OCIError *err; /* global error handle */ - zend_bool debug_mode; /* debug mode flag */ - long max_persistent; /* maximum number of persistent connections per process */ long num_persistent; /* number of existing persistent connections */ long num_links; /* non-persistent + persistent connections */ diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt index 91fa4b75b7..d68991a7f2 100644 --- a/ext/oci8/tests/bind_char_1.phpt +++ b/ext/oci8/tests/bind_char_1.phpt @@ -5,12 +5,15 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_1_11gR1.phpt b/ext/oci8/tests/bind_char_1_11gR1.phpt index a7feff9f6a..2a7c713aa7 100644 --- a/ext/oci8/tests/bind_char_1_11gR1.phpt +++ b/ext/oci8/tests/bind_char_1_11gR1.phpt @@ -5,10 +5,12 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt index 43661a065d..3695c85854 100644 --- a/ext/oci8/tests/bind_char_2.phpt +++ b/ext/oci8/tests/bind_char_2.phpt @@ -5,12 +5,15 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_2_11gR1.phpt b/ext/oci8/tests/bind_char_2_11gR1.phpt index edb2a12ff0..b9afd6940b 100644 --- a/ext/oci8/tests/bind_char_2_11gR1.phpt +++ b/ext/oci8/tests/bind_char_2_11gR1.phpt @@ -5,10 +5,12 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt index 25115836df..009e60a542 100644 --- a/ext/oci8/tests/bind_char_3.phpt +++ b/ext/oci8/tests/bind_char_3.phpt @@ -5,12 +5,15 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_3_11gR1.phpt b/ext/oci8/tests/bind_char_3_11gR1.phpt index fea77754d1..a894de00c0 100644 --- a/ext/oci8/tests/bind_char_3_11gR1.phpt +++ b/ext/oci8/tests/bind_char_3_11gR1.phpt @@ -5,10 +5,12 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt index 36765f8137..0ac60e503d 100644 --- a/ext/oci8/tests/bind_char_4.phpt +++ b/ext/oci8/tests/bind_char_4.phpt @@ -5,12 +5,15 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_4_11gR1.phpt b/ext/oci8/tests/bind_char_4_11gR1.phpt index 2bc2f14246..d5ce116afb 100644 --- a/ext/oci8/tests/bind_char_4_11gR1.phpt +++ b/ext/oci8/tests/bind_char_4_11gR1.phpt @@ -5,10 +5,12 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_unsupported_2.phpt b/ext/oci8/tests/bind_unsupported_2.phpt index d3e5375df6..a2bf9de5a6 100644 --- a/ext/oci8/tests/bind_unsupported_2.phpt +++ b/ext/oci8/tests/bind_unsupported_2.phpt @@ -3,7 +3,8 @@ Bind with various unsupported 10g+ bind types --SKIPIF-- <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); -if (preg_match('/^1[01]\./', oci_client_version()) !== 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die ("skip expected output only valid for Oracle 10g+ clients"); } ?> diff --git a/ext/oci8/tests/bug27303_1.phpt b/ext/oci8/tests/bug27303_1.phpt index 40ab4ebed2..0ef47f13dd 100644 --- a/ext/oci8/tests/bug27303_1.phpt +++ b/ext/oci8/tests/bug27303_1.phpt @@ -5,12 +5,15 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && - preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); - // Other point releases may also work +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bug27303_1_11gR1.phpt b/ext/oci8/tests/bug27303_1_11gR1.phpt index 6de9b99378..7b4c158561 100644 --- a/ext/oci8/tests/bug27303_1_11gR1.phpt +++ b/ext/oci8/tests/bug27303_1_11gR1.phpt @@ -5,12 +5,13 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using specific Oracle database versions"); - } - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) || + ($matches[1] == 11 && $matches[2] == 1 && $matches[3] == 0 && $matches[4] == 6) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt index 1fb2b31682..72d4e5a7dd 100644 --- a/ext/oci8/tests/bug27303_2.phpt +++ b/ext/oci8/tests/bug27303_2.phpt @@ -5,12 +5,15 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && - preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); - // Other point releases may also work +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bug27303_2_11gR1.phpt b/ext/oci8/tests/bug27303_2_11gR1.phpt index 1e3e3105ad..27d8a585bd 100644 --- a/ext/oci8/tests/bug27303_2_11gR1.phpt +++ b/ext/oci8/tests/bug27303_2_11gR1.phpt @@ -5,12 +5,13 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using specific Oracle database versions"); - } - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) || + ($matches[1] == 11 && $matches[2] == 1 && $matches[3] == 0 && $matches[4] == 6) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using specific Oracle database versions"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt index 3137db8659..a24ae705ab 100644 --- a/ext/oci8/tests/bug27303_4.phpt +++ b/ext/oci8/tests/bug27303_4.phpt @@ -5,12 +5,16 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && - preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); - // Other point releases may also work +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); + // Other point releases may also work } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bug27303_4_11gR1.phpt b/ext/oci8/tests/bug27303_4_11gR1.phpt index f9bc2da8a2..01db1dc5a0 100644 --- a/ext/oci8/tests/bug27303_4_11gR1.phpt +++ b/ext/oci8/tests/bug27303_4_11gR1.phpt @@ -5,12 +5,13 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using specific Oracle database versions"); - } - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) || + ($matches[1] == 11 && $matches[2] == 1 && $matches[3] == 0 && $matches[4] == 6) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using specific Oracle database versions"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug36403.phpt b/ext/oci8/tests/bug36403.phpt index 53dae694ec..4ac32c4b06 100644 --- a/ext/oci8/tests/bug36403.phpt +++ b/ext/oci8/tests/bug36403.phpt @@ -3,8 +3,9 @@ Bug #36403 (oci_execute no longer supports OCI_DESCRIBE_ONLY) --SKIPIF-- <?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); -if (preg_match('/^1[01]\./', oci_client_version()) != 1) { - die("skip expected output only valid with Oracle 10g or greater version of client"); +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { + die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug43497.phpt b/ext/oci8/tests/bug43497.phpt index 8c57fabeef..05798889c4 100644 --- a/ext/oci8/tests/bug43497.phpt +++ b/ext/oci8/tests/bug43497.phpt @@ -5,8 +5,9 @@ Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory) $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 (preg_match('/^1[01]\./', oci_client_version()) != 1) { - die("skip expected output only valid with Oracle 10g or greater version of client"); +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { + die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug47281.phpt b/ext/oci8/tests/bug47281.phpt index d0e0023537..0098ec5ebb 100644 --- a/ext/oci8/tests/bug47281.phpt +++ b/ext/oci8/tests/bug47281.phpt @@ -6,11 +6,12 @@ $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on t require(dirname(__FILE__).'/skipif.inc'); // error3.phpt obsoletes this test for newer Oracle client versions // Assume runtime client version is >= compile time client version -$cv = explode('.', oci_client_version()); -if ($cv[0] > 11 || ($cv[0] == 11 && $cv[1] > 2) || ($cv[0] == 11 && $cv[1] == 2 && $cv[3] >= 3)) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!isset($matches[0]) || + ($matches[0] > 11 || ($matches[0] == 11 && $matches[1] > 2) || ($matches[0] == 11 && $matches[1] == 2 && $matches[3] >= 3) + )) { die("skip test works only with Oracle 11.2.0.2 or earlier Oracle client libraries"); } - ?> --ENV-- NLS_LANG=.AL32UTF8 diff --git a/ext/oci8/tests/commit_001.phpt b/ext/oci8/tests/commit_001.phpt index 806fb193a0..ef4018118e 100644 --- a/ext/oci8/tests/commit_001.phpt +++ b/ext/oci8/tests/commit_001.phpt @@ -81,48 +81,48 @@ echo "Done\n"; bool(true) int(0) array(5) { - [%u|b%"ID"]=> + ["ID"]=> array(0) { } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(0) { } - [%u|b%"BLOB"]=> + ["BLOB"]=> array(0) { } - [%u|b%"CLOB"]=> + ["CLOB"]=> array(0) { } - [%u|b%"STRING"]=> + ["STRING"]=> array(0) { } } bool(true) int(4) array(5) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %string|unicode%(1) "1" + string(1) "1" [1]=> - %string|unicode%(1) "1" + string(1) "1" [2]=> - %string|unicode%(1) "1" + string(1) "1" [3]=> - %string|unicode%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %string|unicode%(1) "1" + string(1) "1" [1]=> - %string|unicode%(1) "1" + string(1) "1" [2]=> - %string|unicode%(1) "1" + string(1) "1" [3]=> - %string|unicode%(1) "1" + string(1) "1" } - [%u|b%"BLOB"]=> + ["BLOB"]=> array(4) { [0]=> NULL @@ -133,7 +133,7 @@ array(5) { [3]=> NULL } - [%u|b%"CLOB"]=> + ["CLOB"]=> array(4) { [0]=> NULL @@ -144,7 +144,7 @@ array(5) { [3]=> NULL } - [%u|b%"STRING"]=> + ["STRING"]=> array(4) { [0]=> NULL diff --git a/ext/oci8/tests/conn_attr.inc b/ext/oci8/tests/conn_attr.inc index 220e688210..2edc1c9552 100644 --- a/ext/oci8/tests/conn_attr.inc +++ b/ext/oci8/tests/conn_attr.inc @@ -2,30 +2,28 @@ require(dirname(__FILE__)."/connect.inc"); -$sv = oci_server_version($c); -$sv = preg_match('/Release (11\.2|12)\./', $sv, $matches); -if ($sv == 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if ((isset($matches[1]) && $matches[1] >= 11)) { // Server is Oracle 11.2+ $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuser", - "grant connect,resource,dba to testuser", - "alter user testuser enable editions", - "drop edition myedition1", - "drop edition myedition", - "grant create any edition to testuser", + "drop user $testuser cascade", + "create user $testuser identified by $testpassword", // $testuser should be set by the file that includes conn_attr.inc + "grant connect,resource,dba to $testuser", + "alter user $testuser enable editions", + "drop edition myedition1 cascade", + "drop edition myedition cascade", + "grant create any edition to $testuser", "create edition myedition", "create edition myedition1 as child of myedition", - "grant use on edition myedition to testuser", - "grant use on edition myedition1 to testuser", + "grant use on edition myedition to $testuser", + "grant use on edition myedition1 to $testuser", ); -} -else { +} else { // Server is Pre 11.2 $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuser", - "grant connect,resource,dba to testuser", + "drop user $testuser cascade", + "create user $testuser identified by $testpassword", + "grant connect,resource,dba to $testuser", ); } @@ -68,8 +66,8 @@ function get_attr($conn,$attr) function get_conn($conn_type) { - $user = 'testuser'; - $password = 'testuser'; + $user = $GLOBALS['testuser']; + $password = $GLOBALS['testpassword']; $dbase = $GLOBALS['dbase']; switch($conn_type) { case 1: @@ -139,9 +137,9 @@ function get_sys_attr($conn,$attr) function clean_up($c) { $stmtarray = array( - "drop user testuser cascade", - "drop edition myedition1", - "drop edition myedition", + "drop edition myedition1 cascade", + "drop edition myedition cascade", + "drop user " . $GLOBALS['testuser'] . " cascade", ); foreach ($stmtarray as $stmt) { diff --git a/ext/oci8/tests/conn_attr_1.phpt b/ext/oci8/tests/conn_attr_1.phpt index ad508a2ed2..631bc19c1d 100644 --- a/ext/oci8/tests/conn_attr_1.phpt +++ b/ext/oci8/tests/conn_attr_1.phpt @@ -9,15 +9,21 @@ if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } - ?> --FILE-- <?php + +$testuser = 'testuser_attr_1'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); diff --git a/ext/oci8/tests/conn_attr_2.phpt b/ext/oci8/tests/conn_attr_2.phpt index 1072503529..432a3cff04 100644 --- a/ext/oci8/tests/conn_attr_2.phpt +++ b/ext/oci8/tests/conn_attr_2.phpt @@ -8,40 +8,45 @@ require(dirname(__FILE__).'/skipif.inc'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } - ?> --INI-- oci8.privileged_connect = On --FILE-- <?php + +$testuser = 'testuser_attr_2'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); -$user='testuser'; -$password='testuser'; + $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); echo"**Set values using pconnect-1**\n"; -var_dump($pc1 = oci_pconnect($user,$password,$dbase)); +var_dump($pc1 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { set_attr($pc1,$attr,100); } // using pc1 again echo"\n**Get values using pconnect-2**\n"; -var_dump($pc3 = oci_pconnect($user,$password,$dbase)); +var_dump($pc3 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { get_attr($pc3,$attr); } // Get with different pconnect echo"\n**Get values using pconnect-3**\n"; -var_dump($pc2 = oci_pconnect($user,$password,$dbase,'UTF8')); +var_dump($pc2 = oci_pconnect($testuser,$testpassword,$dbase,'UTF8')); foreach($attr_array as $attr) { get_attr($pc2,$attr); } @@ -52,15 +57,22 @@ oci_close($pc3); // Re-open a persistent connection and check for the attr values. echo "\n**Re-open a pconnect()**\n"; -var_dump($pc4 = oci_pconnect($user,$password,$dbase)); +var_dump($pc4 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { get_attr($pc4,$attr); } oci_close($pc4); // Test with SYSDBA connection. -var_dump($sys_c1 = oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA)); -if ($sys_c1) { +echo "\n**Test with SYSDBA connection**\n"; +$sys_c1 = @oci_pconnect($testuser,$testpassword,$dbase,false,OCI_SYSDBA); +var_dump($sys_c1); +if (!$sys_c1) { + $e = oci_error(); + if ($e['code'] != 1031 && $e['code'] != 1017) { + var_dump($e); + } +} else { set_attr($sys_c1,'ACTION',10); get_sys_attr($sys_c1,'ACTION'); get_attr($pc2,'ACTION'); @@ -100,6 +112,6 @@ The value of ACTION is TASK100 The value of CLIENT_INFO is INFO1100 The value of CLIENT_IDENTIFIER is ID00100 -Warning: oci_pconnect(): ORA-01031: %s on line %d +**Test with SYSDBA connection** bool(false) Done diff --git a/ext/oci8/tests/conn_attr_3.phpt b/ext/oci8/tests/conn_attr_3.phpt index be8d3306de..921487c9a0 100644 --- a/ext/oci8/tests/conn_attr_3.phpt +++ b/ext/oci8/tests/conn_attr_3.phpt @@ -8,14 +8,21 @@ require(dirname(__FILE__).'/skipif.inc'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- <?php + +$testuser = 'testuser_attr_3'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); echo"**Test Set and get values for the attributes with oci_close() ************\n"; diff --git a/ext/oci8/tests/conn_attr_4.phpt b/ext/oci8/tests/conn_attr_4.phpt index 4885f80b71..f32f9876d5 100644 --- a/ext/oci8/tests/conn_attr_4.phpt +++ b/ext/oci8/tests/conn_attr_4.phpt @@ -9,21 +9,27 @@ if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release (11\.2|12)\./', oci_server_version($c), $matches) !== 1) { - // Bug fixed in 11.2 prevents client_info being rest +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] >= 2) || + ($matches[1] >= 12) + ))) { + // Bug fixed in 11.2 prevents client_info being reset die("skip expected output only valid when using Oracle 11gR2 or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- <?php +$testuser = 'testuser_attr_4'; // Used in conn_attr.inc +$testpassword = 'testuser'; require(dirname(__FILE__)."/conn_attr.inc"); -$user='testuser'; -$password='testuser'; $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); echo"**Test Negative cases************\n"; @@ -40,7 +46,7 @@ var_dump(oci_set_client_info($str1,$str1)); // Setting an Invalid value. echo "\nInvalid Value \n"; -$c1=oci_connect($user,$password,$dbase); +$c1=oci_connect($testuser,$testpassword,$dbase); var_dump(oci_set_action($c1,$c1)); // Setting values multiple times. diff --git a/ext/oci8/tests/conn_attr_5.phpt b/ext/oci8/tests/conn_attr_5.phpt index d694ec06a5..77f233b4e2 100644 --- a/ext/oci8/tests/conn_attr_5.phpt +++ b/ext/oci8/tests/conn_attr_5.phpt @@ -8,14 +8,21 @@ require(dirname(__FILE__).'/skipif.inc'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- <?php + +$testuser = 'testuser_attr_5'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); echo"**Test - Set and get values for the attributes with scope end ************\n"; diff --git a/ext/oci8/tests/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt index e14fb93695..0acd2bc33a 100644 --- a/ext/oci8/tests/connect_without_oracle_home.phpt +++ b/ext/oci8/tests/connect_without_oracle_home.phpt @@ -10,8 +10,8 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); if ($ov !== 1) { die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); } -$iv = preg_match('/Oracle .*Version => (10\.2)/', $phpinfo); -if ($iv != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!isset($matches[0]) || !($matches[0] == 10 && $matches[0] == 2)) { die ("skip tests a feature that works only with Oracle 10gR2"); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_11.phpt b/ext/oci8/tests/connect_without_oracle_home_11.phpt index 1620803dbb..40dc5a98fc 100644 --- a/ext/oci8/tests/connect_without_oracle_home_11.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_11.phpt @@ -10,7 +10,11 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); if ($ov != 1) { die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); } -if (preg_match('/^11\.2|12\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && + (($matches[0] == 11 && $matches[1] >= 2) || + ($matches[0] >= 12) + ))) { die("skip test expected to work only with Oracle 11gR2 or greater version of client"); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt index c7cfecf396..e04016f41a 100644 --- a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt @@ -10,7 +10,11 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); if ($ov !== 1) { die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); } -if (preg_match('/^11\.2|12\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && + (($matches[0] == 11 && $matches[1] >= 2) || + ($matches[0] >= 12) + ))) { die("skip test expected to work only with Oracle 11gR2 or greater version of client"); } ?> diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt index d60e2ff1ea..aa25937570 100644 --- a/ext/oci8/tests/cursors_old.phpt +++ b/ext/oci8/tests/cursors_old.phpt @@ -52,19 +52,19 @@ echo "Done\n"; ?> --EXPECTF-- array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(1) "1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" } bool(true) Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(1) "1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" } bool(true) Done diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt index fe96e6e87e..66ab0f0d00 100644 --- a/ext/oci8/tests/debug.phpt +++ b/ext/oci8/tests/debug.phpt @@ -16,10 +16,9 @@ else { oci_connect($user, $password); } -echo "Done\n"; - oci_internal_debug(false); ?> ---EXPECTREGEX-- -^OCI8 DEBUG: .*Done$ +===DONE=== +--EXPECT-- +===DONE=== diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt index c6ce7bd9b3..b78f698e7c 100644 --- a/ext/oci8/tests/define.phpt +++ b/ext/oci8/tests/define.phpt @@ -44,5 +44,5 @@ echo "Done\n"; ?> --EXPECTF-- -%unicode|string%(%d) "some" +string(%d) "some" Done diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt index 6e4b74e3ba..be16271d5b 100644 --- a/ext/oci8/tests/define1.phpt +++ b/ext/oci8/tests/define1.phpt @@ -55,5 +55,5 @@ bool(false) Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d NULL -%unicode|string%(4) "some" +string(4) "some" Done diff --git a/ext/oci8/tests/define4.phpt b/ext/oci8/tests/define4.phpt index 266fd7edd7..3114a73937 100644 --- a/ext/oci8/tests/define4.phpt +++ b/ext/oci8/tests/define4.phpt @@ -58,15 +58,15 @@ echo "Done\n"; Test 1 bool(true) Test 2 -%unicode|string%(4) "1234" -%unicode|string%(4) "some" -%unicode|string%(4) "some" -%unicode|string%(4) "some" -%unicode|string%(4) "1234" -%unicode|string%(4) "some" +string(4) "1234" +string(4) "some" +string(4) "some" +string(4) "some" +string(4) "1234" +string(4) "some" Test 3 bool(true) -%unicode|string%(4) "some" +string(4) "some" Warning: oci_result(): %d is not a valid oci8 statement resource in %s on line %d bool(false) diff --git a/ext/oci8/tests/define5.phpt b/ext/oci8/tests/define5.phpt index 68fa01d09a..978d66b260 100644 --- a/ext/oci8/tests/define5.phpt +++ b/ext/oci8/tests/define5.phpt @@ -61,12 +61,12 @@ echo "Done\n"; Test 1 - must do define before execute bool(true) NULL -%unicode|string%(4) "some" +string(4) "some" Test 2 - normal define order bool(true) -%unicode|string%(4) "some" +string(4) "some" Test 3 - no new define done -%unicode|string%(4) "some" -%unicode|string%(5) "thing" +string(4) "some" +string(5) "thing" Done diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt index f65e6b8080..cc07e2ea94 100644 --- a/ext/oci8/tests/define_old.phpt +++ b/ext/oci8/tests/define_old.phpt @@ -44,5 +44,5 @@ echo "Done\n"; ?> --EXPECTF-- -%unicode|string%(4) "some" +string(4) "some" Done diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc index 9a86c46868..e54ea84abd 100644 --- a/ext/oci8/tests/details.inc +++ b/ext/oci8/tests/details.inc @@ -52,7 +52,7 @@ if (!function_exists('oci8_test_sql_execute')) { $s = oci_parse($c, $stmt); if (!$s) { $m = oci_error($c); - echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL; } else { $r = @oci_execute($s); @@ -66,7 +66,7 @@ if (!function_exists('oci8_test_sql_execute')) { , 4080 // trigger does not exist , 38802 // edition does not exist ))) { - echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL; } } } diff --git a/ext/oci8/tests/edition_1.phpt b/ext/oci8/tests/edition_1.phpt index b9c8fd817e..d8ca53cddf 100644 --- a/ext/oci8/tests/edition_1.phpt +++ b/ext/oci8/tests/edition_1.phpt @@ -24,6 +24,9 @@ if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== * already */ +$testuser = 'testuser_attr_1'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); function select_fn($conn) { @@ -39,7 +42,7 @@ function select_fn($conn) { select from both the editions and verify the contents. */ set_edit_attr('MYEDITION'); -$conn = oci_connect('testuser','testuser',$dbase); +$conn = oci_connect($testuser,$testpassword,$dbase); if ($conn === false) { $m = oci_error(); die("Error:" . $m['message']); @@ -61,7 +64,7 @@ select_fn($conn); // Create a different version of view_ed in MYEDITION1. set_edit_attr('MYEDITION1'); -$conn2 = oci_new_connect('testuser','testuser',$dbase); +$conn2 = oci_new_connect($testuser,$testpassword,$dbase); $stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab"; $s = oci_parse($conn2, $stmt); oci_execute($s); @@ -87,58 +90,58 @@ The value of edition has been successfully set The value of current EDITION is MYEDITION array(3) { [0]=> - %unicode|string%(%d) "mike" + string(%d) "mike" [1]=> - %unicode|string%(%d) "30" + string(%d) "30" [2]=> - %unicode|string%(%d) "Senior engineer" + string(%d) "Senior engineer" } array(3) { [0]=> - %unicode|string%(%d) "juan" + string(%d) "juan" [1]=> - %unicode|string%(%d) "25" + string(%d) "25" [2]=> - %unicode|string%(%d) "engineer" + string(%d) "engineer" } The value of edition has been successfully set The value of current EDITION is MYEDITION1 array(4) { [0]=> - %unicode|string%(%d) "mike" + string(%d) "mike" [1]=> - %unicode|string%(%d) "30" + string(%d) "30" [2]=> - %unicode|string%(%d) "Senior engineer" + string(%d) "Senior engineer" [3]=> - %unicode|string%(%d) "200" + string(%d) "200" } array(4) { [0]=> - %unicode|string%(%d) "juan" + string(%d) "juan" [1]=> - %unicode|string%(%d) "25" + string(%d) "25" [2]=> - %unicode|string%(%d) "engineer" + string(%d) "engineer" [3]=> - %unicode|string%(%d) "100" + string(%d) "100" } version of view_ed in MYEDITION The value of current EDITION is MYEDITION array(3) { [0]=> - %unicode|string%(%d) "mike" + string(%d) "mike" [1]=> - %unicode|string%(%d) "30" + string(%d) "30" [2]=> - %unicode|string%(%d) "Senior engineer" + string(%d) "Senior engineer" } array(3) { [0]=> - %unicode|string%(%d) "juan" + string(%d) "juan" [1]=> - %unicode|string%(%d) "25" + string(%d) "25" [2]=> - %unicode|string%(%d) "engineer" + string(%d) "engineer" } Done diff --git a/ext/oci8/tests/edition_2.phpt b/ext/oci8/tests/edition_2.phpt index 030e6a673c..0ffb62dc32 100644 --- a/ext/oci8/tests/edition_2.phpt +++ b/ext/oci8/tests/edition_2.phpt @@ -24,10 +24,10 @@ if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== * already */ -require(dirname(__FILE__)."/conn_attr.inc"); +$testuser = 'testuser_ed_2'; // Used in conn_attr.inc +$testpassword = 'testuser'; -$user = 'testuser'; -$password = 'testuser'; +require(dirname(__FILE__)."/conn_attr.inc"); echo"**Test 1.1 - Default value for the attribute **************\n"; get_edit_attr($c); @@ -50,7 +50,7 @@ get_edit_attr($conn3); oci_close($conn1); // With a oci_pconnect with a different charset. -$pc1 = oci_pconnect($user,$password,$dbase,"utf8"); +$pc1 = oci_pconnect($testuser,$testpassword,$dbase,"utf8"); get_edit_attr($pc1); oci_close($pc1); @@ -145,7 +145,7 @@ function set_scope() { } function get_scope() { - $sc1 = oci_connect($GLOBALS['user'],$GLOBALS['password'],$GLOBALS['dbase']); + $sc1 = oci_connect($GLOBALS['testuser'],$GLOBALS['testpassword'],$GLOBALS['dbase']); if ($sc1 === false) { $m = oci_error(); die("Error:" . $m['message']); diff --git a/ext/oci8/tests/error_set.phpt b/ext/oci8/tests/error_set.phpt new file mode 100644 index 0000000000..ad56e8aefa --- /dev/null +++ b/ext/oci8/tests/error_set.phpt @@ -0,0 +1,72 @@ +--TEST-- +Check oci_set_{action,client_identifier,module_name,client_info} error handling +--SKIPIF-- +<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +error_reporting(E_ALL); +ini_set('display_errors', 'Off'); + +echo "Test 1\n"; + +// Generates "ORA-24960: the attribute OCI_ATTR_* is greater than the maximum allowable length of 64" +$s = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + +$r = oci_set_action($c, $s); +var_dump($r); +$m = oci_error($c); +echo $m['code'] , "\n"; + +$r = oci_set_client_identifier($c, $s); +var_dump($r); +$m = oci_error($c); +echo $m['code'] , "\n"; + +$r = oci_set_module_name($c, $s); +var_dump($r); +$m = oci_error($c); +echo $m['code'] , "\n"; + +$r = oci_set_client_info($c, $s); +var_dump($r); +$m = oci_error($c); +echo $m['code'] , "\n"; + +echo "\nTest 2\n"; +$s = "x"; + +$r = oci_set_action($c, $s); +var_dump($r); + +$r = oci_set_client_identifier($c, $s); +var_dump($r); + +$r = oci_set_module_name($c, $s); +var_dump($r); + +$r = oci_set_client_info($c, $s); +var_dump($r); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +bool(false) +24960 +bool(false) +24960 +bool(false) +24960 +bool(false) +24960 + +Test 2 +bool(true) +bool(true) +bool(true) +bool(true) +===DONE=== diff --git a/ext/oci8/tests/extauth_01.phpt b/ext/oci8/tests/extauth_01.phpt index 37f8f3834d..1194ae180d 100644 --- a/ext/oci8/tests/extauth_01.phpt +++ b/ext/oci8/tests/extauth_01.phpt @@ -143,56 +143,56 @@ Test 7 Warning: oci_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 8 Warning: oci_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 9 Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 10 Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) ===DONE=== diff --git a/ext/oci8/tests/extauth_02.phpt b/ext/oci8/tests/extauth_02.phpt index f3b517f730..0a3227019c 100644 --- a/ext/oci8/tests/extauth_02.phpt +++ b/ext/oci8/tests/extauth_02.phpt @@ -142,56 +142,56 @@ Test 7 Warning: oci_new_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 8 Warning: oci_new_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 9 Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 10 Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) ===DONE=== diff --git a/ext/oci8/tests/extauth_03.phpt b/ext/oci8/tests/extauth_03.phpt index e6685eb176..d7884ce6b4 100644 --- a/ext/oci8/tests/extauth_03.phpt +++ b/ext/oci8/tests/extauth_03.phpt @@ -142,56 +142,56 @@ Test 7 Warning: oci_pconnect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 8 Warning: oci_pconnect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 9 Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 10 Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) ===DONE=== diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt index e48aeefd87..b968ae4bf6 100644 --- a/ext/oci8/tests/fetch.phpt +++ b/ext/oci8/tests/fetch.phpt @@ -47,10 +47,10 @@ oci8_test_sql_execute($c, $stmtarray); echo "Done\n"; ?> --EXPECTF-- -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" Done diff --git a/ext/oci8/tests/fetch_all.phpt b/ext/oci8/tests/fetch_all.phpt index 4fc41daad4..b8155b170b 100644 --- a/ext/oci8/tests/fetch_all.phpt +++ b/ext/oci8/tests/fetch_all.phpt @@ -51,44 +51,44 @@ echo "Done\n"; --EXPECTF-- int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } Done diff --git a/ext/oci8/tests/fetch_all1.phpt b/ext/oci8/tests/fetch_all1.phpt index 4fc41daad4..b8155b170b 100644 --- a/ext/oci8/tests/fetch_all1.phpt +++ b/ext/oci8/tests/fetch_all1.phpt @@ -51,44 +51,44 @@ echo "Done\n"; --EXPECTF-- int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } Done diff --git a/ext/oci8/tests/fetch_all3.phpt b/ext/oci8/tests/fetch_all3.phpt index 1748ea5658..4c0be1cc07 100644 --- a/ext/oci8/tests/fetch_all3.phpt +++ b/ext/oci8/tests/fetch_all3.phpt @@ -129,105 +129,105 @@ echo "Done\n"; None int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_ASSOC int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM @@ -236,24 +236,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC @@ -262,24 +262,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW @@ -287,31 +287,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC @@ -319,31 +319,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN @@ -351,31 +351,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC @@ -383,31 +383,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM @@ -416,30 +416,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC @@ -448,30 +448,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM @@ -480,30 +480,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC @@ -512,30 +512,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_NUM @@ -544,24 +544,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_NUM|OCI_ASSOC @@ -570,24 +570,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } Done diff --git a/ext/oci8/tests/fetch_all4.phpt b/ext/oci8/tests/fetch_all4.phpt index 1d3c9677ee..1d4a8df7b7 100644 --- a/ext/oci8/tests/fetch_all4.phpt +++ b/ext/oci8/tests/fetch_all4.phpt @@ -51,10 +51,10 @@ oci8_test_sql_execute($c, $stmtarray); Test 1 int(0) array(2) { - [%u|b%"MYCOL1"]=> + ["MYCOL1"]=> array(0) { } - [%u|b%"MYCOL2"]=> + ["MYCOL2"]=> array(0) { } } diff --git a/ext/oci8/tests/fetch_all5.phpt b/ext/oci8/tests/fetch_all5.phpt index a6bb3c3f18..d82fd30e41 100644 --- a/ext/oci8/tests/fetch_all5.phpt +++ b/ext/oci8/tests/fetch_all5.phpt @@ -62,45 +62,45 @@ oci_close($c); Test 1 int(3) array(2) { - [%u|b%"MYCOL1"]=> + ["MYCOL1"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" } - [%u|b%"MYCOL2"]=> + ["MYCOL2"]=> array(3) { [0]=> - %unicode|string%(3) "abc" + string(3) "abc" [1]=> - %unicode|string%(3) "def" + string(3) "def" [2]=> - %unicode|string%(3) "ghi" + string(3) "ghi" } } Test 1 int(3) array(2) { - [%u|b%"MYCOL1"]=> + ["MYCOL1"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" } - [%u|b%"MYCOL2"]=> + ["MYCOL2"]=> array(3) { [0]=> - %unicode|string%(3) "abc" + string(3) "abc" [1]=> - %unicode|string%(3) "def" + string(3) "def" [2]=> - %unicode|string%(3) "ghi" + string(3) "ghi" } } Test 3 diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt index 45a6a8132e..d90c4d95dc 100644 --- a/ext/oci8/tests/fetch_into.phpt +++ b/ext/oci8/tests/fetch_into.phpt @@ -53,19 +53,19 @@ echo "Done\n"; int(2) array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } int(2) array(4) { [0]=> - %unicode|string%(1) "1" - [%u|b%"ID"]=> - %unicode|string%(1) "1" + string(1) "1" + ["ID"]=> + string(1) "1" [1]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(1) "1" + string(1) "1" + ["VALUE"]=> + string(1) "1" } Done diff --git a/ext/oci8/tests/fetch_object.phpt b/ext/oci8/tests/fetch_object.phpt index 1c290d5e95..73711baa18 100644 --- a/ext/oci8/tests/fetch_object.phpt +++ b/ext/oci8/tests/fetch_object.phpt @@ -82,28 +82,28 @@ oci8_test_sql_execute($c, $stmtarray); --EXPECTF-- Test 1 object(stdClass)#1 (3) { - [%u|b%"caseSensitive"]=> - %unicode|string%(3) "123" - [%u|b%"SECONDCOL"]=> - %unicode|string%(19) "1st row col2 string" - [%u|b%"ANOTHERCOL"]=> - %unicode|string%(15) "1 more text " + ["caseSensitive"]=> + string(3) "123" + ["SECONDCOL"]=> + string(19) "1st row col2 string" + ["ANOTHERCOL"]=> + string(15) "1 more text " } object(stdClass)#2 (3) { - [%u|b%"caseSensitive"]=> - %unicode|string%(3) "456" - [%u|b%"SECONDCOL"]=> - %unicode|string%(19) "2nd row col2 string" - [%u|b%"ANOTHERCOL"]=> - %unicode|string%(15) "2 more text " + ["caseSensitive"]=> + string(3) "456" + ["SECONDCOL"]=> + string(19) "2nd row col2 string" + ["ANOTHERCOL"]=> + string(15) "2 more text " } object(stdClass)#1 (3) { - [%u|b%"caseSensitive"]=> - %unicode|string%(3) "789" - [%u|b%"SECONDCOL"]=> - %unicode|string%(19) "3rd row col2 string" - [%u|b%"ANOTHERCOL"]=> - %unicode|string%(15) "3 more text " + ["caseSensitive"]=> + string(3) "789" + ["SECONDCOL"]=> + string(19) "3rd row col2 string" + ["ANOTHERCOL"]=> + string(15) "3 more text " } Test 2 123 diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt index 2b28634ab3..40bc4f893c 100644 --- a/ext/oci8/tests/fetch_row.phpt +++ b/ext/oci8/tests/fetch_row.phpt @@ -46,20 +46,20 @@ echo "Done\n"; --EXPECTF-- array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } Done diff --git a/ext/oci8/tests/field_funcs1.phpt b/ext/oci8/tests/field_funcs1.phpt index c14ee8957e..41d8627ce4 100644 --- a/ext/oci8/tests/field_funcs1.phpt +++ b/ext/oci8/tests/field_funcs1.phpt @@ -85,9 +85,9 @@ echo "Done\n"; --EXPECTF-- array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } Test 1 diff --git a/ext/oci8/tests/function_aliases.phpt b/ext/oci8/tests/function_aliases.phpt index 4c6ce83759..2c890d6403 100644 --- a/ext/oci8/tests/function_aliases.phpt +++ b/ext/oci8/tests/function_aliases.phpt @@ -104,8 +104,6 @@ NULL Warning: ocifreestatement() expects exactly 1 parameter, 0 given in %s on line %d NULL - -Warning: ociinternaldebug() expects exactly 1 parameter, 0 given in %s on line %d NULL Warning: ocinumcols() expects exactly 1 parameter, 0 given in %s on line %d diff --git a/ext/oci8/tests/imp_res_1.phpt b/ext/oci8/tests/imp_res_1.phpt new file mode 100644 index 0000000000..a36f89f4da --- /dev/null +++ b/ext/oci8/tests/imp_res_1.phpt @@ -0,0 +1,630 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: basic test +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_1_tab_1", + "create table imp_res_1_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_1_tab_1 values (1, 'abcde')", + "insert into imp_res_1_tab_1 values (2, 'fghij')", + "insert into imp_res_1_tab_1 values (3, 'klmno')", + + "drop table imp_res_1_tab_2", + "create table imp_res_1_tab_2 (c3 varchar2(1))", + "insert into imp_res_1_tab_2 values ('t')", + "insert into imp_res_1_tab_2 values ('u')", + "insert into imp_res_1_tab_2 values ('v')", + + "create or replace procedure imp_res_1_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_1_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_1_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select 99 from dual; + dbms_sql.return_result (c1); + + open c1 for select NULL, 'Z' from dual; + dbms_sql.return_result (c1); + + open c1 for select * from imp_res_1_tab_1 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - oci_fetch_assoc\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_assoc($s)) != false) + var_dump($row); + +echo "\nTest 2 - oci_fetch_object\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_object($s)) != false) + var_dump($row); + +echo "\nTest 3 - oci_fetch_row\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "\nTest 4 - oci_fetch_array(OCI_ASSOC+OCI_RETURN_NULLS)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) + var_dump($row); + +echo "\nTest 5 - oci_fetch_array(OCI_ASSOC)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC)) != false) + var_dump($row); + +echo "\nTest 6 - oci_fetch_array(OCI_NUM)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_NUM)) != false) + var_dump($row); + +echo "\nTest 7 - oci_fetch_array(OCI_BOTH)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_BOTH)) != false) + var_dump($row); + +echo "\nTest 8 - oci_fetch_array(OCI_BOTH+OCI_RETURN_NULLS)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_BOTH+OCI_RETURN_NULLS)) != false) + var_dump($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_1_proc", + "drop table imp_res_1_tab_1", + "drop table imp_res_1_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - oci_fetch_assoc +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +array(1) { + ["C3"]=> + string(1) "t" +} +array(1) { + ["C3"]=> + string(1) "u" +} +array(1) { + [99]=> + string(2) "99" +} +array(2) { + ["NULL"]=> + NULL + ["'Z'"]=> + string(1) "Z" +} +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 2 - oci_fetch_object +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +object(stdClass)#%d (1) { + ["C3"]=> + string(1) "t" +} +object(stdClass)#%d (1) { + ["C3"]=> + string(1) "u" +} +object(stdClass)#%d (1) { + [99]=> + string(2) "99" +} +object(stdClass)#%d (2) { + ["NULL"]=> + NULL + ["'Z'"]=> + string(1) "Z" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 3 - oci_fetch_row +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(2) "99" +} +array(2) { + [0]=> + NULL + [1]=> + string(1) "Z" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} + +Test 4 - oci_fetch_array(OCI_ASSOC+OCI_RETURN_NULLS) +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +array(1) { + ["C3"]=> + string(1) "t" +} +array(1) { + ["C3"]=> + string(1) "u" +} +array(1) { + [99]=> + string(2) "99" +} +array(2) { + ["NULL"]=> + NULL + ["'Z'"]=> + string(1) "Z" +} +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 5 - oci_fetch_array(OCI_ASSOC) +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +array(1) { + ["C3"]=> + string(1) "t" +} +array(1) { + ["C3"]=> + string(1) "u" +} +array(1) { + [99]=> + string(2) "99" +} +array(1) { + ["'Z'"]=> + string(1) "Z" +} +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 6 - oci_fetch_array(OCI_NUM) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(2) "99" +} +array(1) { + [1]=> + string(1) "Z" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} + +Test 7 - oci_fetch_array(OCI_BOTH) +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} +array(2) { + [0]=> + string(1) "t" + ["C3"]=> + string(1) "t" +} +array(2) { + [0]=> + string(1) "u" + ["C3"]=> + string(1) "u" +} +array(2) { + [0]=> + string(2) "99" + [99]=> + string(2) "99" +} +array(2) { + [1]=> + string(1) "Z" + ["'Z'"]=> + string(1) "Z" +} +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} + +Test 8 - oci_fetch_array(OCI_BOTH+OCI_RETURN_NULLS) +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} +array(2) { + [0]=> + string(1) "t" + ["C3"]=> + string(1) "t" +} +array(2) { + [0]=> + string(1) "u" + ["C3"]=> + string(1) "u" +} +array(2) { + [0]=> + string(2) "99" + [99]=> + string(2) "99" +} +array(4) { + [0]=> + NULL + ["NULL"]=> + NULL + [1]=> + string(1) "Z" + ["'Z'"]=> + string(1) "Z" +} +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_2.phpt b/ext/oci8/tests/imp_res_2.phpt new file mode 100644 index 0000000000..860a5fbb34 --- /dev/null +++ b/ext/oci8/tests/imp_res_2.phpt @@ -0,0 +1,99 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: Zero Rows +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_2_proc_a as + c1 sys_refcursor; + begin + open c1 for select * from dual where 1 = 0; + dbms_sql.return_result(c1); + end;", + + "create or replace procedure imp_res_2_proc_b as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result(c1); + open c1 for select * from dual where 1 = 0; + dbms_sql.return_result(c1); + end;", + + "create or replace procedure imp_res_2_proc_c as + c1 sys_refcursor; + begin + open c1 for select * from dual where 1 = 0; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result(c1); + end;" + +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_2_proc_a(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "Test 2\n"; +$s = oci_parse($c, "begin imp_res_2_proc_b(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "Test 2\n"; +$s = oci_parse($c, "begin imp_res_2_proc_c(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_2_proc_a", + "drop procedure imp_res_2_proc_b", + "drop procedure imp_res_2_proc_c" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +Test 2 +array(1) { + [0]=> + string(1) "X" +} +Test 2 +array(1) { + [0]=> + string(1) "X" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_3.phpt b/ext/oci8/tests/imp_res_3.phpt new file mode 100644 index 0000000000..0fc4815893 --- /dev/null +++ b/ext/oci8/tests/imp_res_3.phpt @@ -0,0 +1,1257 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: bigger data size +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_3_tab_1", + "create table imp_res_3_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_3_tab_1 values (1, 'a')", + "insert into imp_res_3_tab_1 values (2, 'f')", + + "drop table imp_res_3_tab_2", + "create table imp_res_3_tab_2 (c3 varchar2(1))", + "insert into imp_res_3_tab_2 values ('t')", + "insert into imp_res_3_tab_2 values ('u')", + "insert into imp_res_3_tab_2 values ('v')", + "insert into imp_res_3_tab_2 values ('w')", + + "create or replace procedure imp_res_3_proc as + c1 sys_refcursor; + i pls_integer; + begin + for i in 1..30 loop -- if this value is too big for Oracle's open_cursors, calling imp_res_3_proc() can fail with ORA-1000 + open c1 for select t1.*, t2.*, t3.*, t4.*, t5.* + from imp_res_3_tab_1 t1, imp_res_3_tab_1 t2, imp_res_3_tab_1 t3, + imp_res_3_tab_1 t4, imp_res_3_tab_1 t5 order by 1,3,5,7,9,2,4,6,8,10; + dbms_sql.return_result(c1); + open c1 for select c2 from imp_res_3_tab_1 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from imp_res_3_tab_2 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end loop; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_3_proc(); end;"); +oci_execute($s); + +while (($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_3_proc", + "drop table imp_res_3_tab_1", + "drop table imp_res_3_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_4.phpt b/ext/oci8/tests/imp_res_4.phpt new file mode 100644 index 0000000000..762ae77224 --- /dev/null +++ b/ext/oci8/tests/imp_res_4.phpt @@ -0,0 +1,82 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_fetch +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_4_proc as + c1 sys_refcursor; + begin + open c1 for select 1 from dual union select 2 from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_4_proc(); end;"); +oci_execute($s); +oci_fetch($s); // This will fail with ORA-24374 +var_dump(oci_result($s, 1)); + +echo "\nTest 2\n"; +$s = oci_parse($c, "begin imp_res_4_proc(); end;"); +oci_execute($s); +$r = oci_fetch_row($s); +var_dump($r); +oci_fetch($s); // This will fail with ORA-24374 +var_dump(oci_result($s, 1)); +$r = oci_fetch_row($s); +var_dump($r); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_4_proc", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d +bool(false) + +Test 2 +array(1) { + [0]=> + string(1) "1" +} + +Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d +bool(false) +array(1) { + [0]=> + string(1) "2" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_5.phpt b/ext/oci8/tests/imp_res_5.phpt new file mode 100644 index 0000000000..564a7a3740 --- /dev/null +++ b/ext/oci8/tests/imp_res_5.phpt @@ -0,0 +1,84 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_fetch_all +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_5_proc as + c1 sys_refcursor; + begin + open c1 for select 1 from dual union select 2 from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_5_proc(); end;"); +oci_execute($s); +oci_fetch_all($s,$res); // This will fail with ORA-24374 +var_dump($res); + +echo "\nTest 2\n"; +$s = oci_parse($c, "begin imp_res_5_proc(); end;"); +oci_execute($s); +$r = oci_fetch_row($s); +var_dump($r); +oci_fetch_all($s, $res); // This will fail with ORA-24374 +var_dump($res); +$r = oci_fetch_row($s); +var_dump($r); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_5_proc", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d +array(0) { +} + +Test 2 +array(1) { + [0]=> + string(1) "1" +} + +Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d +array(0) { +} +array(1) { + [0]=> + string(1) "2" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_6.phpt b/ext/oci8/tests/imp_res_6.phpt new file mode 100644 index 0000000000..f94efe70db --- /dev/null +++ b/ext/oci8/tests/imp_res_6.phpt @@ -0,0 +1,118 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: alternating oci_fetch_* calls +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_6_tab", + "create table imp_res_6_tab (c1 number, c2 varchar2(10))", + "insert into imp_res_6_tab values (1, 'a')", + "insert into imp_res_6_tab values (2, 'b')", + "insert into imp_res_6_tab values (3, 'c')", + "insert into imp_res_6_tab values (4, 'd')", + "insert into imp_res_6_tab values (5, 'e')", + "insert into imp_res_6_tab values (6, 'f')", + + "create or replace procedure imp_res_6_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_6_tab order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_6_proc(); end;"); +oci_execute($s); + +$row = oci_fetch_assoc($s); +var_dump($row); +$row = oci_fetch_row($s); +var_dump($row); +$row = oci_fetch_object($s); +var_dump($row); +$row = oci_fetch_array($s); +var_dump($row); +$row = oci_fetch_array($s, OCI_NUM); +var_dump($row); +$row = oci_fetch_array($s, OCI_ASSOC); +var_dump($row); + + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_6_proc", + "drop table imp_res_6_tab", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(1) "a" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(1) "b" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(1) "c" +} +array(4) { + [0]=> + string(1) "4" + ["C1"]=> + string(1) "4" + [1]=> + string(1) "d" + ["C2"]=> + string(1) "d" +} +array(2) { + [0]=> + string(1) "5" + [1]=> + string(1) "e" +} +array(2) { + ["C1"]=> + string(1) "6" + ["C2"]=> + string(1) "f" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_7.phpt b/ext/oci8/tests/imp_res_7.phpt new file mode 100644 index 0000000000..05ae5e6857 --- /dev/null +++ b/ext/oci8/tests/imp_res_7.phpt @@ -0,0 +1,873 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: bigger data size +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmt = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual; + dbms_sql.return_result(c1); + open c1 for select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual; + dbms_sql.return_result(c1); + open c1 for select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual; + dbms_sql.return_result(c1); + open c1 for select 6 from dual; + dbms_sql.return_result(c1); + open c1 for select 7 from dual; + dbms_sql.return_result(c1); + open c1 for select 8 from dual; + dbms_sql.return_result(c1); + open c1 for select 9 from dual; + dbms_sql.return_result(c1); + open c1 for select 10 from dual; + dbms_sql.return_result(c1); + open c1 for select 11 from dual; + dbms_sql.return_result(c1); + open c1 for select 12 from dual; + dbms_sql.return_result(c1); + open c1 for select 13 from dual; + dbms_sql.return_result(c1); + open c1 for select 14 from dual; + dbms_sql.return_result(c1); + open c1 for select 15 from dual; + dbms_sql.return_result(c1); + open c1 for select 16 from dual; + dbms_sql.return_result(c1); + open c1 for select 17 from dual; + dbms_sql.return_result(c1); + open c1 for select 18 from dual; + dbms_sql.return_result(c1); + open c1 for select 19 from dual; + dbms_sql.return_result(c1); + open c1 for select 20 from dual; + dbms_sql.return_result(c1); + open c1 for select 21 from dual; + dbms_sql.return_result(c1); + open c1 for select 22 from dual; + dbms_sql.return_result(c1); + open c1 for select 23 from dual; + dbms_sql.return_result(c1); + open c1 for select 24 from dual; + dbms_sql.return_result(c1); + open c1 for select 25 from dual; + dbms_sql.return_result(c1); + open c1 for select 26 from dual; + dbms_sql.return_result(c1); + open c1 for select 27 from dual; + dbms_sql.return_result(c1); + open c1 for select 28 from dual; + dbms_sql.return_result(c1); + open c1 for select 29 from dual; + dbms_sql.return_result(c1); + open c1 for select 30 from dual; + dbms_sql.return_result(c1); + open c1 for select 31 from dual; + dbms_sql.return_result(c1); + open c1 for select 32 from dual; + dbms_sql.return_result(c1); + open c1 for select 33 from dual; + dbms_sql.return_result(c1); + open c1 for select 34 from dual; + dbms_sql.return_result(c1); + open c1 for select 35 from dual; + dbms_sql.return_result(c1); + open c1 for select 36 from dual; + dbms_sql.return_result(c1); + open c1 for select 37 from dual; + dbms_sql.return_result(c1); + open c1 for select 38 from dual; + dbms_sql.return_result(c1); + open c1 for select 39 from dual; + dbms_sql.return_result(c1); + open c1 for select 40 from dual; + dbms_sql.return_result(c1); + open c1 for select 41 from dual; + dbms_sql.return_result(c1); + open c1 for select 42 from dual; + dbms_sql.return_result(c1); + open c1 for select 43 from dual; + dbms_sql.return_result(c1); + open c1 for select 44 from dual; + dbms_sql.return_result(c1); + open c1 for select 45 from dual; + dbms_sql.return_result(c1); + open c1 for select 46 from dual; + dbms_sql.return_result(c1); + open c1 for select 47 from dual; + dbms_sql.return_result(c1); + open c1 for select 48 from dual; + dbms_sql.return_result(c1); + open c1 for select 49 from dual; + dbms_sql.return_result(c1); + open c1 for select 50 from dual; + dbms_sql.return_result(c1); + open c1 for select 51 from dual; + dbms_sql.return_result(c1); + open c1 for select 52 from dual; + dbms_sql.return_result(c1); + open c1 for select 53 from dual; + dbms_sql.return_result(c1); + open c1 for select 54 from dual; + dbms_sql.return_result(c1); + open c1 for select 55 from dual; + dbms_sql.return_result(c1); + open c1 for select 56 from dual; + dbms_sql.return_result(c1); + open c1 for select 57 from dual; + dbms_sql.return_result(c1); + open c1 for select 58 from dual; + dbms_sql.return_result(c1); + open c1 for select 59 from dual; + dbms_sql.return_result(c1); + open c1 for select 60 from dual; + dbms_sql.return_result(c1); + open c1 for select 61 from dual; + dbms_sql.return_result(c1); + open c1 for select 62 from dual; + dbms_sql.return_result(c1); + open c1 for select 63 from dual; + dbms_sql.return_result(c1); + open c1 for select 64 from dual; + dbms_sql.return_result(c1); + open c1 for select 65 from dual; + dbms_sql.return_result(c1); + open c1 for select 66 from dual; + dbms_sql.return_result(c1); + open c1 for select 67 from dual; + dbms_sql.return_result(c1); + open c1 for select 68 from dual; + dbms_sql.return_result(c1); + open c1 for select 69 from dual; + dbms_sql.return_result(c1); + open c1 for select 70 from dual; + dbms_sql.return_result(c1); + open c1 for select 71 from dual; + dbms_sql.return_result(c1); + open c1 for select 72 from dual; + dbms_sql.return_result(c1); + open c1 for select 73 from dual; + dbms_sql.return_result(c1); + open c1 for select 74 from dual; + dbms_sql.return_result(c1); + open c1 for select 75 from dual; + dbms_sql.return_result(c1); + open c1 for select 76 from dual; + dbms_sql.return_result(c1); + open c1 for select 77 from dual; + dbms_sql.return_result(c1); + open c1 for select 78 from dual; + dbms_sql.return_result(c1); + open c1 for select 79 from dual; + dbms_sql.return_result(c1); + open c1 for select 80 from dual; + dbms_sql.return_result(c1); + open c1 for select 81 from dual; + dbms_sql.return_result(c1); + open c1 for select 82 from dual; + dbms_sql.return_result(c1); + open c1 for select 83 from dual; + dbms_sql.return_result(c1); + open c1 for select 84 from dual; + dbms_sql.return_result(c1); + open c1 for select 85 from dual; + dbms_sql.return_result(c1); + open c1 for select 86 from dual; + dbms_sql.return_result(c1); + open c1 for select 87 from dual; + dbms_sql.return_result(c1); + open c1 for select 88 from dual; + dbms_sql.return_result(c1); + open c1 for select 89 from dual; + dbms_sql.return_result(c1); + open c1 for select 90 from dual; + dbms_sql.return_result(c1); + open c1 for select 91 from dual; + dbms_sql.return_result(c1); + open c1 for select 92 from dual; + dbms_sql.return_result(c1); + open c1 for select 93 from dual; + dbms_sql.return_result(c1); + open c1 for select 94 from dual; + dbms_sql.return_result(c1); + open c1 for select 95 from dual; + dbms_sql.return_result(c1); + open c1 for select 96 from dual; + dbms_sql.return_result(c1); + open c1 for select 97 from dual; + dbms_sql.return_result(c1); + open c1 for select 98 from dual; + dbms_sql.return_result(c1); + open c1 for select 99 from dual; + dbms_sql.return_result(c1); + open c1 for select 100 from dual; + dbms_sql.return_result(c1); + open c1 for select 101 from dual; + dbms_sql.return_result(c1); + open c1 for select 102 from dual; + dbms_sql.return_result(c1); + open c1 for select 103 from dual; + dbms_sql.return_result(c1); + open c1 for select 104 from dual; + dbms_sql.return_result(c1); + open c1 for select 105 from dual; + dbms_sql.return_result(c1); + open c1 for select 106 from dual; + dbms_sql.return_result(c1); + open c1 for select 107 from dual; + dbms_sql.return_result(c1); + open c1 for select 108 from dual; + dbms_sql.return_result(c1); + open c1 for select 109 from dual; + dbms_sql.return_result(c1); + open c1 for select 110 from dual; + dbms_sql.return_result(c1); + open c1 for select 111 from dual; + dbms_sql.return_result(c1); + open c1 for select 112 from dual; + dbms_sql.return_result(c1); + open c1 for select 113 from dual; + dbms_sql.return_result(c1); + open c1 for select 114 from dual; + dbms_sql.return_result(c1); + open c1 for select 115 from dual; + dbms_sql.return_result(c1); + open c1 for select 116 from dual; + dbms_sql.return_result(c1); + open c1 for select 117 from dual; + dbms_sql.return_result(c1); + open c1 for select 118 from dual; + dbms_sql.return_result(c1); + open c1 for select 119 from dual; + dbms_sql.return_result(c1); + open c1 for select 120 from dual; + dbms_sql.return_result(c1); + open c1 for select 121 from dual; + dbms_sql.return_result(c1); + open c1 for select 122 from dual; + dbms_sql.return_result(c1); + open c1 for select 123 from dual; + dbms_sql.return_result(c1); + open c1 for select 124 from dual; + dbms_sql.return_result(c1); + open c1 for select 125 from dual; + dbms_sql.return_result(c1); + open c1 for select 126 from dual; + dbms_sql.return_result(c1); + open c1 for select 127 from dual; + dbms_sql.return_result(c1); + open c1 for select 128 from dual; + dbms_sql.return_result(c1); + open c1 for select 129 from dual; + dbms_sql.return_result(c1); + open c1 for select 130 from dual; + dbms_sql.return_result(c1); + open c1 for select 131 from dual; + dbms_sql.return_result(c1); + open c1 for select 132 from dual; + dbms_sql.return_result(c1); + open c1 for select 133 from dual; + dbms_sql.return_result(c1); + open c1 for select 134 from dual; + dbms_sql.return_result(c1); + open c1 for select 135 from dual; + dbms_sql.return_result(c1); + open c1 for select 136 from dual; + dbms_sql.return_result(c1); + open c1 for select 137 from dual; + dbms_sql.return_result(c1); + open c1 for select 138 from dual; + dbms_sql.return_result(c1); + open c1 for select 139 from dual; + dbms_sql.return_result(c1); + open c1 for select 140 from dual; + dbms_sql.return_result(c1); + open c1 for select 141 from dual; + dbms_sql.return_result(c1); + open c1 for select 142 from dual; + dbms_sql.return_result(c1); + open c1 for select 143 from dual; + dbms_sql.return_result(c1); + open c1 for select 144 from dual; + dbms_sql.return_result(c1); + open c1 for select 145 from dual; + dbms_sql.return_result(c1); + open c1 for select 146 from dual; + dbms_sql.return_result(c1); + open c1 for select 147 from dual; + dbms_sql.return_result(c1); + open c1 for select 148 from dual; + dbms_sql.return_result(c1); + open c1 for select 149 from dual; + dbms_sql.return_result(c1); + open c1 for select 150 from dual; + dbms_sql.return_result(c1); + open c1 for select 151 from dual; + dbms_sql.return_result(c1); + open c1 for select 152 from dual; + dbms_sql.return_result(c1); + open c1 for select 153 from dual; + dbms_sql.return_result(c1); + open c1 for select 154 from dual; + dbms_sql.return_result(c1); + open c1 for select 155 from dual; + dbms_sql.return_result(c1); + open c1 for select 156 from dual; + dbms_sql.return_result(c1); + open c1 for select 157 from dual; + dbms_sql.return_result(c1); + open c1 for select 158 from dual; + dbms_sql.return_result(c1); + open c1 for select 159 from dual; + dbms_sql.return_result(c1); + open c1 for select 160 from dual; + dbms_sql.return_result(c1); + open c1 for select 161 from dual; + dbms_sql.return_result(c1); + open c1 for select 162 from dual; + dbms_sql.return_result(c1); + open c1 for select 163 from dual; + dbms_sql.return_result(c1); + open c1 for select 164 from dual; + dbms_sql.return_result(c1); + open c1 for select 165 from dual; + dbms_sql.return_result(c1); + open c1 for select 166 from dual; + dbms_sql.return_result(c1); + open c1 for select 167 from dual; + dbms_sql.return_result(c1); + open c1 for select 168 from dual; + dbms_sql.return_result(c1); + open c1 for select 169 from dual; + dbms_sql.return_result(c1); + open c1 for select 170 from dual; + dbms_sql.return_result(c1); + open c1 for select 171 from dual; + dbms_sql.return_result(c1); + open c1 for select 172 from dual; + dbms_sql.return_result(c1); + open c1 for select 173 from dual; + dbms_sql.return_result(c1); + open c1 for select 174 from dual; + dbms_sql.return_result(c1); + open c1 for select 175 from dual; + dbms_sql.return_result(c1); + open c1 for select 176 from dual; + dbms_sql.return_result(c1); + open c1 for select 177 from dual; + dbms_sql.return_result(c1); + open c1 for select 178 from dual; + dbms_sql.return_result(c1); + open c1 for select 179 from dual; + dbms_sql.return_result(c1); + open c1 for select 180 from dual; + dbms_sql.return_result(c1); + open c1 for select 181 from dual; + dbms_sql.return_result(c1); + open c1 for select 182 from dual; + dbms_sql.return_result(c1); + open c1 for select 183 from dual; + dbms_sql.return_result(c1); + open c1 for select 184 from dual; + dbms_sql.return_result(c1); + open c1 for select 185 from dual; + dbms_sql.return_result(c1); + open c1 for select 186 from dual; + dbms_sql.return_result(c1); + open c1 for select 187 from dual; + dbms_sql.return_result(c1); + open c1 for select 188 from dual; + dbms_sql.return_result(c1); + open c1 for select 189 from dual; + dbms_sql.return_result(c1); + open c1 for select 190 from dual; + dbms_sql.return_result(c1); + open c1 for select 191 from dual; + dbms_sql.return_result(c1); + open c1 for select 192 from dual; + dbms_sql.return_result(c1); + open c1 for select 193 from dual; + dbms_sql.return_result(c1); + open c1 for select 194 from dual; + dbms_sql.return_result(c1); + open c1 for select 195 from dual; + dbms_sql.return_result(c1); + open c1 for select 196 from dual; + dbms_sql.return_result(c1); + open c1 for select 197 from dual; + dbms_sql.return_result(c1); + open c1 for select 198 from dual; + dbms_sql.return_result(c1); + open c1 for select 199 from dual; + dbms_sql.return_result(c1); + open c1 for select 200 from dual; + dbms_sql.return_result(c1); + open c1 for select 201 from dual; + dbms_sql.return_result(c1); + open c1 for select 202 from dual; + dbms_sql.return_result(c1); + open c1 for select 203 from dual; + dbms_sql.return_result(c1); + open c1 for select 204 from dual; + dbms_sql.return_result(c1); + open c1 for select 205 from dual; + dbms_sql.return_result(c1); + open c1 for select 206 from dual; + dbms_sql.return_result(c1); + open c1 for select 207 from dual; + dbms_sql.return_result(c1); + open c1 for select 208 from dual; + dbms_sql.return_result(c1); + open c1 for select 209 from dual; + dbms_sql.return_result(c1); + open c1 for select 210 from dual; + dbms_sql.return_result(c1); + open c1 for select 211 from dual; + dbms_sql.return_result(c1); + open c1 for select 212 from dual; + dbms_sql.return_result(c1); + open c1 for select 213 from dual; + dbms_sql.return_result(c1); + open c1 for select 214 from dual; + dbms_sql.return_result(c1); + open c1 for select 215 from dual; + dbms_sql.return_result(c1); + open c1 for select 216 from dual; + dbms_sql.return_result(c1); + open c1 for select 217 from dual; + dbms_sql.return_result(c1); + open c1 for select 218 from dual; + dbms_sql.return_result(c1); + open c1 for select 219 from dual; + dbms_sql.return_result(c1); + open c1 for select 220 from dual; + dbms_sql.return_result(c1); + open c1 for select 221 from dual; + dbms_sql.return_result(c1); + open c1 for select 222 from dual; + dbms_sql.return_result(c1); + open c1 for select 223 from dual; + dbms_sql.return_result(c1); + open c1 for select 224 from dual; + dbms_sql.return_result(c1); + open c1 for select 225 from dual; + dbms_sql.return_result(c1); + open c1 for select 226 from dual; + dbms_sql.return_result(c1); + open c1 for select 227 from dual; + dbms_sql.return_result(c1); + open c1 for select 228 from dual; + dbms_sql.return_result(c1); + open c1 for select 229 from dual; + dbms_sql.return_result(c1); + open c1 for select 230 from dual; + dbms_sql.return_result(c1); + open c1 for select 231 from dual; + dbms_sql.return_result(c1); + open c1 for select 232 from dual; + dbms_sql.return_result(c1); + open c1 for select 233 from dual; + dbms_sql.return_result(c1); + open c1 for select 234 from dual; + dbms_sql.return_result(c1); + open c1 for select 235 from dual; + dbms_sql.return_result(c1); + open c1 for select 236 from dual; + dbms_sql.return_result(c1); + open c1 for select 237 from dual; + dbms_sql.return_result(c1); + open c1 for select 238 from dual; + dbms_sql.return_result(c1); + open c1 for select 239 from dual; + dbms_sql.return_result(c1); + open c1 for select 240 from dual; + dbms_sql.return_result(c1); + open c1 for select 241 from dual; + dbms_sql.return_result(c1); + open c1 for select 242 from dual; + dbms_sql.return_result(c1); + open c1 for select 243 from dual; + dbms_sql.return_result(c1); + open c1 for select 244 from dual; + dbms_sql.return_result(c1); + open c1 for select 245 from dual; + dbms_sql.return_result(c1); + open c1 for select 246 from dual; + dbms_sql.return_result(c1); + open c1 for select 247 from dual; + dbms_sql.return_result(c1); + open c1 for select 248 from dual; + dbms_sql.return_result(c1); + open c1 for select 249 from dual; + dbms_sql.return_result(c1); + open c1 for select 250 from dual; + dbms_sql.return_result(c1); + open c1 for select 251 from dual; + dbms_sql.return_result(c1); + open c1 for select 252 from dual; + dbms_sql.return_result(c1); + open c1 for select 253 from dual; + dbms_sql.return_result(c1); + open c1 for select 254 from dual; + dbms_sql.return_result(c1); + open c1 for select 255 from dual; + dbms_sql.return_result(c1); + open c1 for select 256 from dual; + dbms_sql.return_result(c1); + open c1 for select 257 from dual; + dbms_sql.return_result(c1); + open c1 for select 258 from dual; + dbms_sql.return_result(c1); + open c1 for select 259 from dual; + dbms_sql.return_result(c1); + open c1 for select 260 from dual; + dbms_sql.return_result(c1); + open c1 for select 261 from dual; + dbms_sql.return_result(c1); + open c1 for select 262 from dual; + dbms_sql.return_result(c1); + open c1 for select 263 from dual; + dbms_sql.return_result(c1); + open c1 for select 264 from dual; + dbms_sql.return_result(c1); + open c1 for select 265 from dual; + dbms_sql.return_result(c1); + open c1 for select 266 from dual; + dbms_sql.return_result(c1); + open c1 for select 267 from dual; + dbms_sql.return_result(c1); + open c1 for select 268 from dual; + dbms_sql.return_result(c1); + open c1 for select 269 from dual; + dbms_sql.return_result(c1); + open c1 for select 270 from dual; + dbms_sql.return_result(c1); + open c1 for select 271 from dual; + dbms_sql.return_result(c1); + open c1 for select 272 from dual; + dbms_sql.return_result(c1); + open c1 for select 273 from dual; + dbms_sql.return_result(c1); + open c1 for select 274 from dual; + dbms_sql.return_result(c1); + open c1 for select 275 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, $stmt); +oci_execute($s); + +while (($row = oci_fetch_row($s)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + 172 + 173 + 174 + 175 + 176 + 177 + 178 + 179 + 180 + 181 + 182 + 183 + 184 + 185 + 186 + 187 + 188 + 189 + 190 + 191 + 192 + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + 203 + 204 + 205 + 206 + 207 + 208 + 209 + 210 + 211 + 212 + 213 + 214 + 215 + 216 + 217 + 218 + 219 + 220 + 221 + 222 + 223 + 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + 233 + 234 + 235 + 236 + 237 + 238 + 239 + 240 + 241 + 242 + 243 + 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + 255 + 256 + 257 + 258 + 259 + 260 + 261 + 262 + 263 + 264 + 265 + 266 + 267 + 268 + 269 + 270 + 271 + 272 + 273 + 274 + 275 +===DONE=== diff --git a/ext/oci8/tests/imp_res_call_error.phpt b/ext/oci8/tests/imp_res_call_error.phpt new file mode 100644 index 0000000000..8b0fa78db9 --- /dev/null +++ b/ext/oci8/tests/imp_res_call_error.phpt @@ -0,0 +1,61 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: using SQL 'CALL' +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_call_err_proc as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;"); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "call imp_res_call_err_proc()"); +oci_execute($s); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_call_err_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_execute(): ORA-29478: %s +ORA-06512: at "SYS.DBMS_SQL", line %d +ORA-06512: at "SYS.DBMS_SQL", line %d +ORA-06512: at "SYSTEM.IMP_RES_CALL_ERR_PROC", line %d in %simp_res_call_error.php on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_cancel.phpt b/ext/oci8/tests/imp_res_cancel.phpt new file mode 100644 index 0000000000..663d630dfb --- /dev/null +++ b/ext/oci8/tests/imp_res_cancel.phpt @@ -0,0 +1,68 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_cancel +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$stmtarray = array( + "create or replace procedure imp_res_cancel_proc as + c1 sys_refcursor; + c2 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c2 for select 3 from dual; + dbms_sql.return_result (c2); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_cancel_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + var_dump(oci_cancel($s)); +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_cancel_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 +bool(true) + 2 +bool(true) + 3 +bool(true) +===DONE=== diff --git a/ext/oci8/tests/imp_res_close.phpt b/ext/oci8/tests/imp_res_close.phpt new file mode 100644 index 0000000000..01ac2c75e0 --- /dev/null +++ b/ext/oci8/tests/imp_res_close.phpt @@ -0,0 +1,69 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_free_statement #1 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_close_proc as + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual order by 1; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual order by 1; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_close_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_free_statement($s); // Free the implicit result handle +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_close_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %simp_res_close.php on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_cursor.phpt b/ext/oci8/tests/imp_res_cursor.phpt new file mode 100644 index 0000000000..cac0a5d1c0 --- /dev/null +++ b/ext/oci8/tests/imp_res_cursor.phpt @@ -0,0 +1,99 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: nested cursor +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_cursor_tab_1", + "create table imp_res_cursor_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_cursor_tab_1 values (1, 'abcde')", + "insert into imp_res_cursor_tab_1 values (2, 'fghij')", + "insert into imp_res_cursor_tab_1 values (3, 'klmno')", + + "drop table imp_res_cursor_tab_2", + "create table imp_res_cursor_tab_2 (c3 varchar2(1))", + "insert into imp_res_cursor_tab_2 values ('t')", + "insert into imp_res_cursor_tab_2 values ('u')", + "insert into imp_res_cursor_tab_2 values ('v')", + + "create or replace procedure imp_res_cursor_proc as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result (c1); + + open c1 for select cursor(select c1, c2 from imp_res_cursor_tab_1 order by 1) as curs from dual; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_cursor_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function do_fetch($s) +{ + while (($row = oci_fetch_assoc($s)) != false) { + foreach ($row as $item) { + if (is_resource($item)) { // Nested cursor + oci_execute($item); + do_fetch($item); + } else { + echo " ".$item; + } + } + echo "\n"; + } +} + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_cursor_proc(); end;"); +oci_execute($s); + +do_fetch($s); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_cursor_proc", + "drop table imp_res_cursor_tab_1", + "drop table imp_res_cursor_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + X + 1 abcde + 2 fghij + 3 klmno + + t + u +===DONE=== diff --git a/ext/oci8/tests/imp_res_dbmsoutput.phpt b/ext/oci8/tests/imp_res_dbmsoutput.phpt new file mode 100644 index 0000000000..8c9808d96c --- /dev/null +++ b/ext/oci8/tests/imp_res_dbmsoutput.phpt @@ -0,0 +1,136 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: interleaved with DBMS_OUTPUT +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_dbmsoutput_tab_1", + "create table imp_res_dbmsoutput_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_dbmsoutput_tab_1 values (1, 'abcde')", + "insert into imp_res_dbmsoutput_tab_1 values (2, 'fghij')", + "insert into imp_res_dbmsoutput_tab_1 values (3, 'klmno')", + + "drop table imp_res_dbmsoutput_tab_2", + "create table imp_res_dbmsoutput_tab_2 (c3 varchar2(1))", + "insert into imp_res_dbmsoutput_tab_2 values ('t')", + "insert into imp_res_dbmsoutput_tab_2 values ('u')", + "insert into imp_res_dbmsoutput_tab_2 values ('v')", + + "create or replace procedure imp_res_dbmsoutput_proc as + c1 sys_refcursor; + begin + dbms_output.put_line('dbms_output Line 1'); + open c1 for select * from imp_res_dbmsoutput_tab_1 order by 1; + dbms_sql.return_result(c1); + dbms_output.put_line('dbms_output Line 2'); + open c1 for select * from imp_res_dbmsoutput_tab_2 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function setserveroutputon($c) +{ + $s = oci_parse($c, "begin dbms_output.enable(null); end;"); + oci_execute($s); +} + +function getdbmsoutput_do($c) +{ + $s = oci_parse($c, "begin dbms_output.get_line(:ln, :st); end;"); + oci_bind_by_name($s, ":ln", $ln, 100); + oci_bind_by_name($s, ":st", $st, -1, SQLT_INT); + $res = false; + while (($succ = oci_execute($s)) && !$st) { + $res[] = $ln; // append each line to the array + } + return $res; +} + +setserveroutputon($c); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_dbmsoutput_proc(); end;"); +oci_execute($s); +var_dump(getdbmsoutput_do($c)); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +echo "\nTest 2\n"; +$s = oci_parse($c, "begin imp_res_dbmsoutput_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +var_dump(getdbmsoutput_do($c)); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_dbmsoutput_proc", + "drop table imp_res_dbmsoutput_tab_1", + "drop table imp_res_dbmsoutput_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(2) { + [0]=> + string(18) "dbms_output Line 1" + [1]=> + string(18) "dbms_output Line 2" +} + 1 abcde + 2 fghij + 3 klmno + t + u + v + +Test 2 + 1 abcde + 2 fghij + 3 klmno + t + u + v +array(2) { + [0]=> + string(18) "dbms_output Line 1" + [1]=> + string(18) "dbms_output Line 2" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_field.phpt b/ext/oci8/tests/imp_res_field.phpt new file mode 100644 index 0000000000..54b8295cf9 --- /dev/null +++ b/ext/oci8/tests/imp_res_field.phpt @@ -0,0 +1,227 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: field tests +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_field_tab_1", + "create table imp_res_field_tab_1 (c1_number number, c2_varchar210 varchar2(10))", + "insert into imp_res_field_tab_1 values (1111, 'abcde')", + + "drop table imp_res_field_tab_2", + "create table imp_res_field_tab_2 (c3_varchar21 varchar2(4))", + "insert into imp_res_field_tab_2 values ('tttt')", + + "drop table imp_res_field_tab_3", + "create table imp_res_field_tab_3 (c4_number52 number(5,2))", + "insert into imp_res_field_tab_3 values (33)", + "insert into imp_res_field_tab_3 values (NULL)", + + "create or replace procedure imp_res_field_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_field_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_field_tab_2 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_field_tab_3 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function print_fields($s) +{ + echo "num fields : " . oci_num_fields($s) . "\n"; + for ($i = 1; $i <= oci_num_fields($s); $i++) { + $is_null = oci_field_is_null($s, $i) ? "T" : "F"; + $name = oci_field_name($s, $i); + $precision = oci_field_precision($s, $i); + $scale = oci_field_scale($s, $i); + $size = oci_field_size($s, $i); + $typeraw = oci_field_type_raw($s, $i); + $type = oci_field_type($s, $i); + echo "$name\t: is_null $is_null, precision $precision, scale $scale, size $size, typeraw $typeraw, type $type\n"; + } +} + +// Run Test + +echo "Test 1 - can't get IRS fields from parent\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +print_fields($s); + +echo "\nTest 2 - can't get IRS fields from parent when fetching\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +while (($r = oci_fetch_row($s))) { + var_dump($r); + print_fields($s); +} + +echo "\nTest 3 - get IRS fields\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + print_fields($s1); +} + +echo "\nTest 4 - get IRS fields before fetching rows\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +$i = 0; +while (($s1 = oci_get_implicit_resultset($s))) { + echo "===> Result set ".++$i."\n"; + print_fields($s1); + while (($r = oci_fetch_row($s1)) !== false) { + var_dump($r); + } +} + +echo "\nTest 5 - get IRS fields when fetching rows\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +$i = 0; +while (($s1 = oci_get_implicit_resultset($s))) { + echo "===> Result set ".++$i."\n"; + while (($r = oci_fetch_row($s1)) !== false) { + var_dump($r); + print_fields($s1); + } +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_field_proc", + "drop table imp_res_field_tab_1", + "drop table imp_res_field_tab_2", + "drop table imp_res_field_tab_3" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - can't get IRS fields from parent +num fields : 0 + +Test 2 - can't get IRS fields from parent when fetching +array(2) { + [0]=> + string(4) "1111" + [1]=> + string(5) "abcde" +} +num fields : 0 +array(1) { + [0]=> + string(4) "tttt" +} +num fields : 0 +array(1) { + [0]=> + string(2) "33" +} +num fields : 0 +array(1) { + [0]=> + NULL +} +num fields : 0 + +Test 3 - get IRS fields +num fields : 2 +C1_NUMBER : is_null F, precision 0, scale -127, size 22, typeraw 2, type NUMBER +C2_VARCHAR210 : is_null F, precision 0, scale 0, size 10, typeraw 1, type VARCHAR2 +num fields : 1 +C3_VARCHAR21 : is_null F, precision 0, scale 0, size 4, typeraw 1, type VARCHAR2 +num fields : 1 +C4_NUMBER52 : is_null F, precision 5, scale 2, size 22, typeraw 2, type NUMBER + +Test 4 - get IRS fields before fetching rows +===> Result set 1 +num fields : 2 +C1_NUMBER : is_null F, precision 0, scale -127, size 22, typeraw 2, type NUMBER +C2_VARCHAR210 : is_null F, precision 0, scale 0, size 10, typeraw 1, type VARCHAR2 +array(2) { + [0]=> + string(4) "1111" + [1]=> + string(5) "abcde" +} +===> Result set 2 +num fields : 1 +C3_VARCHAR21 : is_null F, precision 0, scale 0, size 4, typeraw 1, type VARCHAR2 +array(1) { + [0]=> + string(4) "tttt" +} +===> Result set 3 +num fields : 1 +C4_NUMBER52 : is_null F, precision 5, scale 2, size 22, typeraw 2, type NUMBER +array(1) { + [0]=> + string(2) "33" +} +array(1) { + [0]=> + NULL +} + +Test 5 - get IRS fields when fetching rows +===> Result set 1 +array(2) { + [0]=> + string(4) "1111" + [1]=> + string(5) "abcde" +} +num fields : 2 +C1_NUMBER : is_null F, precision 0, scale -127, size 22, typeraw 2, type NUMBER +C2_VARCHAR210 : is_null F, precision 0, scale 0, size 10, typeraw 1, type VARCHAR2 +===> Result set 2 +array(1) { + [0]=> + string(4) "tttt" +} +num fields : 1 +C3_VARCHAR21 : is_null F, precision 0, scale 0, size 4, typeraw 1, type VARCHAR2 +===> Result set 3 +array(1) { + [0]=> + string(2) "33" +} +num fields : 1 +C4_NUMBER52 : is_null F, precision 5, scale 2, size 22, typeraw 2, type NUMBER +array(1) { + [0]=> + NULL +} +num fields : 1 +C4_NUMBER52 : is_null T, precision 5, scale 2, size 22, typeraw 2, type NUMBER +===DONE=== diff --git a/ext/oci8/tests/imp_res_func_error.phpt b/ext/oci8/tests/imp_res_func_error.phpt new file mode 100644 index 0000000000..73c0557930 --- /dev/null +++ b/ext/oci8/tests/imp_res_func_error.phpt @@ -0,0 +1,67 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: test with a PL/SQL function +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace function imp_res_func_error return number as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result(c1); + return 1234; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "select imp_res_func_error from dual"); +$r = oci_execute($s); // This will fail with ORA-29478 in Oracle 12.1 +if ($r) { + while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} +// Clean up + +$stmtarray = array( + "drop function imp_res_func_error", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_execute(): ORA-29478: %s +ORA-06512: %s +ORA-06512: %s +ORA-06512: %s +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_1.phpt b/ext/oci8/tests/imp_res_get_1.phpt new file mode 100644 index 0000000000..665f773b57 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_1.phpt @@ -0,0 +1,109 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_1_tab_1", + "create table imp_res_get_1_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_1_tab_1 values (1, 'abcde')", + "insert into imp_res_get_1_tab_1 values (2, 'fghij')", + "insert into imp_res_get_1_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_1_tab_2", + "create table imp_res_get_1_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_1_tab_2 values ('t')", + "insert into imp_res_get_1_tab_2 values ('u')", + "insert into imp_res_get_1_tab_2 values ('v')", + + "create or replace procedure imp_res_get_1_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_get_1_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_1_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_get_1_proc(); end;"); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +echo "\nTest 2 - with execute\n"; +$s = oci_parse($c, "begin imp_res_get_1_proc(); end;"); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + oci_execute($s1); // no op + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_1_proc", + "drop table imp_res_get_1_tab_1", + "drop table imp_res_get_1_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + t + u + X + +Test 2 - with execute + 1 abcde + 2 fghij + 3 klmno + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_2.phpt b/ext/oci8/tests/imp_res_get_2.phpt new file mode 100644 index 0000000000..b20b8dd397 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_2.phpt @@ -0,0 +1,107 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: similar to imp_res_get_1 but with unrolled loop +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_2_tab_1", + "create table imp_res_get_2_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_2_tab_1 values (1, 'abcde')", + "insert into imp_res_get_2_tab_1 values (2, 'fghij')", + "insert into imp_res_get_2_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_2_tab_2", + "create table imp_res_get_2_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_2_tab_2 values ('t')", + "insert into imp_res_get_2_tab_2 values ('u')", + "insert into imp_res_get_2_tab_2 values ('v')", + + "create or replace procedure imp_res_get_2_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_get_2_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_2_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_2_proc(); end;"); +oci_execute($s); + +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS))) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +$s2 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS))) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +oci_free_statement($s2); + +$s3 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_array($s3, OCI_ASSOC+OCI_RETURN_NULLS))) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +oci_free_statement($s3); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_2_proc", + "drop table imp_res_get_2_tab_1", + "drop table imp_res_get_2_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_3.phpt b/ext/oci8/tests/imp_res_get_3.phpt new file mode 100644 index 0000000000..15b2efaef0 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_3.phpt @@ -0,0 +1,267 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test 3 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--INI-- +oci8.statement_cache_size = 0 +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_3_tab_1", + "create table imp_res_get_3_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_3_tab_1 values (1, 'abcde')", + "insert into imp_res_get_3_tab_1 values (2, 'fghij')", + "insert into imp_res_get_3_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_3_tab_2", + "create table imp_res_get_3_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_3_tab_2 values ('t')", + "insert into imp_res_get_3_tab_2 values ('u')", + "insert into imp_res_get_3_tab_2 values ('v')", + + "create or replace procedure imp_res_get_3_proc as + c1 sys_refcursor; + i pls_integer; + begin + for i in 1..30 loop -- if this value is too big for Oracle's open_cursors, calling imp_res_get_3_proc() can fail with ORA-1000 + open c1 for select * from imp_res_get_3_tab_1 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from imp_res_get_3_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end loop; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_3_proc(); end;"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_3_proc", + "drop table imp_res_get_3_tab_1", + "drop table imp_res_get_3_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_4.phpt b/ext/oci8/tests/imp_res_get_4.phpt new file mode 100644 index 0000000000..ea7fb8775a --- /dev/null +++ b/ext/oci8/tests/imp_res_get_4.phpt @@ -0,0 +1,146 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: interleaved fetches +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_4_tab_1", + "create table imp_res_get_4_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_4_tab_1 values (1, 'abcde')", + "insert into imp_res_get_4_tab_1 values (2, 'fghij')", + "insert into imp_res_get_4_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_4_tab_2", + "create table imp_res_get_4_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_4_tab_2 values ('t')", + "insert into imp_res_get_4_tab_2 values ('u')", + "insert into imp_res_get_4_tab_2 values ('v')", + + "create or replace procedure imp_res_get_4_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_get_4_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_4_tab_2 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function print_row($row) +{ + if ($row === false) { + print "Return is false\n"; + return; + } + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_4_proc(); end;"); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +$s2 = oci_get_implicit_resultset($s); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); + +echo "Test 2 - too many fetches\n"; + +$s = oci_parse($c, "begin imp_res_get_4_proc(); end;"); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +$s2 = oci_get_implicit_resultset($s); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_4_proc", + "drop table imp_res_get_4_tab_1", + "drop table imp_res_get_4_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + t + 2 fghij + u + 3 klmno + v +Test 2 - too many fetches + 1 abcde + t + 2 fghij + u + 3 klmno + v +Return is false +Return is false + +Warning: oci_fetch_array(): ORA-01002: %s in %simp_res_get_4.php on line %d +Return is false + +Warning: oci_fetch_array(): ORA-01002: %s in %simp_res_get_4.php on line %d +Return is false +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_5.phpt b/ext/oci8/tests/imp_res_get_5.phpt new file mode 100644 index 0000000000..3cfa0967a2 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_5.phpt @@ -0,0 +1,124 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: get from wrong statement +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +function print_row($row) +{ + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; +// This test effectively discards all the first IRS results +$s = oci_parse($c, $plsql); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { // $s1 is never used again so its results are lost + while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { // use parent $s instead of $s1 + print_row($row); + } +} +oci_free_statement($s); + +echo "\nTest 2 - fetch first IRS explicitly\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s1)) != false) { + print_row($row); +} +while (($row = oci_fetch_row($s)) != false) { + print_row($row); +} +oci_free_statement($s); + +echo "\nTest 3 - fetch part of IRS explicitly\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s1)) != false) { + print_row($row); +} +$row = oci_fetch_row($s); +print_row($row); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s1)) != false) { + print_row($row); +} +while (($row = oci_fetch_row($s)) != false) { + print_row($row); +} +oci_free_statement($s); + +echo "\nTest 4 - skip IRSs\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s)) != false) { // parent + print_row($row); +} +oci_free_statement($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 3 + 4 + 5 + 6 + +Test 2 - fetch first IRS explicitly + 1 + 2 + 3 + 4 + 5 + 6 + +Test 3 - fetch part of IRS explicitly + 1 + 2 + 3 + 5 + 6 + 4 + +Test 4 - skip IRSs + 5 + 6 +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_all.phpt b/ext/oci8/tests/imp_res_get_all.phpt new file mode 100644 index 0000000000..d2dcbea6c7 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_all.phpt @@ -0,0 +1,120 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_fetch_all +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$plsql = "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); + +$s1 = oci_get_implicit_resultset($s); +oci_fetch_all($s1, $res); +var_dump($res); + +$s2 = oci_get_implicit_resultset($s); +oci_fetch_all($s2, $res); +var_dump($res); + +$s3 = oci_get_implicit_resultset($s); +oci_fetch_all($s3, $res); +var_dump($res); + +echo "\nTest 2\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + $r = oci_fetch_all($s1, $res); + var_dump($res); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(1) { + [1]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + } +} +array(1) { + [3]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(1) "4" + } +} +array(1) { + [5]=> + array(2) { + [0]=> + string(1) "5" + [1]=> + string(1) "6" + } +} + +Test 2 +array(1) { + [1]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + } +} +array(1) { + [3]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(1) "4" + } +} +array(1) { + [5]=> + array(2) { + [0]=> + string(1) "5" + [1]=> + string(1) "6" + } +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_cancel.phpt b/ext/oci8/tests/imp_res_get_cancel.phpt new file mode 100644 index 0000000000..7dbcecbfe9 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_cancel.phpt @@ -0,0 +1,56 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_cancel +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$plsql = + "declare + c1 sys_refcursor; + c2 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c2 for select 3 from dual; + dbms_sql.return_result (c2); + end;"; + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_cancel($s1); + } +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 3 +===DONE=== + diff --git a/ext/oci8/tests/imp_res_get_close_1.phpt b/ext/oci8/tests/imp_res_get_close_1.phpt new file mode 100644 index 0000000000..2edc8bf604 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_close_1.phpt @@ -0,0 +1,68 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_free_statement #1 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_free_statement($s1); // Free the implicit result handle + } +} +oci_free_statement($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d + 3 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d + 5 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_close_2.phpt b/ext/oci8/tests/imp_res_get_close_2.phpt new file mode 100644 index 0000000000..b3153834ba --- /dev/null +++ b/ext/oci8/tests/imp_res_get_close_2.phpt @@ -0,0 +1,64 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_free_statement #2 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_free_statement($s); // close parent + } +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + +Warning: oci_fetch_array(): OCI_INVALID_HANDLE in %s on line %d + +Warning: oci_get_implicit_resultset(): %d is not a valid oci8 statement resource in %s on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_close_3.phpt b/ext/oci8/tests/imp_res_get_close_3.phpt new file mode 100644 index 0000000000..4793a6c882 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_close_3.phpt @@ -0,0 +1,65 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_free_statement #3 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } + oci_free_statement($s1); +} +oci_free_statement($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + 3 + 4 + 5 + 6 +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_cursor.phpt b/ext/oci8/tests/imp_res_get_cursor.phpt new file mode 100644 index 0000000000..ccdb6f5490 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_cursor.phpt @@ -0,0 +1,101 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: nested cursor +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_cursor_tab_1", + "create table imp_res_get_cursor_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_cursor_tab_1 values (1, 'abcde')", + "insert into imp_res_get_cursor_tab_1 values (2, 'fghij')", + "insert into imp_res_get_cursor_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_cursor_tab_2", + "create table imp_res_get_cursor_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_cursor_tab_2 values ('t')", + "insert into imp_res_get_cursor_tab_2 values ('u')", + "insert into imp_res_get_cursor_tab_2 values ('v')", + + "create or replace procedure imp_res_get_cursor_proc as + c1 sys_refcursor; + begin + open c1 for select cursor(select c1, c2 from imp_res_get_cursor_tab_1 order by 1) as curs from dual; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_cursor_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function do_fetch($s) +{ + while (($row = oci_fetch_assoc($s)) != false) { + foreach ($row as $item) { + if (is_resource($item)) { // Nested cursor + oci_execute($item); + do_fetch($item); + } else { + echo " ".$item; + } + } + echo "\n"; + } +} + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_cursor_proc(); end;"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + do_fetch($s1); +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_cursor_proc", + "drop table imp_res_get_cursor_tab_1", + "drop table imp_res_get_cursor_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_dbmsoutput.phpt b/ext/oci8/tests/imp_res_get_dbmsoutput.phpt new file mode 100644 index 0000000000..cbc2389e46 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_dbmsoutput.phpt @@ -0,0 +1,156 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: interleaved with DBMS_OUTPUT +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_dbmsoutput_tab_1", + "create table imp_res_get_dbmsoutput_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_dbmsoutput_tab_1 values (1, 'abcde')", + "insert into imp_res_get_dbmsoutput_tab_1 values (2, 'fghij')", + "insert into imp_res_get_dbmsoutput_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_dbmsoutput_tab_2", + "create table imp_res_get_dbmsoutput_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_dbmsoutput_tab_2 values ('t')", + "insert into imp_res_get_dbmsoutput_tab_2 values ('u')", + "insert into imp_res_get_dbmsoutput_tab_2 values ('v')", + + "create or replace procedure imp_res_get_dbmsoutput_proc as + c1 sys_refcursor; + begin + dbms_output.put_line('Line 1'); + open c1 for select * from imp_res_get_dbmsoutput_tab_1 order by 1; + dbms_sql.return_result(c1); + dbms_output.put_line('Line 2'); + open c1 for select * from imp_res_get_dbmsoutput_tab_2 order by 1; + dbms_sql.return_result(c1); + dbms_output.put_line('Line 3'); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Turn DBMS_OUTPUT on +function setserveroutputon($c) +{ + $s = oci_parse($c, "begin dbms_output.enable(null); end;"); + oci_execute($s); +} + +function getdbmsoutput_do($c) +{ + $s = oci_parse($c, "begin dbms_output.get_line(:ln, :st); end;"); + oci_bind_by_name($s, ":ln", $ln, 100); + oci_bind_by_name($s, ":st", $st, -1, SQLT_INT); + $res = false; + while (($succ = oci_execute($s)) && !$st) { + $res[] = $ln; // append each line to the array + } + return $res; +} + +setserveroutputon($c); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_dbmsoutput_proc(); end;"); +oci_execute($s); + +var_dump(getdbmsoutput_do($c)); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +echo "Test 2\n"; + +$s = oci_parse($c, "begin imp_res_get_dbmsoutput_proc(); end;"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +var_dump(getdbmsoutput_do($c)); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_dbmsoutput_proc", + "drop table imp_res_get_dbmsoutput_tab_1", + "drop table imp_res_get_dbmsoutput_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(3) { + [0]=> + string(6) "Line 1" + [1]=> + string(6) "Line 2" + [2]=> + string(6) "Line 3" +} + 1 abcde + 2 fghij + 3 klmno + t + u + v + X +Test 2 + 1 abcde + 2 fghij + 3 klmno + t + u + v + X +array(3) { + [0]=> + string(6) "Line 1" + [1]=> + string(6) "Line 2" + [2]=> + string(6) "Line 3" +} +===DONE=== + diff --git a/ext/oci8/tests/imp_res_get_exec.phpt b/ext/oci8/tests/imp_res_get_exec.phpt new file mode 100644 index 0000000000..dbd8f3ef3a --- /dev/null +++ b/ext/oci8/tests/imp_res_get_exec.phpt @@ -0,0 +1,55 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: Execute twice +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$plsql = "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +$s1 = oci_get_implicit_resultset($s); +oci_execute($s1); +oci_execute($s1); // execute twice; should be NOP +while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +oci_free_statement($s); + + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_none.phpt b/ext/oci8/tests/imp_res_get_none.phpt new file mode 100644 index 0000000000..981f4945e2 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_none.phpt @@ -0,0 +1,46 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: no implicit results +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from dual"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +var_dump($s1); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +bool(false) +===DONE=== diff --git a/ext/oci8/tests/imp_res_insert.phpt b/ext/oci8/tests/imp_res_insert.phpt new file mode 100644 index 0000000000..d9c0705b55 --- /dev/null +++ b/ext/oci8/tests/imp_res_insert.phpt @@ -0,0 +1,152 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: Commit modes +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$c2 = oci_new_connect($user, $password, $dbase); + +$stmtarray = array( + "drop table imp_res_insert_tab", + "create table imp_res_insert_tab (c1 number)", + + "create or replace procedure imp_res_insert_proc_nc (p1 in number) as + c1 sys_refcursor; + begin + execute immediate 'insert into imp_res_insert_tab values ('||p1||')'; + open c1 for select * from imp_res_insert_tab order by 1; + dbms_sql.return_result(c1); + end;", + + "create or replace procedure imp_res_insert_proc_c (p1 in number) as + c1 sys_refcursor; + begin + execute immediate 'insert into imp_res_insert_tab values ('||p1||')'; + commit; + open c1 for select * from imp_res_insert_tab order by 1; + dbms_sql.return_result(c1); + end;" + +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - No commit in procedure, OCI_COMMIT_ON_SUCCESS mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_nc(111); end;"); +oci_execute($s, OCI_COMMIT_ON_SUCCESS); +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +echo "\nTest 2 - No commit in procedure, OCI_NO_AUTO_COMMIT mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_nc(222); end;"); +oci_execute($s, OCI_NO_AUTO_COMMIT); +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +// The 2nd connection won't see the newly inserted data +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +echo "\nTest 3 - Commit in procedure, OCI_COMMIT_ON_SUCCESS mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_c(333); end;"); +oci_execute($s, OCI_COMMIT_ON_SUCCESS); +// The 2nd connection will now see the previously uncommitted data inserted in the previous test +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +echo "\nTest 4 - Commit in procedure, OCI_NO_AUTO_COMMIT mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_c(444); end;"); +oci_execute($s, OCI_NO_AUTO_COMMIT); +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_insert_proc_nc", + "drop procedure imp_res_insert_proc_c", + "drop table imp_res_insert_tab", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - No commit in procedure, OCI_COMMIT_ON_SUCCESS mode +111 +array(1) { + [0]=> + string(3) "111" +} + +Test 2 - No commit in procedure, OCI_NO_AUTO_COMMIT mode +111 +222 +array(1) { + [0]=> + string(3) "111" +} + +Test 3 - Commit in procedure, OCI_COMMIT_ON_SUCCESS mode +111 +222 +333 +array(3) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + [2]=> + string(3) "333" +} + +Test 4 - Commit in procedure, OCI_NO_AUTO_COMMIT mode +111 +222 +333 +444 +array(4) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + [2]=> + string(3) "333" + [3]=> + string(3) "444" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_lob.phpt b/ext/oci8/tests/imp_res_lob.phpt new file mode 100644 index 0000000000..247803581d --- /dev/null +++ b/ext/oci8/tests/imp_res_lob.phpt @@ -0,0 +1,101 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: LOBs +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_lob_tab", + "create table imp_res_lob_tab (c1 number, c2 clob, c3 varchar2(10))", + "insert into imp_res_lob_tab values (1, 'aaaaa', 'a')", + "insert into imp_res_lob_tab values (2, 'bbbbb', 'b')", + "insert into imp_res_lob_tab values (3, 'ccccc', 'c')", + "insert into imp_res_lob_tab values (4, 'ddddd', 'd')", + + "create or replace procedure imp_res_lob_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_lob_tab order by 1; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result(c1); + open c1 for select c2 from imp_res_lob_tab order by c1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_lob_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) { + foreach ($row as $item) { + if (is_object($item)) { + echo " " . $item->load(); + } else { + echo " " . $item; + } + } + echo "\n"; +} + +echo "\nTest 2 - don't fetch all rows\n"; +$s = oci_parse($c, "begin imp_res_lob_proc(); end;"); +oci_execute($s); +$row = oci_fetch_row($s); +foreach ($row as $item) { + if (is_object($item)) { + echo " " . $item->load(); + } else { + echo " " . $item; + } +} +echo "\n"; + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_lob_proc", + "drop table imp_res_lob_tab", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 aaaaa a + 2 bbbbb b + 3 ccccc c + 4 ddddd d + X + aaaaa + bbbbb + ccccc + ddddd + +Test 2 - don't fetch all rows + 1 aaaaa a +===DONE=== diff --git a/ext/oci8/tests/imp_res_prefetch.phpt b/ext/oci8/tests/imp_res_prefetch.phpt new file mode 100644 index 0000000000..5acdd518e5 --- /dev/null +++ b/ext/oci8/tests/imp_res_prefetch.phpt @@ -0,0 +1,185 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: basic test +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_prefetch_tab_1", + "create table imp_res_prefetch_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_prefetch_tab_1 values (1, 'abcde')", + "insert into imp_res_prefetch_tab_1 values (2, 'fghij')", + "insert into imp_res_prefetch_tab_1 values (3, 'klmno')", + + "drop table imp_res_prefetch_tab_2", + "create table imp_res_prefetch_tab_2 (c3 varchar2(1))", + "insert into imp_res_prefetch_tab_2 values ('t')", + "insert into imp_res_prefetch_tab_2 values ('u')", + "insert into imp_res_prefetch_tab_2 values ('v')", + + "create or replace procedure imp_res_prefetch_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_prefetch_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_prefetch_tab_2 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - prefetch 0\n"; +$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); +oci_execute($s); +var_dump(oci_set_prefetch($s, 0)); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "\nTest 1 - prefetch 1\n"; +$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); +oci_execute($s); +var_dump(oci_set_prefetch($s, 1)); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "\nTest 1 - prefetch 2\n"; +$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); +oci_execute($s); +var_dump(oci_set_prefetch($s, 2)); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_prefetch_proc", + "drop table imp_res_prefetch_tab_1", + "drop table imp_res_prefetch_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - prefetch 0 +bool(true) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(1) "v" +} + +Test 1 - prefetch 1 +bool(true) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(1) "v" +} + +Test 1 - prefetch 2 +bool(true) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(1) "v" +} +===DONE=== diff --git a/ext/oci8/tests/lob_015.phpt b/ext/oci8/tests/lob_015.phpt index b4a19684a3..59e8fec42a 100644 --- a/ext/oci8/tests/lob_015.phpt +++ b/ext/oci8/tests/lob_015.phpt @@ -48,7 +48,7 @@ Warning: oci_bind_by_name() expects at least 3 parameters, 2 given in %s on line Warning: oci_bind_by_name() expects at least 3 parameters, 1 given in %s on line %d -Warning: oci_execute(): ORA-00932: %s NUMBER %s BLOB in %s on line %d +Warning: oci_execute(): ORA-00932: %s on line %d object(OCI-Lob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) diff --git a/ext/oci8/tests/lob_temp2.phpt b/ext/oci8/tests/lob_temp2.phpt new file mode 100644 index 0000000000..d774b4d724 --- /dev/null +++ b/ext/oci8/tests/lob_temp2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Writing temporary lob before binding +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); +require(dirname(__FILE__).'/create_table.inc'); + +$ora_sql = "INSERT INTO ".$schema.$table_name." (clob) VALUES (:v_clob)"; + +$clob = oci_new_descriptor($c, OCI_D_LOB); +var_dump($clob->writeTemporary("test")); + +$statement = oci_parse($c, $ora_sql); +oci_bind_by_name($statement, ":v_clob", $clob, -1, OCI_B_CLOB); +oci_execute($statement, OCI_DEFAULT); + +$s = oci_parse($c, "select clob from ". $schema.$table_name); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +?> +===DONE=== +--EXPECTF-- +bool(true) +array(1) { + ["CLOB"]=> + array(1) { + [0]=> + string(4) "test" + } +} +===DONE=== diff --git a/ext/oci8/tests/minfo.phpt b/ext/oci8/tests/minfo.phpt index f6b95ff296..34a19ca693 100644 --- a/ext/oci8/tests/minfo.phpt +++ b/ext/oci8/tests/minfo.phpt @@ -8,12 +8,12 @@ Code coverage for PHP_MINFO_FUNCTION(oci) ob_start(); phpinfo(INFO_MODULES); $v = ob_get_clean(); -$r = strpos($v, 'OCI8 Support => enabled'); -var_dump($r); +$r = preg_match('/OCI8 Support .* enabled/', $v); +if ($r !== 1) + var_dump($r); echo "Done\n"; ?> --EXPECTF-- -int(%d) Done diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt index 1738702cb6..8ea81d3fc0 100644 --- a/ext/oci8/tests/password.phpt +++ b/ext/oci8/tests/password.phpt @@ -14,28 +14,28 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode"); require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuserpwd", - "grant connect, create session to testuser" + "drop user testuser_pw cascade", + "create user testuser_pw identified by testuserpwd", + "grant connect, create session to testuser_pw" ); oci8_test_sql_execute($c, $stmtarray); // Connect and change the password -$c1 = oci_connect("testuser", "testuserpwd", $dbase); +$c1 = oci_connect("testuser_pw", "testuserpwd", $dbase); var_dump($c1); $rn1 = (int)$c1; -oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); +oci_password_change($c1, "testuser_pw", "testuserpwd", "testuserpwd2"); // Second connect should return a new resource because the hash string will be different from $c1 -$c2 = oci_connect("testuser", "testuserpwd2", $dbase); +$c2 = oci_connect("testuser_pw", "testuserpwd2", $dbase); var_dump($c2); $rn2 = (int)$c2; // Despite using the old password this connect should succeed and return the original resource -$c3 = oci_connect("testuser", "testuserpwd", $dbase); +$c3 = oci_connect("testuser_pw", "testuserpwd", $dbase); var_dump($c3); $rn3 = (int)$c3; @@ -67,7 +67,7 @@ echo "Done\n"; require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade" + "drop user testuser_pw cascade" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/password_2.phpt b/ext/oci8/tests/password_2.phpt index ceba0bba80..13da9ff7b2 100644 --- a/ext/oci8/tests/password_2.phpt +++ b/ext/oci8/tests/password_2.phpt @@ -14,27 +14,27 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode"); require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuserpwd", - "grant connect, create session to testuser" + "drop user testuser_pw2 cascade", + "create user testuser_pw2 identified by testuserpwd", + "grant connect, create session to testuser_pw2" ); oci8_test_sql_execute($c, $stmtarray); // Connect (persistent) and change the password -$c1 = oci_pconnect("testuser", "testuserpwd", $dbase); +$c1 = oci_pconnect("testuser_pw2", "testuserpwd", $dbase); var_dump($c1); $rn1 = (int)$c1; -oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); +oci_password_change($c1, "testuser_pw2", "testuserpwd", "testuserpwd2"); // Second connect should return a new resource because the hash string will be different from $c1 -$c2 = oci_pconnect("testuser", "testuserpwd2", $dbase); +$c2 = oci_pconnect("testuser_pw2", "testuserpwd2", $dbase); var_dump($c2); $rn2 = (int)$c2; // Despite using the old password this connect should succeed and return the original resource -$c3 = oci_pconnect("testuser", "testuserpwd", $dbase); +$c3 = oci_pconnect("testuser_pw2", "testuserpwd", $dbase); var_dump($c3); $rn3 = (int)$c3; @@ -66,7 +66,7 @@ echo "Done\n"; require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade" + "drop user testuser_pw2 cascade" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt index c218d904fa..2c66dd94ab 100644 --- a/ext/oci8/tests/password_new.phpt +++ b/ext/oci8/tests/password_new.phpt @@ -3,15 +3,27 @@ oci_password_change() --SKIPIF-- <?php $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes -require(dirname(__FILE__).'/skipif.inc'); +require(dirname(__FILE__).'/connect.inc'); if (empty($dbase)) die ("skip requires database connection string be set"); if ($test_drcp) die("skip password change not supported in DRCP Mode"); -// This test is known to fail with Oracle 10.2.0.4 client libraries -// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5) -if (preg_match('/Release (11|12)\./', oci_server_version($c), $matches) === 1 && - preg_match('/^10\.2\.0\.[1234]/', oci_client_version()) === 1) { - die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv); +if (isset($matches_sv[1]) && $matches_sv[1] >= 11) { + preg_match('/([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches); + if (isset($matches[0]) && $matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] < 5) { + die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); + } +} + +// This test in Oracle 12c needs a non-CDB or the root container +if (isset($matches_sv[1]) && $matches_sv[1] >= 12) { + $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual"); + $r = @oci_execute($s); + if (!$r) + die('skip could not identify container type'); + $r = oci_fetch_array($s); + if ($r['DBTYPE'] !== 'CDB$ROOT') + die('skip cannot run test using a PDB'); } ?> --FILE-- diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt index fdbb1f9e89..2e186528e3 100644 --- a/ext/oci8/tests/password_old.phpt +++ b/ext/oci8/tests/password_old.phpt @@ -3,18 +3,28 @@ ocipasswordchange() --SKIPIF-- <?php $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes -require(dirname(__FILE__).'/skipif.inc'); +require(dirname(__FILE__).'/connect.inc'); if (empty($dbase)) die ("skip requires database connection string be set"); if ($test_drcp) die("skip password change not supported in DRCP Mode"); -// This test is known to fail with Oracle 10.2.0.4 client libraries -// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5) -if (preg_match('/Release (11|12)\./', oci_server_version($c), $matches) === 1 && - preg_match('/^10\.2\.0\.[1234]/', oci_client_version()) === 1) { - die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv); +if (isset($matches_sv[1]) && $matches_sv[1] >= 11) { + preg_match('/([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches); + if (isset($matches[0]) && $matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] < 5) { + die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); + } } - +// This test in Oracle 12c needs a non-CDB or the root container +if (isset($matches_sv[1]) && $matches_sv[1] >= 12) { + $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual"); + $r = @oci_execute($s); + if (!$r) + die('skip could not identify container type'); + $r = oci_fetch_array($s); + if ($r['DBTYPE'] !== 'CDB$ROOT') + die('skip cannot run test using a PDB'); +} ?> --FILE-- <?php diff --git a/ext/oci8/tests/refcur_prefetch_3.phpt b/ext/oci8/tests/refcur_prefetch_3.phpt index 8c0414042b..974864cbd9 100644 --- a/ext/oci8/tests/refcur_prefetch_3.phpt +++ b/ext/oci8/tests/refcur_prefetch_3.phpt @@ -86,52 +86,52 @@ Test with Nested Cursors Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test0" + string(%d) "test0" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test1" + string(%d) "test1" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test2" + string(%d) "test2" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test3" + string(%d) "test3" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test4" + string(%d) "test4" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test5" + string(%d) "test5" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test6" + string(%d) "test6" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test7" + string(%d) "test7" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test8" + string(%d) "test8" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test9" + string(%d) "test9" } Number of roundtrips made with prefetch count 5 for 10 rows is 3 Done diff --git a/ext/oci8/tests/reflection1.phpt b/ext/oci8/tests/reflection1.phpt index 5f2e73d80b..f76d7261aa 100644 --- a/ext/oci8/tests/reflection1.phpt +++ b/ext/oci8/tests/reflection1.phpt @@ -126,6 +126,7 @@ reflection::export(new reflectionfunction('oci_set_module_name')); reflection::export(new reflectionfunction('oci_set_action')); reflection::export(new reflectionfunction('oci_set_client_info')); reflection::export(new reflectionfunction('oci_set_client_identifier')); +reflection::export(new reflectionfunction('oci_get_implicit_resultset')); ?> ===DONE=== @@ -1093,4 +1094,11 @@ Function [ <internal%s> function oci_set_client_identifier ] { } } +Function [ <internal%s> function oci_get_implicit_resultset ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + ===DONE=== diff --git a/ext/odbc/config.m4 b/ext/odbc/config.m4 index eaed212cd7..7bc06715dd 100644 --- a/ext/odbc/config.m4 +++ b/ext/odbc/config.m4 @@ -365,7 +365,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(iodbc,, -[ --with-iodbc[=DIR] Include iODBC support [/usr/local]]) +[ --with-iodbc[=DIR] Include iODBC support]) if test "$PHP_IODBC" != "no"; then AC_MSG_CHECKING(for iODBC support) diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c new file mode 100644 index 0000000000..b29241344c --- /dev/null +++ b/ext/opcache/Optimizer/compact_literals.c @@ -0,0 +1,481 @@ +/* pass 11 + * - compact literals table + */ +#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO + +#define DEBUG_COMPACT_LITERALS 0 + +#define LITERAL_VALUE 0x0100 +#define LITERAL_FUNC 0x0200 +#define LITERAL_CLASS 0x0300 +#define LITERAL_CONST 0x0400 +#define LITERAL_CLASS_CONST 0x0500 +#define LITERAL_STATIC_METHOD 0x0600 +#define LITERAL_STATIC_PROPERTY 0x0700 +#define LITERAL_METHOD 0x0800 +#define LITERAL_PROPERTY 0x0900 + +#define LITERAL_EX_CLASS 0x4000 +#define LITERAL_EX_OBJ 0x2000 +#define LITERAL_MAY_MERGE 0x1000 +#define LITERAL_KIND_MASK 0x0f00 +#define LITERAL_NUM_RELATED_MASK 0x000f +#define LITERAL_NUM_SLOTS_MASK 0x00f0 +#define LITERAL_NUM_SLOTS_SHIFT 4 + +#define LITERAL_NUM_RELATED(info) (info & LITERAL_NUM_RELATED_MASK) +#define LITERAL_NUM_SLOTS(info) ((info & LITERAL_NUM_SLOTS_MASK) >> LITERAL_NUM_SLOTS_SHIFT) + +typedef struct _literal_info { + zend_uint flags; /* bitmask (see defines above) */ + union { + int num; /* variable number or class name literal number */ + } u; +} literal_info; + +#define LITERAL_FLAGS(kind, slots, related) \ + ((kind) | ((slots) << LITERAL_NUM_SLOTS_SHIFT) | (related)) + +#define LITERAL_INFO(n, kind, merge, slots, related) do { \ + info[n].flags = (((merge) ? LITERAL_MAY_MERGE : 0) | LITERAL_FLAGS(kind, slots, related)); \ + } while (0) + +#define LITERAL_INFO_CLASS(n, kind, merge, slots, related, _num) do { \ + info[n].flags = (LITERAL_EX_CLASS | ((merge) ? LITERAL_MAY_MERGE : 0) | LITERAL_FLAGS(kind, slots, related)); \ + info[n].u.num = (_num); \ + } while (0) + +#define LITERAL_INFO_OBJ(n, kind, merge, slots, related, _num) do { \ + info[n].flags = (LITERAL_EX_OBJ | ((merge) ? LITERAL_MAY_MERGE : 0) | LITERAL_FLAGS(kind, slots, related)); \ + info[n].u.num = (_num); \ + } while (0) + +static void optimizer_literal_obj_info(literal_info *info, + zend_uchar op_type, + znode_op op, + int constant, + zend_uint kind, + zend_uint slots, + zend_uint related, + zend_op_array *op_array) +{ + /* For now we merge only $this object properties and methods. + * In general it's also possible to do it for any CV variable as well, + * but it would require complex dataflow and/or type analysis. + */ + if (Z_TYPE(op_array->literals[constant].constant) == IS_STRING && + op_type == IS_UNUSED) { + LITERAL_INFO_OBJ(constant, kind, 1, slots, related, op_array->this_var); + } else { + LITERAL_INFO(constant, kind, 0, slots, related); + } +} + +static void optimizer_literal_class_info(literal_info *info, + zend_uchar op_type, + znode_op op, + int constant, + zend_uint kind, + zend_uint slots, + zend_uint related, + zend_op_array *op_array) +{ + if (op_type == IS_CONST) { + LITERAL_INFO_CLASS(constant, kind, 1, slots, related, op.constant); + } else { + LITERAL_INFO(constant, kind, 0, slots, related); + } +} + +static void optimizer_compact_literals(zend_op_array *op_array TSRMLS_DC) +{ + zend_op *opline, *end; + int i, j, n, *pos, *map, cache_slots; + ulong h; + literal_info *info; + int l_null = -1; + int l_false = -1; + int l_true = -1; + HashTable hash; + char *key; + int key_len; + + if (op_array->last_literal) { + info = (literal_info*)ecalloc(op_array->last_literal, sizeof(literal_info)); + + /* Mark literals of specific types */ + opline = op_array->opcodes; + end = opline + op_array->last; + while (opline < end) { + switch (opline->opcode) { + case ZEND_DO_FCALL: + LITERAL_INFO(opline->op1.constant, LITERAL_FUNC, 1, 1, 1); + break; + case ZEND_INIT_FCALL_BY_NAME: + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op2.constant, LITERAL_FUNC, 1, 1, 2); + } + break; + case ZEND_INIT_NS_FCALL_BY_NAME: + LITERAL_INFO(opline->op2.constant, LITERAL_FUNC, 1, 1, 3); + break; + case ZEND_INIT_METHOD_CALL: + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + optimizer_literal_obj_info( + info, + opline->op1_type, + opline->op1, + opline->op2.constant, + LITERAL_METHOD, 2, 2, + op_array); + } + break; + case ZEND_INIT_STATIC_METHOD_CALL: + if (ZEND_OP1_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op1.constant, LITERAL_CLASS, 1, 1, 2); + } + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + optimizer_literal_class_info( + info, + opline->op1_type, + opline->op1, + opline->op2.constant, + LITERAL_STATIC_METHOD, (ZEND_OP1_TYPE(opline) == IS_CONST) ? 1 : 2, 2, + op_array); + } + break; + case ZEND_CATCH: + LITERAL_INFO(opline->op1.constant, LITERAL_CLASS, 1, 1, 2); + break; + case ZEND_FETCH_CONSTANT: + if (ZEND_OP1_TYPE(opline) == IS_UNUSED) { + if ((opline->extended_value & (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) == (IS_CONSTANT_IN_NAMESPACE|IS_CONSTANT_UNQUALIFIED)) { + LITERAL_INFO(opline->op2.constant, LITERAL_CONST, 1, 1, 5); + } else { + LITERAL_INFO(opline->op2.constant, LITERAL_CONST, 1, 1, 3); + } + } else { + if (ZEND_OP1_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op1.constant, LITERAL_CLASS, 1, 1, 2); + } + optimizer_literal_class_info( + info, + opline->op1_type, + opline->op1, + opline->op2.constant, + LITERAL_CLASS_CONST, (ZEND_OP1_TYPE(opline) == IS_CONST) ? 1 : 2, 1, + op_array); + } + break; + case ZEND_FETCH_R: + case ZEND_FETCH_W: + case ZEND_FETCH_RW: + case ZEND_FETCH_IS: + case ZEND_FETCH_UNSET: + case ZEND_FETCH_FUNC_ARG: + case ZEND_UNSET_VAR: + case ZEND_ISSET_ISEMPTY_VAR: + if (ZEND_OP2_TYPE(opline) == IS_UNUSED) { + if (ZEND_OP1_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 1, 0, 1); + } + } else { + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op2.constant, LITERAL_CLASS, 1, 1, 2); + } + if (ZEND_OP1_TYPE(opline) == IS_CONST) { + optimizer_literal_class_info( + info, + opline->op2_type, + opline->op2, + opline->op1.constant, + LITERAL_STATIC_PROPERTY, 2, 1, + op_array); + } + } + break; + case ZEND_FETCH_CLASS: + case ZEND_ADD_INTERFACE: + case ZEND_ADD_TRAIT: + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op2.constant, LITERAL_CLASS, 1, 1, 2); + } + break; + case ZEND_ASSIGN_OBJ: + case ZEND_FETCH_OBJ_R: + case ZEND_FETCH_OBJ_W: + case ZEND_FETCH_OBJ_RW: + case ZEND_FETCH_OBJ_IS: + case ZEND_FETCH_OBJ_UNSET: + case ZEND_FETCH_OBJ_FUNC_ARG: + case ZEND_UNSET_OBJ: + case ZEND_PRE_INC_OBJ: + case ZEND_PRE_DEC_OBJ: + case ZEND_POST_INC_OBJ: + case ZEND_POST_DEC_OBJ: + case ZEND_ISSET_ISEMPTY_PROP_OBJ: + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + optimizer_literal_obj_info( + info, + opline->op1_type, + opline->op1, + opline->op2.constant, + LITERAL_PROPERTY, 2, 1, + op_array); + } + break; + case ZEND_ASSIGN_ADD: + case ZEND_ASSIGN_SUB: + case ZEND_ASSIGN_MUL: + case ZEND_ASSIGN_DIV: + case ZEND_ASSIGN_MOD: + case ZEND_ASSIGN_SL: + case ZEND_ASSIGN_SR: + case ZEND_ASSIGN_CONCAT: + case ZEND_ASSIGN_BW_OR: + case ZEND_ASSIGN_BW_AND: + case ZEND_ASSIGN_BW_XOR: + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + if (opline->extended_value == ZEND_ASSIGN_OBJ) { + optimizer_literal_obj_info( + info, + opline->op1_type, + opline->op1, + opline->op2.constant, + LITERAL_PROPERTY, 2, 1, + op_array); + } else { + LITERAL_INFO(opline->op2.constant, LITERAL_VALUE, 1, 0, 1); + } + } + break; + default: + if (ZEND_OP1_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 1, 0, 1); + } + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + LITERAL_INFO(opline->op2.constant, LITERAL_VALUE, 1, 0, 1); + } + break; + } + opline++; + } + +#if DEBUG_COMPACT_LITERALS + { + int i, use_copy; + fprintf(stderr, "File %s func %s\n", op_array->filename, + op_array->function_name? op_array->function_name : "main"); + fprintf(stderr, "Literlas table size %d\n", op_array->last_literal); + + for (i = 0; i < op_array->last_literal; i++) { + zval zv = op_array->literals[i].constant; + zend_make_printable_zval(&op_array->literals[i].constant, &zv, &use_copy); + fprintf(stderr, "Literal %d, val (%d):%s\n", i, Z_STRLEN(zv), Z_STRVAL(zv)); + if (use_copy) { + zval_dtor(&zv); + } + } + fflush(stderr); + } +#endif + + /* Merge equal constants */ + j = 0; cache_slots = 0; + zend_hash_init(&hash, 16, NULL, NULL, 0); + map = (int*)ecalloc(op_array->last_literal, sizeof(int)); + for (i = 0; i < op_array->last_literal; i++) { + if (!info[i].flags) { + /* unsed literal */ + zval_dtor(&op_array->literals[i].constant); + continue; + } + switch (Z_TYPE(op_array->literals[i].constant)) { + case IS_NULL: + if (l_null < 0) { + l_null = j; + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + j++; + } + map[i] = l_null; + break; + case IS_BOOL: + if (Z_LVAL(op_array->literals[i].constant)) { + if (l_true < 0) { + l_true = j; + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + j++; + } + map[i] = l_true; + } else { + if (l_false < 0) { + l_false = j; + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + j++; + } + map[i] = l_false; + } + break; + case IS_LONG: + if (zend_hash_index_find(&hash, Z_LVAL(op_array->literals[i].constant), (void**)&pos) == SUCCESS) { + map[i] = *pos; + } else { + map[i] = j; + zend_hash_index_update(&hash, Z_LVAL(op_array->literals[i].constant), (void**)&j, sizeof(int), NULL); + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + j++; + } + break; + case IS_DOUBLE: + if (zend_hash_find(&hash, (char*)&Z_DVAL(op_array->literals[i].constant), sizeof(double), (void**)&pos) == SUCCESS) { + map[i] = *pos; + } else { + map[i] = j; + zend_hash_add(&hash, (char*)&Z_DVAL(op_array->literals[i].constant), sizeof(double), (void**)&j, sizeof(int), NULL); + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + j++; + } + break; + case IS_STRING: + case IS_CONSTANT: + if (info[i].flags & LITERAL_MAY_MERGE) { + if (info[i].flags & LITERAL_EX_OBJ) { + key_len = MAX_LENGTH_OF_LONG + sizeof("->") + Z_STRLEN(op_array->literals[i].constant); + key = emalloc(key_len); + key_len = snprintf(key, key_len-1, "%d->%s", info[i].u.num, Z_STRVAL(op_array->literals[i].constant)); + } else if (info[i].flags & LITERAL_EX_CLASS) { + zval *class_name = &op_array->literals[(info[i].u.num < i) ? map[info[i].u.num] : info[i].u.num].constant; + key_len = Z_STRLEN_P(class_name) + sizeof("::") + Z_STRLEN(op_array->literals[i].constant); + key = emalloc(key_len); + memcpy(key, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); + memcpy(key + Z_STRLEN_P(class_name), "::", sizeof("::") - 1); + memcpy(key + Z_STRLEN_P(class_name) + sizeof("::") - 1, + Z_STRVAL(op_array->literals[i].constant), + Z_STRLEN(op_array->literals[i].constant) + 1); + } else { + key = Z_STRVAL(op_array->literals[i].constant); + key_len = Z_STRLEN(op_array->literals[i].constant)+1; + } + h = zend_hash_func(key, key_len); + h += info[i].flags; + } + if ((info[i].flags & LITERAL_MAY_MERGE) && + zend_hash_quick_find(&hash, key, key_len, h, (void**)&pos) == SUCCESS && + Z_TYPE(op_array->literals[i].constant) == Z_TYPE(op_array->literals[*pos].constant) && + info[i].flags == info[*pos].flags) { + + if (info[i].flags & (LITERAL_EX_OBJ|LITERAL_EX_CLASS)) { + efree(key); + } + map[i] = *pos; + zval_dtor(&op_array->literals[i].constant); + n = LITERAL_NUM_RELATED(info[i].flags); + while (n > 1) { + i++; + zval_dtor(&op_array->literals[i].constant); + n--; + } + } else { + map[i] = j; + if (info[i].flags & LITERAL_MAY_MERGE) { + zend_hash_quick_add(&hash, key, key_len, h, (void**)&j, sizeof(int), NULL); + if (info[i].flags & (LITERAL_EX_OBJ|LITERAL_EX_CLASS)) { + efree(key); + } + } + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + if (!op_array->literals[j].hash_value) { + if (IS_INTERNED(Z_STRVAL(op_array->literals[j].constant))) { + op_array->literals[j].hash_value = INTERNED_HASH(Z_STRVAL(op_array->literals[j].constant)); + } else { + op_array->literals[j].hash_value = zend_hash_func(Z_STRVAL(op_array->literals[j].constant), Z_STRLEN(op_array->literals[j].constant)+1); + } + } + if (LITERAL_NUM_SLOTS(info[i].flags)) { + op_array->literals[j].cache_slot = cache_slots; + cache_slots += LITERAL_NUM_SLOTS(info[i].flags); + } + j++; + n = LITERAL_NUM_RELATED(info[i].flags); + while (n > 1) { + i++; + if (i != j) op_array->literals[j] = op_array->literals[i]; + if (!op_array->literals[j].hash_value) { + if (IS_INTERNED(Z_STRVAL(op_array->literals[j].constant))) { + op_array->literals[j].hash_value = INTERNED_HASH(Z_STRVAL(op_array->literals[j].constant)); + } else { + op_array->literals[j].hash_value = zend_hash_func(Z_STRVAL(op_array->literals[j].constant), Z_STRLEN(op_array->literals[j].constant)+1); + } + } + j++; + n--; + } + } + break; + default: + /* don't merge other types */ + map[i] = j; + if (i != j) { + op_array->literals[j] = op_array->literals[i]; + info[j] = info[i]; + } + j++; + break; + } + } + zend_hash_destroy(&hash); + op_array->last_literal = j; + op_array->last_cache_slot = cache_slots; + + /* Update opcodes to use new literals table */ + opline = op_array->opcodes; + end = opline + op_array->last; + while (opline < end) { + if (ZEND_OP1_TYPE(opline) == IS_CONST) { + opline->op1.constant = map[opline->op1.constant]; + } + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + opline->op2.constant = map[opline->op2.constant]; + } + opline++; + } + efree(map); + efree(info); + +#if DEBUG_COMPACT_LITERALS + { + int i, use_copy; + fprintf(stderr, "Optimized literlas table size %d\n", op_array->last_literal); + + for (i = 0; i < op_array->last_literal; i++) { + zval zv = op_array->literals[i].constant; + zend_make_printable_zval(&op_array->literals[i].constant, &zv, &use_copy); + fprintf(stderr, "Literal %d, val (%d):%s\n", i, Z_STRLEN(zv), Z_STRVAL(zv)); + if (use_copy) { + zval_dtor(&zv); + } + } + fflush(stderr); + } +#endif + } +} +#endif diff --git a/ext/opcache/Optimizer/optimize_func_calls.c b/ext/opcache/Optimizer/optimize_func_calls.c new file mode 100644 index 0000000000..98bfc1e99e --- /dev/null +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -0,0 +1,138 @@ +/* pass 4 + * - optimize INIT_FCALL_BY_NAME to DO_FCALL + */ +#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO + +typedef struct _optimizer_call_info { + zend_function *func; + zend_op *opline; +} optimizer_call_info; + +static void optimize_func_calls(zend_op_array *op_array, zend_persistent_script *script TSRMLS_DC) { + zend_op *opline = op_array->opcodes; + zend_op *end = opline + op_array->last; + int call = 0; +#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO + optimizer_call_info *call_stack = ecalloc(op_array->nested_calls + 1, sizeof(optimizer_call_info)); +#else + int stack_size = 4; + optimizer_call_info *call_stack = ecalloc(stack_size, sizeof(optimizer_call_info)); +#endif + + while (opline < end) { + switch (opline->opcode) { + case ZEND_INIT_FCALL_BY_NAME: + case ZEND_INIT_NS_FCALL_BY_NAME: + if (ZEND_OP2_TYPE(opline) == IS_CONST) { + zend_function *func; + zval *function_name = &op_array->literals[opline->op2.constant + 1].constant; + if ((zend_hash_quick_find(&script->function_table, + Z_STRVAL_P(function_name), Z_STRLEN_P(function_name) + 1, + Z_HASH_P(function_name), (void **)&func) == SUCCESS)) { + call_stack[call].func = func; + } + } + /* break missing intentionally */ + case ZEND_NEW: + case ZEND_INIT_METHOD_CALL: + case ZEND_INIT_STATIC_METHOD_CALL: + call_stack[call].opline = opline; + call++; +#if ZEND_EXTENSION_API_NO < PHP_5_5_X_API_NO + if (call == stack_size) { + stack_size += 4; + call_stack = erealloc(call_stack, sizeof(optimizer_call_info) * stack_size); + memset(call_stack + 4, 0, 4 * sizeof(optimizer_call_info)); + } +#endif + break; + case ZEND_DO_FCALL_BY_NAME: + call--; + if (call_stack[call].func && call_stack[call].opline) { + zend_op *fcall = call_stack[call].opline; + + opline->opcode = ZEND_DO_FCALL; + ZEND_OP1_TYPE(opline) = IS_CONST; + opline->op1.constant = fcall->op2.constant + 1; + op_array->literals[fcall->op2.constant + 1].cache_slot = op_array->literals[fcall->op2.constant].cache_slot; + literal_dtor(&ZEND_OP2_LITERAL(fcall)); + if (fcall->opcode == ZEND_INIT_NS_FCALL_BY_NAME) { + literal_dtor(&op_array->literals[fcall->op2.constant + 2].constant); + } + MAKE_NOP(fcall); + } else if (opline->extended_value == 0 && + call_stack[call].opline && + call_stack[call].opline->opcode == ZEND_INIT_FCALL_BY_NAME && + ZEND_OP2_TYPE(call_stack[call].opline) == IS_CONST) { + + zend_op *fcall = call_stack[call].opline; + + opline->opcode = ZEND_DO_FCALL; + ZEND_OP1_TYPE(opline) = IS_CONST; + opline->op1.constant = fcall->op2.constant + 1; + op_array->literals[fcall->op2.constant + 1].cache_slot = op_array->literals[fcall->op2.constant].cache_slot; + literal_dtor(&ZEND_OP2_LITERAL(fcall)); + MAKE_NOP(fcall); + } + call_stack[call].func = NULL; + call_stack[call].opline = NULL; + break; + case ZEND_FETCH_FUNC_ARG: + case ZEND_FETCH_OBJ_FUNC_ARG: + case ZEND_FETCH_DIM_FUNC_ARG: + if (call_stack[call - 1].func) { + if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, (opline->extended_value & ZEND_FETCH_ARG_MASK))) { + opline->extended_value = 0; + opline->opcode -= 9; + } else { + opline->extended_value = 0; + opline->opcode -= 12; + } + } + break; + case ZEND_SEND_VAL: + if (opline->extended_value == ZEND_DO_FCALL_BY_NAME && call_stack[call - 1].func) { + if (ARG_MUST_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) { + /* We won't convert it into_DO_FCALL to emit error at run-time */ + call_stack[call - 1].opline = NULL; + } else { + opline->extended_value = ZEND_DO_FCALL; + } + } + break; + case ZEND_SEND_VAR: + if (opline->extended_value == ZEND_DO_FCALL_BY_NAME && call_stack[call - 1].func) { + if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) { + opline->opcode = ZEND_SEND_REF; + } + opline->extended_value = ZEND_DO_FCALL; + } + break; + case ZEND_SEND_VAR_NO_REF: + if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) && call_stack[call - 1].func) { + if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, opline->op2.num)) { + opline->extended_value |= ZEND_ARG_COMPILE_TIME_BOUND | ZEND_ARG_SEND_BY_REF; + } else if (opline->extended_value) { + opline->extended_value |= ZEND_ARG_COMPILE_TIME_BOUND; + } else { + opline->opcode = ZEND_SEND_VAR; + opline->extended_value = ZEND_DO_FCALL; + } + } + break; + case ZEND_SEND_REF: + if (opline->extended_value == ZEND_DO_FCALL_BY_NAME && call_stack[call - 1].func) { + /* We won't handle run-time pass by reference */ + call_stack[call - 1].opline = NULL; + } + break; + + default: + break; + } + opline++; + } + + efree(call_stack); +} +#endif diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 795b954173..9309d4b462 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -3,13 +3,13 @@ * - perform compile-time evaluation of constant binary and unary operations * - optimize series of ADD_STRING and/or ADD_CHAR * - convert CAST(IS_BOOL,x) into BOOL(x) - * - convert INTI_FCALL_BY_NAME, DO_FCALL_BY_NAME into DO_FCALL */ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { int i = 0; zend_op *opline = op_array->opcodes; zend_op *end = opline + op_array->last; + zend_bool collect_constants = (op_array == &script->main_op_array); while (opline < end) { switch (opline->opcode) { @@ -357,7 +357,9 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { zval c; if (!zend_get_persistent_constant(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), &c, 1 TSRMLS_CC)) { - break; + if (!*constants || !zend_optimizer_get_collected_constant(*constants, &ZEND_OP2_LITERAL(opline), &c)) { + break; + } } literal_dtor(&ZEND_OP2_LITERAL(opline)); ZEND_OP1_TYPE(opline) = IS_CONST; @@ -371,22 +373,70 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { } break; - case ZEND_INIT_FCALL_BY_NAME: - if (opline->extended_value == 0 /* not method */ && - ZEND_OP1_TYPE(opline) == IS_UNUSED && - ZEND_OP2_TYPE(opline) == IS_CONST) { - if ((opline + 1)->opcode == ZEND_DO_FCALL_BY_NAME && - (opline + 1)->extended_value == 0) { - (opline + 1)->opcode = ZEND_DO_FCALL; - COPY_NODE((opline + 1)->op1, opline->op2); - zend_str_tolower(Z_STRVAL(ZEND_OP1_LITERAL(opline + 1)), Z_STRLEN(ZEND_OP1_LITERAL(opline + 1))); + case ZEND_DO_FCALL: + /* define("name", scalar); */ + if (collect_constants && + opline->extended_value == 2 && + ZEND_OP1_TYPE(opline) == IS_CONST && + Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING && + Z_STRLEN(ZEND_OP1_LITERAL(opline)) == sizeof("define")-1 && + zend_binary_strcasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)), Z_STRLEN(ZEND_OP1_LITERAL(opline)), "define", sizeof("define")-1) == 0 && + (opline-1)->opcode == ZEND_SEND_VAL && + ZEND_OP1_TYPE(opline-1) == IS_CONST && + (Z_TYPE(ZEND_OP1_LITERAL(opline-1)) <= IS_BOOL || + Z_TYPE(ZEND_OP1_LITERAL(opline-1)) == IS_STRING) && + (opline-2)->opcode == ZEND_SEND_VAL && + ZEND_OP1_TYPE(opline-2) == IS_CONST && + Z_TYPE(ZEND_OP1_LITERAL(opline-2)) == IS_STRING) { + zend_optimizer_collect_constant(constants, &ZEND_OP1_LITERAL(opline-2), &ZEND_OP1_LITERAL(opline-1)); + } + break; +#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO + case ZEND_DECLARE_CONST: + if (collect_constants && + Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING && + (Z_TYPE(ZEND_OP2_LITERAL(opline)) <= IS_BOOL || + Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING)) { + zend_optimizer_collect_constant(constants, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline)); + } + break; +#endif + + case ZEND_RETURN: #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - Z_HASH_P(&ZEND_OP1_LITERAL(opline + 1)) = zend_hash_func(Z_STRVAL(ZEND_OP1_LITERAL(opline + 1)), Z_STRLEN(ZEND_OP1_LITERAL(opline + 1)) + 1); - op_array->literals[(opline + 1)->op1.constant].cache_slot = op_array->last_cache_slot++; + case ZEND_RETURN_BY_REF: #endif - MAKE_NOP(opline); - } - } +#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO + case ZEND_GENERATOR_RETURN: +#endif + case ZEND_EXIT: + case ZEND_THROW: + case ZEND_CATCH: + case ZEND_BRK: + case ZEND_CONT: +#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO + case ZEND_GOTO: +#endif +#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO + case ZEND_FAST_CALL: + case ZEND_FAST_RET: +#endif + case ZEND_JMP: + case ZEND_JMPZNZ: + case ZEND_JMPZ: + case ZEND_JMPNZ: + case ZEND_JMPZ_EX: + case ZEND_JMPNZ_EX: + case ZEND_FE_RESET: + case ZEND_FE_FETCH: + case ZEND_NEW: +#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO + case ZEND_JMP_SET: +#endif +#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO + case ZEND_JMP_SET_VAR: +#endif + collect_constants = 0; break; #if ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index 1f411d5da8..a058bd73cb 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -24,10 +24,41 @@ #include "zend_API.h"
#include "zend_constants.h"
#include "zend_execute.h"
+#include "zend_vm.h"
#define OPTIMIZATION_LEVEL \
ZCG(accel_directives).optimization_level
+static void zend_optimizer_zval_dtor_wrapper(zval *zvalue)
+{
+ zval_dtor(zvalue);
+}
+
+static void zend_optimizer_collect_constant(HashTable **constants, zval *name, zval* value)
+{
+ zval val;
+
+ if (!*constants) {
+ *constants = emalloc(sizeof(HashTable));
+ zend_hash_init(*constants, 16, NULL, (void (*)(void *))zend_optimizer_zval_dtor_wrapper, 0);
+ }
+ val = *value;
+ zval_copy_ctor(&val);
+ zend_hash_add(*constants, Z_STRVAL_P(name), Z_STRLEN_P(name)+1, (void**)&val, sizeof(zval), NULL);
+}
+
+static int zend_optimizer_get_collected_constant(HashTable *constants, zval *name, zval* value)
+{
+ zval *val;
+
+ if (zend_hash_find(constants, Z_STRVAL_P(name), Z_STRLEN_P(name)+1, (void**)&val) == SUCCESS) {
+ *value = *val;
+ zval_copy_ctor(value);
+ return 1;
+ }
+ return 0;
+}
+
#if ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO
static int zend_optimizer_lookup_cv(zend_op_array *op_array, char* name, int name_len)
{
@@ -62,10 +93,7 @@ int zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC {
int i = op_array->last_literal;
op_array->last_literal++;
- if (i >= CG(context).literals_size) {
- CG(context).literals_size += 16; /* FIXME */
- op_array->literals = (zend_literal*)erealloc(op_array->literals, CG(context).literals_size * sizeof(zend_literal));
- }
+ op_array->literals = (zend_literal*)erealloc(op_array->literals, op_array->last_literal * sizeof(zend_literal));
op_array->literals[i].constant = *zv;
op_array->literals[i].hash_value = 0;
op_array->literals[i].cache_slot = -1;
@@ -113,8 +141,12 @@ int zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC #include "Optimizer/nop_removal.c"
#include "Optimizer/block_pass.c"
#include "Optimizer/optimize_temp_vars_5.c"
+#include "Optimizer/compact_literals.c"
+#include "Optimizer/optimize_func_calls.c"
-void zend_optimizer(zend_op_array *op_array TSRMLS_DC)
+static void zend_optimize(zend_op_array *op_array,
+ zend_persistent_script *script,
+ HashTable **constants TSRMLS_DC)
{
if (op_array->type == ZEND_EVAL_CODE ||
(op_array->fn_flags & ZEND_ACC_INTERACTIVE)) {
@@ -126,7 +158,6 @@ void zend_optimizer(zend_op_array *op_array TSRMLS_DC) * - perform compile-time evaluation of constant binary and unary operations
* - optimize series of ADD_STRING and/or ADD_CHAR
* - convert CAST(IS_BOOL,x) into BOOL(x)
- * - convert INTI_FCALL_BY_NAME + DO_FCALL_BY_NAME into DO_FCALL
*/
#include "Optimizer/pass1_5.c"
@@ -144,12 +175,21 @@ void zend_optimizer(zend_op_array *op_array TSRMLS_DC) */
#include "Optimizer/pass3.c"
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ /* pass 4:
+ * - INIT_FCALL_BY_NAME -> DO_FCALL
+ */
+ if (ZEND_OPTIMIZER_PASS_4 & OPTIMIZATION_LEVEL) {
+ optimize_func_calls(op_array, script TSRMLS_CC);
+ }
+#endif
+
/* pass 5:
* - CFG optimization
*/
#include "Optimizer/pass5.c"
- /* pass 9:
+ /* pass 9:
* - Optimize temp variables usage
*/
#include "Optimizer/pass9.c"
@@ -158,4 +198,143 @@ void zend_optimizer(zend_op_array *op_array TSRMLS_DC) * - remove NOPs
*/
#include "Optimizer/pass10.c"
+
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ /* pass 11:
+ * - Compact literals table
+ */
+ if (ZEND_OPTIMIZER_PASS_11 & OPTIMIZATION_LEVEL) {
+ optimizer_compact_literals(op_array TSRMLS_CC);
+ }
+#endif
+}
+
+static void zend_accel_optimize(zend_op_array *op_array,
+ zend_persistent_script *script,
+ HashTable **constants TSRMLS_DC)
+{
+ zend_op *opline, *end;
+
+ /* Revert pass_two() */
+ opline = op_array->opcodes;
+ end = opline + op_array->last;
+ while (opline < end) {
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ if (opline->op1_type == IS_CONST) {
+ opline->op1.constant = opline->op1.literal - op_array->literals;
+ }
+ if (opline->op2_type == IS_CONST) {
+ opline->op2.constant = opline->op2.literal - op_array->literals;
+ }
+#endif
+ switch (opline->opcode) {
+ case ZEND_JMP:
+#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
+ case ZEND_GOTO:
+#endif
+#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
+ case ZEND_FAST_CALL:
+#endif
+ ZEND_OP1(opline).opline_num = ZEND_OP1(opline).jmp_addr - op_array->opcodes;
+ break;
+ case ZEND_JMPZ:
+ case ZEND_JMPNZ:
+ case ZEND_JMPZ_EX:
+ case ZEND_JMPNZ_EX:
+#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
+ case ZEND_JMP_SET:
+#endif
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ case ZEND_JMP_SET_VAR:
+#endif
+ ZEND_OP2(opline).opline_num = ZEND_OP2(opline).jmp_addr - op_array->opcodes;
+ break;
+ }
+ opline++;
+ }
+
+ /* Do actual optimizations */
+ zend_optimize(op_array, script, constants TSRMLS_CC);
+
+ /* Redo pass_two() */
+ opline = op_array->opcodes;
+ end = opline + op_array->last;
+ while (opline < end) {
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ if (opline->op1_type == IS_CONST) {
+ opline->op1.zv = &op_array->literals[opline->op1.constant].constant;
+ }
+ if (opline->op2_type == IS_CONST) {
+ opline->op2.zv = &op_array->literals[opline->op2.constant].constant;
+ }
+#endif
+ switch (opline->opcode) {
+ case ZEND_JMP:
+#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
+ case ZEND_GOTO:
+#endif
+#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO
+ case ZEND_FAST_CALL:
+#endif
+ ZEND_OP1(opline).jmp_addr = &op_array->opcodes[ZEND_OP1(opline).opline_num];
+ break;
+ case ZEND_JMPZ:
+ case ZEND_JMPNZ:
+ case ZEND_JMPZ_EX:
+ case ZEND_JMPNZ_EX:
+#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO
+ case ZEND_JMP_SET:
+#endif
+#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
+ case ZEND_JMP_SET_VAR:
+#endif
+ ZEND_OP2(opline).jmp_addr = &op_array->opcodes[ZEND_OP2(opline).opline_num];
+ break;
+ }
+ ZEND_VM_SET_OPCODE_HANDLER(opline);
+ opline++;
+ }
+}
+
+int zend_accel_script_optimize(zend_persistent_script *script TSRMLS_DC)
+{
+ Bucket *p, *q;
+ HashTable *constants = NULL;
+
+ zend_accel_optimize(&script->main_op_array, script, &constants TSRMLS_CC);
+
+ p = script->function_table.pListHead;
+ while (p) {
+ zend_op_array *op_array = (zend_op_array*)p->pData;
+ zend_accel_optimize(op_array, script, &constants TSRMLS_CC);
+ p = p->pListNext;
+ }
+
+ p = script->class_table.pListHead;
+ while (p) {
+ zend_class_entry *ce = (zend_class_entry*)p->pDataPtr;
+ q = ce->function_table.pListHead;
+ while (q) {
+ zend_op_array *op_array = (zend_op_array*)q->pData;
+ if (op_array->scope == ce) {
+ zend_accel_optimize(op_array, script, &constants TSRMLS_CC);
+ } else if (op_array->type == ZEND_USER_FUNCTION) {
+ zend_op_array *orig_op_array;
+ if (zend_hash_find(&op_array->scope->function_table, q->arKey, q->nKeyLength, (void**)&orig_op_array) == SUCCESS) {
+ HashTable *ht = op_array->static_variables;
+ *op_array = *orig_op_array;
+ op_array->static_variables = ht;
+ }
+ }
+ q = q->pListNext;
+ }
+ p = p->pListNext;
+ }
+
+ if (constants) {
+ zend_hash_destroy(constants);
+ efree(constants);
+ }
+
+ return 1;
}
diff --git a/ext/opcache/Optimizer/zend_optimizer.h b/ext/opcache/Optimizer/zend_optimizer.h index 98275a20aa..5a3d715ac9 100644 --- a/ext/opcache/Optimizer/zend_optimizer.h +++ b/ext/opcache/Optimizer/zend_optimizer.h @@ -28,14 +28,14 @@ #define ZEND_OPTIMIZER_PASS_1 (1<<0) /* CSE, STRING construction */
#define ZEND_OPTIMIZER_PASS_2 (1<<1) /* Constant conversion and jumps */
#define ZEND_OPTIMIZER_PASS_3 (1<<2) /* ++, +=, series of jumps */
-#define ZEND_OPTIMIZER_PASS_4 (1<<3)
+#define ZEND_OPTIMIZER_PASS_4 (1<<3) /* INIT_FCALL_BY_NAME -> DO_FCALL */
#define ZEND_OPTIMIZER_PASS_5 (1<<4) /* CFG based optimization */
#define ZEND_OPTIMIZER_PASS_6 (1<<5)
#define ZEND_OPTIMIZER_PASS_7 (1<<6)
#define ZEND_OPTIMIZER_PASS_8 (1<<7)
#define ZEND_OPTIMIZER_PASS_9 (1<<8) /* TMP VAR usage */
#define ZEND_OPTIMIZER_PASS_10 (1<<9) /* NOP removal */
-#define ZEND_OPTIMIZER_PASS_11 (1<<10)
+#define ZEND_OPTIMIZER_PASS_11 (1<<10) /* Merge equal constants */
#define ZEND_OPTIMIZER_PASS_12 (1<<11)
#define ZEND_OPTIMIZER_PASS_13 (1<<12)
#define ZEND_OPTIMIZER_PASS_14 (1<<13)
@@ -44,6 +44,4 @@ #define DEFAULT_OPTIMIZATION_LEVEL "0xFFFFFFFF"
-void zend_optimizer(zend_op_array *op_array TSRMLS_DC);
-
#endif
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 827f047cd4..52e9e98443 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1130,6 +1130,10 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr return new_persistent_script; } + if (!zend_accel_script_optimize(new_persistent_script TSRMLS_CC)) { + return new_persistent_script; + } + if (!compact_persistent_script(new_persistent_script)) { return new_persistent_script; } @@ -2754,19 +2758,6 @@ void accelerator_shm_read_unlock(TSRMLS_D) } } -static void accel_op_array_handler(zend_op_array *op_array) -{ - TSRMLS_FETCH(); - - if (ZCG(enabled) && - accel_startup_ok && - ZCSG(accelerator_enabled) && - !ZSMMG(memory_exhausted) && - !ZCSG(restart_pending)) { - zend_optimizer(op_array TSRMLS_CC); - } -} - ZEND_EXT_API zend_extension zend_extension_entry = { ACCELERATOR_PRODUCT_NAME, /* name */ ACCELERATOR_VERSION, /* version */ @@ -2778,7 +2769,7 @@ ZEND_EXT_API zend_extension zend_extension_entry = { accel_activate, /* per-script activation */ accel_deactivate, /* per-script deactivation */ NULL, /* message handler */ - accel_op_array_handler, /* op_array handler */ + NULL, /* op_array handler */ NULL, /* extended statement handler */ NULL, /* extended fcall begin handler */ NULL, /* extended fcall end handler */ diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 361b60b08f..38f2e060f6 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -321,6 +321,7 @@ void accel_shutdown(TSRMLS_D); void zend_accel_schedule_restart(zend_accel_restart_reason reason TSRMLS_DC); void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason TSRMLS_DC); int zend_accel_invalidate(const char *filename, int filename_len, zend_bool force TSRMLS_DC); +int zend_accel_script_optimize(zend_persistent_script *persistent_script TSRMLS_DC); int accelerator_shm_read_lock(TSRMLS_D); void accelerator_shm_read_unlock(TSRMLS_D); diff --git a/ext/opcache/tests/compact_literals.phpt b/ext/opcache/tests/compact_literals.phpt new file mode 100644 index 0000000000..367331f742 --- /dev/null +++ b/ext/opcache/tests/compact_literals.phpt @@ -0,0 +1,215 @@ +--TEST-- +Test with compact literals +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +echo "array key hash" . ":" . PHP_EOL; +$array = array( + "1" => "one", + "2" => "two", + "one" => 1, + "two" => 2, +); + +unset($array["one"]); +unset($array["2"]); + +print_r($array); + +echo "function define" . ":" . PHP_EOL; +if (!function_exists("dummy")) { + function dummy() { + var_dump(__FUNCTION__); + } +} + +dummy(); + +$dummy = function () { var_dump("lambda" . "dummy"); }; +$dummy(); + +if (!class_exists("A")) { + class A { + public static $name = "A"; + public static function say($n = "name") { + var_dump(static::$name); + } + } +} + +class B extends A { + public static $name = "B"; +} + +if (!class_exists("C")) { + class C extends B { + public static $name = "C"; + } +} + +A::say(); +B::Say(); +A::say(); +B::say(); +C::say(); + +function get_eol_define() { + define("MY_EOL", PHP_EOL); +} +get_eol_define(); +define("EOL", MY_EOL); + +echo "constants define" . ":" . EOL; + +echo "define " . "TEST" . EOL; +define("TEST", "TEST"); + +class E { + public static $E="EP"; + const E="E"; + const TEST="NULL"; +} + +class F { + const F="F"; + public static $E="FEP"; + const E="FE"; + const TEST="FALSE"; + public static $F = "FP"; +} + +var_dump(TEST); //"TEST" +var_dump(E::E); //"E" +var_dump(F::E); //"FE" +var_dump(F::F); //"F" +var_dump(E::TEST); //"NULL" +var_dump(F::TEST); //"FALSE" +var_dump(E::$E); //"EP" +var_dumP(F::$F); //"FP" +var_dumP(F::$E); //"FEP" + +echo "propertes and methods" . EOL; + +class CH { + const H = "H"; + public function h() { + var_dump(self::H); + } +} + +class CI { + const H = "I"; + public function h() { + var_dump(self::H); + } +} + +function change(&$obj) { + $obj = new CH; +} + +function geti() { + return new CI; +} + +$h = new CH; + +echo "-->H" . PHP_EOL; +$h->H(); +var_dump($h::H); +var_dump(CH::H); + +$h->H(); +var_dump($h::H); +var_dump(CH::H); + +echo "-->I" . PHP_EOL; +$h = new CI; +$h->H(); +var_dump($h::H); +var_dump(CI::H); +$h->H(); +var_dump($h::H); +var_dump(CI::H); + +echo "-->H" . PHP_EOL; +change($h); + +$h->H(); +var_dump($h::H); +var_dump(CH::H); + +$h->H(); +var_dump($h::H); +var_dump(CH::H); + +echo "-->I" . PHP_EOL; +$h = geti(); +$h->H(); +var_dump($h::H); +var_dump(CI::H); +$h->H(); +var_dump($h::H); +var_dump(CI::H); +?> +--EXPECT-- +array key hash: +Array +( + [1] => one + [two] => 2 +) +function define: +string(5) "dummy" +string(11) "lambdadummy" +string(1) "A" +string(1) "B" +string(1) "A" +string(1) "B" +string(1) "C" +constants define: +define TEST +string(4) "TEST" +string(1) "E" +string(2) "FE" +string(1) "F" +string(4) "NULL" +string(5) "FALSE" +string(2) "EP" +string(2) "FP" +string(3) "FEP" +propertes and methods +-->H +string(1) "H" +string(1) "H" +string(1) "H" +string(1) "H" +string(1) "H" +string(1) "H" +-->I +string(1) "I" +string(1) "I" +string(1) "I" +string(1) "I" +string(1) "I" +string(1) "I" +-->H +string(1) "H" +string(1) "H" +string(1) "H" +string(1) "H" +string(1) "H" +string(1) "H" +-->I +string(1) "I" +string(1) "I" +string(1) "I" +string(1) "I" +string(1) "I" +string(1) "I" diff --git a/ext/opcache/tests/optimize_func_calls.phpt b/ext/opcache/tests/optimize_func_calls.phpt new file mode 100644 index 0000000000..b3bc8da6a9 --- /dev/null +++ b/ext/opcache/tests/optimize_func_calls.phpt @@ -0,0 +1,130 @@ +--TEST-- +Test with optimization of function calls +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +class A { + public $obj; + public function test($a) { + } +} + +function a(&$b) { + $b = "changed"; + return "done"; +} + +$a = "a"; +$b = "b"; +$c = "c"; +$f = "a"; + +/* + * INIT_FCALL_BY_NAME + * SEND_VAR + * DO_FCALL + * DO_FCALL_BY_NAME + */ +foo(a($a)); +var_dump($a); +$a = "a"; + +/* + * INIT_FCALL_BY_NAME + * INIT_FCALL_BY_NAME -- un-optimizable + * DO_FCALL_BY_NAME -- un-optimizable + * DO_FCALL_BY_NAME + */ +foo($f($a)); +var_dump($a); + +/* + * INIT_FCALL_BY_NAME + * ZEND_NEW + * DO_FCALL_BY_NAME + * DO_FCALL_BY_NAME + */ +foo(new A()); + +/* + * INIT_FCALL_BY_NAME + * FETCH_OBJ_FUNC_ARG + * ZEND_SEND_VAR + * DO_FCALL_BY_NAME + */ +foo((new A)->obj); +$obj = new A; +ref($obj->obj); +var_dump($obj->obj); + +ref(retarray()[0]); + +$a = "a"; +foo(a($a), $a, ref($b, $c), $obj); +var_dump($a); +var_dump($b); + +/* + * INIT_FCALL_BY_NAME + * SEND_VAL + * DO_FCALL_BY_NAME + */ +ref("xxx"); + +function retarray() { + return array("retarray"); +} + +function foo($a) { + print_r(func_get_args()); +} + +function ref(&$b) { + $b = "changed"; + return "ref"; +} +--EXPECTF-- +Array +( + [0] => done +) +string(7) "changed" +Array +( + [0] => done +) +string(7) "changed" +Array +( + [0] => A Object + ( + [obj] => + ) + +) +Array +( + [0] => +) +string(7) "changed" +Array +( + [0] => done + [1] => changed + [2] => ref + [3] => A Object + ( + [obj] => changed + ) + +) +string(7) "changed" +string(7) "changed" + +Fatal error: Cannot pass parameter 1 by reference in %soptimize_func_calls.php on line %d diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 4a9fcbc9e3..4aac4e3137 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -394,11 +394,35 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_random_pseudo_bytes, 0, 0, 1) ZEND_ARG_INFO(0, length) ZEND_ARG_INFO(1, result_is_strong) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_spki_new, 0, 0, 2) + ZEND_ARG_INFO(0, privkey) + ZEND_ARG_INFO(0, challenge) + ZEND_ARG_INFO(0, algo) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_verify, 0) + ZEND_ARG_INFO(0, spki) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_export, 0) + ZEND_ARG_INFO(0, spki) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_export_challenge, 0) + ZEND_ARG_INFO(0, spki) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ openssl_functions[] */ const zend_function_entry openssl_functions[] = { +/* spki functions */ + PHP_FE(openssl_spki_new, arginfo_openssl_spki_new) + PHP_FE(openssl_spki_verify, arginfo_openssl_spki_verify) + PHP_FE(openssl_spki_export, arginfo_openssl_spki_export) + PHP_FE(openssl_spki_export_challenge, arginfo_openssl_spki_export_challenge) + /* public/private key functions */ PHP_FE(openssl_pkey_free, arginfo_openssl_pkey_free) PHP_FE(openssl_pkey_new, arginfo_openssl_pkey_new) @@ -781,6 +805,7 @@ static int add_oid_section(struct php_x509_request * req TSRMLS_DC) /* {{{ */ static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(long algo); +int openssl_spki_cleanup(const char *src, char *dest); static int php_openssl_parse_config(struct php_x509_request * req, zval * optional_args TSRMLS_DC) /* {{{ */ { @@ -1325,6 +1350,279 @@ PHP_FUNCTION(openssl_x509_export_to_file) } /* }}} */ +/* {{{ proto string openssl_spki_new(mixed zpkey, string challenge [, mixed method]) + Creates new private key (or uses existing) and creates a new spki cert + outputting results to var */ +PHP_FUNCTION(openssl_spki_new) +{ + int challenge_len; + char * challenge = NULL, * spkstr = NULL, * s = NULL; + long keyresource = -1; + const char *spkac = "SPKAC="; + long algo = OPENSSL_ALGO_MD5; + + zval *method = NULL; + zval * zpkey = NULL; + EVP_PKEY * pkey = NULL; + NETSCAPE_SPKI *spki=NULL; + const EVP_MD *mdtype; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|z", &zpkey, &challenge, &challenge_len, &method) == FAILURE) { + return; + } + RETVAL_FALSE; + + pkey = php_openssl_evp_from_zval(&zpkey, 0, challenge, 1, &keyresource TSRMLS_CC); + + if (pkey == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to use supplied private key"); + goto cleanup; + } + + if (method != NULL) { + if (Z_TYPE_P(method) == IS_LONG) { + algo = Z_LVAL_P(method); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Algorithm must be of supported type"); + goto cleanup; + } + } + mdtype = php_openssl_get_evp_md_from_algo(algo); + + if (!mdtype) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown signature algorithm"); + goto cleanup; + } + + if ((spki = NETSCAPE_SPKI_new()) == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create new SPKAC"); + goto cleanup; + } + + if (challenge) { + ASN1_STRING_set(spki->spkac->challenge, challenge, challenge_len); + } + + if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to embed public key"); + goto cleanup; + } + + if (!NETSCAPE_SPKI_sign(spki, pkey, mdtype)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to sign with specified algorithm"); + goto cleanup; + } + + spkstr = NETSCAPE_SPKI_b64_encode(spki); + if (!spkstr){ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to encode SPKAC"); + goto cleanup; + } + + s = emalloc(strlen(spkac) + strlen(spkstr) + 1); + sprintf(s, "%s%s", spkac, spkstr); + + RETVAL_STRINGL(s, strlen(s), 0); + goto cleanup; + +cleanup: + + if (keyresource == -1 && spki != NULL) { + NETSCAPE_SPKI_free(spki); + } + if (keyresource == -1 && pkey != NULL) { + EVP_PKEY_free(pkey); + } + if (keyresource == -1 && spkstr != NULL) { + efree(spkstr); + } + + if (strlen(s) <= 0) { + RETVAL_FALSE; + } + + if (keyresource == -1 && s != NULL) { + efree(s); + } +} +/* }}} */ + +/* {{{ proto bool openssl_spki_verify(string spki) + Verifies spki returns boolean */ +PHP_FUNCTION(openssl_spki_verify) +{ + int spkstr_len, i = 0; + char *spkstr = NULL, * spkstr_cleaned = NULL; + + EVP_PKEY *pkey = NULL; + NETSCAPE_SPKI *spki = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &spkstr, &spkstr_len) == FAILURE) { + return; + } + RETVAL_FALSE; + + if (spkstr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to use supplied SPKAC"); + goto cleanup; + } + + spkstr_cleaned = emalloc(spkstr_len + 1); + openssl_spki_cleanup(spkstr, spkstr_cleaned); + + if (strlen(spkstr_cleaned)<=0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SPKAC"); + goto cleanup; + } + + spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, strlen(spkstr_cleaned)); + if (spki == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to decode supplied SPKAC"); + goto cleanup; + } + + pkey = X509_PUBKEY_get(spki->spkac->pubkey); + if (pkey == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to acquire signed public key"); + goto cleanup; + } + + i = NETSCAPE_SPKI_verify(spki, pkey); + goto cleanup; + +cleanup: + if (spki != NULL) { + NETSCAPE_SPKI_free(spki); + } + if (pkey != NULL) { + EVP_PKEY_free(pkey); + } + if (spkstr_cleaned != NULL) { + efree(spkstr_cleaned); + } + + if (i > 0) { + RETVAL_TRUE; + } +} +/* }}} */ + +/* {{{ proto string openssl_spki_export(string spki) + Exports public key from existing spki to var */ +PHP_FUNCTION(openssl_spki_export) +{ + int spkstr_len; + char *spkstr = NULL, * spkstr_cleaned = NULL, * s = NULL; + + EVP_PKEY *pkey = NULL; + NETSCAPE_SPKI *spki = NULL; + BIO *out = BIO_new(BIO_s_mem()); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &spkstr, &spkstr_len) == FAILURE) { + return; + } + RETVAL_FALSE; + + if (spkstr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to use supplied SPKAC"); + goto cleanup; + } + + spkstr_cleaned = emalloc(spkstr_len + 1); + openssl_spki_cleanup(spkstr, spkstr_cleaned); + + spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, strlen(spkstr_cleaned)); + if (spki == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to decode supplied SPKAC"); + goto cleanup; + } + + pkey = X509_PUBKEY_get(spki->spkac->pubkey); + if (pkey == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to acquire signed public key"); + goto cleanup; + } + + out = BIO_new_fp(stdout, BIO_NOCLOSE); + PEM_write_bio_PUBKEY(out, pkey); + goto cleanup; + +cleanup: + + if (spki != NULL) { + NETSCAPE_SPKI_free(spki); + } + if (out != NULL) { + BIO_free_all(out); + } + if (pkey != NULL) { + EVP_PKEY_free(pkey); + } + if (spkstr_cleaned != NULL) { + efree(spkstr_cleaned); + } + if (s != NULL) { + efree(s); + } +} +/* }}} */ + +/* {{{ proto string openssl_spki_export_challenge(string spki) + Exports spkac challenge from existing spki to var */ +PHP_FUNCTION(openssl_spki_export_challenge) +{ + int spkstr_len; + char *spkstr = NULL, * spkstr_cleaned = NULL; + + NETSCAPE_SPKI *spki = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &spkstr, &spkstr_len) == FAILURE) { + return; + } + RETVAL_FALSE; + + if (spkstr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to use supplied SPKAC"); + goto cleanup; + } + + spkstr_cleaned = emalloc(spkstr_len + 1); + openssl_spki_cleanup(spkstr, spkstr_cleaned); + + spki = NETSCAPE_SPKI_b64_decode(spkstr_cleaned, strlen(spkstr_cleaned)); + if (spki == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to decode SPKAC"); + goto cleanup; + } + + RETVAL_STRING(ASN1_STRING_data(spki->spkac->challenge), 1); + goto cleanup; + +cleanup: + if (spkstr_cleaned != NULL) { + efree(spkstr_cleaned); + } +} +/* }}} */ + +/* {{{ strip line endings from spkac */ +int openssl_spki_cleanup(const char *src, char *dest) +{ + int removed=0; + + while (*src) { + if (*src!='\n'&&*src!='\r') { + *dest++=*src; + } else { + ++removed; + } + ++src; + } + *dest=0; + return removed; +} +/* }}} */ + /* {{{ proto bool openssl_x509_export(mixed x509, string &out [, bool notext = true]) Exports a CERT to file or a var */ PHP_FUNCTION(openssl_x509_export) diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h index e6b064a277..8483bbf762 100644 --- a/ext/openssl/php_openssl.h +++ b/ext/openssl/php_openssl.h @@ -79,6 +79,11 @@ PHP_FUNCTION(openssl_csr_export_to_file); PHP_FUNCTION(openssl_csr_sign); PHP_FUNCTION(openssl_csr_get_subject); PHP_FUNCTION(openssl_csr_get_public_key); + +PHP_FUNCTION(openssl_spki_new); +PHP_FUNCTION(openssl_spki_verify); +PHP_FUNCTION(openssl_spki_export); +PHP_FUNCTION(openssl_spki_export_challenge); #else #define phpext_openssl_ptr NULL diff --git a/ext/openssl/tests/openssl_spki_export.phpt b/ext/openssl/tests/openssl_spki_export.phpt new file mode 100644 index 0000000000..59332f70a5 --- /dev/null +++ b/ext/openssl/tests/openssl_spki_export.phpt @@ -0,0 +1,62 @@ +--TEST-- +Testing openssl_spki_export() +Creates SPKAC for all available key sizes & signature algorithms and exports public key +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!@openssl_pkey_new()) die("skip cannot create private key"); +?> +--FILE-- +<?php + +/* array of private key sizes to test */ +$ksize = array('1024'=>1024, + '2048'=>2048, + '4096'=>4096); + +/* array of available hashings to test */ +$algo = array('md4'=>OPENSSL_ALGO_MD4, + 'md5'=>OPENSSL_ALGO_MD5, + 'sha1'=>OPENSSL_ALGO_SHA1, + 'sha224'=>OPENSSL_ALGO_SHA224, + 'sha256'=>OPENSSL_ALGO_SHA256, + 'sha384'=>OPENSSL_ALGO_SHA384, + 'sha512'=>OPENSSL_ALGO_SHA512, + 'rmd160'=>OPENSSL_ALGO_RMD160); + +/* loop over key sizes for test */ +foreach($ksize as $k => $v) { + + /* generate new private key of specified size to use for tests */ + $pkey = openssl_pkey_new(array('digest_alg' => 'sha512', + 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'private_key_bits' => $v)); + openssl_pkey_export($pkey, $pass); + + /* loop to create and verify results */ + foreach($algo as $key => $value) { + $spkac = openssl_spki_new($pkey, _uuid(), $value); + echo openssl_spki_export(preg_replace('/SPKAC=/', '', $spkac)); + } + openssl_free_key($pkey); +} + +/* generate a random challenge */ +function _uuid() +{ + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff)); +} + +?> +--EXPECTREGEX-- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- +\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-.*\-\-\-\-\-END PUBLIC KEY\-\-\-\-\- diff --git a/ext/openssl/tests/openssl_spki_export_challenge.phpt b/ext/openssl/tests/openssl_spki_export_challenge.phpt new file mode 100644 index 0000000000..71ef62edd5 --- /dev/null +++ b/ext/openssl/tests/openssl_spki_export_challenge.phpt @@ -0,0 +1,105 @@ +--TEST-- +Testing openssl_spki_export_challenge() +Creates SPKAC for all available key sizes & signature algorithms and exports challenge +--INI-- +error_reporting=0 +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!@openssl_pkey_new()) die("skip cannot create private key"); +?> +--FILE-- +<?php + +/* array of private key sizes to test */ +$ksize = array('1024'=>1024, + '2048'=>2048, + '4096'=>4096); + +/* array of available hashings to test */ +$algo = array('md4'=>OPENSSL_ALGO_MD4, + 'md5'=>OPENSSL_ALGO_MD5, + 'sha1'=>OPENSSL_ALGO_SHA1, + 'sha224'=>OPENSSL_ALGO_SHA224, + 'sha256'=>OPENSSL_ALGO_SHA256, + 'sha384'=>OPENSSL_ALGO_SHA384, + 'sha512'=>OPENSSL_ALGO_SHA512, + 'rmd160'=>OPENSSL_ALGO_RMD160); + +/* loop over key sizes for test */ +foreach($ksize as $k => $v) { + + /* generate new private key of specified size to use for tests */ + $pkey = openssl_pkey_new(array('digest_alg' => 'sha512', + 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'private_key_bits' => $v)); + openssl_pkey_export($pkey, $pass); + + /* loop to create and verify results */ + foreach($algo as $key => $value) { + $spkac = openssl_spki_new($pkey, _uuid(), $value); + var_dump(openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $spkac))); + var_dump(openssl_spki_export_challenge($spkac.'Make it fail')); + } + openssl_free_key($pkey); +} + +/* generate a random challenge */ +function _uuid() +{ + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff)); +} + +?> +--EXPECTREGEX-- +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) +string\(36\) \"[0-9a-f]{8}\-([0-9a-f]{4}\-){3}[0-9a-f]{12}\" +bool\(false\) diff --git a/ext/openssl/tests/openssl_spki_new.phpt b/ext/openssl/tests/openssl_spki_new.phpt new file mode 100644 index 0000000000..e40f9bf28e --- /dev/null +++ b/ext/openssl/tests/openssl_spki_new.phpt @@ -0,0 +1,77 @@ +--TEST-- +Testing openssl_spki_new() +Tests SPKAC for all available private key sizes & hashing algorithms +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!@openssl_pkey_new()) die("skip cannot create private key"); +?> +--FILE-- +<?php + +/* array of private key sizes to test */ +$ksize = array('1024'=>1024, + '2048'=>2048, + '4096'=>4096); + +/* array of available hashings to test */ +$algo = array('md4'=>OPENSSL_ALGO_MD4, + 'md5'=>OPENSSL_ALGO_MD5, + 'sha1'=>OPENSSL_ALGO_SHA1, + 'sha224'=>OPENSSL_ALGO_SHA224, + 'sha256'=>OPENSSL_ALGO_SHA256, + 'sha384'=>OPENSSL_ALGO_SHA384, + 'sha512'=>OPENSSL_ALGO_SHA512, + 'rmd160'=>OPENSSL_ALGO_RMD160); + +/* loop over key sizes for test */ +foreach($ksize as $k => $v) { + + /* generate new private key of specified size to use for tests */ + $pkey = openssl_pkey_new(array('digest_alg' => 'sha512', + 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'private_key_bits' => $v)); + openssl_pkey_export($pkey, $pass); + + /* loop to create and verify results */ + foreach($algo as $key => $value) { + var_dump(openssl_spki_new($pkey, _uuid(), $value)); + } + openssl_free_key($pkey); +} + +/* generate a random challenge */ +function _uuid() +{ + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff)); +} + +?> +--EXPECTF-- +string(478) "%s" +string(478) "%s" +string(478) "%s" +string(478) "%s" +string(478) "%s" +string(478) "%s" +string(478) "%s" +string(474) "%s" +string(830) "%s" +string(830) "%s" +string(830) "%s" +string(830) "%s" +string(830) "%s" +string(830) "%s" +string(830) "%s" +string(826) "%s" +string(1510) "%s" +string(1510) "%s" +string(1510) "%s" +string(1510) "%s" +string(1510) "%s" +string(1510) "%s" +string(1510) "%s" +string(1506) "%s" diff --git a/ext/openssl/tests/openssl_spki_verify.phpt b/ext/openssl/tests/openssl_spki_verify.phpt new file mode 100644 index 0000000000..1ee573fd3f --- /dev/null +++ b/ext/openssl/tests/openssl_spki_verify.phpt @@ -0,0 +1,105 @@ +--TEST-- +Testing openssl_spki_verify() +Creates SPKAC for all available key sizes & signature algorithms and tests for valid signature +--INI-- +error_reporting=0 +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!@openssl_pkey_new()) die("skip cannot create private key"); +?> +--FILE-- +<?php + +/* array of private key sizes to test */ +$ksize = array('1024'=>1024, + '2048'=>2048, + '4096'=>4096); + +/* array of available hashings to test */ +$algo = array('md4'=>OPENSSL_ALGO_MD4, + 'md5'=>OPENSSL_ALGO_MD5, + 'sha1'=>OPENSSL_ALGO_SHA1, + 'sha224'=>OPENSSL_ALGO_SHA224, + 'sha256'=>OPENSSL_ALGO_SHA256, + 'sha384'=>OPENSSL_ALGO_SHA384, + 'sha512'=>OPENSSL_ALGO_SHA512, + 'rmd160'=>OPENSSL_ALGO_RMD160); + +/* loop over key sizes for test */ +foreach($ksize as $k => $v) { + + /* generate new private key of specified size to use for tests */ + $pkey = openssl_pkey_new(array('digest_alg' => 'sha512', + 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'private_key_bits' => $v)); + openssl_pkey_export($pkey, $pass); + + /* loop to create and verify results */ + foreach($algo as $key => $value) { + $spkac = openssl_spki_new($pkey, _uuid(), $value); + var_dump(openssl_spki_verify(preg_replace('/SPKAC=/', '', $spkac))); + var_dump(openssl_spki_verify($spkac.'Make it fail')); + } + openssl_free_key($pkey); +} + +/* generate a random challenge */ +function _uuid() +{ + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), + mt_rand(0, 0xffff), mt_rand(0, 0xffff)); +} + +?> +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false)
\ No newline at end of file diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index a1a7ffc3f4..d7ef42e0b1 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -309,7 +309,7 @@ static inline int php_openssl_setup_crypto(php_stream *stream, php_stream_xport_crypto_param *cparam TSRMLS_DC) { - SSL_METHOD *method; + const SSL_METHOD *method; long ssl_ctx_options = SSL_OP_ALL; if (sslsock->ssl_handle) { @@ -853,7 +853,7 @@ php_stream_ops php_openssl_socket_ops = { php_openssl_sockop_set_option, }; -static char * get_sni(php_stream_context *ctx, char *resourcename, long resourcenamelen, int is_persistent TSRMLS_DC) { +static char * get_sni(php_stream_context *ctx, const char *resourcename, size_t resourcenamelen, int is_persistent TSRMLS_DC) { php_url *url; @@ -900,8 +900,8 @@ static char * get_sni(php_stream_context *ctx, char *resourcename, long resource return NULL; } -php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen, - char *resourcename, long resourcenamelen, +php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen, + const char *resourcename, size_t resourcenamelen, const char *persistent_id, int options, int flags, struct timeval *timeout, php_stream_context *context STREAMS_DC TSRMLS_DC) diff --git a/ext/pdo/Makefile.frag b/ext/pdo/Makefile.frag index 5ba5f80840..dc25c9f70b 100644 --- a/ext/pdo/Makefile.frag +++ b/ext/pdo/Makefile.frag @@ -2,7 +2,8 @@ phpincludedir=$(prefix)/include/php PDO_HEADER_FILES= \ php_pdo.h \ - php_pdo_driver.h + php_pdo_driver.h \ + php_pdo_error.h $(srcdir)/pdo_sql_parser.c: $(srcdir)/pdo_sql_parser.re diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index d5860b1a1e..aec388c03f 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -101,7 +101,7 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate } /* }}} */ -void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ +PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ { pdo_error_type *pdo_err = &dbh->error_code; const char *msg = "<<Unknown>>"; diff --git a/ext/pdo/php_pdo_error.h b/ext/pdo/php_pdo_error.h new file mode 100644 index 0000000000..387436af8f --- /dev/null +++ b/ext/pdo/php_pdo_error.h @@ -0,0 +1,47 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2013 The PHP Group | + +----------------------------------------------------------------------+ + | 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: | + | http://www.php.net/license/3_01.txt | + | 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 | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Wez Furlong <wez@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_PDO_ERROR_H +#define PHP_PDO_ERROR_H + +#include "php_pdo_driver.h" + +PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC); + +#define PDO_DBH_CLEAR_ERR() do { \ + strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \ + if (dbh->query_stmt) { \ + dbh->query_stmt = NULL; \ + zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \ + } \ +} while (0) +#define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE) +#define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); } +#define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); } + +#endif /* PHP_PDO_ERROR_H */ +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index 91d0bf0412..59dbaf9b01 100644 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -23,6 +23,8 @@ /* Stuff private to the PDO extension and not for consumption by PDO drivers * */ +#include "php_pdo_error.h" + extern HashTable pdo_driver_hash; extern zend_class_entry *pdo_exception_ce; PDO_API zend_class_entry *php_pdo_get_exception_base(int root TSRMLS_DC); @@ -55,19 +57,6 @@ zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object extern pdo_driver_t *pdo_find_driver(const char *name, int namelen); -extern void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC); - -#define PDO_DBH_CLEAR_ERR() do { \ - strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \ - if (dbh->query_stmt) { \ - dbh->query_stmt = NULL; \ - zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \ - } \ -} while (0) -#define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE) -#define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); } -#define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); } - int pdo_sqlstate_init_error_table(void); void pdo_sqlstate_fini_error_table(void); const char *pdo_sqlstate_state_to_description(char *state); diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index ff42514721..b49ad2691f 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -369,7 +369,7 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ DBSETOPT(H->link, DBTEXTSIZE, "2147483647"); /* allow double quoted indentifiers */ - DBSETOPT(H->link, DBQUOTEDIDENT, "1"); + DBSETOPT(H->link, DBQUOTEDIDENT, NULL); ret = 1; dbh->max_escaped_char_length = 2; diff --git a/ext/pdo_firebird/CREDITS b/ext/pdo_firebird/CREDITS index a33294b69c..60b917415d 100644 --- a/ext/pdo_firebird/CREDITS +++ b/ext/pdo_firebird/CREDITS @@ -1,2 +1,2 @@ -Firebird/InterBase driver for PDO +Firebird driver for PDO Ard Biesheuvel diff --git a/ext/pdo_firebird/package2.xml b/ext/pdo_firebird/package2.xml index 5b5984c80f..b744d388bc 100644 --- a/ext/pdo_firebird/package2.xml +++ b/ext/pdo_firebird/package2.xml @@ -5,9 +5,9 @@ http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>PDO_FIREBIRD</name> <channel>pecl.php.net</channel> - <summary>Firebird/InterBase 6 driver for PDO</summary> - <description>This extension provides a Firebird/InterBase driver for PDO. It supports -all versions of Firebird and InterBase versions 6 and up. + <summary>Firebird driver for PDO</summary> + <description>This extension provides a Firebird driver for PDO. It supports +all versions of Firebird 2.1 and up. </description> <lead> <name>Ard Biesheuvel</name> @@ -15,18 +15,17 @@ all versions of Firebird and InterBase versions 6 and up. <email>abies@php.net</email> <active>yes</active> </lead> - <date>2006-05-01</date> + <date>2013-09-01</date> <version> - <release>0.3</release> - <api>0.3</api> + <release>1.0</release> + <api>1.0</api> </version> <stability> - <release>beta</release> - <api>beta</api> + <release>stable</release> + <api>stable</api> </stability> <license uri="http://www.php.net/license">PHP</license> - <notes>To compile and run this module, you will need to have the main PDO module and Firebird's -or InterBase's client library installed on your system. + <notes>To compile and run this module, you will need to have the main PDO module and Firebird's client library installed on your system. Hope it works! </notes> <contents> @@ -49,7 +48,7 @@ Hope it works! <dependencies> <required> <php> - <min>5.0.3</min> + <min>5.3.27</min> </php> <pearinstaller> <min>1.4.0</min> diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 50136430a0..cb89809f02 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -27,8 +27,10 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" +#include "main/php_network.h" #include "pdo/php_pdo.h" #include "pdo/php_pdo_driver.h" +#include "pdo/php_pdo_error.h" #include "ext/standard/file.h" #undef PACKAGE_BUGREPORT @@ -60,7 +62,7 @@ static char * _pdo_pgsql_trim_message(const char *message, int persistent) return tmp; } -int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *file, int line TSRMLS_DC) /* {{{ */ +int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *msg, const char *file, int line TSRMLS_DC) /* {{{ */ { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_error_type *pdo_err = stmt ? &stmt->error_code : &dbh->error_code; @@ -83,7 +85,10 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char * strcpy(*pdo_err, sqlstate); } - if (errmsg) { + if (msg) { + einfo->errmsg = estrdup(msg); + } + else if (errmsg) { einfo->errmsg = _pdo_pgsql_trim_message(errmsg, dbh->is_persistent); } @@ -91,7 +96,7 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char * zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s", *pdo_err, einfo->errcode, einfo->errmsg); } - + return errcode; } /* }}} */ @@ -535,11 +540,13 @@ static PHP_METHOD(PDO, pgsqlCopyFromArray) dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); + /* using pre-9.0 syntax as PDO_pgsql is 7.4+ compatible */ if (pg_fields) { - spprintf(&query, 0, "COPY %s (%s) FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s (%s) FROM STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } else { - spprintf(&query, 0, "COPY %s FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s FROM STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } /* Obtain db Handle */ @@ -583,7 +590,8 @@ static PHP_METHOD(PDO, pgsqlCopyFromArray) query[query_len] = '\0'; if (PQputCopyData(H->server, query, query_len) != 1) { efree(query); - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "copy failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } zend_hash_move_forward_ex(Z_ARRVAL_P(pg_rows), &pos); @@ -593,22 +601,25 @@ static PHP_METHOD(PDO, pgsqlCopyFromArray) } if (PQputCopyEnd(H->server, NULL) != 1) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "putcopyend failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } while ((pgsql_result = PQgetResult(H->server))) { if (PGRES_COMMAND_OK != PQresultStatus(pgsql_result)) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, pdo_pgsql_sqlstate(pgsql_result)); command_failed = 1; } PQclear(pgsql_result); } + PDO_HANDLE_DBH_ERR(); RETURN_BOOL(!command_failed); } else { + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, pdo_pgsql_sqlstate(pgsql_result)); PQclear(pgsql_result); - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } } @@ -637,17 +648,20 @@ static PHP_METHOD(PDO, pgsqlCopyFromFile) /* Obtain db Handler */ dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); - stream = php_stream_open_wrapper_ex(filename, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, FG(default_context)); + stream = php_stream_open_wrapper_ex(filename, "rb", ENFORCE_SAFE_MODE, NULL, FG(default_context)); if (!stream) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Unable to open the file"); + pdo_pgsql_error_msg(dbh, PGRES_FATAL_ERROR, "Unable to open the file"); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } + /* using pre-9.0 syntax as PDO_pgsql is 7.4+ compatible */ if (pg_fields) { - spprintf(&query, 0, "COPY %s (%s) FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s (%s) FROM STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } else { - spprintf(&query, 0, "COPY %s FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s FROM STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } H = (pdo_pgsql_db_handle *)dbh->driver_data; @@ -674,8 +688,9 @@ static PHP_METHOD(PDO, pgsqlCopyFromFile) while ((buf = php_stream_get_line(stream, NULL, 0, &line_len)) != NULL) { if (PQputCopyData(H->server, buf, line_len) != 1) { efree(buf); - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "copy failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); php_stream_close(stream); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } efree(buf); @@ -683,23 +698,26 @@ static PHP_METHOD(PDO, pgsqlCopyFromFile) php_stream_close(stream); if (PQputCopyEnd(H->server, NULL) != 1) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "putcopyend failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } while ((pgsql_result = PQgetResult(H->server))) { if (PGRES_COMMAND_OK != PQresultStatus(pgsql_result)) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, pdo_pgsql_sqlstate(pgsql_result)); command_failed = 1; } PQclear(pgsql_result); } + PDO_HANDLE_DBH_ERR(); RETURN_BOOL(!command_failed); } else { - PQclear(pgsql_result); php_stream_close(stream); - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, pdo_pgsql_sqlstate(pgsql_result)); + PQclear(pgsql_result); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } } @@ -730,12 +748,14 @@ static PHP_METHOD(PDO, pgsqlCopyToFile) dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); H = (pdo_pgsql_db_handle *)dbh->driver_data; - stream = php_stream_open_wrapper_ex(filename, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, FG(default_context)); + stream = php_stream_open_wrapper_ex(filename, "wb", ENFORCE_SAFE_MODE, NULL, FG(default_context)); if (!stream) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Unable to open the file for writing"); + pdo_pgsql_error_msg(dbh, PGRES_FATAL_ERROR, "Unable to open the file for writing"); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } @@ -743,10 +763,11 @@ static PHP_METHOD(PDO, pgsqlCopyToFile) PQclear(pgsql_result); } + /* using pre-9.0 syntax as PDO_pgsql is 7.4+ compatible */ if (pg_fields) { - spprintf(&query, 0, "COPY %s (%s) TO STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s (%s) TO STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } else { - spprintf(&query, 0, "COPY %s TO STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s TO STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } pgsql_result = PQexec(H->server, query); efree(query); @@ -767,16 +788,18 @@ static PHP_METHOD(PDO, pgsqlCopyToFile) break; /* done */ } else if (ret > 0) { if (php_stream_write(stream, csv, ret) != ret) { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Unable to write to file"); + pdo_pgsql_error_msg(dbh, PGRES_FATAL_ERROR, "Unable to write to file"); PQfreemem(csv); php_stream_close(stream); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } else { PQfreemem(csv); } } else { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed: getline failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); php_stream_close(stream); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } } @@ -788,8 +811,9 @@ static PHP_METHOD(PDO, pgsqlCopyToFile) RETURN_TRUE; } else { php_stream_close(stream); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, pdo_pgsql_sqlstate(pgsql_result)); PQclear(pgsql_result); - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } } @@ -817,6 +841,7 @@ static PHP_METHOD(PDO, pgsqlCopyToArray) dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); H = (pdo_pgsql_db_handle *)dbh->driver_data; @@ -824,10 +849,11 @@ static PHP_METHOD(PDO, pgsqlCopyToArray) PQclear(pgsql_result); } + /* using pre-9.0 syntax as PDO_pgsql is 7.4+ compatible */ if (pg_fields) { - spprintf(&query, 0, "COPY %s (%s) TO STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s (%s) TO STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, pg_fields, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } else { - spprintf(&query, 0, "COPY %s TO STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); + spprintf(&query, 0, "COPY %s TO STDIN WITH DELIMITER E'%c' NULL AS E'%s'", table_name, (pg_delim_len ? *pg_delim : '\t'), (pg_null_as_len ? pg_null_as : "\\\\N")); } pgsql_result = PQexec(H->server, query); efree(query); @@ -851,7 +877,8 @@ static PHP_METHOD(PDO, pgsqlCopyToArray) add_next_index_stringl(return_value, csv, ret, 1); PQfreemem(csv); } else { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed: getline failed"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } } @@ -860,8 +887,9 @@ static PHP_METHOD(PDO, pgsqlCopyToArray) PQclear(pgsql_result); } } else { + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, pdo_pgsql_sqlstate(pgsql_result)); PQclear(pgsql_result); - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "Copy command failed"); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } } @@ -878,6 +906,7 @@ static PHP_METHOD(PDO, pgsqlLOBCreate) dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); H = (pdo_pgsql_db_handle *)dbh->driver_data; lfd = lo_creat(H->server, INV_READ|INV_WRITE); @@ -887,8 +916,9 @@ static PHP_METHOD(PDO, pgsqlLOBCreate) spprintf(&buf, 0, "%lu", (long) lfd); RETURN_STRING(buf, 0); } - - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "HY000"); + + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } /* }}} */ @@ -924,6 +954,7 @@ static PHP_METHOD(PDO, pgsqlLOBOpen) dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); H = (pdo_pgsql_db_handle *)dbh->driver_data; @@ -936,8 +967,10 @@ static PHP_METHOD(PDO, pgsqlLOBOpen) return; } } else { - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "HY000"); + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); } + + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } /* }}} */ @@ -964,17 +997,98 @@ static PHP_METHOD(PDO, pgsqlLOBUnlink) dbh = zend_object_store_get_object(getThis() TSRMLS_CC); PDO_CONSTRUCT_CHECK; + PDO_DBH_CLEAR_ERR(); H = (pdo_pgsql_db_handle *)dbh->driver_data; - + if (1 == lo_unlink(H->server, oid)) { RETURN_TRUE; } - pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, "HY000"); + + pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL); + PDO_HANDLE_DBH_ERR(); RETURN_FALSE; } /* }}} */ +/* {{{ proto mixed PDO::pgsqlGetNotify([ int $result_type = PDO::FETCH_USE_DEFAULT] [, int $ms_timeout = 0 ]]) + Get asyncronous notification */ +static PHP_METHOD(PDO, pgsqlGetNotify) +{ + pdo_dbh_t *dbh; + pdo_pgsql_db_handle *H; + long result_type = PDO_FETCH_USE_DEFAULT; + long ms_timeout = 0; + PGnotify *pgsql_notify; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", + &result_type, &ms_timeout)) { + RETURN_FALSE; + } + + dbh = zend_object_store_get_object(getThis() TSRMLS_CC); + PDO_CONSTRUCT_CHECK; + + if (result_type == PDO_FETCH_USE_DEFAULT) { + result_type = dbh->default_fetch_type; + } + + if (result_type != PDO_FETCH_BOTH && result_type != PDO_FETCH_ASSOC && result_type != PDO_FETCH_NUM) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type"); + RETURN_FALSE; + } + + if (ms_timeout < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid timeout"); + RETURN_FALSE; + } + + H = (pdo_pgsql_db_handle *)dbh->driver_data; + + PQconsumeInput(H->server); + pgsql_notify = PQnotifies(H->server); + + if (ms_timeout && !pgsql_notify) { + php_pollfd_for_ms(PQsocket(H->server), PHP_POLLREADABLE, ms_timeout); + + PQconsumeInput(H->server); + pgsql_notify = PQnotifies(H->server); + } + + if (!pgsql_notify) { + RETURN_FALSE; + } + + array_init(return_value); + if (result_type == PDO_FETCH_NUM || result_type == PDO_FETCH_BOTH) { + add_index_string(return_value, 0, pgsql_notify->relname, 1); + add_index_long(return_value, 1, pgsql_notify->be_pid); + } + if (result_type == PDO_FETCH_ASSOC || result_type == PDO_FETCH_BOTH) { + add_assoc_string(return_value, "message", pgsql_notify->relname, 1); + add_assoc_long(return_value, "pid", pgsql_notify->be_pid); + } + + PQfreemem(pgsql_notify); +} +/* }}} */ + +/* {{{ proto int PDO::pgsqlGetPid() + Get backend(server) pid */ +static PHP_METHOD(PDO, pgsqlGetPid) +{ + pdo_dbh_t *dbh; + pdo_pgsql_db_handle *H; + + dbh = zend_object_store_get_object(getThis() TSRMLS_CC); + PDO_CONSTRUCT_CHECK; + + H = (pdo_pgsql_db_handle *)dbh->driver_data; + + RETURN_LONG(PQbackendPID(H->server)); +} +/* }}} */ + static const zend_function_entry dbh_methods[] = { PHP_ME(PDO, pgsqlLOBCreate, NULL, ZEND_ACC_PUBLIC) @@ -984,6 +1098,8 @@ static const zend_function_entry dbh_methods[] = { PHP_ME(PDO, pgsqlCopyFromFile, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, pgsqlCopyToArray, NULL, ZEND_ACC_PUBLIC) PHP_ME(PDO, pgsqlCopyToFile, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PDO, pgsqlGetNotify, NULL, ZEND_ACC_PUBLIC) + PHP_ME(PDO, pgsqlGetPid, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h index 02a6717760..5600a92541 100644 --- a/ext/pdo_pgsql/php_pdo_pgsql_int.h +++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h @@ -83,9 +83,11 @@ typedef struct { extern pdo_driver_t pdo_pgsql_driver; -extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *file, int line TSRMLS_DC); -#define pdo_pgsql_error(d,e,z) _pdo_pgsql_error(d, NULL, e, z, __FILE__, __LINE__ TSRMLS_CC) -#define pdo_pgsql_error_stmt(s,e,z) _pdo_pgsql_error(s->dbh, s, e, z, __FILE__, __LINE__ TSRMLS_CC) +extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *sqlstate, const char *msg, const char *file, int line TSRMLS_DC); +#define pdo_pgsql_error(d,e,z) _pdo_pgsql_error(d, NULL, e, z, NULL, __FILE__, __LINE__ TSRMLS_CC) +#define pdo_pgsql_error_msg(d,e,m) _pdo_pgsql_error(d, NULL, e, NULL, m, __FILE__, __LINE__ TSRMLS_CC) +#define pdo_pgsql_error_stmt(s,e,z) _pdo_pgsql_error(s->dbh, s, e, z, NULL, __FILE__, __LINE__ TSRMLS_CC) +#define pdo_pgsql_error_stmt_msg(s,e,m) _pdo_pgsql_error(s->dbh, s, e, NULL, m, __FILE__, __LINE__ TSRMLS_CC) extern struct pdo_stmt_methods pgsql_stmt_methods; diff --git a/ext/pdo_pgsql/tests/copy_from.phpt b/ext/pdo_pgsql/tests/copy_from.phpt index 10967b0fe9..de1140dfea 100644 --- a/ext/pdo_pgsql/tests/copy_from.phpt +++ b/ext/pdo_pgsql/tests/copy_from.phpt @@ -16,8 +16,6 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); $db->exec('CREATE TABLE test (a integer not null primary key, b text, c integer)'); -try { - echo "Preparing test file and array for CopyFrom tests\n"; $tableRows = array(); @@ -68,10 +66,13 @@ $db->rollback(); echo "Testing pgsqlCopyFromArray() with error\n"; $db->beginTransaction(); -var_dump($db->pgsqlCopyFromArray('test_error',$tableRowsWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); +try { + var_dump($db->pgsqlCopyFromArray('test_error',$tableRowsWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); +} catch (Exception $e) { + echo "Exception: {$e->getMessage()}\n"; +} $db->rollback(); - echo "Testing pgsqlCopyFromFile() with default parameters\n"; $db->beginTransaction(); var_dump($db->pgsqlCopyFromFile('test',$filename)); @@ -102,14 +103,21 @@ $db->rollback(); echo "Testing pgsqlCopyFromFile() with error\n"; $db->beginTransaction(); -var_dump($db->pgsqlCopyFromFile('test_error',$filenameWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); +try { + var_dump($db->pgsqlCopyFromFile('test_error',$filenameWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); +} catch (Exception $e) { + echo "Exception: {$e->getMessage()}\n"; +} $db->rollback(); +echo "Testing pgsqlCopyFromFile() with non existing file\n"; +$db->beginTransaction(); +try { + var_dump($db->pgsqlCopyFromFile('test',"nonexisting/foo.csv",";","NULL",'a,c')); } catch (Exception $e) { - /* catch exceptions so that we can show the relative error */ - echo "Exception! at line ", $e->getLine(), "\n"; - var_dump($e->getMessage()); + echo "Exception: {$e->getMessage()}\n"; } +$db->rollback(); // Clean up foreach (array($filename, $filenameWithDifferentNullValues, $filenameWithDifferentNullValuesAndSelectedFields) as $f) { @@ -251,7 +259,7 @@ array(6) { NULL } Testing pgsqlCopyFromArray() with error -bool(false) +Exception: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "test_error" does not exist Testing pgsqlCopyFromFile() with default parameters bool(true) array(6) { @@ -385,4 +393,7 @@ array(6) { NULL } Testing pgsqlCopyFromFile() with error -bool(false) +Exception: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "test_error" does not exist +Testing pgsqlCopyFromFile() with non existing file +Exception: SQLSTATE[HY000]: General error: 7 Unable to open the file + diff --git a/ext/pdo_pgsql/tests/copy_to.phpt b/ext/pdo_pgsql/tests/copy_to.phpt index 1dc7d1de33..7bc46c6e0b 100644 --- a/ext/pdo_pgsql/tests/copy_to.phpt +++ b/ext/pdo_pgsql/tests/copy_to.phpt @@ -17,7 +17,6 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); $db->exec('CREATE TABLE test (a integer not null primary key, b text, c integer)'); $db->beginTransaction(); -try { echo "Preparing test table for CopyTo tests\n"; $stmt = $db->prepare("INSERT INTO test (a, b, c) values (?, ?, ?)"); @@ -42,8 +41,11 @@ echo "Testing pgsqlCopyToArray() with only selected fields\n"; var_dump($db->pgsqlCopyToArray('test',";","NULL",'a,c')); echo "Testing pgsqlCopyToArray() with error\n"; -var_dump($db->pgsqlCopyToArray('test_error')); - +try { + var_dump($db->pgsqlCopyToArray('test_error')); +} catch (Exception $e) { + echo "Exception: {$e->getMessage()}\n"; +} echo "Testing pgsqlCopyToFile() with default parameters\n"; @@ -58,14 +60,19 @@ var_dump($db->pgsqlCopyToFile('test',$filename,";","NULL",'a,c')); echo file_get_contents($filename); echo "Testing pgsqlCopyToFile() with error\n"; -var_dump($db->pgsqlCopyToFile('test_error',$filename)); - +try { + var_dump($db->pgsqlCopyToFile('test_error',$filename)); +} catch (Exception $e) { + echo "Exception: {$e->getMessage()}\n"; +} +echo "Testing pgsqlCopyToFile() to unwritable file\n"; +try { + var_dump($db->pgsqlCopyToFile('test', 'nonexistent/foo.csv')); } catch (Exception $e) { - /* catch exceptions so that we can show the relative error */ - echo "Exception! at line ", $e->getLine(), "\n"; - var_dump($e->getMessage()); + echo "Exception: {$e->getMessage()}\n"; } + if(isset($filename)) { @unlink($filename); } @@ -109,7 +116,7 @@ array(3) { " } Testing pgsqlCopyToArray() with error -bool(false) +Exception: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "test_error" does not exist Testing pgsqlCopyToFile() with default parameters bool(true) 0 test insert 0 \N @@ -126,4 +133,7 @@ bool(true) 1;NULL 2;NULL Testing pgsqlCopyToFile() with error -bool(false)
\ No newline at end of file +Exception: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "test_error" does not exist +Testing pgsqlCopyToFile() to unwritable file +Exception: SQLSTATE[HY000]: General error: 7 Unable to open the file for writing + diff --git a/ext/pdo_pgsql/tests/getnotify.phpt b/ext/pdo_pgsql/tests/getnotify.phpt new file mode 100644 index 0000000000..c093e0357a --- /dev/null +++ b/ext/pdo_pgsql/tests/getnotify.phpt @@ -0,0 +1,109 @@ +--TEST-- +PDO PgSQL LISTEN/NOTIFY support +--SKIPIF-- +<?php # vim:se ft=php: +if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); +require dirname(__FILE__) . '/config.inc'; +require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; +$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +// pgsqlGetPid should return something meaningful +$pid = $db->pgsqlGetPid(); +var_dump($pid > 0); + +// No listen, no notifies +var_dump($db->pgsqlGetNotify()); + +// Listen started, no notifies +$db->exec("LISTEN notifies_phpt"); +var_dump($db->pgsqlGetNotify()); + +// No parameters, use default PDO::FETCH_NUM +$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM); +$db->exec("NOTIFY notifies_phpt"); +$notify = $db->pgsqlGetNotify(); +var_dump(count($notify)); +var_dump($notify[0]); +var_dump($notify[1] == $pid); + +// No parameters, use default PDO::FETCH_ASSOC +$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); +$db->exec("NOTIFY notifies_phpt"); +$notify = $db->pgsqlGetNotify(); +var_dump(count($notify)); +var_dump($notify['message']); +var_dump($notify['pid'] == $pid); + +// Test PDO::FETCH_NUM as parameter +$db->exec("NOTIFY notifies_phpt"); +$notify = $db->pgsqlGetNotify(PDO::FETCH_NUM); +var_dump(count($notify)); +var_dump($notify[0]); +var_dump($notify[1] == $pid); + +// Test PDO::FETCH_ASSOC as parameter +$db->exec("NOTIFY notifies_phpt"); +$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC); +var_dump(count($notify)); +var_dump($notify['message']); +var_dump($notify['pid'] == $pid); + +// Test PDO::FETCH_BOTH as parameter +$db->exec("NOTIFY notifies_phpt"); +$notify = $db->pgsqlGetNotify(PDO::FETCH_BOTH); +var_dump(count($notify)); +var_dump($notify['message']); +var_dump($notify['pid'] == $pid); +var_dump($notify[0]); +var_dump($notify[1] == $pid); + +// Verify that there are no notifies queued +var_dump($db->pgsqlGetNotify()); + + +// Test second parameter, should wait 2 seconds because no notify is queued +$t = microtime(1); +$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC, 1000); +var_dump((microtime(1) - $t) >= 1); +var_dump($notify); + +// Test second parameter, should return immediately because a notify is queued +$db->exec("NOTIFY notifies_phpt"); +$t = microtime(1); +$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC, 5000); +var_dump((microtime(1) - $t) < 1); +var_dump(count($notify)); + +?> +--EXPECT-- +bool(true) +bool(false) +bool(false) +int(2) +string(13) "notifies_phpt" +bool(true) +int(2) +string(13) "notifies_phpt" +bool(true) +int(2) +string(13) "notifies_phpt" +bool(true) +int(2) +string(13) "notifies_phpt" +bool(true) +int(4) +string(13) "notifies_phpt" +bool(true) +string(13) "notifies_phpt" +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +int(2) diff --git a/ext/pgsql/tests/00version.phpt b/ext/pgsql/tests/00version.phpt new file mode 100644 index 0000000000..d72d9e1f21 --- /dev/null +++ b/ext/pgsql/tests/00version.phpt @@ -0,0 +1,30 @@ +--TEST-- +PostgreSQL version +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +// Get postgresql version for easier debugging. +// Execute run-test.php with --keep-all to get version string in 00version.log or 00version.out +include('config.inc'); + +$db = pg_connect($conn_str); +var_dump(pg_version($db)); +pg_close($db); + +// Get environment vars for debugging +var_dump(serialize($_ENV)); + +echo "OK"; +?> +--EXPECTF-- +array(3) { + ["client"]=> + string(%d) "%s" + ["protocol"]=> + int(%d) + ["server"]=> + string(%d) "%s" +} +string(%d) "%s" +OK diff --git a/ext/pgsql/tests/14pg_update_9.phpt b/ext/pgsql/tests/14pg_update_9.phpt index e766c1f380..c33f1afbd6 100644 --- a/ext/pgsql/tests/14pg_update_9.phpt +++ b/ext/pgsql/tests/14pg_update_9.phpt @@ -1,5 +1,5 @@ --TEST-- -PostgreSQL pg_update() (9.0) +PostgreSQL pg_update() (9.0+) --SKIPIF-- <?php include("skipif.inc"); diff --git a/ext/pgsql/tests/80_bug14383.phpt b/ext/pgsql/tests/80_bug14383.phpt index a736f34c90..cb54aa8dfb 100644 --- a/ext/pgsql/tests/80_bug14383.phpt +++ b/ext/pgsql/tests/80_bug14383.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #14383 (using postgres with DBA causes DBA not to be able to find any keys) +Bug #14383 (8.0+) (using postgres with DBA causes DBA not to be able to find any keys) --SKIPIF-- <?php require_once(dirname(__FILE__).'/../../dba/tests/skipif.inc'); diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt index 9cc8a1d4fd..e1b7fa1b50 100644 --- a/ext/pgsql/tests/80_bug36625.phpt +++ b/ext/pgsql/tests/80_bug36625.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #36625 (pg_trace() does not work) +Bug #36625 (8.0+) (pg_trace() does not work) --SKIPIF-- <?php require_once('skipif.inc'); diff --git a/ext/pgsql/tests/80_bug39971.phpt b/ext/pgsql/tests/80_bug39971.phpt index 45d26319d3..49f370b88d 100644 --- a/ext/pgsql/tests/80_bug39971.phpt +++ b/ext/pgsql/tests/80_bug39971.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #39971 (pg_insert/pg_update do not allow now() to be used for timestamp fields) +Bug #39971 (8.0+) (pg_insert/pg_update do not allow now() to be used for timestamp fields) --SKIPIF-- <?php require_once('skipif.inc'); diff --git a/ext/pgsql/tests/config.inc b/ext/pgsql/tests/config.inc index d4bbb33824..ffe31a875e 100644 --- a/ext/pgsql/tests/config.inc +++ b/ext/pgsql/tests/config.inc @@ -2,8 +2,10 @@ // These vars are used to connect db and create test table. // values can be set to meet your environment +// "test" database must be existed. i.e. "createdb test" before testing +// PostgreSQL uses login name as username, user must have access to "test" database. $conn_str = "host=localhost dbname=test port=5432"; // connection string -$table_name = "php_pgsql_test"; // test table that should be exist +$table_name = "php_pgsql_test"; // test table that will be created $num_test_record = 1000; // Number of records to create $table_def = "CREATE TABLE php_pgsql_test (num int, str text, bin bytea);"; // Test table diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index c29ca9d968..62b19a79d9 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -94,31 +94,23 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D { size_t to_read; HashTable *data = (HashTable *)stream->abstract; - phar_zstr key; char *str_key; uint keylen; ulong unused; - if (FAILURE == zend_hash_has_more_elements(data)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &str_key, &keylen, &unused, 0, NULL)) { return 0; } - if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) { - return 0; - } - - PHAR_STR(key, str_key); zend_hash_move_forward(data); to_read = MIN(keylen, count); if (to_read == 0 || count < keylen) { - PHAR_STR_FREE(str_key); return 0; } memset(buf, 0, sizeof(php_stream_dirent)); memcpy(((php_stream_dirent *) buf)->d_name, str_key, to_read); - PHAR_STR_FREE(str_key); ((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0'; return sizeof(php_stream_dirent); @@ -193,13 +185,12 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) { HashTable *data; int dirlen = strlen(dir); - phar_zstr key; char *entry, *found, *save, *str_key; uint keylen; ulong unused; ALLOC_HASHTABLE(data); - zend_hash_init(data, 64, zend_get_hash_value, NULL, 0); + zend_hash_init(data, 64, NULL, NULL, 0); if ((*dir == '/' && dirlen == 1 && (manifest->nNumOfElements == 0)) || (dirlen >= sizeof(".phar")-1 && !memcmp(dir, ".phar", sizeof(".phar")-1))) { /* make empty root directory for empty phar */ @@ -211,15 +202,12 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) zend_hash_internal_pointer_reset(manifest); while (FAILURE != zend_hash_has_more_elements(manifest)) { - if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) { break; } - PHAR_STR(key, str_key); - if (keylen <= (uint)dirlen) { if (keylen < (uint)dirlen || !strncmp(str_key, dir, dirlen)) { - PHAR_STR_FREE(str_key); if (SUCCESS != zend_hash_move_forward(manifest)) { break; } @@ -230,7 +218,6 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) if (*dir == '/') { /* root directory */ if (keylen >= sizeof(".phar")-1 && !memcmp(str_key, ".phar", sizeof(".phar")-1)) { - PHAR_STR_FREE(str_key); /* do not add any magic entries to this directory */ if (SUCCESS != zend_hash_move_forward(manifest)) { break; @@ -250,19 +237,16 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) entry[keylen] = '\0'; } - PHAR_STR_FREE(str_key); goto PHAR_ADD_ENTRY; } else { if (0 != memcmp(str_key, dir, dirlen)) { /* entry in directory not found */ - PHAR_STR_FREE(str_key); if (SUCCESS != zend_hash_move_forward(manifest)) { break; } continue; } else { if (str_key[dirlen] != '/') { - PHAR_STR_FREE(str_key); if (SUCCESS != zend_hash_move_forward(manifest)) { break; } @@ -289,7 +273,6 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) entry[keylen - dirlen - 1] = '\0'; keylen = keylen - dirlen - 1; } - PHAR_STR_FREE(str_key); PHAR_ADD_ENTRY: if (keylen) { phar_add_empty(data, entry, keylen); @@ -319,12 +302,11 @@ PHAR_ADD_ENTRY: /** * Open a directory handle within a phar archive */ -php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ +php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ { php_url *resource = NULL; php_stream *ret; char *internal_file, *error, *str_key; - phar_zstr key; uint keylen; ulong unused; phar_archive_data *phar; @@ -405,17 +387,14 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) { if (HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex( - &phar->manifest, &key, &keylen, &unused, 0, NULL)) { - PHAR_STR(key, str_key); + &phar->manifest, &str_key, &keylen, &unused, 0, NULL)) { if (keylen > (uint)i_len && 0 == memcmp(str_key, internal_file, i_len)) { - PHAR_STR_FREE(str_key); /* directory found */ internal_file = estrndup(internal_file, i_len); php_url_free(resource); return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC); } - PHAR_STR_FREE(str_key); } if (SUCCESS != zend_hash_move_forward(&phar->manifest)) { @@ -432,7 +411,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char /** * Make a new directory within a phar archive */ -int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ +int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ { phar_entry_info entry, *e; phar_archive_data *phar = NULL; @@ -564,7 +543,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in /** * Remove a directory within a phar archive */ -int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ +int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ { phar_entry_info *entry; phar_archive_data *phar = NULL; @@ -572,7 +551,6 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_ int arch_len, entry_len; php_url *resource = NULL; uint host_len; - phar_zstr key; char *str_key; uint key_len; ulong unused; @@ -637,15 +615,12 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_ if (!entry->is_deleted) { for (zend_hash_internal_pointer_reset(&phar->manifest); - HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL); - zend_hash_move_forward(&phar->manifest)) { - - PHAR_STR(key, str_key); - + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->manifest, &str_key, &key_len, &unused, 0, NULL); + zend_hash_move_forward(&phar->manifest) + ) { if (key_len > path_len && memcmp(str_key, resource->path+1, path_len) == 0 && IS_SLASH(str_key[path_len])) { - PHAR_STR_FREE(str_key); php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty"); if (entry->is_temp_dir) { efree(entry->filename); @@ -654,19 +629,15 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_ php_url_free(resource); return 0; } - PHAR_STR_FREE(str_key); } for (zend_hash_internal_pointer_reset(&phar->virtual_dirs); - HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &str_key, &key_len, &unused, 0, NULL); zend_hash_move_forward(&phar->virtual_dirs)) { - PHAR_STR(key, str_key); - if (key_len > path_len && memcmp(str_key, resource->path+1, path_len) == 0 && IS_SLASH(str_key[path_len])) { - PHAR_STR_FREE(str_key); php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty"); if (entry->is_temp_dir) { efree(entry->filename); @@ -675,7 +646,6 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_ php_url_free(resource); return 0; } - PHAR_STR_FREE(str_key); } } diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h index 9b07c9d799..030fe6536e 100644 --- a/ext/phar/dirstream.h +++ b/ext/phar/dirstream.h @@ -20,11 +20,11 @@ /* $Id$ */ BEGIN_EXTERN_C() -int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC); -int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC); +int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC); +int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC); #ifdef PHAR_DIRSTREAM -php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC); +php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC); /* directory handlers */ static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC); @@ -33,7 +33,7 @@ static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC); static int phar_dir_flush(php_stream *stream TSRMLS_DC); static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC); #else -php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); #endif END_EXTERN_C() diff --git a/ext/phar/phar.c b/ext/phar/phar.c index ec8e5fbde7..79f88b4362 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -27,9 +27,7 @@ static void destroy_phar_data(void *pDest); ZEND_DECLARE_MODULE_GLOBALS(phar) -#if PHP_VERSION_ID >= 50300 char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC); -#endif /** * set's phar->is_writeable based on the current INI value @@ -1641,7 +1639,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a php_stream_filter_append(&temp->writefilters, filter); - if (SUCCESS != phar_stream_copy_to_stream(fp, temp, PHP_STREAM_COPY_ALL, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(fp, temp, PHP_STREAM_COPY_ALL, NULL)) { if (err) { php_stream_close(temp); MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older than 5.2.6") @@ -1683,7 +1681,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *a php_stream_filter_append(&temp->writefilters, filter); - if (SUCCESS != phar_stream_copy_to_stream(fp, temp, PHP_STREAM_COPY_ALL, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(fp, temp, PHP_STREAM_COPY_ALL, NULL)) { php_stream_close(temp); MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file") } @@ -1956,67 +1954,45 @@ woohoo: goto woohoo; } } else { - phar_zstr key; char *str_key; uint keylen; ulong unused; - zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map)); - - while (FAILURE != zend_hash_has_more_elements(&(PHAR_GLOBALS->phar_fname_map))) { - if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) { - break; - } - - PHAR_STR(key, str_key); - + for (zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map)); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &str_key, &keylen, &unused, 0, NULL); + zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map)) + ) { if (keylen > (uint) filename_len) { - zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map)); - PHAR_STR_FREE(str_key); continue; } if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen || filename[keylen] == '/' || filename[keylen] == '\0')) { - PHAR_STR_FREE(str_key); if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) { break; } *ext_str = filename + (keylen - (*pphar)->ext_len); goto woohoo; } - - PHAR_STR_FREE(str_key); - zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map)); } if (PHAR_G(manifest_cached)) { - zend_hash_internal_pointer_reset(&cached_phars); - - while (FAILURE != zend_hash_has_more_elements(&cached_phars)) { - if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) { - break; - } - - PHAR_STR(key, str_key); - + for (zend_hash_internal_pointer_reset(&cached_phars); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&cached_phars, &str_key, &keylen, &unused, 0, NULL); + zend_hash_move_forward(&cached_phars) + ) { if (keylen > (uint) filename_len) { - zend_hash_move_forward(&cached_phars); - PHAR_STR_FREE(str_key); continue; } if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen || filename[keylen] == '/' || filename[keylen] == '\0')) { - PHAR_STR_FREE(str_key); if (FAILURE == zend_hash_get_current_data(&cached_phars, (void **) &pphar)) { break; } *ext_str = filename + (keylen - (*pphar)->ext_len); goto woohoo; } - PHAR_STR_FREE(str_key); - zend_hash_move_forward(&cached_phars); } } } @@ -2251,13 +2227,13 @@ last_time: * * This is used by phar_parse_url() */ -int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC) /* {{{ */ +int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC) /* {{{ */ { const char *ext_str; #ifdef PHP_WIN32 char *save; #endif - int ext_len, free_filename = 0; + int ext_len; if (!strncasecmp(filename, "phar://", 7)) { filename += 7; @@ -2266,7 +2242,6 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le ext_len = 0; #ifdef PHP_WIN32 - free_filename = 1; save = filename; filename = estrndup(filename, filename_len); phar_unixify_path_separators(filename, filename_len); @@ -2282,10 +2257,9 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le #endif } - if (free_filename) { - efree(filename); - } - +#ifdef PHP_WIN32 + efree(filename); +#endif return FAILURE; } @@ -2308,9 +2282,9 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le *entry = estrndup("/", 1); } - if (free_filename) { - efree(filename); - } +#ifdef PHP_WIN32 + efree(filename); +#endif return SUCCESS; } @@ -2703,7 +2677,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, size_t written; if (!user_stub && phar->halt_offset && oldfile && !phar->is_brandnew) { - phar_stream_copy_to_stream(oldfile, newfile, phar->halt_offset, &written); + php_stream_copy_to_stream_ex(oldfile, newfile, phar->halt_offset, &written); newstub = NULL; } else { /* this is either a brand new phar or a default stub overwrite */ @@ -2891,7 +2865,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, return EOF; } php_stream_filter_append((&entry->cfp->writefilters), filter); - if (SUCCESS != phar_stream_copy_to_stream(file, entry->cfp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(file, entry->cfp, entry->uncompressed_filesize, NULL)) { if (closeoldfile) { php_stream_close(oldfile); } @@ -3123,7 +3097,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, /* this will have changed for all files that have either changed compression or been modified */ entry->offset = entry->offset_abs = offset; offset += entry->compressed_filesize; - if (phar_stream_copy_to_stream(file, newfile, entry->compressed_filesize, &wrote) == FAILURE) { + if (php_stream_copy_to_stream_ex(file, newfile, entry->compressed_filesize, &wrote) == FAILURE) { if (closeoldfile) { php_stream_close(oldfile); } @@ -3269,7 +3243,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, } php_stream_filter_append(&phar->fp->writefilters, filter); - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); php_stream_filter_flush(filter, 1); php_stream_filter_remove(filter, 1 TSRMLS_CC); php_stream_close(phar->fp); @@ -3278,14 +3252,14 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, } else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) { filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC); php_stream_filter_append(&phar->fp->writefilters, filter); - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); php_stream_filter_flush(filter, 1); php_stream_filter_remove(filter, 1 TSRMLS_CC); php_stream_close(phar->fp); /* use the temp stream as our base */ phar->fp = newfile; } else { - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); /* we could also reopen the file in "rb" mode but there is no need for that */ php_stream_close(newfile); } @@ -3321,31 +3295,17 @@ static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS } /* }}} */ -#if PHP_VERSION_ID >= 50300 static size_t phar_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */ { return ((phar_archive_data*)handle)->halt_offset + 32; } /* }}} */ -#else /* PHP_VERSION_ID */ - -static long phar_stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */ -{ - return (long)php_stream_tell(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC)); -} -/* }}} */ -#endif - zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); -#if PHP_VERSION_ID >= 50300 #define phar_orig_zend_open zend_stream_open_function static char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC) { return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC); } -#else -int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC); -#endif static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */ { @@ -3378,7 +3338,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type } } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) { /* compressed phar */ -#if PHP_VERSION_ID >= 50300 file_handle->type = ZEND_HANDLE_STREAM; /* we do our own reading directly from the phar, don't change the next line */ file_handle->handle.stream.handle = phar; @@ -3390,18 +3349,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) : php_stream_rewind(phar->fp); memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap)); -#else /* PHP_VERSION_ID */ - file_handle->type = ZEND_HANDLE_STREAM; - /* we do our own reading directly from the phar, don't change the next line */ - file_handle->handle.stream.handle = phar; - file_handle->handle.stream.reader = phar_zend_stream_reader; - file_handle->handle.stream.closer = NULL; /* don't close - let phar handle this one */ - file_handle->handle.stream.fteller = phar_stream_fteller_for_zend; - file_handle->handle.stream.interactive = 0; - phar->is_persistent ? - php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) : - php_stream_rewind(phar->fp); -#endif } } } @@ -3426,60 +3373,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type } /* }}} */ -#if PHP_VERSION_ID < 50300 -int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */ -{ - char *arch, *entry; - int arch_len, entry_len; - - /* this code is obsoleted in php 5.3 */ - entry = (char *) filename; - if (!IS_ABSOLUTE_PATH(entry, strlen(entry)) && !strstr(entry, "://")) { - phar_archive_data **pphar = NULL; - char *fname; - int fname_len; - - fname = (char*)zend_get_executed_filename(TSRMLS_C); - fname_len = strlen(fname); - - if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) { - if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { - zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar); - if (!pphar && PHAR_G(manifest_cached)) { - zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar); - } - efree(arch); - efree(entry); - } - } - - /* retrieving an include within the current directory, so use this if possible */ - if (!(entry = phar_find_in_include_path((char *) filename, strlen(filename), NULL TSRMLS_CC))) { - /* this file is not in the phar, use the original path */ - goto skip_phar; - } - - if (SUCCESS == phar_orig_zend_open(entry, handle TSRMLS_CC)) { - if (!handle->opened_path) { - handle->opened_path = entry; - } - if (entry != filename) { - handle->free_filename = 1; - } - return SUCCESS; - } - - if (entry != filename) { - efree(entry); - } - - return FAILURE; - } -skip_phar: - return phar_orig_zend_open(filename, handle TSRMLS_CC); -} -/* }}} */ -#endif typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC); typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr); @@ -3556,13 +3449,8 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */ phar_orig_compile_file = zend_compile_file; zend_compile_file = phar_compile_file; -#if PHP_VERSION_ID >= 50300 phar_save_resolve_path = zend_resolve_path; zend_resolve_path = phar_resolve_path; -#else - phar_orig_zend_open = zend_stream_open_function; - zend_stream_open_function = phar_zend_open; -#endif phar_object_init(TSRMLS_C); @@ -3583,11 +3471,6 @@ PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */ zend_compile_file = phar_orig_compile_file; } -#if PHP_VERSION_ID < 50300 - if (zend_stream_open_function == phar_zend_open) { - zend_stream_open_function = phar_orig_zend_open; - } -#endif if (PHAR_G(manifest_cached)) { zend_hash_destroy(&(cached_phars)); zend_hash_destroy(&(cached_alias)); diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index daa85f1b70..64953f66b7 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -63,27 +63,11 @@ #include "ext/spl/spl_iterators.h" #endif #include "php_phar.h" -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif #ifdef PHAR_HASH_OK #include "ext/hash/php_hash.h" #include "ext/hash/php_hash_sha.h" #endif -#ifndef E_RECOVERABLE_ERROR -# define E_RECOVERABLE_ERROR E_ERROR -#endif - -#ifndef pestrndup -# define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length))) -#endif - -#ifndef ALLOC_PERMANENT_ZVAL -# define ALLOC_PERMANENT_ZVAL(z) \ - (z) = (zval*)malloc(sizeof(zval)) -#endif - /* PHP_ because this is public information via MINFO */ #define PHP_PHAR_API_VERSION "1.1.1" /* x.y.z maps to 0xyz0 */ @@ -516,75 +500,7 @@ union _phar_entry_object { #endif #ifndef PHAR_MAIN -# if PHP_VERSION_ID >= 50300 extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC); -# endif -#endif - -#if PHP_VERSION_ID < 50209 -static inline size_t phar_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC) -{ - size_t ret = php_stream_copy_to_stream(src, dest, maxlen); - if (len) { - *len = ret; - } - if (ret) { - return SUCCESS; - } - return FAILURE; -} -#else -# define phar_stream_copy_to_stream(src, dest, maxlen, len) _php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC TSRMLS_CC) - -#endif - -#if PHP_VERSION_ID >= 60000 -typedef zstr phar_zstr; -#define PHAR_STR(a, b) \ - spprintf(&b, 0, "%s", a.s); -#define PHAR_ZSTR(a, b) \ - b = ZSTR(a); -#define PHAR_STR_FREE(a) \ - efree(a); -static inline int phar_make_unicode(zstr *c_var, char *arKey, uint nKeyLength TSRMLS_DC) -{ - int c_var_len; - UConverter *conv = ZEND_U_CONVERTER(UG(runtime_encoding_conv)); - - c_var->u = NULL; - if (zend_string_to_unicode(conv, &c_var->u, &c_var_len, arKey, nKeyLength TSRMLS_CC) == FAILURE) { - - if (c_var->u) { - efree(c_var->u); - } - return 0; - - } - return c_var_len; -} -static inline int phar_find_key(HashTable *_SERVER, char *key, int len, void **stuff TSRMLS_DC) -{ - if (SUCCESS == zend_hash_find(_SERVER, key, len, stuff)) { - return 1; - } else { - int s = len; - zstr var; - s = phar_make_unicode(&var, key, len TSRMLS_CC); - if (SUCCESS == zend_u_hash_find(_SERVER, IS_UNICODE, var, s, stuff)) { - efree(var.u); - return 1; - } - efree(var.u); - return 0; - } -} -#else -typedef char *phar_zstr; -#define PHAR_STR(a, b) \ - b = a; -#define PHAR_ZSTR(a, b) \ - b = a; -#define PHAR_STR_FREE(a) #endif BEGIN_EXTERN_C() @@ -690,11 +606,11 @@ int phar_entry_delref(phar_entry_data *idata TSRMLS_DC); phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC); phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC); -phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC); -int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC); +phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC); +int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC); int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC); int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC); -int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC); +int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC); typedef enum { pcr_use_query, diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index dcb67fe9fa..7c11a48f9c 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -685,11 +685,7 @@ PHP_METHOD(Phar, webPhar) ZVAL_STRINGL(params, entry, entry_len, 1); zp[0] = ¶ms; -#if PHP_VERSION_ID < 50300 - if (FAILURE == zend_fcall_info_init(rewrite, &fci, &fcc TSRMLS_CC)) { -#else if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) { -#endif zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: invalid rewrite callback"); if (free_pathinfo) { @@ -701,11 +697,7 @@ PHP_METHOD(Phar, webPhar) fci.param_count = 1; fci.params = zp; -#if PHP_VERSION_ID < 50300 - ++(params->refcount); -#else Z_ADDREF_P(params); -#endif fci.retval_ptr_ptr = &retval_ptr; if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) { @@ -729,11 +721,6 @@ PHP_METHOD(Phar, webPhar) } switch (Z_TYPE_P(retval_ptr)) { -#if PHP_VERSION_ID >= 60000 - case IS_UNICODE: - zval_unicode_to_string(retval_ptr TSRMLS_CC); - /* break intentionally omitted */ -#endif case IS_STRING: efree(entry); @@ -1155,11 +1142,7 @@ PHP_METHOD(Phar, __construct) #else char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname; int fname_len, alias_len = 0, arch_len, entry_len, is_data; -#if PHP_VERSION_ID < 50300 - long flags = 0; -#else long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS; -#endif long format = 0; phar_archive_object *phar_obj; phar_archive_data *phar_data; @@ -1459,11 +1442,6 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ } switch (Z_TYPE_PP(value)) { -#if PHP_VERSION_ID >= 60000 - case IS_UNICODE: - zval_unicode_to_string(*(value) TSRMLS_CC); - /* break intentionally omitted */ -#endif case IS_STRING: break; case IS_RESOURCE: @@ -1514,13 +1492,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ switch (intern->type) { case SPL_FS_DIR: -#if PHP_VERSION_ID >= 60000 - test = spl_filesystem_object_get_path(intern, NULL, NULL TSRMLS_CC).s; -#elif PHP_VERSION_ID >= 50300 test = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC); -#else - test = intern->path; -#endif fname_len = spprintf(&fname, 0, "%s%c%s", test, DEFAULT_SLASH, intern->u.dir.entry.d_name); php_stat(fname, fname_len, FS_IS_DIR, &dummy TSRMLS_CC); @@ -1545,25 +1517,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ goto phar_spl_fileinfo; case SPL_FS_INFO: case SPL_FS_FILE: -#if PHP_VERSION_ID >= 60000 - if (intern->file_name_type == IS_UNICODE) { - zval zv; - - INIT_ZVAL(zv); - Z_UNIVAL(zv) = intern->file_name; - Z_UNILEN(zv) = intern->file_name_len; - Z_TYPE(zv) = IS_UNICODE; - - zval_copy_ctor(&zv); - zval_unicode_to_string(&zv TSRMLS_CC); - fname = expand_filepath(Z_STRVAL(zv), NULL TSRMLS_CC); - ezfree(Z_UNIVAL(zv)); - } else { - fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC); - } -#else fname = expand_filepath(intern->file_name, NULL TSRMLS_CC); -#endif if (!fname) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path"); return ZEND_HASH_APPLY_STOP; @@ -1753,7 +1707,7 @@ after_open_fp: data->internal_file->fp_type = PHAR_UFP; data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp); data->fp = NULL; - phar_stream_copy_to_stream(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len); + php_stream_copy_to_stream_ex(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len); data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize = php_stream_tell(p_obj->fp) - data->internal_file->offset; } @@ -1816,11 +1770,7 @@ PHP_METHOD(Phar, buildFromDirectory) INIT_PZVAL(&arg); ZVAL_STRINGL(&arg, dir, dir_len, 0); INIT_PZVAL(&arg2); -#if PHP_VERSION_ID < 50300 - ZVAL_LONG(&arg2, 0); -#else ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS); -#endif zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator, &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg, &arg2); @@ -2047,7 +1997,7 @@ static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS link = entry; } - if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", entry->phar->fname, entry->filename); return FAILURE; @@ -2313,11 +2263,7 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char ALLOC_ZVAL(phar->metadata); *phar->metadata = *t; zval_copy_ctor(phar->metadata); -#if PHP_VERSION_ID < 50300 - phar->metadata->refcount = 1; -#else Z_SET_REFCOUNT_P(phar->metadata, 1); -#endif phar->metadata_len = 0; } @@ -2365,11 +2311,7 @@ no_copy: ALLOC_ZVAL(newentry.metadata); *newentry.metadata = *t; zval_copy_ctor(newentry.metadata); -#if PHP_VERSION_ID < 50300 - newentry.metadata->refcount = 1; -#else Z_SET_REFCOUNT_P(newentry.metadata, 1); -#endif newentry.metadata_str.c = NULL; newentry.metadata_str.len = 0; @@ -3552,11 +3494,7 @@ PHP_METHOD(Phar, copy) ALLOC_ZVAL(newentry.metadata); *newentry.metadata = *t; zval_copy_ctor(newentry.metadata); -#if PHP_VERSION_ID < 50300 - newentry.metadata->refcount = 1; -#else Z_SET_REFCOUNT_P(newentry.metadata, 1); -#endif newentry.metadata_str.c = NULL; newentry.metadata_str.len = 0; @@ -3713,7 +3651,7 @@ static void phar_add_file(phar_archive_data **pphar, char *filename, int filenam zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", filename); return; } - phar_stream_copy_to_stream(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len); + php_stream_copy_to_stream_ex(contents_file, data->fp, PHP_STREAM_COPY_ALL, &contents_len); } data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len; @@ -4286,7 +4224,7 @@ static int phar_extract_file(zend_bool overwrite, phar_entry_info *entry, char * return FAILURE; } - if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), fp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), fp, entry->uncompressed_filesize, NULL)) { spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying contents failed", entry->filename, fullpath); efree(fullpath); php_stream_close(fp); @@ -4371,11 +4309,6 @@ PHP_METHOD(Phar, extractTo) switch (Z_TYPE_P(zval_files)) { case IS_NULL: goto all_files; -#if PHP_VERSION_ID >= 60000 - case IS_UNICODE: - zval_unicode_to_string(zval_files TSRMLS_CC); - /* break intentionally omitted */ -#endif case IS_STRING: filename = Z_STRVAL_P(zval_files); filename_len = Z_STRLEN_P(zval_files); @@ -4389,11 +4322,6 @@ PHP_METHOD(Phar, extractTo) zval **zval_file; if (zend_hash_index_find(Z_ARRVAL_P(zval_files), i, (void **) &zval_file) == SUCCESS) { switch (Z_TYPE_PP(zval_file)) { -#if PHP_VERSION_ID >= 60000 - case IS_UNICODE: - zval_unicode_to_string(*(zval_file) TSRMLS_CC); - /* break intentionally omitted */ -#endif case IS_STRING: break; default: @@ -5414,11 +5342,7 @@ zend_function_entry phar_exception_methods[] = { #define REGISTER_PHAR_CLASS_CONST_LONG(class_name, const_name, value) \ zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); -#if PHP_VERSION_ID < 50200 -# define phar_exception_get_default() zend_exception_get_default() -#else -# define phar_exception_get_default() zend_exception_get_default(TSRMLS_C) -#endif +#define phar_exception_get_default() zend_exception_get_default(TSRMLS_C) void phar_object_init(TSRMLS_D) /* {{{ */ { diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 401d81e109..1b353e0d18 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -56,7 +56,7 @@ php_stream_wrapper php_stream_phar_wrapper = { /** * Open a phar file for streams API */ -php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */ +php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC) /* {{{ */ { php_url *resource; char *arch = NULL, *entry = NULL, *error; @@ -155,7 +155,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, /** * used for fopen('phar://...') and company */ -static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ +static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ { phar_archive_data *phar; phar_entry_data *idata; @@ -563,7 +563,7 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D /** * Stream wrapper stat implementation of stat() */ -static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, +static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */ { php_url *resource = NULL; @@ -627,21 +627,16 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, } /* check for mounted directories */ if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) { - phar_zstr key; char *str_key; ulong unused; uint keylen; HashPosition pos; - zend_hash_internal_pointer_reset_ex(&phar->mounted_dirs, &pos); - while (FAILURE != zend_hash_has_more_elements_ex(&phar->mounted_dirs, &pos)) { - if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, &pos)) { - break; - } - PHAR_STR(key, str_key); + for (zend_hash_internal_pointer_reset_ex(&phar->mounted_dirs, &pos); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->mounted_dirs, &str_key, &keylen, &unused, 0, &pos); + zend_hash_move_forward_ex(&phar->mounted_dirs, &pos) + ) { if ((int)keylen >= internal_file_len || strncmp(str_key, internal_file, keylen)) { - zend_hash_move_forward_ex(&phar->mounted_dirs, &pos); - PHAR_STR_FREE(str_key); continue; } else { char *test; @@ -649,17 +644,14 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf ssbi; if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) { - PHAR_STR_FREE(str_key); goto free_resource; } - PHAR_STR_FREE(str_key); if (!entry->tmp || !entry->is_mounted) { goto free_resource; } test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, internal_file + keylen); if (SUCCESS != php_stream_stat_path(test, &ssbi)) { efree(test); - zend_hash_move_forward_ex(&phar->mounted_dirs, &pos); continue; } /* mount the file/directory just in time */ @@ -686,7 +678,7 @@ free_resource: /** * Unlink a file within a phar archive */ -static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ +static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ { php_url *resource; char *internal_file, *error; @@ -762,7 +754,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio } /* }}} */ -static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ +static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ { php_url *resource_from, *resource_to; char *error; @@ -910,7 +902,6 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char /* Rename directory. Update all nested paths */ if (is_dir) { int key_type; - phar_zstr key, new_key; char *str_key, *new_str_key; uint key_len, new_key_len; ulong unused; @@ -918,12 +909,10 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char uint to_len = strlen(resource_to->path+1); for (zend_hash_internal_pointer_reset(&phar->manifest); - HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL)) && + HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &str_key, &key_len, &unused, 0, NULL)) && SUCCESS == zend_hash_get_current_data(&phar->manifest, (void **) &entry); - zend_hash_move_forward(&phar->manifest)) { - - PHAR_STR(key, str_key); - + zend_hash_move_forward(&phar->manifest) + ) { if (!entry->is_deleted && key_len > from_len && memcmp(str_key, resource_from->path+1, from_len) == 0 && @@ -941,22 +930,14 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char entry->filename = new_str_key; entry->filename_len = new_key_len; - PHAR_ZSTR(new_str_key, new_key); -#if PHP_VERSION_ID < 50300 - zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, NULL); -#else - zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL); -#endif + zend_hash_update_current_key_ex(&phar->manifest, key_type, new_str_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL); } - PHAR_STR_FREE(str_key); } for (zend_hash_internal_pointer_reset(&phar->virtual_dirs); - HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL)); - zend_hash_move_forward(&phar->virtual_dirs)) { - - PHAR_STR(key, str_key); - + HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &str_key, &key_len, &unused, 0, NULL)); + zend_hash_move_forward(&phar->virtual_dirs) + ) { if (key_len >= from_len && memcmp(str_key, resource_from->path+1, from_len) == 0 && (key_len == from_len || IS_SLASH(str_key[from_len]))) { @@ -967,24 +948,16 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len); new_str_key[new_key_len] = 0; - PHAR_ZSTR(new_str_key, new_key); -#if PHP_VERSION_ID < 50300 - zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_key, new_key_len, 0, NULL); -#else - zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL); -#endif + zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_str_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL); efree(new_str_key); } - PHAR_STR_FREE(str_key); } for (zend_hash_internal_pointer_reset(&phar->mounted_dirs); - HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &key_len, &unused, 0, NULL)) && + HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &str_key, &key_len, &unused, 0, NULL)) && SUCCESS == zend_hash_get_current_data(&phar->mounted_dirs, (void **) &entry); - zend_hash_move_forward(&phar->mounted_dirs)) { - - PHAR_STR(key, str_key); - + zend_hash_move_forward(&phar->mounted_dirs) + ) { if (key_len >= from_len && memcmp(str_key, resource_from->path+1, from_len) == 0 && (key_len == from_len || IS_SLASH(str_key[from_len]))) { @@ -995,15 +968,9 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len); new_str_key[new_key_len] = 0; - PHAR_ZSTR(new_str_key, new_key); -#if PHP_VERSION_ID < 50300 - zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_key, new_key_len, 0, NULL); -#else - zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL); -#endif + zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_str_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL); efree(new_str_key); } - PHAR_STR_FREE(str_key); } } diff --git a/ext/phar/stream.h b/ext/phar/stream.h index b22b67ab01..0155759d12 100644 --- a/ext/phar/stream.h +++ b/ext/phar/stream.h @@ -21,13 +21,13 @@ BEGIN_EXTERN_C() -php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC); +php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC); void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC); -static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); -static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC); -static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC); -static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC); +static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC); +static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC); +static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC); /* file/stream handlers */ static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 0e60e3db13..180675a9d2 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -783,7 +783,7 @@ static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ * return ZEND_HASH_APPLY_STOP; } - if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), fp->new, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), fp->new, entry->uncompressed_filesize, NULL)) { if (fp->error) { spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filename); } @@ -1288,7 +1288,7 @@ nostub: if (!filter) { /* copy contents uncompressed rather than lose them */ - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); php_stream_close(newfile); if (error) { spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname); @@ -1297,7 +1297,7 @@ nostub: } php_stream_filter_append(&phar->fp->writefilters, filter); - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); php_stream_filter_flush(filter, 1); php_stream_filter_remove(filter, 1 TSRMLS_CC); php_stream_close(phar->fp); @@ -1308,14 +1308,14 @@ nostub: filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC); php_stream_filter_append(&phar->fp->writefilters, filter); - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); php_stream_filter_flush(filter, 1); php_stream_filter_remove(filter, 1 TSRMLS_CC); php_stream_close(phar->fp); /* use the temp stream as our base */ phar->fp = newfile; } else { - phar_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); /* we could also reopen the file in "rb" mode but there is no need for that */ php_stream_close(newfile); } diff --git a/ext/phar/tests/031.phpt b/ext/phar/tests/031.phpt index 4d5988621d..d458f068f5 100644 --- a/ext/phar/tests/031.phpt +++ b/ext/phar/tests/031.phpt @@ -22,10 +22,10 @@ require $pname; ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/031.phar.php'); __halt_compiler(); ?> --EXPECTF-- string(25) "<?php echo new new class;" -Parse error: %s in phar://%sphar_oo_test.phar.php/a.php on line %d +Parse error: %s in phar://%s031.phar.php/a.php on line %d diff --git a/ext/phar/tests/032.phpt b/ext/phar/tests/032.phpt index faf3dcbf58..4df6cc32b0 100644 --- a/ext/phar/tests/032.phpt +++ b/ext/phar/tests/032.phpt @@ -21,9 +21,9 @@ echo $e->getMessage(); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/032.phar.php'); __halt_compiler(); ?> --EXPECTF-- -phar "%sphar_oo_test.phar.php" does not have a signature===DONE===
\ No newline at end of file +phar "%s032.phar.php" does not have a signature===DONE===
\ No newline at end of file diff --git a/ext/phar/tests/files/phar_oo_test.inc b/ext/phar/tests/files/phar_oo_test.inc index e92b4444c1..45421568de 100644 --- a/ext/phar/tests/files/phar_oo_test.inc +++ b/ext/phar/tests/files/phar_oo_test.inc @@ -2,7 +2,8 @@ ini_set('date.timezone', 'GMT'); -$fname = dirname(__FILE__) . '/phar_oo_test.phar.php'; +$tname = basename(current(get_included_files()), ".php"); +$fname = dirname(__FILE__) . "/$tname.phar.php"; $pname = 'phar://' . $fname; $file = (binary)'<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>'; diff --git a/ext/phar/tests/phar_buildfromdirectory1.phpt b/ext/phar/tests/phar_buildfromdirectory1.phpt index 63e06fa474..957f246664 100644 --- a/ext/phar/tests/phar_buildfromdirectory1.phpt +++ b/ext/phar/tests/phar_buildfromdirectory1.phpt @@ -7,7 +7,7 @@ phar.require_hash=0 phar.readonly=0 --FILE-- <?php -$phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); +$phar = new Phar(dirname(__FILE__) . '/buildfromdirectory1.phar'); try { ini_set('phar.readonly', 1); $phar->buildFromDirectory(1); @@ -19,7 +19,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory1.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromdirectory2-win.phpt b/ext/phar/tests/phar_buildfromdirectory2-win.phpt index 9dbcf965e3..5ed890a48b 100644 --- a/ext/phar/tests/phar_buildfromdirectory2-win.phpt +++ b/ext/phar/tests/phar_buildfromdirectory2-win.phpt @@ -11,7 +11,7 @@ phar.readonly=0 --FILE-- <?php try { - $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory2.phar'); $phar->buildFromDirectory(1); } catch (Exception $e) { var_dump(get_class($e)); @@ -21,7 +21,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory2.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromdirectory2.phpt b/ext/phar/tests/phar_buildfromdirectory2.phpt index 639ff0bd4b..a33e50abbb 100644 --- a/ext/phar/tests/phar_buildfromdirectory2.phpt +++ b/ext/phar/tests/phar_buildfromdirectory2.phpt @@ -11,7 +11,7 @@ phar.readonly=0 --FILE-- <?php try { - $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory2.phar'); $phar->buildFromDirectory(1); } catch (Exception $e) { var_dump(get_class($e)); @@ -21,7 +21,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory2.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromdirectory3.phpt b/ext/phar/tests/phar_buildfromdirectory3.phpt index 2134cbdb53..921e39593d 100644 --- a/ext/phar/tests/phar_buildfromdirectory3.phpt +++ b/ext/phar/tests/phar_buildfromdirectory3.phpt @@ -9,7 +9,7 @@ phar.readonly=0 <?php try { - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory3.phar'); $phar->buildFromDirectory('files', new stdClass); } catch (Exception $e) { var_dump(get_class($e)); @@ -19,7 +19,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory3.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromdirectory4.phpt b/ext/phar/tests/phar_buildfromdirectory4.phpt index 683ac4bbc8..5ee2c33871 100644 --- a/ext/phar/tests/phar_buildfromdirectory4.phpt +++ b/ext/phar/tests/phar_buildfromdirectory4.phpt @@ -9,14 +9,14 @@ open_basedir= --FILE-- <?php -mkdir(dirname(__FILE__).'/testdir'); +mkdir(dirname(__FILE__).'/testdir4'); foreach(range(1, 4) as $i) { - file_put_contents(dirname(__FILE__)."/testdir/file$i.txt", "some content for file $i"); + file_put_contents(dirname(__FILE__)."/testdir4/file$i.txt", "some content for file $i"); } try { - $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); - $a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir'); + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory4.phar'); + $a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir4'); asort($a); var_dump($a); } catch (Exception $e) { @@ -24,28 +24,28 @@ try { echo $e->getMessage() . "\n"; } -var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar')); +var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory4.phar')); ?> ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory4.phar'); foreach(range(1, 4) as $i) { - unlink(dirname(__FILE__) . "/testdir/file$i.txt"); + unlink(dirname(__FILE__) . "/testdir4/file$i.txt"); } -rmdir(dirname(__FILE__) . '/testdir'); +rmdir(dirname(__FILE__) . '/testdir4'); ?> --EXPECTF-- array(4) { ["file1.txt"]=> - string(%d) "%stestdir%cfile1.txt" + string(%d) "%stestdir4%cfile1.txt" ["file2.txt"]=> - string(%d) "%stestdir%cfile2.txt" + string(%d) "%stestdir4%cfile2.txt" ["file3.txt"]=> - string(%d) "%stestdir%cfile3.txt" + string(%d) "%stestdir4%cfile3.txt" ["file4.txt"]=> - string(%d) "%stestdir%cfile4.txt" + string(%d) "%stestdir4%cfile4.txt" } bool(true) ===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory5.phpt b/ext/phar/tests/phar_buildfromdirectory5.phpt index 51e5cec691..f20c52ab91 100644 --- a/ext/phar/tests/phar_buildfromdirectory5.phpt +++ b/ext/phar/tests/phar_buildfromdirectory5.phpt @@ -8,14 +8,14 @@ phar.readonly=0 --FILE-- <?php -mkdir(dirname(__FILE__).'/testdir'); +mkdir(dirname(__FILE__).'/testdir5'); foreach(range(1, 4) as $i) { - file_put_contents(dirname(__FILE__)."/testdir/file$i.txt", "some content for file $i"); + file_put_contents(dirname(__FILE__)."/testdir5/file$i.txt", "some content for file $i"); } try { - $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); - $a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.txt/'); + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory5.phar'); + $a = $phar->buildFromDirectory(dirname(__FILE__) . '/testdir5', '/\.txt/'); asort($a); var_dump($a); } catch (Exception $e) { @@ -23,28 +23,28 @@ try { echo $e->getMessage() . "\n"; } -var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar')); +var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory5.phar')); ?> ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory5.phar'); foreach(range(1, 4) as $i) { - unlink(dirname(__FILE__) . "/testdir/file$i.txt"); + unlink(dirname(__FILE__) . "/testdir5/file$i.txt"); } -rmdir(dirname(__FILE__) . '/testdir'); +rmdir(dirname(__FILE__) . '/testdir5'); ?> --EXPECTF-- array(4) { ["file1.txt"]=> - string(%d) "%stestdir%cfile1.txt" + string(%d) "%stestdir5%cfile1.txt" ["file2.txt"]=> - string(%d) "%stestdir%cfile2.txt" + string(%d) "%stestdir5%cfile2.txt" ["file3.txt"]=> - string(%d) "%stestdir%cfile3.txt" + string(%d) "%stestdir5%cfile3.txt" ["file4.txt"]=> - string(%d) "%stestdir%cfile4.txt" + string(%d) "%stestdir5%cfile4.txt" } bool(true) ===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory6.phpt b/ext/phar/tests/phar_buildfromdirectory6.phpt index 99566c1926..5537ebac23 100644 --- a/ext/phar/tests/phar_buildfromdirectory6.phpt +++ b/ext/phar/tests/phar_buildfromdirectory6.phpt @@ -8,30 +8,30 @@ phar.readonly=0 --FILE-- <?php -mkdir(dirname(__FILE__).'/testdir', 0777); +mkdir(dirname(__FILE__).'/testdir6', 0777); foreach(range(1, 4) as $i) { - file_put_contents(dirname(__FILE__)."/testdir/file$i.txt", "some content for file $i"); + file_put_contents(dirname(__FILE__)."/testdir6/file$i.txt", "some content for file $i"); } try { - $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory.phar'); - var_dump($phar->buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.php$/')); + $phar = new Phar(dirname(__FILE__) . '/buildfromdirectory6.phar'); + var_dump($phar->buildFromDirectory(dirname(__FILE__) . '/testdir6', '/\.php$/')); } catch (Exception $e) { var_dump(get_class($e)); echo $e->getMessage() . "\n"; } -var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar')); +var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory6.phar')); ?> ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromdirectory.phar'); +unlink(dirname(__FILE__) . '/buildfromdirectory6.phar'); foreach(range(1, 4) as $i) { - unlink(dirname(__FILE__) . "/testdir/file$i.txt"); + unlink(dirname(__FILE__) . "/testdir6/file$i.txt"); } -rmdir(dirname(__FILE__) . '/testdir'); +rmdir(dirname(__FILE__) . '/testdir6'); ?> --EXPECT-- array(0) { diff --git a/ext/phar/tests/phar_buildfromiterator1.phpt b/ext/phar/tests/phar_buildfromiterator1.phpt index 238ede6cbe..0f656b64f2 100644 --- a/ext/phar/tests/phar_buildfromiterator1.phpt +++ b/ext/phar/tests/phar_buildfromiterator1.phpt @@ -7,7 +7,7 @@ phar.require_hash=0 phar.readonly=0 --FILE-- <?php -$phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); +$phar = new Phar(dirname(__FILE__) . '/buildfromiterator1.phar'); try { ini_set('phar.readonly', 1); $phar->buildFromIterator(1); @@ -19,7 +19,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator1.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator10.phpt b/ext/phar/tests/phar_buildfromiterator10.phpt index 024277ed0a..e6b9c025da 100644 --- a/ext/phar/tests/phar_buildfromiterator10.phpt +++ b/ext/phar/tests/phar_buildfromiterator10.phpt @@ -11,7 +11,7 @@ phar.readonly=0 <?php try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator10.phar'); $dir = new RecursiveDirectoryIterator('.'); $iter = new RecursiveIteratorIterator($dir); $a = $phar->buildFromIterator(new RegexIterator($iter, '/_\d{3}\.phpt$/'), dirname(__FILE__) . DIRECTORY_SEPARATOR); @@ -25,7 +25,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator10.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator2.phpt b/ext/phar/tests/phar_buildfromiterator2.phpt index cdc2df1050..e9dd26e9de 100644 --- a/ext/phar/tests/phar_buildfromiterator2.phpt +++ b/ext/phar/tests/phar_buildfromiterator2.phpt @@ -8,7 +8,7 @@ phar.readonly=0 --FILE-- <?php try { - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator2.phar'); $phar->buildFromIterator(new stdClass); } catch (Exception $e) { var_dump(get_class($e)); @@ -18,7 +18,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator2.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator3.phpt b/ext/phar/tests/phar_buildfromiterator3.phpt index 4a3bc7c0a5..1603631278 100644 --- a/ext/phar/tests/phar_buildfromiterator3.phpt +++ b/ext/phar/tests/phar_buildfromiterator3.phpt @@ -36,7 +36,7 @@ class myIterator implements Iterator } } try { - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator3.phar'); $phar->buildFromIterator(new myIterator(array()), new stdClass); } catch (Exception $e) { var_dump(get_class($e)); @@ -46,7 +46,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator3.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator4.phpt b/ext/phar/tests/phar_buildfromiterator4.phpt index cd261386d5..9277db562b 100644 --- a/ext/phar/tests/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/phar_buildfromiterator4.phpt @@ -37,7 +37,7 @@ class myIterator implements Iterator } try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator4.phar'); var_dump($phar->buildFromIterator(new myIterator( array( 'a' => basename(__FILE__, 'php') . 'phpt', @@ -54,7 +54,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator4.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt index 8431c12a7c..b6fafec6f4 100644 --- a/ext/phar/tests/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/phar_buildfromiterator5.phpt @@ -37,7 +37,7 @@ class myIterator implements Iterator } try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator5.phar'); var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); } catch (Exception $e) { var_dump(get_class($e)); @@ -47,7 +47,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator5.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator6.phpt b/ext/phar/tests/phar_buildfromiterator6.phpt index 9c506c8528..3a315fae4d 100644 --- a/ext/phar/tests/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/phar_buildfromiterator6.phpt @@ -37,7 +37,7 @@ class myIterator implements Iterator } try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator6.phar'); var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); } catch (Exception $e) { var_dump(get_class($e)); @@ -47,7 +47,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator6.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator7.phpt b/ext/phar/tests/phar_buildfromiterator7.phpt index 2bac4c8269..3dd8fc1b00 100644 --- a/ext/phar/tests/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/phar_buildfromiterator7.phpt @@ -37,7 +37,7 @@ class myIterator implements Iterator } try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator7.phar'); var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); } catch (Exception $e) { var_dump(get_class($e)); @@ -47,7 +47,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator7.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator8.phpt b/ext/phar/tests/phar_buildfromiterator8.phpt index bb1b780d75..de37ee8687 100644 --- a/ext/phar/tests/phar_buildfromiterator8.phpt +++ b/ext/phar/tests/phar_buildfromiterator8.phpt @@ -8,7 +8,7 @@ phar.readonly=0 <?php try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator8.phar'); $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^\d{0,3}\.phpt\\z|^\.\\z|^\.\.\\z/'), dirname(__FILE__) . DIRECTORY_SEPARATOR); asort($a); var_dump($a); @@ -20,7 +20,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator8.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_buildfromiterator9.phpt b/ext/phar/tests/phar_buildfromiterator9.phpt index 0b56307545..2c9306b6cc 100644 --- a/ext/phar/tests/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/phar_buildfromiterator9.phpt @@ -37,7 +37,7 @@ class myIterator implements Iterator } try { chdir(dirname(__FILE__)); - $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar'); + $phar = new Phar(dirname(__FILE__) . '/buildfromiterator9.phar'); var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); fclose($a); } catch (Exception $e) { @@ -48,7 +48,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/buildfromiterator.phar'); +unlink(dirname(__FILE__) . '/buildfromiterator9.phar'); __HALT_COMPILER(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt index 01d65f9091..bc545236fd 100644 --- a/ext/phar/tests/phar_extract.phpt +++ b/ext/phar/tests/phar_extract.phpt @@ -38,9 +38,9 @@ var_dump(file_get_contents(dirname(__FILE__) . '/extract1/file1.txt')); $a->extractTo(dirname(__FILE__) . '/extract1', 'subdir/ectory/file.txt'); var_dump(file_get_contents(dirname(__FILE__) . '/extract1/subdir/ectory/file.txt')); -$a->extractTo(dirname(__FILE__) . '/extract2', array('file2.txt', 'one/level')); -var_dump(file_get_contents(dirname(__FILE__) . '/extract2/file2.txt')); -var_dump(is_dir(dirname(__FILE__) . '/extract2/one/level')); +$a->extractTo(dirname(__FILE__) . '/extract1-2', array('file2.txt', 'one/level')); +var_dump(file_get_contents(dirname(__FILE__) . '/extract1-2/file2.txt')); +var_dump(is_dir(dirname(__FILE__) . '/extract1-2/one/level')); try { $a->extractTo(dirname(__FILE__) . '/whatever', 134); @@ -119,7 +119,7 @@ $e = dirname(__FILE__) . '/extract1/'; @rmdir($e . 'subdir/ectory'); @rmdir($e . 'subdir'); @rmdir($e); -$e = dirname(__FILE__) . '/extract2/'; +$e = dirname(__FILE__) . '/extract1-2/'; @unlink($e . 'file2.txt'); @rmdir($e . 'one/level'); @rmdir($e . 'one'); diff --git a/ext/phar/tests/phar_extract2.phpt b/ext/phar/tests/phar_extract2.phpt index cac509f9dc..7de8cee5b0 100644 --- a/ext/phar/tests/phar_extract2.phpt +++ b/ext/phar/tests/phar_extract2.phpt @@ -16,14 +16,14 @@ $phar->setAlias('fred'); $phar['file1.txt'] = 'hi'; $phar['file2.txt'] = 'hi2'; $phar['subdir/ectory/file.txt'] = 'hi3'; -$phar->mount($pname . '/mount', __FILE__); +$phar->mount($pname . '/mount2', __FILE__); $phar->addEmptyDir('one/level'); -$phar->extractTo(dirname(__FILE__) . '/extract', 'mount'); -$phar->extractTo(dirname(__FILE__) . '/extract'); +$phar->extractTo(dirname(__FILE__) . '/extract2', 'mount2'); +$phar->extractTo(dirname(__FILE__) . '/extract2'); $out = array(); -foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x00003000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) { +foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract2', 0x00003000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) { $extracted[] = $path; } @@ -38,7 +38,7 @@ foreach ($extracted as $out) { --CLEAN-- <?php @unlink(dirname(__FILE__) . '/tempmanifest2.phar.php'); -$dir = dirname(__FILE__) . '/extract/'; +$dir = dirname(__FILE__) . '/extract2/'; @unlink($dir . 'file1.txt'); @unlink($dir . 'file2.txt'); @unlink($dir . 'subdir/ectory/file.txt'); @@ -51,10 +51,10 @@ $dir = dirname(__FILE__) . '/extract1/'; @rmdir($dir); ?> --EXPECTF-- -%sextract%cfile1.txt -%sextract%cfile2.txt -%sextract%cone -%sextract%csubdir -%sextract%csubdir%cectory -%sextract%csubdir%cectory%cfile.txt +%sextract2%cfile1.txt +%sextract2%cfile2.txt +%sextract2%cone +%sextract2%csubdir +%sextract2%csubdir%cectory +%sextract2%csubdir%cectory%cfile.txt ===DONE=== diff --git a/ext/phar/tests/phar_extract3.phpt b/ext/phar/tests/phar_extract3.phpt index df85211a23..475583938b 100644 --- a/ext/phar/tests/phar_extract3.phpt +++ b/ext/phar/tests/phar_extract3.phpt @@ -9,7 +9,7 @@ phar.readonly=0 $fname = dirname(__FILE__) . '/files/bogus.zip'; $fname2 = dirname(__FILE__) . '/files/notbogus.zip'; -$extract = dirname(__FILE__) . '/test'; +$extract = dirname(__FILE__) . '/test-extract3'; $phar = new PharData($fname); @@ -34,7 +34,7 @@ try { ===DONE=== --CLEAN-- <?php -$dir = dirname(__FILE__) . '/test/'; +$dir = dirname(__FILE__) . '/test-extract3/'; @unlink($dir . 'stuff.txt'); @unlink($dir . 'nonsense.txt'); @rmdir($dir); diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt index 7a81bbb4b8..bb4c9d7188 100644 --- a/ext/phar/tests/phar_oo_001.phpt +++ b/ext/phar/tests/phar_oo_001.phpt @@ -46,7 +46,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_001.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_001U.phpt b/ext/phar/tests/phar_oo_001U.phpt index f13ddd4b0b..a21026a5b6 100644 --- a/ext/phar/tests/phar_oo_001U.phpt +++ b/ext/phar/tests/phar_oo_001U.phpt @@ -46,7 +46,7 @@ try { ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_001U.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_002.phpt b/ext/phar/tests/phar_oo_002.phpt index 3754151d42..476cd7d3c2 100644 --- a/ext/phar/tests/phar_oo_002.phpt +++ b/ext/phar/tests/phar_oo_002.phpt @@ -50,11 +50,11 @@ foreach(new RecursiveIteratorIterator($phar) as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_002.phar.php'); __halt_compiler(); ?> --EXPECTF-- -string(42) "phar://*/files/phar_oo_test.phar.php%ca.php" +string(41) "phar://*/files/phar_oo_002.phar.php%ca.php" string(5) "a.php" int(32) string(4) "file" @@ -67,7 +67,7 @@ bool(false) int(%d) int(%d) int(%d) -string(38) "phar://*/files/phar_oo_test.phar.php%cb" +string(37) "phar://*/files/phar_oo_002.phar.php%cb" string(1) "b" int(0) string(3) "dir" @@ -80,7 +80,7 @@ bool(false) int(%d) int(%d) int(%d) -string(42) "phar://*/files/phar_oo_test.phar.php%cb.php" +string(41) "phar://*/files/phar_oo_002.phar.php%cb.php" string(5) "b.php" int(32) string(4) "file" @@ -93,7 +93,7 @@ bool(false) int(%d) int(%d) int(%d) -string(42) "phar://*/files/phar_oo_test.phar.php%ce.php" +string(41) "phar://*/files/phar_oo_002.phar.php%ce.php" string(5) "e.php" int(32) string(4) "file" @@ -107,31 +107,31 @@ int(%d) int(%d) int(%d) ==RECURSIVE== -string(42) "phar://*/files/phar_oo_test.phar.php%ca.php" +string(41) "phar://*/files/phar_oo_002.phar.php%ca.php" string(5) "a.php" int(32) bool(false) NULL int(0) -string(44) "phar://*/files/phar_oo_test.phar.php/b%cc.php" +string(43) "phar://*/files/phar_oo_002.phar.php/b%cc.php" string(5) "c.php" int(34) bool(false) NULL int(0) -string(44) "phar://*/files/phar_oo_test.phar.php/b%cd.php" +string(43) "phar://*/files/phar_oo_002.phar.php/b%cd.php" string(5) "d.php" int(34) bool(false) NULL int(0) -string(42) "phar://*/files/phar_oo_test.phar.php%cb.php" +string(41) "phar://*/files/phar_oo_002.phar.php%cb.php" string(5) "b.php" int(32) bool(false) NULL int(0) -string(42) "phar://*/files/phar_oo_test.phar.php%ce.php" +string(41) "phar://*/files/phar_oo_002.phar.php%ce.php" string(5) "e.php" int(32) bool(false) diff --git a/ext/phar/tests/phar_oo_002U.phpt b/ext/phar/tests/phar_oo_002U.phpt index 26d0d68d97..da17152b32 100644 --- a/ext/phar/tests/phar_oo_002U.phpt +++ b/ext/phar/tests/phar_oo_002U.phpt @@ -50,11 +50,11 @@ foreach(new RecursiveIteratorIterator($phar) as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_002U.phar.php'); __halt_compiler(); ?> --EXPECTF-- -unicode(42) "phar://*/files/phar_oo_test.phar.php%ca.php" +unicode(42) "phar://*/files/phar_oo_002.phar.php%ca.php" string(5) "a.php" int(32) unicode(4) "file" @@ -67,7 +67,7 @@ bool(false) int(%d) int(%d) int(%d) -unicode(38) "phar://*/files/phar_oo_test.phar.php%cb" +unicode(38) "phar://*/files/phar_oo_002.phar.php%cb" string(1) "b" int(0) unicode(3) "dir" @@ -80,7 +80,7 @@ bool(false) int(%d) int(%d) int(%d) -unicode(42) "phar://*/files/phar_oo_test.phar.php%cb.php" +unicode(42) "phar://*/files/phar_oo_002.phar.php%cb.php" string(5) "b.php" int(32) unicode(4) "file" @@ -93,7 +93,7 @@ bool(false) int(%d) int(%d) int(%d) -unicode(42) "phar://*/files/phar_oo_test.phar.php%ce.php" +unicode(42) "phar://*/files/phar_oo_002.phar.php%ce.php" string(5) "e.php" int(32) unicode(4) "file" @@ -107,31 +107,31 @@ int(%d) int(%d) int(%d) ==RECURSIVE== -unicode(42) "phar://*/files/phar_oo_test.phar.php%ca.php" +unicode(42) "phar://*/files/phar_oo_002.phar.php%ca.php" unicode(5) "a.php" int(32) bool(false) NULL int(0) -unicode(44) "phar://*/files/phar_oo_test.phar.php/b%cc.php" +unicode(44) "phar://*/files/phar_oo_002.phar.php/b%cc.php" unicode(5) "c.php" int(34) bool(false) NULL int(0) -unicode(44) "phar://*/files/phar_oo_test.phar.php/b%cd.php" +unicode(44) "phar://*/files/phar_oo_002.phar.php/b%cd.php" unicode(5) "d.php" int(34) bool(false) NULL int(0) -unicode(42) "phar://*/files/phar_oo_test.phar.php%cb.php" +unicode(42) "phar://*/files/phar_oo_002.phar.php%cb.php" unicode(5) "b.php" int(32) bool(false) NULL int(0) -unicode(42) "phar://*/files/phar_oo_test.phar.php%ce.php" +unicode(42) "phar://*/files/phar_oo_002.phar.php%ce.php" unicode(5) "e.php" int(32) bool(false) diff --git a/ext/phar/tests/phar_oo_003.phpt b/ext/phar/tests/phar_oo_003.phpt index ccaf7c65f8..4395792632 100644 --- a/ext/phar/tests/phar_oo_003.phpt +++ b/ext/phar/tests/phar_oo_003.phpt @@ -27,7 +27,7 @@ foreach($phar as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_003.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_oo_004.phpt b/ext/phar/tests/phar_oo_004.phpt index ba67749843..3e4581992e 100644 --- a/ext/phar/tests/phar_oo_004.phpt +++ b/ext/phar/tests/phar_oo_004.phpt @@ -78,7 +78,7 @@ foreach($it as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_004.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_004U.phpt b/ext/phar/tests/phar_oo_004U.phpt index 2762ee3c35..51be9dab2e 100644 --- a/ext/phar/tests/phar_oo_004U.phpt +++ b/ext/phar/tests/phar_oo_004U.phpt @@ -78,7 +78,7 @@ foreach($it as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_004U.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_005.phpt b/ext/phar/tests/phar_oo_005.phpt index cb3f298728..b01231e9c2 100644 --- a/ext/phar/tests/phar_oo_005.phpt +++ b/ext/phar/tests/phar_oo_005.phpt @@ -32,7 +32,7 @@ foreach($it as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_005.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_005U.phpt b/ext/phar/tests/phar_oo_005U.phpt index bcdcb08b0d..9c04b93cef 100644 --- a/ext/phar/tests/phar_oo_005U.phpt +++ b/ext/phar/tests/phar_oo_005U.phpt @@ -31,7 +31,7 @@ foreach($it as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_005U.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_005_5.2.phpt b/ext/phar/tests/phar_oo_005_5.2.phpt index 9e509d94b7..399edb0dd3 100644 --- a/ext/phar/tests/phar_oo_005_5.2.phpt +++ b/ext/phar/tests/phar_oo_005_5.2.phpt @@ -31,7 +31,7 @@ foreach($it as $name => $ent) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_005_5.2.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_006.phpt b/ext/phar/tests/phar_oo_006.phpt index 556c98ce0b..5d1d705206 100644 --- a/ext/phar/tests/phar_oo_006.phpt +++ b/ext/phar/tests/phar_oo_006.phpt @@ -38,7 +38,7 @@ echo $phar['b.php']->getFilename() . "\n"; ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_006.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_oo_007.phpt b/ext/phar/tests/phar_oo_007.phpt index 788b11f1f8..d0b5aa5eca 100644 --- a/ext/phar/tests/phar_oo_007.phpt +++ b/ext/phar/tests/phar_oo_007.phpt @@ -59,11 +59,11 @@ var_dump($f->eof()); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_007.phar.php'); __halt_compiler(); ?> --EXPECTF-- -MyFile::__construct(phar://*/files/phar_oo_test.phar.php/a.php) +MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php) int(%d) int(%d) int(%d) @@ -79,7 +79,7 @@ int(0) string(32) "<?php echo "This is a.php\n"; ?>" int(32) ===AGAIN=== -MyFile::__construct(phar://*/files/phar_oo_test.phar.php/a.php) +MyFile::__construct(phar://*/files/phar_oo_007.phar.php/a.php) int(0) bool(false) string(32) "<?php echo "This is a.php\n"; ?>" diff --git a/ext/phar/tests/phar_oo_008.phpt b/ext/phar/tests/phar_oo_008.phpt index 80d1ece0ca..d95af571b3 100644 --- a/ext/phar/tests/phar_oo_008.phpt +++ b/ext/phar/tests/phar_oo_008.phpt @@ -83,7 +83,7 @@ foreach($v as $k => $d) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_008.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_oo_009.phpt b/ext/phar/tests/phar_oo_009.phpt index 6abd03ee30..3c842fabed 100644 --- a/ext/phar/tests/phar_oo_009.phpt +++ b/ext/phar/tests/phar_oo_009.phpt @@ -36,7 +36,7 @@ foreach($f as $k => $v) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_009.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_oo_010.phpt b/ext/phar/tests/phar_oo_010.phpt index 1d3ff73242..331d300a8c 100644 --- a/ext/phar/tests/phar_oo_010.phpt +++ b/ext/phar/tests/phar_oo_010.phpt @@ -36,7 +36,7 @@ var_dump(isset($phar['b'])); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_010.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_oo_011.phpt b/ext/phar/tests/phar_oo_011.phpt index cfbab702ad..01fa9f01e6 100644 --- a/ext/phar/tests/phar_oo_011.phpt +++ b/ext/phar/tests/phar_oo_011.phpt @@ -26,7 +26,7 @@ echo "\n"; ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_011.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_011b.phpt b/ext/phar/tests/phar_oo_011b.phpt index 36d9963a22..34cae0e760 100644 --- a/ext/phar/tests/phar_oo_011b.phpt +++ b/ext/phar/tests/phar_oo_011b.phpt @@ -31,7 +31,7 @@ catch (BadMethodCallException $e) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_011b.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phar_oo_012.phpt b/ext/phar/tests/phar_oo_012.phpt index e79ac0960e..b6f9f44b1e 100644 --- a/ext/phar/tests/phar_oo_012.phpt +++ b/ext/phar/tests/phar_oo_012.phpt @@ -27,7 +27,7 @@ var_dump(isset($phar['f.php'])); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_012.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_012_confirm.phpt b/ext/phar/tests/phar_oo_012_confirm.phpt index 58a3be87b3..ce5a58f212 100644 --- a/ext/phar/tests/phar_oo_012_confirm.phpt +++ b/ext/phar/tests/phar_oo_012_confirm.phpt @@ -30,7 +30,7 @@ var_dump(isset($phar['f.php'])); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_012_confirm.phar.php'); __halt_compiler(); ?> --EXPECT-- diff --git a/ext/phar/tests/phar_oo_012b.phpt b/ext/phar/tests/phar_oo_012b.phpt index 80d8ed8dc4..066d3bc068 100644 --- a/ext/phar/tests/phar_oo_012b.phpt +++ b/ext/phar/tests/phar_oo_012b.phpt @@ -34,7 +34,7 @@ catch (BadMethodCallException $e) ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php'); +unlink(dirname(__FILE__) . '/files/phar_oo_012b.phar.php'); __halt_compiler(); ?> --EXPECTF-- diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt index 24263f07be..c57e850d82 100644 --- a/ext/phar/tests/phpinfo_004.phpt +++ b/ext/phar/tests/phpinfo_004.phpt @@ -23,9 +23,9 @@ phpinfo(INFO_MODULES); ?> ===DONE=== --EXPECTF-- -%a<br /> +%a <h2><a name="module_Phar">Phar</a></h2> -<table border="0" cellpadding="3" width="600"> +<table> <tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr> <tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr> <tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr> @@ -36,20 +36,20 @@ phpinfo(INFO_MODULES); <tr><td class="e">gzip compression </td><td class="v">enabled </td></tr> <tr><td class="e">bzip2 compression </td><td class="v">enabled </td></tr> <tr><td class="e">OpenSSL support </td><td class="v">disabled (install ext/openssl) </td></tr> -</table><br /> -<table border="0" cellpadding="3" width="600"> +</table> +<table> <tr class="v"><td> Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr> -</table><br /> -<table border="0" cellpadding="3" width="600"> +</table> +<table> <tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr> <tr><td class="e">phar.cache_list</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr> <tr><td class="e">phar.readonly</td><td class="v">Off</td><td class="v">Off</td></tr> <tr><td class="e">phar.require_hash</td><td class="v">Off</td><td class="v">Off</td></tr> -</table><br /> -%a<br /> +</table> +%a <h2><a name="module_Phar">Phar</a></h2> -<table border="0" cellpadding="3" width="600"> +<table> <tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr> <tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr> <tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr> @@ -60,16 +60,16 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar full <tr><td class="e">gzip compression </td><td class="v">enabled </td></tr> <tr><td class="e">bzip2 compression </td><td class="v">enabled </td></tr> <tr><td class="e">OpenSSL support </td><td class="v">disabled (install ext/openssl) </td></tr> -</table><br /> -<table border="0" cellpadding="3" width="600"> +</table> +<table> <tr class="v"><td> Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar fully realized by Gregory Beaver and Marcus Boerger.<br />Portions of tar implementation Copyright (c) %d-%d Tim Kientzle.</td></tr> -</table><br /> -<table border="0" cellpadding="3" width="600"> +</table> +<table> <tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr> <tr><td class="e">phar.cache_list</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr> <tr><td class="e">phar.readonly</td><td class="v">On</td><td class="v">Off</td></tr> <tr><td class="e">phar.require_hash</td><td class="v">On</td><td class="v">Off</td></tr> -</table><br /> -%a<br /> +</table> +%a </div></body></html>===DONE=== diff --git a/ext/phar/util.c b/ext/phar/util.c index 8348a47874..d42164a57c 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -41,10 +41,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC); #endif -#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300 -extern php_stream_wrapper php_stream_phar_wrapper; -#endif - /* for links to relative location, prepend cwd of the entry */ static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */ { @@ -256,7 +252,6 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar TSRMLS_DC) /* {{{ */ { -#if PHP_VERSION_ID >= 50300 char *path, *fname, *arch, *entry, *ret, *test; int arch_len, entry_len, fname_len, ret_len; phar_archive_data *phar; @@ -344,223 +339,6 @@ splitted: } return ret; -#else /* PHP 5.2 */ - char resolved_path[MAXPATHLEN]; - char trypath[MAXPATHLEN]; - char *ptr, *end, *path = PG(include_path); - php_stream_wrapper *wrapper; - const char *p; - int n = 0; - char *fname, *arch, *entry, *ret, *test; - int arch_len, entry_len; - phar_archive_data *phar = NULL; - - if (!filename) { - return NULL; - } - - if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) { - goto doit; - } - - fname = (char*)zend_get_executed_filename(TSRMLS_C); - - if (SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { - goto doit; - } - - efree(entry); - - if (*filename == '.') { - int try_len; - - if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) { - efree(arch); - goto doit; - } - - try_len = filename_len; - test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC); - - if (*test == '/') { - if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) { - spprintf(&ret, 0, "phar://%s%s", arch, test); - efree(arch); - efree(test); - return ret; - } - } else { - if (zend_hash_exists(&(phar->manifest), test, try_len)) { - spprintf(&ret, 0, "phar://%s/%s", arch, test); - efree(arch); - efree(test); - return ret; - } - } - - efree(test); - } - - efree(arch); -doit: - if (*filename == '.' || IS_ABSOLUTE_PATH(filename, filename_len) || !path || !*path) { - if (tsrm_realpath(filename, resolved_path TSRMLS_CC)) { - return estrdup(resolved_path); - } else { - return NULL; - } - } - - /* test for stream wrappers and return */ - for (p = filename; p - filename < filename_len && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); ++p, ++n); - - if (n < filename_len - 3 && (*p == ':') && (!strncmp("//", p+1, 2) || ( filename_len > 4 && !memcmp("data", filename, 4)))) { - /* found stream wrapper, this is an absolute path until stream wrappers implement realpath */ - return estrndup(filename, filename_len); - } - - ptr = (char *) path; - while (ptr && *ptr) { - int len, is_stream_wrapper = 0, maybe_stream = 1; - - end = strchr(ptr, DEFAULT_DIR_SEPARATOR); -#ifndef PHP_WIN32 - /* search for stream wrapper */ - if (end - ptr <= 1) { - maybe_stream = 0; - goto not_stream; - } - - for (p = ptr, n = 0; p < end && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); ++p, ++n); - - if (n == end - ptr && *p && !strncmp("//", p+1, 2)) { - is_stream_wrapper = 1; - /* seek to real end of include_path portion */ - end = strchr(end + 1, DEFAULT_DIR_SEPARATOR); - } else { - maybe_stream = 0; - } -not_stream: -#endif - if (end) { - if ((end-ptr) + 1 + filename_len + 1 >= MAXPATHLEN) { - ptr = end + 1; - continue; - } - - memcpy(trypath, ptr, end-ptr); - len = end-ptr; - trypath[end-ptr] = '/'; - memcpy(trypath+(end-ptr)+1, filename, filename_len+1); - ptr = end+1; - } else { - len = strlen(ptr); - - if (len + 1 + filename_len + 1 >= MAXPATHLEN) { - break; - } - - memcpy(trypath, ptr, len); - trypath[len] = '/'; - memcpy(trypath+len+1, filename, filename_len+1); - ptr = NULL; - } - - if (!is_stream_wrapper && maybe_stream) { - /* search for stream wrapper */ - for (p = trypath, n = 0; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; ++p, ++n); - } - - if (is_stream_wrapper || (n < len - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4)))) { - char *actual; - - wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); - if (wrapper == &php_plain_files_wrapper) { - strlcpy(trypath, actual, sizeof(trypath)); - } else if (!wrapper) { - /* if wrapper is NULL, there was a mal-formed include_path stream wrapper, so skip this ptr */ - continue; - } else { - if (wrapper->wops->url_stat) { - php_stream_statbuf ssb; - - if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, 0, &ssb, NULL TSRMLS_CC)) { - if (wrapper == &php_stream_phar_wrapper) { - char *arch, *entry; - int arch_len, entry_len, ret_len; - - ret_len = strlen(trypath); - /* found phar:// */ - - if (SUCCESS != phar_split_fname(trypath, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { - return estrndup(trypath, ret_len); - } - - zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar); - - if (!pphar && PHAR_G(manifest_cached)) { - zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar); - } - - efree(arch); - efree(entry); - - return estrndup(trypath, ret_len); - } - return estrdup(trypath); - } - } - continue; - } - } - - if (tsrm_realpath(trypath, resolved_path TSRMLS_CC)) { - return estrdup(resolved_path); - } - } /* end provided path */ - - /* check in calling scripts' current working directory as a fall back case */ - if (zend_is_executing(TSRMLS_C)) { - char *exec_fname = (char*)zend_get_executed_filename(TSRMLS_C); - int exec_fname_length = strlen(exec_fname); - const char *p; - int n = 0; - - while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); - if (exec_fname && exec_fname[0] != '[' && - exec_fname_length > 0 && - exec_fname_length + 1 + filename_len + 1 < MAXPATHLEN) { - memcpy(trypath, exec_fname, exec_fname_length + 1); - memcpy(trypath+exec_fname_length + 1, filename, filename_len+1); - - /* search for stream wrapper */ - for (p = trypath; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; ++p, ++n); - - if (n < exec_fname_length - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4))) { - char *actual; - - wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); - - if (wrapper == &php_plain_files_wrapper) { - /* this should never technically happen, but we'll leave it here for completeness */ - strlcpy(trypath, actual, sizeof(trypath)); - } else if (!wrapper) { - /* if wrapper is NULL, there was a malformed include_path stream wrapper - this also should be impossible */ - return NULL; - } else { - return estrdup(trypath); - } - } - - if (tsrm_realpath(trypath, resolved_path TSRMLS_CC)) { - return estrdup(resolved_path); - } - } - } - - return NULL; -#endif /* PHP 5.2 */ } /* }}} */ @@ -572,7 +350,7 @@ not_stream: * appended, truncated, or read. For read, if the entry is marked unmodified, it is * assumed that the file pointer, if present, is opened for reading */ -int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */ +int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */ { phar_archive_data *phar; phar_entry_info *entry; @@ -733,7 +511,7 @@ really_get_entry: /** * Create a new dummy file slot within a writeable phar for a newly created file */ -phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */ +phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */ { phar_archive_data *phar; phar_entry_info *entry, etemp; @@ -900,7 +678,7 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er link = source; } - if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0 TSRMLS_CC), dest->fp, link->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0 TSRMLS_CC), dest->fp, link->uncompressed_filesize, NULL)) { php_stream_close(dest->fp); dest->fp_type = PHAR_FP; if (error) { @@ -1002,7 +780,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET); if (entry->uncompressed_filesize) { - if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) { spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename); php_stream_filter_remove(filter, 1 TSRMLS_CC); return FAILURE; @@ -1031,47 +809,11 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS } /* }}} */ -#if defined(PHP_VERSION_ID) && PHP_VERSION_ID < 50202 -typedef struct { - char *data; - size_t fpos; - size_t fsize; - size_t smax; - int mode; - php_stream **owner_ptr; -} php_stream_memory_data; -#endif - int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */ { if (entry->fp_type == PHAR_MOD) { /* already newly created, truncate */ -#if PHP_VERSION_ID >= 50202 php_stream_truncate_set_size(entry->fp, 0); -#else - if (php_stream_is(entry->fp, PHP_STREAM_IS_TEMP)) { - if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_MEMORY)) { - php_stream *inner = *(php_stream**)entry->fp->abstract; - php_stream_memory_data *memfp = (php_stream_memory_data*)inner->abstract; - memfp->fpos = 0; - memfp->fsize = 0; - } else if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_STDIO)) { - php_stream_truncate_set_size(*(php_stream**)entry->fp->abstract, 0); - } else { - if (error) { - spprintf(error, 0, "phar error: file \"%s\" cannot be opened for writing, no truncate support", phar->fname); - } - return FAILURE; - } - } else if (php_stream_is(entry->fp, PHP_STREAM_IS_STDIO)) { - php_stream_truncate_set_size(entry->fp, 0); - } else { - if (error) { - spprintf(error, 0, "phar error: file \"%s\" cannot be opened for writing, no truncate support", phar->fname); - } - return FAILURE; - } -#endif entry->old_flags = entry->flags; entry->is_modified = 1; phar->is_modified = 1; @@ -1144,7 +886,7 @@ int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{ link = entry; } - if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0 TSRMLS_CC), fp, link->uncompressed_filesize, NULL)) { if (error) { spprintf(error, 4096, "phar error: cannot separate entry file \"%s\" contents in phar archive \"%s\" for write access", entry->filename, entry->phar->fname); } @@ -1547,21 +1289,17 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in } if (phar->mounted_dirs.arBuckets && zend_hash_num_elements(&phar->mounted_dirs)) { - phar_zstr key; char *str_key; ulong unused; uint keylen; zend_hash_internal_pointer_reset(&phar->mounted_dirs); while (FAILURE != zend_hash_has_more_elements(&phar->mounted_dirs)) { - if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &str_key, &keylen, &unused, 0, NULL)) { break; } - PHAR_STR(key, str_key); - if ((int)keylen >= path_len || strncmp(str_key, path, keylen)) { - PHAR_STR_FREE(str_key); continue; } else { char *test; @@ -1572,7 +1310,6 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in if (error) { spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", str_key); } - PHAR_STR_FREE(str_key); return NULL; } @@ -1580,10 +1317,8 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in if (error) { spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", str_key); } - PHAR_STR_FREE(str_key); return NULL; } - PHAR_STR_FREE(str_key); test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + keylen); @@ -1691,11 +1426,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, return FAILURE; } -#if PHP_VERSION_ID < 50300 - if (FAILURE == zend_fcall_info_init(openssl, &fci, &fcc TSRMLS_CC)) { -#else if (FAILURE == zend_fcall_info_init(openssl, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) { -#endif zval_dtor(zdata); zval_dtor(zsig); zval_dtor(zkey); @@ -1709,13 +1440,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, fci.param_count = 3; fci.params = zp; -#if PHP_VERSION_ID < 50300 - ++(zdata->refcount); - if (!is_sign) { - ++(zsig->refcount); - } - ++(zkey->refcount); -#else Z_ADDREF_P(zdata); if (is_sign) { Z_SET_ISREF_P(zsig); @@ -1723,7 +1447,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, Z_ADDREF_P(zsig); } Z_ADDREF_P(zkey); -#endif fci.retval_ptr_ptr = &retval_ptr; if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) { @@ -1740,13 +1463,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, zval_dtor(openssl); efree(openssl); -#if PHP_VERSION_ID < 50300 - --(zdata->refcount); - if (!is_sign) { - --(zsig->refcount); - } - --(zkey->refcount); -#else Z_DELREF_P(zdata); if (is_sign) { Z_UNSET_ISREF_P(zsig); @@ -1754,7 +1470,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, Z_DELREF_P(zsig); } Z_DELREF_P(zkey); -#endif zval_dtor(zdata); efree(zdata); zval_dtor(zkey); @@ -2280,11 +1995,7 @@ static int phar_update_cached_entry(void *data, void *argument) /* {{{ */ ALLOC_ZVAL(entry->metadata); *entry->metadata = *t; zval_copy_ctor(entry->metadata); -#if PHP_VERSION_ID < 50300 - entry->metadata->refcount = 1; -#else Z_SET_REFCOUNT_P(entry->metadata, 1); -#endif entry->metadata_str.c = NULL; entry->metadata_str.len = 0; } @@ -2328,11 +2039,7 @@ static void phar_copy_cached_phar(phar_archive_data **pphar TSRMLS_DC) /* {{{ */ ALLOC_ZVAL(phar->metadata); *phar->metadata = *t; zval_copy_ctor(phar->metadata); -#if PHP_VERSION_ID < 50300 - phar->metadata->refcount = 1; -#else Z_SET_REFCOUNT_P(phar->metadata, 1); -#endif } } diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 6ba745e9cb..2e977b8840 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -417,11 +417,11 @@ foundit: php_stream_seek(fp, 0, SEEK_SET); /* copy file contents + local headers and zip comment, if any, to be hashed for signature */ - phar_stream_copy_to_stream(fp, sigfile, entry.header_offset, NULL); + php_stream_copy_to_stream_ex(fp, sigfile, entry.header_offset, NULL); /* seek to central directory */ php_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET); /* copy central directory header */ - phar_stream_copy_to_stream(fp, sigfile, beforeus - PHAR_GET_32(locator.cdir_offset), NULL); + php_stream_copy_to_stream_ex(fp, sigfile, beforeus - PHAR_GET_32(locator.cdir_offset), NULL); if (metadata) { php_stream_write(sigfile, metadata, PHAR_GET_16(locator.comment_len)); } @@ -578,10 +578,6 @@ foundit: /* construct actual offset to file start - local extra_len can be different from central extra_len */ entry.offset = entry.offset_abs = sizeof(local) + entry.header_offset + PHAR_GET_16(local.filename_len) + PHAR_GET_16(local.extra_len); -#if PHP_VERSION_ID < 50207 - /* work around Bug #46147 */ - fp->writepos = fp->readpos = 0; -#endif php_stream_seek(fp, entry.offset, SEEK_SET); /* these next lines should be for php < 5.2.6 after 5.3 filters are fixed */ fp->writepos = 0; @@ -605,9 +601,6 @@ foundit: if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { pefree(entry.filename, entry.is_persistent); -#if PHP_VERSION_ID < 50207 - PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); -#endif PHAR_ZIP_FAIL("unable to read in alias, truncated"); } @@ -626,9 +619,6 @@ foundit: if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { pefree(entry.filename, entry.is_persistent); -#if PHP_VERSION_ID < 50207 - PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); -#endif PHAR_ZIP_FAIL("unable to read in alias, truncated"); } @@ -915,7 +905,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */ php_stream_filter_append((&entry->cfp->writefilters), filter); - if (SUCCESS != phar_stream_copy_to_stream(efp, entry->cfp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(efp, entry->cfp, entry->uncompressed_filesize, NULL)) { spprintf(p->error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", entry->filename, entry->phar->fname); return ZEND_HASH_APPLY_STOP; } @@ -1020,7 +1010,7 @@ continue_dir: if (!not_really_modified && entry->is_modified) { if (entry->cfp) { - if (SUCCESS != phar_stream_copy_to_stream(entry->cfp, p->filefp, entry->compressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(entry->cfp, p->filefp, entry->compressed_filesize, NULL)) { spprintf(p->error, 0, "unable to write compressed contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname); return ZEND_HASH_APPLY_STOP; } @@ -1034,7 +1024,7 @@ continue_dir: phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC); - if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), p->filefp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0 TSRMLS_CC), p->filefp, entry->uncompressed_filesize, NULL)) { spprintf(p->error, 0, "unable to write contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname); return ZEND_HASH_APPLY_STOP; } @@ -1060,7 +1050,7 @@ continue_dir: } } - if (!entry->is_dir && entry->compressed_filesize && SUCCESS != phar_stream_copy_to_stream(p->old, p->filefp, entry->compressed_filesize, NULL)) { + if (!entry->is_dir && entry->compressed_filesize && SUCCESS != php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize, NULL)) { spprintf(p->error, 0, "unable to copy contents of file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname); return ZEND_HASH_APPLY_STOP; } @@ -1103,10 +1093,10 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas st = tell = php_stream_tell(pass->filefp); /* copy the local files, central directory, and the zip comment to generate the hash */ php_stream_seek(pass->filefp, 0, SEEK_SET); - phar_stream_copy_to_stream(pass->filefp, newfile, tell, NULL); + php_stream_copy_to_stream_ex(pass->filefp, newfile, tell, NULL); tell = php_stream_tell(pass->centralfp); php_stream_seek(pass->centralfp, 0, SEEK_SET); - phar_stream_copy_to_stream(pass->centralfp, newfile, tell, NULL); + php_stream_copy_to_stream_ex(pass->centralfp, newfile, tell, NULL); if (metadata->c) { php_stream_write(newfile, metadata->c, metadata->len); } @@ -1441,7 +1431,7 @@ nocentralerror: { size_t clen; - int ret = phar_stream_copy_to_stream(pass.centralfp, pass.filefp, PHP_STREAM_COPY_ALL, &clen); + int ret = php_stream_copy_to_stream_ex(pass.centralfp, pass.filefp, PHP_STREAM_COPY_ALL, &clen); if (SUCCESS != ret || clen != cdir_size) { if (error) { spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname); @@ -1511,7 +1501,7 @@ nocentralerror: return EOF; } php_stream_rewind(pass.filefp); - phar_stream_copy_to_stream(pass.filefp, phar->fp, PHP_STREAM_COPY_ALL, NULL); + php_stream_copy_to_stream_ex(pass.filefp, phar->fp, PHP_STREAM_COPY_ALL, NULL); /* we could also reopen the file in "rb" mode but there is no need for that */ php_stream_close(pass.filefp); } diff --git a/ext/session/php_session.h b/ext/session/php_session.h index e8e79f0fa6..4307e6afc5 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -180,6 +180,7 @@ typedef struct _php_ps_globals { double rfc1867_min_freq; /* session.upload_progress.min_freq */ zend_bool use_strict_mode; /* whether or not PHP accepts unknown session ids */ + unsigned char session_data_hash[16]; /* binary MD5 hash length */ } php_ps_globals; typedef php_ps_globals zend_ps_globals; diff --git a/ext/session/session.c b/ext/session/session.c index 7bb6584621..5b4820a65c 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -505,8 +505,17 @@ static void php_session_initialize(TSRMLS_D) /* {{{ */ */ } if (val) { + PHP_MD5_CTX context; + + /* Store read data's MD5 hash */ + PHP_MD5Init(&context); + PHP_MD5Update(&context, val, vallen); + PHP_MD5Final(PS(session_data_hash), &context); + php_session_decode(val, vallen TSRMLS_CC); efree(val); + } else { + memset(PS(session_data_hash),'\0', 16); } if (!PS(use_cookies) && PS(send_cookie)) { @@ -529,7 +538,19 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ val = php_session_encode(&vallen TSRMLS_CC); if (val) { - ret = PS(mod)->s_write(&PS(mod_data), PS(id), val, vallen TSRMLS_CC); + PHP_MD5_CTX context; + unsigned char digest[16]; + + /* Generate data's MD5 hash */ + PHP_MD5Init(&context); + PHP_MD5Update(&context, val, vallen); + PHP_MD5Final(digest, &context); + /* Write only when save is required */ + if (memcmp(digest, PS(session_data_hash), 16)) { + ret = PS(mod)->s_write(&PS(mod_data), PS(id), val, vallen TSRMLS_CC); + } else { + ret = SUCCESS; + } efree(val); } else { ret = PS(mod)->s_write(&PS(mod_data), PS(id), "", 0 TSRMLS_CC); @@ -727,6 +748,7 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ } #endif /* HAVE_HASH_EXT }}} */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "session.configuration 'session.hash_function' must be existing hash function. %s does not exist.", new_value); return FAILURE; } /* }}} */ @@ -1567,6 +1589,26 @@ static void php_session_flush(TSRMLS_D) /* {{{ */ } /* }}} */ +static void php_session_abort(TSRMLS_D) /* {{{ */ +{ + if (PS(session_status) == php_session_active) { + PS(session_status) = php_session_none; + if (PS(mod_data) || PS(mod_user_implemented)) { + PS(mod)->s_close(&PS(mod_data) TSRMLS_CC); + } + } +} +/* }}} */ + +static void php_session_reset(TSRMLS_D) /* {{{ */ +{ + if (PS(session_status) == php_session_active) { + php_session_initialize(TSRMLS_C); + } +} +/* }}} */ + + PHPAPI void session_adapt_url(const char *url, size_t urllen, char **new, size_t *newlen TSRMLS_DC) /* {{{ */ { if (PS(apply_trans_sid) && (PS(session_status) == php_session_active)) { @@ -1685,6 +1727,31 @@ static PHP_FUNCTION(session_module_name) } /* }}} */ +/* {{{ proto mixed session_serializer_name([string newname]) + Return the current serializer name used for encode/decode session data. If newname is given, the serialzer name is replaced with newname and return bool */ +static PHP_FUNCTION(session_serializer_name) +{ + char *name = NULL; + int name_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + return; + } + + /* Return serializer name */ + if (!name) { + RETURN_STRING(zend_ini_string("session.serialize_handler", sizeof("session.serialize_handler"), 0), 1); + } + + /* Set serializer name */ + if (zend_alter_ini_entry("session.serialize_handler", sizeof("session.serialize_handler"), name, name_len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto void session_set_save_handler(string open, string close, string read, string write, string destroy, string gc, string create_sid) Sets user-level functions */ static PHP_FUNCTION(session_set_save_handler) @@ -2048,6 +2115,22 @@ static PHP_FUNCTION(session_write_close) } /* }}} */ +/* {{{ proto void session_abort(void) + Abort session and end session. Session data will not be written */ +static PHP_FUNCTION(session_abort) +{ + php_session_abort(TSRMLS_C); +} +/* }}} */ + +/* {{{ proto void session_reset(void) + Reset session data from saved session data */ +static PHP_FUNCTION(session_reset) +{ + php_session_reset(TSRMLS_C); +} +/* }}} */ + /* {{{ proto int session_status(void) Returns the current session status */ static PHP_FUNCTION(session_status) @@ -2060,6 +2143,39 @@ static PHP_FUNCTION(session_status) } /* }}} */ +/* {{{ proto int session_gc([int maxlifetime]) + Execute garbage collection returns number of deleted data */ +static PHP_FUNCTION(session_gc) +{ + int nrdels = -1; + long maxlifetime = PS(gc_maxlifetime); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &maxlifetime) == FAILURE) { + return; + } + + /* Session must be active to have PS(mod) */ + if (PS(session_status) != php_session_active) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to garbage collect without active session"); + RETURN_FALSE; + } + + if (!PS(mod) || !PS(mod)->s_gc) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session save handler does not have gc()"); + RETURN_FALSE; + } + PS(mod)->s_gc(&PS(mod_data), maxlifetime, &nrdels TSRMLS_CC); + + if (nrdels < 0) { + /* Files save handler return -1 if there is not a permission to remove. + Save handlder should return negative nrdels when something wrong. */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session gc failed. Check permission or session storage"); + RETURN_FALSE; + } + RETURN_LONG((long)nrdels); +} +/* }}} */ + /* {{{ proto void session_register_shutdown(void) Registers session_write_close() as a shutdown function */ static PHP_FUNCTION(session_register_shutdown) @@ -2106,6 +2222,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_session_module_name, 0, 0, 0) ZEND_ARG_INFO(0, module) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_session_serializer_name, 0, 0, 0) + ZEND_ARG_INFO(0, module) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_session_save_path, 0, 0, 0) ZEND_ARG_INFO(0, path) ZEND_END_ARG_INFO() @@ -2151,6 +2271,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_session_set_cookie_params, 0, 0, 1) ZEND_ARG_INFO(0, httponly) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_session_gc, 0) + ZEND_ARG_INFO(0, maxlifetime) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_session_class_open, 0) ZEND_ARG_INFO(0, save_path) ZEND_ARG_INFO(0, session_name) @@ -2185,6 +2309,7 @@ ZEND_END_ARG_INFO() static const zend_function_entry session_functions[] = { PHP_FE(session_name, arginfo_session_name) PHP_FE(session_module_name, arginfo_session_module_name) + PHP_FE(session_serializer_name, arginfo_session_serializer_name) PHP_FE(session_save_path, arginfo_session_save_path) PHP_FE(session_id, arginfo_session_id) PHP_FE(session_regenerate_id, arginfo_session_regenerate_id) @@ -2199,7 +2324,10 @@ static const zend_function_entry session_functions[] = { PHP_FE(session_set_cookie_params, arginfo_session_set_cookie_params) PHP_FE(session_get_cookie_params, arginfo_session_void) PHP_FE(session_write_close, arginfo_session_void) + PHP_FE(session_abort, arginfo_session_void) + PHP_FE(session_reset, arginfo_session_void) PHP_FE(session_status, arginfo_session_void) + PHP_FE(session_gc, arginfo_session_gc) PHP_FE(session_register_shutdown, arginfo_session_void) PHP_FALIAS(session_commit, session_write_close, arginfo_session_void) PHP_FE_END diff --git a/ext/session/tests/session_abort_basic.phpt b/ext/session/tests/session_abort_basic.phpt new file mode 100644 index 0000000000..4a6702f0dc --- /dev/null +++ b/ext/session/tests/session_abort_basic.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test session_abort() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_path= +session.name=PHPSESSID +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_abort(void) + * Description : Should abort session. Session data should not be written. + * Source code : ext/session/session.c + */ + +echo "*** Testing session_abort() : basic functionality ***\n"; + +session_start(); +$session_id = session_id(); +$_SESSION['foo'] = 123; +session_commit(); + +session_id($session_id); +session_start(); +$_SESSION['bar'] = 456; +var_dump($_SESSION); +session_abort(); + +session_id($session_id); +session_start(); +var_dump($_SESSION); // Should only have 'foo' + +echo "Done".PHP_EOL; + +?> +--EXPECTF-- +*** Testing session_abort() : basic functionality *** +array(2) { + ["foo"]=> + int(123) + ["bar"]=> + int(456) +} +array(1) { + ["foo"]=> + int(123) +} +Done diff --git a/ext/session/tests/session_gc_basic.phpt b/ext/session/tests/session_gc_basic.phpt new file mode 100644 index 0000000000..f0726ce93b --- /dev/null +++ b/ext/session/tests/session_gc_basic.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_gc() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=php +session.save_handler=files +session.maxlifetime=782000 +--FILE-- +<?php +error_reporting(E_ALL); + +ob_start(); + +/* + * Prototype : int session_gc([int maxlifetime]) + * Description : Execute gc and return number of deleted data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_gc() : basic functionality ***\n"; + +// Should fail. It requires active session. +var_dump(session_gc()); + +session_start(); +// Should succeed with some number +var_dump(session_gc()); +// Secound time must be int(0) +var_dump(session_gc()); +session_write_close(); + +// Start&stop session to generate +session_start(); +session_write_close(); +session_start(); +session_write_close(); +session_start(); +session_write_close(); + +session_start(); +$ndeleted = session_gc(0); // Delete all +var_dump($ndeleted >= 3); + +echo "Done".PHP_EOL; + +?> +--EXPECTF-- +*** Testing session_gc() : basic functionality *** + +Warning: session_gc(): Trying to garbage collect without active session in %s on line 15 +bool(false) +int(%d) +int(0) +bool(true) +Done diff --git a/ext/session/tests/session_hash_function_basic.phpt b/ext/session/tests/session_hash_function_basic.phpt new file mode 100644 index 0000000000..663852d9d1 --- /dev/null +++ b/ext/session/tests/session_hash_function_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test session.hash_function ini setting : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.hash_bits_per_character=4 +--FILE-- +<?php + +ob_start(); + +echo "*** Testing session.hash_function : basic functionality ***\n"; + +var_dump(ini_set('session.hash_function', 'md5')); +var_dump(session_start()); +var_dump(!empty(session_id()), session_id()); +var_dump(session_destroy()); + +var_dump(ini_set('session.hash_function', 'sha1')); +var_dump(session_start()); +var_dump(!empty(session_id()), session_id()); +var_dump(session_destroy()); + +var_dump(ini_set('session.hash_function', 'none')); // Should fail +var_dump(session_start()); +var_dump(!empty(session_id()), session_id()); +var_dump(session_destroy()); + + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session.hash_function : basic functionality *** +string(1) "0" +bool(true) +bool(true) +string(32) "%s" +bool(true) +string(3) "md5" +bool(true) +bool(true) +string(40) "%s" +bool(true) + +Warning: ini_set(): session.configuration 'session.hash_function' must be existing hash function. none does not exist. in %s/session_hash_function_basic.php on line 17 +bool(false) +bool(true) +bool(true) +string(40) "%s" +bool(true) +Done diff --git a/ext/session/tests/session_reset_basic.phpt b/ext/session/tests/session_reset_basic.phpt new file mode 100644 index 0000000000..75c6a04119 --- /dev/null +++ b/ext/session/tests/session_reset_basic.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_reset() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_path= +session.name=PHPSESSID +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_reset(void) + * Description : Should abort session. Session data should not be written. + * Source code : ext/session/session.c + */ + +echo "*** Testing session_abort() : basic functionality ***\n"; + +session_start(); +$session_id = session_id(); +$_SESSION['foo'] = 123; +session_commit(); + +session_id($session_id); +session_start(); +$_SESSION['bar'] = 456; +var_dump($_SESSION); +session_reset(); + +var_dump($_SESSION); // Should only have 'foo' + +echo "Done".PHP_EOL; + +?> +--EXPECTF-- +*** Testing session_abort() : basic functionality *** +array(2) { + ["foo"]=> + int(123) + ["bar"]=> + int(456) +} +array(1) { + ["foo"]=> + int(123) +} +Done diff --git a/ext/session/tests/session_serializer_name_basic.phpt b/ext/session/tests/session_serializer_name_basic.phpt new file mode 100644 index 0000000000..ca292dd36f --- /dev/null +++ b/ext/session/tests/session_serializer_name_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test session_serializer_name() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : mixed session_serializer_name([string name]) + * Description : Change/get serialize handler name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_serializer_name() : basic functionality ***\n"; + +var_dump(session_serializer_name()); +var_dump(session_serializer_name('php')); +var_dump(session_serializer_name('php_binary')); +var_dump(session_serializer_name('none')); +var_dump(session_serializer_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_serializer_name() : basic functionality *** +string(3) "php" +bool(true) +bool(true) + +Warning: session_serializer_name(): Cannot find serialization handler 'none' in %s/session_serializer_name_basic.php on line 16 +bool(false) +string(10) "php_binary" +Done + diff --git a/ext/session/tests/session_set_save_handler_basic.phpt b/ext/session/tests/session_set_save_handler_basic.phpt index 3897ba9a92..e8496e8afb 100644 --- a/ext/session/tests/session_set_save_handler_basic.phpt +++ b/ext/session/tests/session_set_save_handler_basic.phpt @@ -43,6 +43,7 @@ session_id($session_id); session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); session_start(); var_dump($_SESSION); +$_SESSION['Bar'] = 'Foo'; session_write_close(); ob_end_flush(); @@ -91,5 +92,5 @@ array(3) { ["Guff"]=> int(1234567890) } -Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";] Close [%s,PHPSESSID] diff --git a/ext/session/tests/session_set_save_handler_class_003.phpt b/ext/session/tests/session_set_save_handler_class_003.phpt index e9a3cc2feb..29b3846851 100644 --- a/ext/session/tests/session_set_save_handler_class_003.phpt +++ b/ext/session/tests/session_set_save_handler_class_003.phpt @@ -58,6 +58,7 @@ session_set_save_handler($handler); session_start(); +$_SESSION['bar'] = 'hello'; session_write_close(); session_unset(); @@ -71,8 +72,10 @@ array(1) { } int(4) string(%d) "%s" -array(1) { +array(2) { ["foo"]=> string(5) "hello" + ["bar"]=> + string(5) "hello" } string(3) "hai" diff --git a/ext/session/tests/session_set_save_handler_class_007.phpt b/ext/session/tests/session_set_save_handler_class_007.phpt index 7344ae1ef3..55f722515e 100644 --- a/ext/session/tests/session_set_save_handler_class_007.phpt +++ b/ext/session/tests/session_set_save_handler_class_007.phpt @@ -56,6 +56,7 @@ $handler = new MySession(2); session_set_save_handler($handler); session_start(); +$_SESSION['abc'] = 'xyz'; // implicit close (called by shutdown function) echo "done\n"; ob_end_flush(); @@ -69,6 +70,6 @@ ob_end_flush(); (#2) constructor called (#1) destructor called done -(#2) writing %s = foo|s:3:"bar"; +(#2) writing %s = foo|s:3:"bar";abc|s:3:"xyz"; (#2) closing %s (#2) destructor called diff --git a/ext/session/tests/session_set_save_handler_closures.phpt b/ext/session/tests/session_set_save_handler_closures.phpt index 21b2c68737..1251886b01 100644 --- a/ext/session/tests/session_set_save_handler_closures.phpt +++ b/ext/session/tests/session_set_save_handler_closures.phpt @@ -42,6 +42,7 @@ echo "Starting session again..!\n"; session_id($session_id); session_set_save_handler($open_closure, $close_closure, $read_closure, $write_closure, $destroy_closure, $gc_closure); session_start(); +$_SESSION['Bar'] = 'Foo'; var_dump($_SESSION); session_write_close(); @@ -83,13 +84,15 @@ array(3) { Starting session again..! Open [%s,PHPSESSID] Read [%s,%s] -array(3) { +array(4) { ["Blah"]=> string(12) "Hello World!" ["Foo"]=> bool(false) ["Guff"]=> int(1234567890) + ["Bar"]=> + string(3) "Foo" } -Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";] Close [%s,PHPSESSID] diff --git a/ext/session/tests/session_set_save_handler_write_short_circuit.phpt b/ext/session/tests/session_set_save_handler_write_short_circuit.phpt new file mode 100644 index 0000000000..02ca182ec6 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_write_short_circuit.phpt @@ -0,0 +1,104 @@ +--TEST-- +Test session_set_save_handler() function : test write short circuit +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : test write short circuit ***\n"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$session_id = session_id(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +session_unset(); +var_dump($_SESSION); + +echo "Starting session again..!\n"; +session_id($session_id); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +$_SESSION['Bar'] = 'Foo'; +session_write_close(); + +echo "Starting session again..!\n"; +session_id($session_id); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +// $_SESSION should be the same and should skip write() +session_write_close(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : test write short circuit *** + +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";] +Close [%s,PHPSESSID] +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(4) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) + ["Bar"]=> + string(3) "Foo" +} +Close [%s,PHPSESSID]
\ No newline at end of file diff --git a/ext/simplexml/config.m4 b/ext/simplexml/config.m4 index 387a24ea21..b06f5b00f0 100644 --- a/ext/simplexml/config.m4 +++ b/ext/simplexml/config.m4 @@ -18,6 +18,7 @@ if test "$PHP_SIMPLEXML" != "no"; then PHP_SETUP_LIBXML(SIMPLEXML_SHARED_LIBADD, [ AC_DEFINE(HAVE_SIMPLEXML,1,[ ]) PHP_NEW_EXTENSION(simplexml, simplexml.c sxe.c, $ext_shared) + PHP_INSTALL_HEADERS([ext/simplexml/php_simplexml.h ext/simplexml/php_simplexml_exports.h]) PHP_SUBST(SIMPLEXML_SHARED_LIBADD) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) diff --git a/ext/simplexml/config.w32 b/ext/simplexml/config.w32 index 2d2ed285eb..a02f3dded3 100644 --- a/ext/simplexml/config.w32 +++ b/ext/simplexml/config.w32 @@ -16,6 +16,7 @@ if (PHP_SIMPLEXML == "yes") { MESSAGE("\tSPL support in simplexml disabled"); } ADD_FLAG("CFLAGS_SIMPLEXML", "/D PHP_SIMPLEXML_EXPORTS "); + PHP_INSTALL_HEADERS("ext/simplexml/", "php_simplexml.h php_simplexml_exports.h"); } else { PHP_SIMPLEXML = "no"; WARNING("simplexml not enabled; libraries and headers not found"); diff --git a/ext/skeleton/php_skeleton.h b/ext/skeleton/php_skeleton.h index 495907bbd1..86836c03e2 100644 --- a/ext/skeleton/php_skeleton.h +++ b/ext/skeleton/php_skeleton.h @@ -18,15 +18,6 @@ extern zend_module_entry extname_module_entry; #include "TSRM.h" #endif -PHP_MINIT_FUNCTION(extname); -PHP_MSHUTDOWN_FUNCTION(extname); -PHP_RINIT_FUNCTION(extname); -PHP_RSHUTDOWN_FUNCTION(extname); -PHP_MINFO_FUNCTION(extname); - -PHP_FUNCTION(confirm_extname_compiled); /* For testing, remove later. */ -/* __function_declarations_here__ */ - /* Declare any global variables you may need between the BEGIN and END macros here: diff --git a/ext/skeleton/skeleton.c b/ext/skeleton/skeleton.c index ee4ea74e16..b9a918806c 100644 --- a/ext/skeleton/skeleton.c +++ b/ext/skeleton/skeleton.c @@ -16,41 +16,6 @@ ZEND_DECLARE_MODULE_GLOBALS(extname) /* True global resources - no need for thread safety here */ static int le_extname; -/* {{{ extname_functions[] - * - * Every user visible function must have an entry in extname_functions[]. - */ -const zend_function_entry extname_functions[] = { - PHP_FE(confirm_extname_compiled, NULL) /* For testing, remove later. */ - /* __function_entries_here__ */ - PHP_FE_END /* Must be the last line in extname_functions[] */ -}; -/* }}} */ - -/* {{{ extname_module_entry - */ -zend_module_entry extname_module_entry = { -#if ZEND_MODULE_API_NO >= 20010901 - STANDARD_MODULE_HEADER, -#endif - "extname", - extname_functions, - PHP_MINIT(extname), - PHP_MSHUTDOWN(extname), - PHP_RINIT(extname), /* Replace with NULL if there's nothing to do at request start */ - PHP_RSHUTDOWN(extname), /* Replace with NULL if there's nothing to do at request end */ - PHP_MINFO(extname), -#if ZEND_MODULE_API_NO >= 20010901 - "0.1", /* Replace with version number for your extension */ -#endif - STANDARD_MODULE_PROPERTIES -}; -/* }}} */ - -#ifdef COMPILE_DL_EXTNAME -ZEND_GET_MODULE(extname) -#endif - /* {{{ PHP_INI */ /* Remove comments and fill if you need to have entries in php.ini @@ -61,6 +26,35 @@ PHP_INI_END() */ /* }}} */ +/* Remove the following function when you have successfully modified config.m4 + so that your module can be compiled into PHP, it exists only for testing + purposes. */ + +/* Every user-visible function in PHP should document itself in the source */ +/* {{{ proto string confirm_extname_compiled(string arg) + Return a string to confirm that the module is compiled in */ +PHP_FUNCTION(confirm_extname_compiled) +{ + char *arg = NULL; + int arg_len, len; + char *strg; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { + return; + } + + len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg); + RETURN_STRINGL(strg, len, 0); +} +/* }}} */ +/* The previous line is meant for vim and emacs, so it can correctly fold and + unfold functions in source code. See the corresponding marks just before + function definition, where the functions purpose is also documented. Please + follow this convention for the convenience of others editing your code. +*/ + +/* __function_stubs_here__ */ + /* {{{ php_extname_init_globals */ /* Uncomment this function if you have INI entries @@ -126,35 +120,36 @@ PHP_MINFO_FUNCTION(extname) } /* }}} */ +/* {{{ extname_functions[] + * + * Every user visible function must have an entry in extname_functions[]. + */ +const zend_function_entry extname_functions[] = { + PHP_FE(confirm_extname_compiled, NULL) /* For testing, remove later. */ + /* __function_entries_here__ */ + PHP_FE_END /* Must be the last line in extname_functions[] */ +}; +/* }}} */ -/* Remove the following function when you have successfully modified config.m4 - so that your module can be compiled into PHP, it exists only for testing - purposes. */ - -/* Every user-visible function in PHP should document itself in the source */ -/* {{{ proto string confirm_extname_compiled(string arg) - Return a string to confirm that the module is compiled in */ -PHP_FUNCTION(confirm_extname_compiled) -{ - char *arg = NULL; - int arg_len, len; - char *strg; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { - return; - } - - len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg); - RETURN_STRINGL(strg, len, 0); -} +/* {{{ extname_module_entry + */ +zend_module_entry extname_module_entry = { + STANDARD_MODULE_HEADER, + "extname", + extname_functions, + PHP_MINIT(extname), + PHP_MSHUTDOWN(extname), + PHP_RINIT(extname), /* Replace with NULL if there's nothing to do at request start */ + PHP_RSHUTDOWN(extname), /* Replace with NULL if there's nothing to do at request end */ + PHP_MINFO(extname), + "0.1", /* Replace with version number for your extension */ + STANDARD_MODULE_PROPERTIES +}; /* }}} */ -/* The previous line is meant for vim and emacs, so it can correctly fold and - unfold functions in source code. See the corresponding marks just before - function definition, where the functions purpose is also documented. Please - follow this convention for the convenience of others editing your code. -*/ -/* __function_stubs_here__ */ +#ifdef COMPILE_DL_EXTNAME +ZEND_GET_MODULE(extname) +#endif /* * Local variables: diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 00e80efbcb..c5900dc645 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1560,48 +1560,45 @@ PHP_METHOD(SoapServer, handle) } if (ZEND_NUM_ARGS() == 0) { - if (SG(request_info).raw_post_data) { - char *post_data = SG(request_info).raw_post_data; - int post_data_length = SG(request_info).raw_post_data_length; + if (SG(request_info).request_body && 0 == php_stream_rewind(SG(request_info).request_body)) { zval **server_vars, **encoding; + php_stream_filter *zf = NULL; zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS && Z_TYPE_PP(server_vars) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING"), (void **) &encoding)==SUCCESS && Z_TYPE_PP(encoding) == IS_STRING) { - zval func; - zval retval; - zval param; - zval *params[1]; - - if ((strcmp(Z_STRVAL_PP(encoding),"gzip") == 0 || - strcmp(Z_STRVAL_PP(encoding),"x-gzip") == 0) && - zend_hash_exists(EG(function_table), "gzinflate", sizeof("gzinflate"))) { - ZVAL_STRING(&func, "gzinflate", 0); - params[0] = ¶m; - ZVAL_STRINGL(params[0], post_data+10, post_data_length-10, 0); - INIT_PZVAL(params[0]); - } else if (strcmp(Z_STRVAL_PP(encoding),"deflate") == 0 && - zend_hash_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress"))) { - ZVAL_STRING(&func, "gzuncompress", 0); - params[0] = ¶m; - ZVAL_STRINGL(params[0], post_data, post_data_length, 0); - INIT_PZVAL(params[0]); + + if (strcmp(Z_STRVAL_PP(encoding),"gzip") == 0 + || strcmp(Z_STRVAL_PP(encoding),"x-gzip") == 0 + || strcmp(Z_STRVAL_PP(encoding),"deflate") == 0 + ) { + zval filter_params; + + INIT_PZVAL(&filter_params); + array_init_size(&filter_params, 1); + add_assoc_long_ex(&filter_params, ZEND_STRS("window"), 0x2f); /* ANY WBITS */ + + zf = php_stream_filter_create("zlib.inflate", &filter_params, 0 TSRMLS_CC); + zval_dtor(&filter_params); + + if (zf) { + php_stream_filter_append(&SG(request_info).request_body->readfilters, zf); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request"); + return; + } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_PP(encoding)); return; } - if (call_user_function(CG(function_table), (zval**)NULL, &func, &retval, 1, params TSRMLS_CC) == SUCCESS && - Z_TYPE(retval) == IS_STRING) { - doc_request = soap_xmlParseMemory(Z_STRVAL(retval),Z_STRLEN(retval)); - zval_dtor(&retval); - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request"); - return; - } - } else { - doc_request = soap_xmlParseMemory(post_data, post_data_length); + } + + doc_request = soap_xmlParseFile("php://input" TSRMLS_CC); + + if (zf) { + php_stream_filter_remove(zf, 1 TSRMLS_CC); } } else { zval_ptr_dtor(&retval); diff --git a/ext/sockets/tests/ipv4loop.phpt b/ext/sockets/tests/ipv4loop.phpt index 9fdcc17dad..920b27b66e 100644 --- a/ext/sockets/tests/ipv4loop.phpt +++ b/ext/sockets/tests/ipv4loop.phpt @@ -13,8 +13,15 @@ IPv4 Loopback test if (!$server) { die('Unable to create AF_INET socket [server]'); } - if (!socket_bind($server, '127.0.0.1', 31337)) { - die('Unable to bind to 127.0.0.1:31337'); + $bound = false; + for($port = 31337; $port < 31357; ++$port) { + if (socket_bind($server, '127.0.0.1', $port)) { + $bound = true; + break; + } + } + if (!$bound) { + die("Unable to bind to 127.0.0.1"); } if (!socket_listen($server, 2)) { die('Unable to listen on socket'); @@ -25,7 +32,7 @@ IPv4 Loopback test if (!$client) { die('Unable to create AF_INET socket [client]'); } - if (!socket_connect($client, '127.0.0.1', 31337)) { + if (!socket_connect($client, '127.0.0.1', $port)) { die('Unable to connect to server socket'); } diff --git a/ext/sockets/tests/ipv6loop.phpt b/ext/sockets/tests/ipv6loop.phpt index 6967605ffa..4720cb49e4 100644 --- a/ext/sockets/tests/ipv6loop.phpt +++ b/ext/sockets/tests/ipv6loop.phpt @@ -14,8 +14,15 @@ IPv6 Loopback test if (!$server) { die('Unable to create AF_INET6 socket [server]'); } - if (!socket_bind($server, '::1', 31337)) { - die('Unable to bind to [::1]:31337'); + $bound = false; + for($port = 31337; $port < 31357; ++$port) { + if (socket_bind($server, '::1', $port)) { + $bound = true; + break; + } + } + if (!$bound) { + die("Unable to bind to [::1]:$port"); } if (!socket_listen($server, 2)) { die('Unable to listen on socket'); @@ -26,7 +33,7 @@ IPv6 Loopback test if (!$client) { die('Unable to create AF_INET6 socket [client]'); } - if (!socket_connect($client, '::1', 31337)) { + if (!socket_connect($client, '::1', $port)) { die('Unable to connect to server socket'); } diff --git a/ext/sockets/tests/socket_getpeername_ipv4loop.phpt b/ext/sockets/tests/socket_getpeername_ipv4loop.phpt index aa59abb8da..b948e0e7f4 100644 --- a/ext/sockets/tests/socket_getpeername_ipv4loop.phpt +++ b/ext/sockets/tests/socket_getpeername_ipv4loop.phpt @@ -14,17 +14,23 @@ ext/sockets - socket_getpeername_ipv4loop - basic test /* Bind and connect sockets to localhost */ $localhost = '127.0.0.1'; - /* Hold the port associated to address */ - $port = 31337; - /* Setup socket server */ $server = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); if (!$server) { die('Unable to create AF_INET socket [server]'); } - - if (!socket_bind($server, $localhost, $port)) { - die('Unable to bind to '.$localhost.':'.$port); + + $minport = 31337; + $maxport = 31356; + $bound = false; + for($port = $minport; $port <= $maxport; ++$port) { + if (socket_bind($server, $localhost, $port)) { + $bound = true; + break; + } + } + if (!$bound) { + die('Unable to bind to '.$localhost); } if (!socket_listen($server, 2)) { die('Unable to listen on socket'); @@ -45,10 +51,10 @@ ext/sockets - socket_getpeername_ipv4loop - basic test die('Unable to accept connection'); } - if (!socket_getpeername($client, $address, $port)) { + if (!socket_getpeername($client, $address, $peerport)) { die('Unable to retrieve peer name'); } - var_dump($address, $port); + var_dump($address, $port === $peerport); socket_close($client); socket_close($socket); @@ -56,4 +62,4 @@ ext/sockets - socket_getpeername_ipv4loop - basic test ?> --EXPECT-- string(9) "127.0.0.1" -int(31337) +bool(true) diff --git a/ext/sockets/tests/socket_getpeername_ipv6loop.phpt b/ext/sockets/tests/socket_getpeername_ipv6loop.phpt index e865f3e064..5d03e32ce0 100644 --- a/ext/sockets/tests/socket_getpeername_ipv6loop.phpt +++ b/ext/sockets/tests/socket_getpeername_ipv6loop.phpt @@ -15,17 +15,23 @@ require 'ipv6_skipif.inc'; /* Bind and connect sockets to localhost */ $localhost = '::1'; - /* Hold the port associated to address */ - $port = 31337; - /* Setup socket server */ $server = socket_create(AF_INET6, SOCK_STREAM, getprotobyname('tcp')); if (!$server) { die('Unable to create AF_INET6 socket [server]'); } - - if (!socket_bind($server, $localhost, $port)) { - die('Unable to bind to '.$localhost.':'.$port); + + $minport = 31337; + $maxport = 31356; + $bound = false; + for($port = $minport; $port <= $maxport; ++$port) { + if (socket_bind($server, $localhost, $port)) { + $bound = true; + break; + } + } + if (!$bound) { + die('Unable to bind to '.$localhost); } if (!socket_listen($server, 2)) { die('Unable to listen on socket'); @@ -46,10 +52,10 @@ require 'ipv6_skipif.inc'; die('Unable to accept connection'); } - if (!socket_getpeername($client, $address, $port)) { + if (!socket_getpeername($client, $address, $peerport)) { die('Unable to retrieve peer name'); } - var_dump($address, $port); + var_dump($address, $port === $peerport); socket_close($client); socket_close($socket); @@ -57,4 +63,4 @@ require 'ipv6_skipif.inc'; ?> --EXPECT-- string(3) "::1" -int(31337) +bool(true) diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h index 4794f12443..28aa19def3 100644 --- a/ext/spl/php_spl.h +++ b/ext/spl/php_spl.h @@ -20,11 +20,6 @@ #define PHP_SPL_H #include "php.h" -#if defined(PHP_WIN32) -# include "win32/php_stdint.h" -#elif defined(HAVE_STDINT_H) -# include <stdint.h> -#endif #include <stdarg.h> #if 0 diff --git a/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt b/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt index ed1f473be9..d4f22f68a1 100644 --- a/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt +++ b/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt @@ -4,7 +4,7 @@ DirectoryIterator::getBasename() - Basic Test PHPNW Testfest 2009 - Adrian Hardy --FILE-- <?php - $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename'); + $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename1'); mkdir($targetDir); touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt'); $dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR); @@ -15,7 +15,7 @@ PHPNW Testfest 2009 - Adrian Hardy ?> --CLEAN-- <?php - $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename'); + $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename1'); unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt'); rmdir($targetDir); ?> diff --git a/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt b/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt index b2df8a55c9..ef13520237 100644 --- a/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt +++ b/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt @@ -4,7 +4,7 @@ DirectoryIterator::getBasename() - Pass unexpected array PHPNW Testfest 2009 - Adrian Hardy --FILE-- <?php - $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename'); + $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename2'); mkdir($targetDir); touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt'); $dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR); @@ -15,7 +15,7 @@ PHPNW Testfest 2009 - Adrian Hardy ?> --CLEAN-- <?php - $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename'); + $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename2'); unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt'); rmdir($targetDir); ?> diff --git a/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt b/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt index f0b2b0182c..f6bc266cb1 100644 --- a/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt +++ b/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt @@ -5,7 +5,7 @@ Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl> #testfest AmsterdamPHP 2012-06-23 --FILE-- <?php -$depth0 = "depth0"; +$depth0 = "depth01"; $depth1 = 'depth1'; $depth2 = 'depth2'; $targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2; @@ -38,7 +38,7 @@ function rrmdir($dir) { rmdir($dir); } -$targetDir = __DIR__.DIRECTORY_SEPARATOR . "depth0"; +$targetDir = __DIR__.DIRECTORY_SEPARATOR . "depth01"; rrmdir($targetDir); ?> diff --git a/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt b/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt index 7b12672e14..6527d84bfe 100644 --- a/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt +++ b/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt @@ -5,7 +5,7 @@ Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl> #testfest AmsterdamPHP 2012-06-23 --FILE-- <?php -$depth0 = "depth0"; +$depth0 = "depth02"; $depth1 = "depth1"; $depth2 = "depth2"; $targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2; @@ -41,7 +41,7 @@ function rrmdir($dir) { rmdir($dir); } -$targetDir = __DIR__ . DIRECTORY_SEPARATOR . "depth0"; +$targetDir = __DIR__ . DIRECTORY_SEPARATOR . "depth02"; rrmdir($targetDir); ?> --EXPECTF-- diff --git a/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt index abfe5f235f..84b5403698 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt @@ -2,7 +2,7 @@ SplFileObject::fgetcsv default path --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv1.csv', 'w+'); fputcsv($fp, array( 'field1', 'field2', @@ -11,12 +11,12 @@ fputcsv($fp, array( )); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv1.csv'); var_dump($fo->fgetcsv()); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv1.csv'); ?> --EXPECTF-- array(4) { diff --git a/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt index 4402d6ca4c..a8125a0257 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt @@ -2,7 +2,7 @@ SplFileObject::fgetcsv with alternative delimiter --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv2.csv', 'w+'); fputcsv($fp, array( 'field1', 'field2', @@ -11,12 +11,12 @@ fputcsv($fp, array( ), '|'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv2.csv'); var_dump($fo->fgetcsv('|')); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv2.csv'); ?> --EXPECTF-- array(4) { diff --git a/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt index 64d6514a29..169ded7dc3 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt @@ -2,7 +2,7 @@ SplFileObject::fgetcsv with alternative delimiter --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv3.csv', 'w+'); fputcsv($fp, array( 'field1', 'field2', @@ -11,12 +11,12 @@ fputcsv($fp, array( ), '|'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv3.csv'); var_dump($fo->fgetcsv('invalid')); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv3.csv'); ?> --EXPECTF-- Warning: SplFileObject::fgetcsv(): delimiter must be a character in %s on line %d diff --git a/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt index efbb5fb685..efe765cbf8 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt @@ -2,7 +2,7 @@ SplFileObject::fgetcsv with alternative delimiter --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv4.csv', 'w+'); fputcsv($fp, array( 'field1', 'field2', @@ -11,12 +11,12 @@ fputcsv($fp, array( ), ',', '"'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv4.csv'); var_dump($fo->fgetcsv(',', '"')); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv4.csv'); ?> --EXPECTF-- array(4) { diff --git a/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt index 7487b8353c..f8c14f0e35 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt @@ -2,7 +2,7 @@ SplFileObject::fgetcsv with alternative delimiter --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv5.csv', 'w+'); fputcsv($fp, array( 'field1', 'field2', @@ -11,12 +11,12 @@ fputcsv($fp, array( ), ',', '"'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv5.csv'); var_dump($fo->fgetcsv(',', 'invalid')); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv5.csv'); ?> --EXPECTF-- Warning: SplFileObject::fgetcsv(): enclosure must be a character in %s on line %d diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt index 1a94532b2b..960f36d63f 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt @@ -2,16 +2,16 @@ SplFileObject::fgetcsv with alternative delimiter --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv6.csv', 'w+'); fwrite($fp, '"aaa","b""bb","ccc"'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv6.csv'); var_dump($fo->fgetcsv(',', '"', '"')); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv6.csv'); ?> --EXPECTF-- array(3) { diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt index c628ac043d..69089636c1 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt @@ -2,16 +2,16 @@ SplFileObject::fgetcsv with default escape character --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv7.csv', 'w+'); fwrite($fp, '"aa\"","bb","\"c"'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv7.csv'); var_dump($fo->fgetcsv()); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv7.csv'); ?> --EXPECTF-- array(3) { diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt index fd90103bfa..b49bcdd13c 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt @@ -2,16 +2,16 @@ SplFileObject::fgetcsv with alternative delimiter --FILE-- <?php -$fp = fopen('SplFileObject__fgetcsv.csv', 'w+'); +$fp = fopen('SplFileObject__fgetcsv8.csv', 'w+'); fwrite($fp, '"aaa","b""bb","ccc"'); fclose($fp); -$fo = new SplFileObject('SplFileObject__fgetcsv.csv'); +$fo = new SplFileObject('SplFileObject__fgetcsv8.csv'); var_dump($fo->fgetcsv(',', '"', 'invalid')); ?> --CLEAN-- <?php -unlink('SplFileObject__fgetcsv.csv'); +unlink('SplFileObject__fgetcsv8.csv'); ?> --EXPECTF-- Warning: SplFileObject::fgetcsv(): escape must be a character in %s on line %d diff --git a/ext/spl/tests/SplFileObject_fputcsv_002.phpt b/ext/spl/tests/SplFileObject_fputcsv_002.phpt index db174931f7..fdd4112ee6 100644 --- a/ext/spl/tests/SplFileObject_fputcsv_002.phpt +++ b/ext/spl/tests/SplFileObject_fputcsv_002.phpt @@ -2,7 +2,7 @@ SplFileObject::fputcsv(): Checking data after calling the function --FILE-- <?php -$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w'); +$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv1.csv', 'w'); $data = array(1, 2, 'foo', 'haha', array(4, 5, 6), 1.3, null); @@ -12,7 +12,7 @@ var_dump($data); ?> --CLEAN-- <?php -$file = __DIR__ . '/SplFileObject_fputcsv.csv'; +$file = __DIR__ . '/SplFileObject_fputcsv1.csv'; unlink($file); ?> --EXPECTF-- diff --git a/ext/spl/tests/SplFileObject_fputcsv_error.phpt b/ext/spl/tests/SplFileObject_fputcsv_error.phpt index 8368e4211d..cdee48c874 100644 --- a/ext/spl/tests/SplFileObject_fputcsv_error.phpt +++ b/ext/spl/tests/SplFileObject_fputcsv_error.phpt @@ -2,7 +2,7 @@ SplFileObject::fputcsv(): error conditions --FILE-- <?php -$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w'); +$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv2.csv', 'w'); echo "*** Testing error conditions ***\n"; // zero argument @@ -19,7 +19,7 @@ var_dump( $fo->fputcsv($fields, $delim, $enclosure, $fo) ); echo "Done\n"; --CLEAN-- <?php -$file = __DIR__ . '/SplFileObject_fputcsv.csv'; +$file = __DIR__ . '/SplFileObject_fputcsv2.csv'; unlink($file); ?> --EXPECTF-- diff --git a/ext/spl/tests/dit_006.phpt b/ext/spl/tests/dit_006.phpt index 1e627a20e0..9edbb9f157 100644 --- a/ext/spl/tests/dit_006.phpt +++ b/ext/spl/tests/dit_006.phpt @@ -2,7 +2,7 @@ SPL: DirectoryIterator and seek --FILE-- <?php -$di = new DirectoryIterator(__DIR__); +$di = new DirectoryIterator(__DIR__."/.."); $di->seek(2); $n = 0; diff --git a/ext/sqlite3/config.w32 b/ext/sqlite3/config.w32 index 01e4625fed..8ddb6b9ac8 100644 --- a/ext/sqlite3/config.w32 +++ b/ext/sqlite3/config.w32 @@ -4,7 +4,7 @@ ARG_WITH("sqlite3", "SQLite 3 support", "no"); if (PHP_SQLITE3 != "no") { - ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 "); + ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /D SQLITE_API=__declspec(dllexport) "); EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname); ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3"); diff --git a/ext/standard/array.c b/ext/standard/array.c index 51972033ee..ae6e5d266f 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -830,7 +830,7 @@ PHP_FUNCTION(end) RETURN_FALSE; } - RETURN_ZVAL(*entry, 1, 0); + RETURN_ZVAL_FAST(*entry); } } /* }}} */ @@ -853,7 +853,7 @@ PHP_FUNCTION(prev) RETURN_FALSE; } - RETURN_ZVAL(*entry, 1, 0); + RETURN_ZVAL_FAST(*entry); } } /* }}} */ @@ -876,7 +876,7 @@ PHP_FUNCTION(next) RETURN_FALSE; } - RETURN_ZVAL(*entry, 1, 0); + RETURN_ZVAL_FAST(*entry); } } /* }}} */ @@ -899,7 +899,7 @@ PHP_FUNCTION(reset) RETURN_FALSE; } - RETURN_ZVAL(*entry, 1, 0); + RETURN_ZVAL_FAST(*entry); } } /* }}} */ @@ -918,7 +918,8 @@ PHP_FUNCTION(current) if (zend_hash_get_current_data(array, (void **) &entry) == FAILURE) { RETURN_FALSE; } - RETURN_ZVAL(*entry, 1, 0); + + RETURN_ZVAL_FAST(*entry); } /* }}} */ @@ -958,7 +959,7 @@ PHP_FUNCTION(min) RETVAL_NULL(); } else { if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), php_array_data_compare, 0, (void **) &result TSRMLS_CC) == SUCCESS) { - RETVAL_ZVAL(*result, 1, 0); + RETVAL_ZVAL_FAST(*result); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element"); RETVAL_FALSE; @@ -978,7 +979,7 @@ PHP_FUNCTION(min) } } - RETVAL_ZVAL(*min, 1, 0); + RETVAL_ZVAL_FAST(*min); } if (args) { @@ -1009,7 +1010,7 @@ PHP_FUNCTION(max) RETVAL_NULL(); } else { if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), php_array_data_compare, 1, (void **) &result TSRMLS_CC) == SUCCESS) { - RETVAL_ZVAL(*result, 1, 0); + RETVAL_ZVAL_FAST(*result); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element"); RETVAL_FALSE; @@ -1029,7 +1030,7 @@ PHP_FUNCTION(max) } } - RETVAL_ZVAL(*max, 1, 0); + RETVAL_ZVAL_FAST(*max); } if (args) { @@ -1955,7 +1956,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) zend_hash_internal_pointer_reset(Z_ARRVAL_P(stack)); } zend_hash_get_current_data(Z_ARRVAL_P(stack), (void **)&val); - RETVAL_ZVAL(*val, 1, 0); + RETVAL_ZVAL_FAST(*val); /* Delete the first or last value */ zend_hash_get_current_key_ex(Z_ARRVAL_P(stack), &key, &key_len, &index, 0, NULL); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index eca7d90368..3e5084e837 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2679,6 +2679,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_unserialize, 0) ZEND_ARG_INFO(0, variable_representation) + ZEND_ARG_INFO(1, consumed) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_usage, 0, 0, 0) diff --git a/ext/standard/credits_ext.h b/ext/standard/credits_ext.h index 2770d162fb..382e70e7d7 100644 --- a/ext/standard/credits_ext.h +++ b/ext/standard/credits_ext.h @@ -42,8 +42,8 @@ CREDIT_LINE("MS SQL", "Frank M. Kromann"); CREDIT_LINE("Multibyte String Functions", "Tsukada Takuya, Rui Hirokawa"); CREDIT_LINE("MySQL driver for PDO", "George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter"); CREDIT_LINE("MySQLi", "Zak Greant, Georg Richter, Andrey Hristov, Ulf Wendel"); -CREDIT_LINE("MySQLnd", "Andrey Hristov, Ulf Wendel, Georg Richter, Johannes Schlueter"); -CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter, Andrey Hristov"); +CREDIT_LINE("MySQLnd", "Andrey Hristov, Ulf Wendel, Georg Richter"); +CREDIT_LINE("MySQL", "Zeev Suraski, Zak Greant, Georg Richter"); CREDIT_LINE("OCI8", "Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong, Christopher Jones, Oracle Corporation"); CREDIT_LINE("ODBC driver for PDO", "Wez Furlong"); CREDIT_LINE("ODBC", "Stig Bakken, Andreas Karajannis, Frank M. Kromann, Daniel R. Kalowsky"); diff --git a/ext/standard/crypt_freesec.h b/ext/standard/crypt_freesec.h index a87663d4fe..860462a2dd 100644 --- a/ext/standard/crypt_freesec.h +++ b/ext/standard/crypt_freesec.h @@ -4,26 +4,13 @@ #define _CRYPT_FREESEC_H #if PHP_WIN32 -# include "win32/php_stdint.h" # ifndef inline # define inline __inline # endif -#else -# include "php_config.h" -# if HAVE_INTTYPES_H -# include <inttypes.h> -# elif HAVE_STDINT_H -# include <stdint.h> -# endif -# ifndef HAVE_UINT32_T -# if SIZEOF_INT == 4 -typedef unsigned int uint32_t; -# elif SIZEOF_LONG == 4 -typedef unsigned long int uint32_t; -# endif -# endif #endif +#include "php_stdint.h" + #define MD5_HASH_MAX_LEN 120 struct php_crypt_extended_data { diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c index d334e3d477..ccfa66bd60 100644 --- a/ext/standard/crypt_sha256.c +++ b/ext/standard/crypt_sha256.c @@ -9,15 +9,9 @@ #include <limits.h> #ifdef PHP_WIN32 -# include "win32/php_stdint.h" # define __alignof__ __alignof # define alloca _alloca #else -# if HAVE_INTTYPES_H -# include <inttypes.h> -# elif HAVE_STDINT_H -# include <stdint.h> -# endif # ifndef HAVE_ALIGNOF # include <stddef.h> # define __alignof__(type) offsetof (struct { char c; type member;}, member) diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c index 0955532131..ebabed9d24 100644 --- a/ext/standard/crypt_sha512.c +++ b/ext/standard/crypt_sha512.c @@ -8,15 +8,9 @@ #include <errno.h> #include <limits.h> #ifdef PHP_WIN32 -# include "win32/php_stdint.h" # define __alignof__ __alignof # define alloca _alloca #else -# if HAVE_INTTYPES_H -# include <inttypes.h> -# elif HAVE_STDINT_H -# include <stdint.h> -# endif # ifndef HAVE_ALIGNOF # include <stddef.h> # define __alignof__(type) offsetof (struct { char c; type member;}, member) diff --git a/ext/standard/css.c b/ext/standard/css.c index d76f9ee662..459a7bfc30 100644 --- a/ext/standard/css.c +++ b/ext/standard/css.c @@ -1,4 +1,4 @@ -/* +/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ @@ -12,7 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Colin Viebrock <colin@easydns.com> | + | Authors: Colin Viebrock <colin@viebrock.ca> | +----------------------------------------------------------------------+ */ @@ -23,25 +23,24 @@ PHPAPI void php_info_print_css(TSRMLS_D) /* {{{ */ { - PUTS("body {background-color: #ffffff; color: #000000;}\n"); - PUTS("body, td, th, h1, h2 {font-family: sans-serif;}\n"); - PUTS("pre {margin: 0px; font-family: monospace;}\n"); - PUTS("a:link {color: #000099; text-decoration: none; background-color: #ffffff;}\n"); + PUTS("body {background-color: #fff; color: #222; font-family: sans-serif;}\n"); + PUTS("pre {margin: 0; font-family: monospace;}\n"); + PUTS("a:link {color: #009; text-decoration: none; background-color: #fff;}\n"); PUTS("a:hover {text-decoration: underline;}\n"); - PUTS("table {border-collapse: collapse;}\n"); + PUTS("table {border-collapse: collapse; border: 0; width: 934px; box-shadow: 1px 2px 3px #ccc;}\n"); PUTS(".center {text-align: center;}\n"); - PUTS(".center table { margin-left: auto; margin-right: auto; text-align: left;}\n"); - PUTS(".center th { text-align: center !important; }\n"); - PUTS("td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}\n"); + PUTS(".center table {margin: 1em auto; text-align: left;}\n"); + PUTS(".center th {text-align: center !important;}\n"); + PUTS("td, th {border: 1px solid #666; font-size: 75%; vertical-align: baseline; padding: 4px 5px;}\n"); PUTS("h1 {font-size: 150%;}\n"); PUTS("h2 {font-size: 125%;}\n"); PUTS(".p {text-align: left;}\n"); - PUTS(".e {background-color: #ccccff; font-weight: bold; color: #000000;}\n"); - PUTS(".h {background-color: #9999cc; font-weight: bold; color: #000000;}\n"); - PUTS(".v {background-color: #cccccc; color: #000000;}\n"); - PUTS(".vr {background-color: #cccccc; text-align: right; color: #000000;}\n"); - PUTS("img {float: right; border: 0px;}\n"); - PUTS("hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}\n"); + PUTS(".e {background-color: #ccf; width: 300px; font-weight: bold;}\n"); + PUTS(".h {background-color: #99c; font-weight: bold;}\n"); + PUTS(".v {background-color: #ddd; max-width: 300px; overflow-x: auto;}\n"); + PUTS(".v i {color: #999;}\n"); + PUTS("img {float: right; border: 0;}\n"); + PUTS("hr {width: 934px; background-color: #ccc; border: 0; height: 1px;}\n"); } /* }}} */ diff --git a/ext/standard/css.h b/ext/standard/css.h index d7275e08ef..0b3ae87cbd 100644 --- a/ext/standard/css.h +++ b/ext/standard/css.h @@ -1,4 +1,4 @@ -/* +/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ @@ -12,7 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Colin Viebrock <colin@easydns.com> | + | Authors: Colin Viebrock <colin@viebrock.ca> | +----------------------------------------------------------------------+ */ diff --git a/ext/standard/dir.c b/ext/standard/dir.c index ef28e9feaf..ca7e576c92 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -491,13 +491,18 @@ PHP_FUNCTION(glob) /* now catch the FreeBSD style of "no matches" */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { no_results: +#ifndef PHP_WIN32 + /* Paths containing '*', '?' and some other chars are + illegal on Windows but legit on other platforms. For + this reason the direct basedir check against the glob + query is senseless on windows. For instance while *.txt + is a pretty valid filename on EXT3, it's invalid on NTFS. */ if (PG(open_basedir) && *PG(open_basedir)) { - struct stat s; - - if (0 != VCWD_STAT(pattern, &s) || S_IFDIR != (s.st_mode & S_IFMT)) { + if (php_check_open_basedir_ex(pattern, 0 TSRMLS_CC)) { RETURN_FALSE; } } +#endif array_init(return_value); return; } diff --git a/ext/standard/file.c b/ext/standard/file.c index ad6bdad34f..1ec6a74f3f 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1284,7 +1284,7 @@ PHPAPI PHP_FUNCTION(fseek) */ /* DEPRECATED APIs: Use php_stream_mkdir() instead */ -PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC) +PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC) { int ret; @@ -1299,7 +1299,7 @@ PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC) return ret; } -PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC) +PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC) { return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC); } @@ -1623,7 +1623,7 @@ PHP_FUNCTION(copy) /* {{{ php_copy_file */ -PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) +PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC) { return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC); } @@ -1631,7 +1631,7 @@ PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) /* {{{ php_copy_file_ex */ -PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC) +PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_flg TSRMLS_DC) { return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC); } @@ -1639,7 +1639,7 @@ PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC) /* {{{ php_copy_file_ctx */ -PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC) +PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC) { php_stream *srcstream = NULL, *deststream = NULL; int ret = FAILURE; diff --git a/ext/standard/file.h b/ext/standard/file.h index 2bcdfd64bf..d6f142a769 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -74,11 +74,11 @@ PHP_MINIT_FUNCTION(user_streams); PHPAPI int php_le_stream_context(TSRMLS_D); PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC); -PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC); -PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC); -PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC); -PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC); -PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC); +PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC); +PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk TSRMLS_DC); +PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC); +PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC); +PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC); PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char, size_t buf_len, char *buf, zval *return_value TSRMLS_DC); PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC); @@ -121,7 +121,7 @@ typedef struct { long default_socket_timeout; char *user_agent; /* for the http wrapper */ char *from_address; /* for the ftp and http wrappers */ - char *user_stream_current_filename; /* for simple recursion protection */ + const char *user_stream_current_filename; /* for simple recursion protection */ php_stream_context *default_context; HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */ HashTable *stream_filters; /* per-request copy of stream_filters_hash */ diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 2713d23f1d..0b40e7319b 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -857,7 +857,7 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ "dev", "ino", "mode", "nlink", "uid", "gid", "rdev", "size", "atime", "mtime", "ctime", "blksize", "blocks" }; - char *local; + const char *local; php_stream_wrapper *wrapper; if (!filename_length) { diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 86975d7f5b..d04ef52be7 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -130,8 +130,9 @@ static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream * /* {{{ php_ftp_fopen_connect */ -static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, - php_stream **preuseid, php_url **presource, int *puse_ssl, int *puse_ssl_on_data TSRMLS_DC) +static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, + char **opened_path, php_stream_context *context, php_stream **preuseid, + php_url **presource, int *puse_ssl, int *puse_ssl_on_data TSRMLS_DC) { php_stream *stream = NULL, *reuseid = NULL; php_url *resource = NULL; @@ -410,7 +411,8 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_ /* {{{ php_fopen_url_wrap_ftp */ -php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) +php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, + int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) { php_stream *stream = NULL, *datastream = NULL; php_url *resource = NULL; @@ -691,7 +693,8 @@ static php_stream_ops php_ftp_dirstream_ops = { /* {{{ php_stream_ftp_opendir */ -php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) +php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, + char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) { php_stream *stream, *reuseid, *datastream = NULL; php_ftp_dirstream_data *dirsdata; @@ -780,7 +783,7 @@ opendir_errexit: /* {{{ php_stream_ftp_url_stat */ -static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) +static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) { php_stream *stream = NULL; php_url *resource = NULL; @@ -903,7 +906,7 @@ stat_errexit: /* {{{ php_stream_ftp_unlink */ -static int php_stream_ftp_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) +static int php_stream_ftp_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { php_stream *stream = NULL; php_url *resource = NULL; @@ -953,7 +956,7 @@ unlink_errexit: /* {{{ php_stream_ftp_rename */ -static int php_stream_ftp_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) +static int php_stream_ftp_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC) { php_stream *stream = NULL; php_url *resource_from = NULL, *resource_to = NULL; @@ -1032,7 +1035,7 @@ rename_errexit: /* {{{ php_stream_ftp_mkdir */ -static int php_stream_ftp_mkdir(php_stream_wrapper *wrapper, char *url, int mode, int options, php_stream_context *context TSRMLS_DC) +static int php_stream_ftp_mkdir(php_stream_wrapper *wrapper, const char *url, int mode, int options, php_stream_context *context TSRMLS_DC) { php_stream *stream = NULL; php_url *resource = NULL; @@ -1126,7 +1129,7 @@ mkdir_errexit: /* {{{ php_stream_ftp_rmdir */ -static int php_stream_ftp_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) +static int php_stream_ftp_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { php_stream *stream = NULL; php_url *resource = NULL; diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index b8676bbba4..8762fa4849 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -80,11 +80,13 @@ #define HTTP_HEADER_FROM 8 #define HTTP_HEADER_CONTENT_LENGTH 16 #define HTTP_HEADER_TYPE 32 +#define HTTP_HEADER_CONNECTION 64 #define HTTP_WRAPPER_HEADER_INIT 1 #define HTTP_WRAPPER_REDIRECTED 2 -php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */ +php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, + char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */ { php_stream *stream = NULL; php_url *resource = NULL; @@ -385,8 +387,6 @@ finish: strlcat(scratch, " HTTP/", scratch_len); strlcat(scratch, protocol_version, scratch_len); strlcat(scratch, "\r\n", scratch_len); - efree(protocol_version); - protocol_version = NULL; } else { strlcat(scratch, " HTTP/1.0\r\n", scratch_len); } @@ -489,6 +489,11 @@ finish: *(s-1) == '\t' || *(s-1) == ' ')) { have_header |= HTTP_HEADER_TYPE; } + if ((s = strstr(tmp, "connection:")) && + (s == tmp || *(s-1) == '\r' || *(s-1) == '\n' || + *(s-1) == '\t' || *(s-1) == ' ')) { + have_header |= HTTP_HEADER_CONNECTION; + } /* remove Proxy-Authorization header */ if (use_proxy && use_ssl && (s = strstr(tmp, "proxy-authorization:")) && (s == tmp || *(s-1) == '\r' || *(s-1) == '\n' || @@ -562,6 +567,16 @@ finish: } } + /* Send a Connection: close header when using HTTP 1.1 or later to avoid + * hanging when the server interprets the RFC literally and establishes a + * keep-alive connection, unless the user specifically requests something + * else by specifying a Connection header in the context options. */ + if (protocol_version && + ((have_header & HTTP_HEADER_CONNECTION) == 0) && + (strncmp(protocol_version, "1.0", MIN(protocol_version_len, 3)) > 0)) { + php_stream_write_string(stream, "Connection: close\r\n"); + } + if (context && php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS && Z_TYPE_PP(ua_zval) == IS_STRING) { @@ -921,7 +936,7 @@ out: } /* }}} */ -php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ +php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ { return php_stream_url_wrap_http_ex(wrapper, path, mode, options, opened_path, context, PHP_URL_REDIRECT_MAX, HTTP_WRAPPER_HEADER_INIT STREAMS_CC TSRMLS_CC); } diff --git a/ext/standard/info.c b/ext/standard/info.c index 48e0e85cc5..cfff023afa 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -1,4 +1,4 @@ -/* +/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ @@ -14,7 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | | Zeev Suraski <zeev@zend.com> | - | Colin Viebrock <colin@easydns.com> | + | Colin Viebrock <colin@viebrock.ca> | +----------------------------------------------------------------------+ */ @@ -67,7 +67,7 @@ static int php_info_print_html_esc(const char *str, int len) /* {{{ */ int written; char *new_str; TSRMLS_FETCH(); - + new_str = php_escape_html_entities((unsigned char *) str, len, &new_len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC); written = php_output_write(new_str, new_len TSRMLS_CC); efree(new_str); @@ -81,11 +81,11 @@ static int php_info_printf(const char *fmt, ...) /* {{{ */ int len, written; va_list argv; TSRMLS_FETCH(); - + va_start(argv, fmt); len = vspprintf(&buf, 0, fmt, argv); va_end(argv); - + written = php_output_write(buf, len TSRMLS_CC); efree(buf); return written; @@ -103,7 +103,7 @@ static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC { char *key; uint len; - + if (ht) { if (zend_hash_num_elements(ht)) { HashPosition pos; @@ -113,7 +113,7 @@ static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC } else { php_info_printf("\nRegistered %s => ", name); } - + zend_hash_internal_pointer_reset_ex(ht, &pos); while (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) { @@ -129,7 +129,7 @@ static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC break; } } - + if (!sapi_module.phpinfo_as_text) { php_info_print("</td></tr>\n"); } @@ -164,10 +164,10 @@ PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* { } } else { if (!sapi_module.phpinfo_as_text) { - php_info_printf("<tr><td>%s</td></tr>\n", zend_module->name); + php_info_printf("<tr><td class=\"v\">%s</td></tr>\n", zend_module->name); } else { php_info_printf("%s\n", zend_module->name); - } + } } } /* }}} */ @@ -212,7 +212,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) php_info_print(name); php_info_print("[\""); - + switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) { case HASH_KEY_IS_STRING: if (!sapi_module.phpinfo_as_text) { @@ -442,7 +442,7 @@ char* php_get_windows_name() sub = "Web Edition"; else sub = "Standard Edition"; } - } + } } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) { @@ -535,7 +535,7 @@ PHPAPI char *php_get_uname(char mode) DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; char ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; - + GetComputerName(ComputerName, &dwSize); if (mode == 's') { @@ -584,7 +584,7 @@ PHPAPI char *php_get_uname(char mode) if (mode == 's') { php_uname = buf.sysname; } else if (mode == 'r') { - snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d.%d", + snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d.%d", buf.netware_major, buf.netware_minor, buf.netware_revision); php_uname = tmp_uname; } else if (mode == 'n') { @@ -674,7 +674,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) char temp_api[10]; php_uname = php_get_uname('a'); - + if (!sapi_module.phpinfo_as_text) { php_info_print_box_start(1); } @@ -698,7 +698,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION); } else { php_info_print_table_row(2, "PHP Version", PHP_VERSION); - } + } php_info_print_box_end(); php_info_print_table_start(); php_info_print_table_row(2, "System", php_uname ); @@ -783,7 +783,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) #else php_info_print_table_row(2, "DTrace Support", "disabled" ); #endif - + php_info_print_stream_hash("PHP Streams", php_stream_get_url_stream_wrappers_hash() TSRMLS_CC); php_info_print_stream_hash("Stream Socket Transports", php_stream_xport_get_hash() TSRMLS_CC); php_info_print_stream_hash("Stream Filters", php_get_stream_filters_hash() TSRMLS_CC); @@ -815,7 +815,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_info_print("<h1>Configuration</h1>\n"); } else { SECTION("Configuration"); - } + } if (!(flag & PHP_INFO_MODULES)) { SECTION("PHP Core"); display_ini_entries(NULL); @@ -889,7 +889,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) } - if ((flag & PHP_INFO_CREDITS) && !sapi_module.phpinfo_as_text) { + if ((flag & PHP_INFO_CREDITS) && !sapi_module.phpinfo_as_text) { php_info_print_hr(); php_print_credits(PHP_CREDITS_ALL & ~PHP_CREDITS_FULLPAGE TSRMLS_CC); } @@ -930,24 +930,24 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) if (!sapi_module.phpinfo_as_text) { php_info_print("</div></body></html>"); - } + } } /* }}} */ PHPAPI void php_info_print_table_start(void) /* {{{ */ { if (!sapi_module.phpinfo_as_text) { - php_info_print("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n"); + php_info_print("<table>\n"); } else { php_info_print("\n"); - } + } } /* }}} */ PHPAPI void php_info_print_table_end(void) /* {{{ */ { if (!sapi_module.phpinfo_as_text) { - php_info_print("</table><br />\n"); + php_info_print("</table>\n"); } } @@ -965,7 +965,7 @@ PHPAPI void php_info_print_box_start(int flag) /* {{{ */ php_info_print("<tr class=\"v\"><td>\n"); } else { php_info_print("\n"); - } + } } } /* }}} */ @@ -998,7 +998,7 @@ PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) /* { } else { spaces = (74 - strlen(header)); php_info_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " "); - } + } } /* }}} */ @@ -1013,7 +1013,7 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) va_start(row_elements, num_cols); if (!sapi_module.phpinfo_as_text) { php_info_print("<tr class=\"h\">"); - } + } for (i=0; i<num_cols; i++) { row_element = va_arg(row_elements, char *); if (!row_element || !*row_element) { @@ -1042,7 +1042,7 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) /* {{{ php_info_print_table_row_internal */ -static void php_info_print_table_row_internal(int num_cols, +static void php_info_print_table_row_internal(int num_cols, const char *value_class, va_list row_elements) { int i; @@ -1050,13 +1050,13 @@ static void php_info_print_table_row_internal(int num_cols, if (!sapi_module.phpinfo_as_text) { php_info_print("<tr>"); - } + } for (i=0; i<num_cols; i++) { if (!sapi_module.phpinfo_as_text) { php_info_printf("<td class=\"%s\">", (i==0 ? "e" : value_class ) ); - } + } row_element = va_arg(row_elements, char *); if (!row_element || !*row_element) { if (!sapi_module.phpinfo_as_text) { @@ -1071,7 +1071,7 @@ static void php_info_print_table_row_internal(int num_cols, php_info_print(row_element); if (i < num_cols-1) { php_info_print(" => "); - } + } } } if (!sapi_module.phpinfo_as_text) { @@ -1091,7 +1091,7 @@ static void php_info_print_table_row_internal(int num_cols, PHPAPI void php_info_print_table_row(int num_cols, ...) { va_list row_elements; - + va_start(row_elements, num_cols); php_info_print_table_row_internal(num_cols, "v", row_elements); va_end(row_elements); @@ -1100,11 +1100,11 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) /* {{{ php_info_print_table_row_ex */ -PHPAPI void php_info_print_table_row_ex(int num_cols, const char *value_class, +PHPAPI void php_info_print_table_row_ex(int num_cols, const char *value_class, ...) { va_list row_elements; - + va_start(row_elements, value_class); php_info_print_table_row_internal(num_cols, value_class, row_elements); va_end(row_elements); @@ -1232,7 +1232,7 @@ PHP_FUNCTION(php_ini_scanned_files) if (zend_parse_parameters_none() == FAILURE) { return; } - + if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) { RETURN_STRING(php_ini_scanned_files, 1); } else { @@ -1248,7 +1248,7 @@ PHP_FUNCTION(php_ini_loaded_file) if (zend_parse_parameters_none() == FAILURE) { return; } - + if (php_ini_opened_path) { RETURN_STRING(php_ini_opened_path, 1); } else { diff --git a/ext/standard/info.h b/ext/standard/info.h index 46a0dfc240..b616204b30 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -1,4 +1,4 @@ -/* +/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ @@ -14,6 +14,7 @@ +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | | Zeev Suraski <zeev@zend.com> | + | Colin Viebrock <colin@viebrock.ca> | +----------------------------------------------------------------------+ */ @@ -22,9 +23,9 @@ #ifndef INFO_H #define INFO_H -#define PHP_ENTRY_NAME_COLOR "#ccccff" -#define PHP_CONTENTS_COLOR "#cccccc" -#define PHP_HEADER_COLOR "#9999cc" +#define PHP_ENTRY_NAME_COLOR "#ccf" +#define PHP_CONTENTS_COLOR "#ccc" +#define PHP_HEADER_COLOR "#99c" #define PHP_INFO_GENERAL (1<<0) #define PHP_INFO_CREDITS (1<<1) @@ -50,9 +51,9 @@ #endif /* HAVE_CREDITS_DEFS */ -#define PHP_LOGO_DATA_URI "data:image/gif;base64,R0lGODlheABDAOZqAH+CuDk3RyglKszN4qGky9PV57K01ENCWIOGuYKDs1JScpCSwsLE3qqs0ExLY1tcg93e7Ds4PG5xpWptnWFjjXV5sXt+teXm8JmcxoyNwbm62Wtrkk5Oa3F0qXp6o4iLvXJ0o3RzmI6QwVpbfuLj73t9raSl0G1wonJ2rJWWyLu92XR4roWIu5KVw9jZ6pKSxGRmkmtun6WozpSWxS4rL1NRaLO012xqjFxbdoqNv2ZolmhqmpyfyDEuOa6w05yczVVWeJ6hypaZxYGCr2dplz89ULy+2l5giZiZyIyOv4mKuldYfLa319XX6CIeIGxvns7Q5L/A3Hd7tHZ4p19efZmZzG5vmHN3riIeH////5COj1lWV8fGx+7u9dXU1fb2+oKAgayqq3Ryc/Hw8Z6cnePi40tISbm4uWdkZYmJtgD/AEdGX9/g7ZuczGlrnG9zp4yMuri52bi615qbzKeqz9vc65qcyWZkhGhniaeo0m5woIuLucbH4MfJ4WlsnJeYyyH5BAEAAGoALAAAAAB4AEMAAAf/gGqCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXlm0/bXOYnp+gP3l5Nj4acUwaGkwGPj4NMgRBPBhCLQtJIjkfGTkiLymgwqENGgx9TQVQUAN9fAxRUSpyrK90sbNCMy26HwgAFhYVVyglFgkZwcPrjCZxfC5sbBAQdS7JA9QysyIf/iwAEQgEQLDgN4LhpKxA8UbCCT87nkwZkoSdRTVBbAxgQ+KCRxIk8jUQskCKyZMoU6pceXJcBwkTduiAQeEIBStDRFzEFIQJFI4eL7gwQqcFy6NIk6K88iYGjCNHHoxYcsSDzp2Qfmh0AYEjBCMEWCgdSzbplRM6HiwBokDBiCkz/7AuMqGhQBMXdQoYSFK2r1+kHWAsUcCBgwM8CeQayhNlAJQCA3zk+LtyAYbLmDF8oJz0DQUFDtasUeBBsZo8Rvj0GcBkBueVH7JwmU2bS5fXSt0sWXPggIMQO91FYcCgAQLcKzFwwcK8uZnbyJN22F2kyJrSw374kGNEBQ8L0VeqINO8uZgC4ZVeeXAgQAAOcECZMMBEDgEA6VcWEFOeORkV+Sn1hgLu9XAHJnPQ4YMBMhwXoEpdmNEfFlwQ8KBSMazRQw8H7FHJDzI00EBJF6YEQBYTYpHFZiUm9UAAGwInSRsE7ONgiycpN6EZX+ColB9F0EADFZHYEQQBM4CH1P8HmTXZJItHqRDGhGJc0CSJLDHp5Jb4jYWCAzQIUMMjSGAQBJRHffBFFmy26eabWXRRQANdolQAGBOSAWebFwxg4UkL7Ckom10M0IBSQAgggAONzCAEBmIpRcByKVZqBhhcfAEgSl1sUWmKNGyhRRldkGjAlJ9OuAUYXnRxKFIjCOAEo4psI8SNSY2X6qdbeAFBlyfu+ikYY2AgxQB4CqtqGQMkNYITTuCQSAoitIBmUhDwp2yKYUBgEgZebJsiGrdd4Km45dHgRbNIrQEtdoX84ctkZX0hIbr9eQGglPjm2wCK/TZHQxl/HhWAEwIsYEg/9JIVW8DlbdHjnRAzp8X/BeFWjIUY0B3VgaxjEpICAh/UOdakO8I5xhnaTugFAZ1OyMWbY3CBRopaZIFqxHCWcca5E5aBJUsKQJsGId7gOpau/YnhLUoLNNAFeRNqwQDA/a2IEgYNfBFB1VloUTW7gBrwRbL9hWGAUjTMOsgfACCgZFnZ5rmpiVl83XQWGZfH40oQAN1czoIzd8baKn0wBs53H7UEtAqrIYIFJpNlr8wFpxS4qjpT+XRKMfd3RhY0BG3sSqGXp0XjLHUA7Q2CsJBQXw9POMa1J23eHxpZoN3cfyoFG3QZE9KQxVGpD846S0W4rUY4c5OFcn8R9MjS5f0RjrlK4BafxRmqXnAU/9blAa8UB070IEgFlDFdHhqfp1R72uQ3d7tK/Pa3Rdhjs4QB8dtTCgWgJYgVUKZu2VueSQwAvqD1rTnV04/vmAOGLBQOC4djCQOo1p/7CZCAKbgC+/yCvfJUiCXJY04EOre7+J0khVgIA+lMtxIAeG1C5CLLAJ0gCBQYsC/C6yDujkWp7PWuassLYnm8AMB0HU8/HCxPGBS4kh0KogMoGCFZdES9J6LkAwXwQun6Q4MxfOGCJ0xJ9yb0vfBxDwJinFD1KncUK6phIVpcWhSZQy4V+FEFEOjCGLQwRtENoH7M8SBK8sczsWWvC38EZBfK4EiZUXEl6FPf8zpwhb7sR/9VWghlKMVwrxSJ4QsEeKAKvWinCWKhghcUlSi1QMphia8szaPVB97Qgb5ESGNo+MICToVDF5rEXBOSYSEDdsqhSed1gkiBBN7wQ6UosV/NPJYrrbYSRGKBiRoDgzD78jgnRO55EujlWNbYLxqcYZxSQGZ/uPCqramSOW0MWATOcAFnss15gnjBCSTQSaUwUlxmIMMYBlCnGXbQn8TUH//wZQYZMoCOSSmaE45GiCGc4A1joZj+ZjlLMnBhDIVCU6BIGkpWnkQFXGDp6C4oBpaG0qQoZcAQpQMyQ6TgBCdQJ1JgyIUL0IMeBfgjAfxpEkAe9aiZA9QAnkqPQy6TOV7/MOpRk+pHAux0LAdL2CGSEIMToAAp10wkU30khQU0sTxZwChy3OUEeBkiAWUtaHLuuUK2sqQBDYxYx/JTTmkpogR5ZclB+WhMv0qBAZVsDhjQE6By0moRiDWrBKvGAMeqRHdSvCRlNHpZRpRgAjHoQB6lQNR6etYkeXPZ6aLTgQNAq7SNSABqJaDFtGJhDGv10QIWx0a5+oUIPYCWYSOhhCdMQLNS+N8Wpktd3r3WntSlLhgG+xoFyEoAMprEC0DghxjwFgAFoCo9EHddKaBXvRBwLWWIcDAnRICjlkiAG1D7htW2168nsK1yQfGCKfgBtar9r19RwAFZOaEI+AWF/xL04IYD91fBJTrBGhzcg/CygwUUPrAEzorh8BzhAIoSQA9gpxgWgGAHbnBDDKhZYsr4gQMBCJMAAsBi0wgiCSUgwg5gPAEa1zgpEyBQD4QkJrv6eBApSIAedEAEIbshqP7F8BuOgOMNLbkIeHjBkxfxAinr4Mxn3sFHSXzdHRxBAe2B0YYOcAMPjfkRL0DAFIgAgz77mQh++KhQ8zMBIjwANNVxj6JxEAI735kSIhjCnilA6UpT+gh9rnCg38BpTkvg058GKlCJcGm2iKY3B6hOEQJwABxsIDGPFkYKPlACEFgBKlB5gK53PZUlrAUIbGkLYQpjmNCcujdFUAAVbjgwBDHHWjEpUAICPOCBDWwgLb4GdrDbQmzDcIAKIxiBFaxQgmY/+9yLEEEaEHAVdLv73fCOd7wDAQA7AA==" -#define PHP_EGG_LOGO_DATA_URI "data:image/gif;base64,R0lGODlheABDAOf/ABIZISAeIhwhLA8jRwYlVSUoLyIpNSkoKwkvbR4tRBUwVDMuNysxOx87Yg89gDo3RTI5SgBCkDg6PDY7RyBCcTxBQz9BVD9ETxxPkQ9SoktIYkROVkpNWDJSeilVhkxObEZTZQVevgBfxVZQZRxcn1BUYFNTc1FXWRZht1ZYVQBm0ghlzBhksVVafyNlqSpkn1hcZwBr2EVfhABs0lRdcF5adRJpyWBcaVlgYl5dh15efh5q0gdw3iFsxhBy2Rtxxhhx0Ttsn2BkigB45SxwtDFwq0dslGNoc1pqfRtz6GRmkypzwFZuiQl772psaWlpiiF25Ax94zB10BB+3iV44BR96yN71TJ5vit7zih73GluoDt6tk53nix66QOG+nBwl0l7r3F2cjOAzSKB9guI9SKC8HF1lW90pm93jTCC3SaE6zWC12F8knR6fHV5gzaC5SmH6ESC3y6H9kGGyiqJ8UuDzXx5oWV9v1aA0nl6qWmAnXl6tHJ8tV6AyVGGuS6K/EyHwyKO/D6J5T+K2SGQ9zqL3ziN9jaP6jmP8WaHwYGCsHqIkC6U/C2V9naFv0GS50mS2IGFuYeHnEWU4iyZ/16P2ISIr1iSz4mLiF2SxV+TvImLlmiSsnqPrIeLvzmc/kOa9Uaa74aNtHWRyXiSvk+a6YyNvIGQwo6OsImTnFib3lKd5l2d2kKi/WSd0k2h9zeo/1Gi8ZSUw5GVyn+czE2m/46bsY2ZyHugwUmr/12n8GCn6pieoGWn5Hekzpueq26n25yby1ms/ICk25ejrlGy/56iymav+V2y+2yv7Wex9KaopWG2/1e5/5Wu2H216265/HW3/qus0aavxWe+/66wvYy33YC4+Hi7+bO0uHPB/aq3wa6112vF/4e/9pfA27u31YDF/XnK/5PG77y/25TI/MDBxYbN/qvH7LfH2qPP+47V/57T/cPN2abT9c3M5Jna/77S7LrU57HV+KLg/7zd+tbb3dbb6a7l/sbh99Hi+Lrp++Pm7+Hx/P3//P///yH5BAEKAP8ALAAAAAB4AEMAAAj+AP8JHEiwoMGDCBMqXMiwocOHECNKnEixosWLFoNpDIaxo8ePwaRJ4yaNHDhw5EySFCnNmEtjt2TJMmXKk01PpmbN+sgTZEly7+7de0eUaMqj4FaKfBlzps1IkfZI3cMnzx5Fnnb23MrQGLig/PgJHTvUZEtjNZ9CXcu2bVSpfPicOaOlrpY8ikxx3fvPGLd3YQOHfUdOWkw+jkaNEjVtquPHkCNLnVtXieUcSr7k5YvRK2DB9wrLctSnUi9dxYpRo6atEy/JsGM7pqskh+0WLXLY0csZYrC/QsOGNubplrNkxWq1Wp6rObNu53y5kU2dupbaLUxob5FHVu+Fxsj+kb3HzdTUc/TonWtWrLnqXMWaiQvnC031+7LPKMn+4YOGJ4p8Z1BJRA0ljSeQ1XMOPOt00wx7xYhDjWrinDNOEFzQwgd+HEamnwkahGiCHQL+QyBR4MgSWzjw0CNOM+4xKN868FhjhB/PqIMON844c8spp6zlSSSexIXYUx06pkULGlhggQZfcObVUdK8FRs70NCzDnvNUeNgN+vQ4w4XfvSizDHIQAMNM8LooosyaWqDDTbhhOPNnc9g88www/RIHH5nMOmkBiT2FNJRxuBXjzAMTghLK/IVAyY843TgAhaHIKIpIXDQgUgjhwjySCijllLKKrqssssuqaqaTDL+e57CYQ4WPPDAB7x15BdKxlgp2zi9JBPLOetQkwsssBTTYDPwwMMOBSRYgQghdMhRxrVl0AHHG9xuO0UWghRSyCOlTCJuIZNAoq4qwMh63xkm2LrAExiFNFKV96GzyyOICPNIOfRQs9wnucCjTTf07OMOBREAQQcZZXhRxcTYUmExFVFEkUUWaXTscRqhlDuIGGJA0ssoHGqhwQILWJCrRPZKo+J9z5xpCBnUNtrKJwTjc4426bHTQQQzVHFtFU00AUUXEw8BxRBUDBHFtnAIksYUVpOLzDGpTjLIIJA40mEOD7AcJczGtORrbJ48E8orn8jhhRyv4AMPMrBQAkv+M14ijI/QRHeBLdJdMA3F0jzwAIUPb2iKCBwbTwHHI6PqEoub6c6xYcoWHHCADhEF49LM1UWyCyigEMIIIYY0EY56xeycCzO5NAP0PoDPEDG2XSR9eBeHQ8GDD3CUk4862AgD+cZZwAHHIY/EEssqkGjeIR8aeD7CQ6L/eZ8jlWg6hxVkQFxFi8bunOze4tCDzzgNOFB0E9c2UcUYSRd++BA++JCFPm5wwjLKcQjnZcEHQJjcuB6BKl2oQmwdMoHnNNAQWdyiV/iJRB2yoAY1vOEFVbBWFegBD3HkYjmtaI+X4PG++PmgfnKIobXKEDWnDWF4abgHBwzgBG/AQXL+kANCGg6RBitYAQtrgMQqVgFBDrXgAAGgoEJkcou1xeYWdZjCFKKghiqQQAr4o0N61hG7T+gtF+IQBz7wYQ0FEG0M12IEz0DBM001QlNU8EEa2nEBA7QBG5ATxLeAgMRChGINP0jkD7AghkQ08T4tCEAAapCQWZhCFgi6zyjWIAhr2MIFQ5DaD4bQBUS4Dx7NeJQZYQGdfdDjGQOIQAzo14h5yCMf+ahHPfIhj3ZsQx7QgMMg2jEBAbQBecd4xSOIuIZmkguJWFDkJWiRJA1IslAFmQVOMkmdSFxiDYfQhz/8gYQodMFpwAsFPlzZjJ0xohVoPMc+4OEKAkSACnL+IMQxsnGBC3DgnyXgwAYusIFslGMV1SjmAU6AAzfwIh3YCMUkelEKcj0CXWuI5hzmYA0ryuYBATiAdwqSlvvwQRVYyMI8xumPVKTBaEgrwzHWCI/YMeKdxdBG+9jBBQJkoAqBQAQ2NlECGJSABjCgwVEDygBzeGMTEyiAAUrQTwYUIAzeCIUtiPGNZ+jCVI9Iww/EcAlX+OIWHDoDFLdHkFkQyaORuURKB5GCaoxTD4gog7WaMAZvjJE9rUjWg9JTKQKggAyMaEQ53FDUauAyl/r4RQkY0AZ+HOECASBGNX7BWAEAYBGlYAJBcRAGTGBiG8oQK1kzwQpSbK46JpD+5MuGBFfI3AELQKBCEAxQgHbYwwWNKB+22JEeF7WHldQIEzy8kQAEZOETO5sHDU5Qgm08QxiNgEMhzFGCAlTgHiWYgATycad52KKYJ3gGCATAgA1woJ8GwEQpevCDQQACEHMwqzPuA0Up/sOttX0MH3oAhBn4wAPTOAANNpEFMuyVfuxoETy6cSxJSXgdroglHGbXCnnQwA1HSIcyJhaFQqSjuwzYBgcYcIRywCENkPhFAQBwAmJ+Nh7TIAYaeAsMIPRADHPwwxKuAAhXkOIUpJNMJAMwUvMEeCoDtsEKVjADEhQgAAIggRrIUIXCNYEM7KARPNIHC3Gs48zhkIH+YUEhDIGlgwM3cIMtjlEFKrzhEe1Y8QIka4BFxEINgngGGjy7iGp4Fhe64Fo8DAAATkyhB1iYQxBcsAQiXGELW8iENcwjmTNIkl7/ePJUPLEEKatABTsAAgUSgAE43OxavVMDO85h5mZANxfJPbM3GoCANLyiGMyAxDQ4AINNWEMYhEDEIdTxiwsU4AhouIAAqoEINWTBGRAAAAC2MWgGJEOZj7hEAgDAhTSgAAtXeIELWMBuEpCACJl2RqIiY4EoCsSkgOjBCmIQgx34GwiF4CAhhHutRqwjjetABnRhQawzZ2IAGXiFMNqjilT8MxvooAYzoMGObBxhAgywBxL++oiODmahE4xmQDuyvQFtvCIUhfCDZzlxiB8sYQ5bIAG7WeBuF5CgCGDwAy6SLJUPBGAB967OKbBggx3wIAYq4PcOfBAFOljdwVXwAjPCcY5uSCgXyulGs8rRAQLUgRlsyoU30MCBEpjjHubYBjGcQGwIpOIeMJjABp5BBzVYAQmePcI0ZkwMbQgjFpDoxKHhIIYrXKEIL3gBEdTtbgz8HNOcgIwSJCmQ18LGE3MAwgpUwIMh8LvfPqBCsgcOMTLQ6WDnmBB75lOODDsgFhpnRivmAYK2X4AGE7hA8IvqhnhUY8Vt8IYa6FAHC2h7G0gAwAbkMQ49pYMGAJAAKwT+MYgrECEIHog8vOHt7hcUYQuZf8zmA/Df6owCC1OOOg/KUIWnx2AIjYCbIT5BBkNwHRoVcg7MkFPUcA7eUHZigAy0Iwy5IA8QAGdHAGJHAAMw4AbbMA+PIAkcMAG8UA5UoAaJwGgXkA7ZJgG8cIK8AAOYlQrmMgiWFgQyAAZbQAQu4AKRB35BEARbgAvqx3n/EBeyUQdSIAKoFgM+MARkoAZPFwWH8AqtMC37Bw3noCZmdg51Uid+AHG6gAwMWAu5sA0TcAMlwA+5VA/zEA/qcAyIUArtQAzEcA/XQAVwgAsW0Ge2IAEAwADvBVAX0AbPUAhgA29GgAZ2wARgAHn+JPACYLAhlsAFXOAr6ycQZ+B5kDEKPzADoxcDw/OBZaAGqfcKyAAKzNEKwhAOycMiB5cM4QAMCuAAk6ANtOOF0PALxOYG/XAMn9B3VmcI1vYK0VAO0QAKQwAH4xAP98APSMBb9rANqbAIbpAK1gU9I+MCWyADViEVXAAGL+ABMiAKsBGJP0iJjnEKYtB0UcdvPEAFj1MGQ6AGsRAO0KANasIMyKAM2nAMUpgMu6AKl0ABCPADCrgzlNAKi1UCJbAJ/SAMhlAG+1M+VJAtjUAIVMADnggEVkAKHCAAOOANwrAL3lAOyhAKhyAujQdvLeAYkZAJWwAGRgAGcGV0SPf+D3twBrBBCz+wbzvQb5rYjocACogQCsKgDcmgDXUiDtCADLrQC7twCYDgARRAAAhgA8sBC59wU69QDzTQdsSQD7kgQkNQBWRAB1FTOFUwAxTpAzbQA53AAABADNAACj8EB8o2koUwB5dABGBwkpDhB2DABeIoFfUmRZ4wF5FhCnNgAyIweudYenCgBqUQC6FwDMpwCZcQDuIgj/QoBhjgAAiAABGAAoeAQq1ACYxACbnQD8SQCr/AD+wACnJgOF0gB0l4Q1BABTuAhFQABGswaAXwDcIACm8ABEAgOWmALqswB98nBJEBhJ32aQIxC3MhjqfwAzbgA5mYOFDzBnD+AIqxIAzQoApqgg0AGA7FgJRr0ANWIIrKwTNVeVOtcA7lwA7qUA6toFdlADwhlIRwIDw8MAO46QOq4EvtgA1PSAVU9i1TAIjdRwQyQJMdsmQjJZOE+RiJgJgr4G85eYRcBAehoAxvogtzIJnHsHU/U570CAqUMJDtGQgsGghyEAipwQgLKTiFwwP0Y3VUUAVQwG/0wz9AEAq6IAwF6gMxMAPDmQZYMDLw9gFJsgf91VZa4KCOIQYhMGX+dkOpJwiv0ITSswu9sAXKoAxrwnVT2Aq0U5Us6gVj4AV/4AVuOgayWQZKMzFQwJD2Uwaf0nemN0sMOQPVyYSgoAZRMAT+MzADWWBESep9QWACSRJbAfAy/6AIUeoYjrAEISACiTkDVAAFHVQ1QJoqqpAJXHAJpRCPxGKFDLgzaKqmY7Cmc+OirZo099llWVcGhNAIPlkFQ5CTE8MDK2ADUfAKjaAGX9mffmoDRyQGRFAEMpAkahUAbAWlkyoVpmCpU9ZviVMFzgMKoTA9quAHIAABMgAJukAnVmh4yqGqjOCmavoHbeqmMeQFhuAFSUM/clAFt5o6N6QCsUkGUGCkbNYKXMY/MxACBktfiiql+AFSInUQplAXm3MLV2ChM8BvnKpsoCA9q8AKIBB8MNAJvYCU0BAOsEg7N0WagcCmf7CmcqP+pl4AMU3AA0nQBHNDBqCAq4SgBjwKMTxgA3Bws2QQCOwIBDZgsCGAAijAAkSgBNV0TQkhqVowFXOgb5m4A3KIOofQravgCv2EBlFxCqzwJtigDfIopGj6B4HgroHACHLQpoaAPxGTOE0gm4QgiohQBToLBS/bBf0JBy5KCOzoA/SFAkeLtCwQBEmyZJSkEHlQF1LhCjeZiUaoBoggCC9WCKWgCRNgBo7BB6OwC8rAdfLoTmzrru46BmjLqknjBUkws0GLq69QbVRQNLLZBLs6BNlSBVNjBT2AtL7LAi7AtE4kSf7FuHWRB7TAdIrJb4VKdVlwCLqgCRcQGZ+rU/D+eEJoOgaBsKauCqdkUK/1ijOgkAtwmUcvVD4xW3p0ADxRAASYerRLkAEZcLgRRLwP0bhaUK02UKinJzwW8wbQK72SMQracK4Tdyw8Q7ot6qJyUK9dVgafAAqxCwdRcIQvS69OYzQ8oAJWWqg2sAQukAFXcI3VcQb1Zm8QIamKMLGYuJMTmXocmgycML2S8QxXCA0a1x7tWQvIgAyyA13r6gVlkITQlSkV/JDcGzx1+nSh5KOEdAUukAj4oQQLIEmLGxGm8AWQ0AP7u2+lJ4eI8AqSKcCScQrnYIXUIAxww6JoGwitADe31go3VZVPyK2QY2CqI1zAMwR0QH+h9IH+U1CckxBk3ghbUHQAZzMRwcAKkXuhBna1r/AmmUDDNUyy2oAMuVCVbfsHhCAHhvAHMbS2awu7W3oIUmADWYAIrdAImlwGjdAIgWAIA2d1zyNRG8uD1KEEIBUAEgCpEjEOa4CJ+5Z6VysM9QgMG/CXUvEM2kANOCwMtcAIaXtT0iw3oMyilEAwuRAKoVBEaTC+ckzNN5VPrEctcNAIo7IKyYDLsKEFJzxJHjEIUubFX6nKbaIMwEADlgAbySMMbCIM0tyiN+WibhrL7vnGsaAMkDAIsXAMwgCUzQE30izN5UMHyQYqDJQMvgAbfPABUBQALvMRqmAFhXqbH6jKDo3+DL2ABJIgGXygDasskC1qCIbwogu8ttCVQuWpDZegCvdYCkRZtlXpYMJl0VGgbJfTC8DwGKjAByrz0QuQyB6RDGlQqM2rBuf8CpezC5xwBPy8xmRwzS4a0HLzou7phWhXjy/ACspQCshAlOGgxmgaCLOJt3J4CKai1L5CK55zAPPCFX/opzPgb1RXy6WwC5oAA9z0GL0Qzg7WtgtsCGlr0+8kDJYdJx6wBazQCw7NDNpQC+tJCSwqm4aAMbU8CaowCuahBR/wAH39AKC2F5NAtBc6dVQXBYJwKq4AA5bwl6uQOgHNrnJQzaBs1gMZ0bmgDcrQAAPgAZcgppg5MIb+cFMQcy1yuAZ9cAd7oAXxsgB9PQLYxBeQUGAVW7H9EwVTcNjAUAJfYBdS6gmlgAhBG7RuSgij3bY2nc21wIC58ArQoAsNoAAYAAbQIJ7Q0B7qKt9VkAXYLRc50Nos490W8ARa8R2qQJ3XqpPEk9DJgARmYBkgXheTeAd9sAZxoAbWPDdqet9yBE8nlAv/TQEUcAWqMLbNDM2fQDl4kN3bnQMmUCtlwzIT7su9AbnzvLw+MAXKgA3JwAZu4FZ5AOJSrgQifgYk3gd4YOLc4jgRLJqX45R2yQp8MgqOsCHX4eNNAuS28gA18AVEXiLleKmJqQIGlgXlus4wQBCmoAjAUT7lII4ZVO7eczHohG4X13EZ2hEiTrLotWIBbR4gJaIQl0C4mBp/SV4KSQkMOIAQ2pQHefAFthHqop4DuIEb2nHq2tEf/REirM7oJqADAFLhkc4QlI6pdH6kupAMu+0QlhQJdmAHX/AF2JEdqJ7qqq4BH6ADuBHseCHrs/4QkEu4iJlqFrkGk8AKrrABPEETkfDmz94RgEC4IWCkVpAG4eKlmiAB377uFeEKS4ACNvADQpQG5LILwMAE7J7vAhEQADs=" -#define ZEND_LOGO_DATA_URI "data:image/gif;base64,R0lGODlhcQBIANUAAA0NDgEDBgIFCS5EXhUdJwUPGgQKER0rOgABAgkZKiZpqxhDbQ0kOwobLQkZKSNgnSBXjh1PghpGchQ2Vx1NfAoaKiJYjQoYJgsaKQECAzdQaS0/UTE1OQUPGAkaKh5ViiFclRpJdQocLSBZjh5UhhpIcw8qQxc+YwwgMwcVIQkaKQgXIwcZJTM6PwIEBRkaGjEyMv9mAP///8zMzMfHx7+/v6urq5KSknNzc1VVVTw8PDc3NyYmJgcHBwMDAwAAACwAAAAAcQBIAAAG/8CZcEgsGo/IpHJ5/DGf0KiU+Ks6p9Kr0KrFer9GbReM7IrJ6O95Zt262durUy5uD8/rtL58h7vlf3+AcHlsdoR7iU12eIhzbXVVfpOTgGOKiWNrkpKUhZ99iJijl4d5kFSdXKmdb6OvsFOXsbS1oba4ubq7vL1DNjg6ODW+xVg3OTw/AisCOMbQSsA6AD8FDAsjIwwv0d5DNcnLIhMU2uclPzbf3jwC2Ofx585MwTfssD8n8vwjKDpLcggo8OMZPkw8GPSTN6HKCxg5hhHJ8WOCv4IHFeEwsDAeiQULJjBYUQXGM4oWtTU0mDGNjR/mOi48gcJKynMrW+oBcFNmP/8SJnri/JFDJ5kaL0T4XLqwYVGjWGy8MFCCqVWGRKFKsQGgAImrYIc+1bqEq9ewaEc0vEc2CdKzacOmY9vWxjoiMAx81Sajr9+/MhaE2Iu2hAAexPraJUbGxo3HkB/f/XKjCgBhwH5kOwcYsAoU5dKSMIBYSN8cOSZvxRGjtevXOnREZDwFhogSE1AYqKIwXl8VBlKoUNHXgAEUJwhfJVGgtGkZsek+Afa6uvUY0bFUjEdhgnJtIUwwmLDAb4cU3tM2pz2jb/YnN67Lr/4eSuWYPkmEGDyiL4MODITgm1+CkdBZgSh00xkMOkiHRHzWxSahDvNJyN4SG6HV1wSfJcf/GWAMdObfCQv8IOILDUoj34QTrhgbS0zAgEJYfqGgQnp8yXACA8N9NkFfHQRX4wl+6cADDH2h6KBdz7jIYosRShjFdmD5B6CAH/JIHkgh9JUCeuXJAOBpPDTYF4MO4mDCAU5KmMMNxNDAWpSx2QdTlTJwiNxeIhbYnwzDZeMlcTLAAAOc7qVIxAsVsrjkdRNCkeFVNd5ImIgqmCDgbyoICiihZd5gQ189KDoDDTcYcN1lE+JAgxE2QCrlEzLi+V+Af+4XpnHCafpnoL8SWugNOwD5gqg4oMbDCtahkAGD9RUBIX2xjbUElUyJ6BcDJoQJ2AldfuppoCJe0IEOB5hw/wIEKFRQnQgesJrDhUTI+iJ8d2arbXGdjhDub6BxOm6nJvzVwMEMSCDBAw+AwIAHr3kgQgdl5vAqEjXYq4NqSeAgAFjd2djjyL7qJ9JwDCQXnq/+mqBpCQXsWIEHKVPwQcMgOOyAaw4k0EAKGCmhsbVKVLbCBFUtte+GC+ylH5df6cffCFIbKAMJJ5A4GARcdz2BA2CH3YAIDABA7y8aO1g0NeOEttDSgLJMowwuh9D13VwDFTbYCZjQMEBIDO3FNACY0NFvwY3M72ZoLWCACRTgLfnXYTPwAQgKmFAUDjjQ1SbHtfXWz29gggSSSHKHRcIKJkAAguR4R/C1CJFD8P+AAiykABoCQrQJoxc4FHC4uPLod+DUfxI4mF8O/AhYgXj/JdjNEUSgwAMY1ECDxjpcDEZl330IrDzapvyViCn7FUD5yXXdWcqXg3D7CdPCNqHaWNSA7YDPIw+kkH1BTo3OA6QA9UUAIvhfCoZEAgj0ZUdhA03tRvAAEvhuDzpQCj8wJTcvgamAVgqYDIQTpgIkcIQfFFOAHCgDBjTPdFvj2gPaRDQy4CBf5JMBr4bTQeINinTe+U0BCiYDBzSgL2BbAAtT4IA+xbBrIODe2cDwghltEIVb8p8PPyWwPxlAAERsgAeQ6AAlklFEDtAUFKNIp9iADlXJQs2bbuA9Jdz/ED/i69eHwgUsTvkFPVb7QQUk0BcPNLGIZWRhEsPFqzTazXUzbKOphBCrNnaujkUwS/jgFqItkqszCKDdGRFpRlJa7VuDiaQliVBJ7t0LVl0JX/K0ZYAuCuyUfrEGBUaZREUmEgL/KiJoIqBKagljCPUz5pN+N4MaxLIj4RmZNINSN/BUE2s86gsADBABEJSgbit7ZDjzFgKRgC1lEJgPdiw2g2Ta70lvOkINeACXhTzNdPgUDAX24zR+asN4MjiSAS73AX5WjZxPhMA9Q/ABdbYGVY1aJuiGsBFZxqUjhhFGDlwgP4aN4HWwC2nXLOjQiLJIInbUy0Wt4pQa2IUH/ydQwARmKr8RiDSkJW3T/TCJMXpadKX/ZEBWKEqAFgDgBjCYgAJAetO75VSZjuKpEuYpgKQBlR8lYqZdhsCBhTG1qSR96pMkREcvUNWq/CBPXOixBA5QIGdN5dpTsTPWBkk1CmftR0N+YACkhUUEgJOGD0jwVa7l7LCvy2ld33TXKeQ1HiuxQQ5eUIUVoEBdS5kAAJ7gghM84G45Y9jtSgCCCHjAA2PzwGHqOqF4KuKxagkaJTmngxcIzycU+AH+iFADFCwVtCAgTwRQEIALQEAEIlBBB15QJtbKZrdpqAEMqhrbGiIThx0pgHWJgAMJ/NawDxhADzj3DBioSwQGAIfADpyLUloIpCbbHQJPlsIAGCxhBxa4HcM6at865qCcRFlsWXORA5MwIYMyWQADBBBfIdzgBRpAwVtvpzkjhCM1lHQMZKb4DY/xozsiEMAPeNDeJNDAMT/YwAkkwICJcpgsL9mMgglyGRxMlAmiAoCN2zIFeoZ4xK6NLo+nYIMX3XjISNZKEAAAOw==" +#define PHP_LOGO_DATA_URI "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHkAAABACAYAAAA+j9gsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAD4BJREFUeNrsnXtwXFUdx8/dBGihmE21QCrQDY6oZZykon/gY5qizjgM2KQMfzFAOioOA5KEh+j4R9oZH7zT6MAMKrNphZFSQreKHRgZmspLHSCJ2Co6tBtJk7Zps7tJs5t95F5/33PvWU4293F29ybdlPzaM3df2XPv+Zzf4/zOuWc1tkjl+T0HQ3SQC6SBSlD6WKN4rusGm9F1ps/o5mPriOf8dd0YoNfi0nt4ntB1PT4zYwzQkf3kR9/sW4xtpS0CmE0SyPUFUJXFMIxZcM0jAZ4xrKMudQT7963HBF0n6EaUjkP0vI9K9OEHWqJLkNW1s8mC2WgVTwGAqWTafJzTWTKZmQuZ/k1MpAi2+eys6mpWfVaAPzcILu8EVKoCAaYFtPxrAXo8qyNwzZc7gSgzgN9Hx0Ecn3j8xr4lyHOhNrlpaJIgptM5DjCdzrJ0Jmce6bWFkOpqs0MErA4gXIBuAmY53gFmOPCcdaTXCbq+n16PPLXjewMfGcgEttECeouTpk5MplhyKsPBTiXNYyULtwIW7Cx1vlwuJyDLR9L0mQiVPb27fhA54yBbGttMpc1OWwF1cmKaH2FSF7vAjGezOZZJZ9j0dIZlMhnuRiToMO0c+N4X7oksasgEt9XS2KZCHzoem2Ixq5zpAuDTqTR14FMslZyepeEI4Ogj26n0vLj33uiigExgMWRpt+CGCsEePZqoePM738BPTaJzT7CpU0nu1yXpAXCC3VeRkCW4bfJYFZo6dmJyQTW2tvZc1nb719iyZWc5fmZ6Osu6H3uVzit52oBnMll2YizGxk8muFZLAshb/YKtzQdcaO3Y2CQ7eiy+YNGvLN+4+nJetm3bxhKJxJz316xZw1pbW9kLew+w1944XBEaPj6eYCeOx1gqNe07bK1MwIDbKcOFOR49GuePT5fcfOMX2drPXcQ0zf7y2tvbWVdXF/v1k2+yQ4dPVpQ5P0Um/NjoCX6UBMFZR6k+u7qMYVBYDIEqBW7eXAfPZX19zp2/oaGBHysNMGTFinPZik9fWggbI5Omb13zUDeB3lLsdwaK/YPeyAFU0i8Aw9/2Dwyx4SPjFQEYUlf3MTYw4Jx7CIVCbHR0oqIDNMD+FMG+ZE0dO/tsHlvAWnYS6H4qjfMC+Zld/wg92/tuv2WeeYT87j+H2aFDxysGLuSy+o/z49DQkONnmpqa2MjRyoYsZOXKGnb5Z+vZqlUrxUsAvI9At/oK+elnBpoNw+Dai9TekSMxDrgSh0KrSYshTprc2NhoRf1JtlikqirAVl98AddsSavDBDrsC+QdT7/TSoB344tzOZ39+70RbporVerqasyw1MEnC8iV6I9VTDi0uqbmfPFSq2W+gyUHXuEdb3WR5rab5jnD3i/BNMN8ChNaqsTiKa55KmBWX+Tuj0XQdQVF307nhTH0CPls+O0UPbaT5TQG/8qX68u6LpV67LQ6dNknaYgaYyPDx2TzvYGCsnhRkH8b/rsF2GDj1MCInkvxvRjOuCUlipWD/zrKx7ZOwBF0vfSSM2ShyaqAAOC1Nw+zt9/5YNbrN1zfwIdpfgnqebv/A6pnWAn4qlW1HPgHQ6OeoG3N9RO/+StMdDtmV2LxJPfBpQCGfwTgrVu38jFrKaW2tpZt2LCBdXR0sEgkwhv21u9cxQsyW3ZB1+DgoOM54btU6tu8eTPr6elhy5fr7IZNDey+e76e9/fCLcAllHpdKKinpaUlX8+111xB9VzNrYxqUAY/XVVVJYMOekLu2fFGM8VWYQRYiYkU9bD4vPlHFYnH4/zvkb1CgwACHgMoUpdyw3sFXcXUh4YHaNSHDqaxdL5jwVTXBpeXVY9oF3RcUQ+O09NT7Cayfld+4RJlP42gTIq8w66Qf/X4a6FTSSMMDcaE/NhYecMM+MdyG90OAhodWoAGkTUaSZByO5WdiA4GqwStrrM6k5vFKEXQserr63l7oR5V0NBojKctaSZtbneErOtGmFxwkGewjk0UzpCUlJSIRqMcjN8CkHLDqyRByq0PEGBBhDmdj7rQVujAaLfrrlk7xyW5gUaxpEtOmOQDr0e799NYmDVBi0+OT7FcbsaXxEQk8qprEBQMBm0vVKUBRcNjskFE8W71lSt79uzhda1d6w4ZGTUUp3NWAQ3TvW/fPvbVq+rZH/ceULOcF1/I06CY3QJohCCzNJnYdgEwwvpUKuNbUsLNpO3evZtfSGHp7+/nS2pw3LLFPVWLoA5yHQUtXvXFYjH+vU4F5yOibzsRUL38MTqC3XWh8GCWziMcDjt2BNEZUIfoUOpJkwvziT3S5ua8Jj/4yD5E0yERbPkhKv4RF4mhkN1wCMHN2rWfYZ2dnWz9+vXchNkJzBoaQ8Bxqg91wWo41YdO2dzczD+3bt06Rw0rBG4nOF8oi9M0Jsw9OgLqQ124BifLgeuHyVbN0NXUrODBmDWxgRR0pNrUYqMNgDOZGZbNzvgCuc4j0kX+GPJ2//CcMagQmKkbrm/knwVEp++SIXulM1+nhj9AY207QRDnpsnye24WA59DkuPlV/5j+z5eB2hE0W1tbTyQdNJmDpksRzFp2E9csFJAboRvDvz8gZdJgw2ek55KZphfAv+Inu8UdKnmkEUHQK93EjEZ4Rbkifq8JiactEpYAy9Nli2Gm6CjIZPn1qlKFWizleOG3BIwdKNZ+KRMxr9VHKvr1NKLXo2BhlAVFRPq1qlWW6MBr3NWyY2rTGXO5ySJlN9uDuiGsV7XTVPtl8CHYGizf/9+V5Om0hAwVV4ahuU8qia03HP26kyqFkMOTudDzjs/P/QKBUiBYa5ZNucfZJUkCG/0IhpCxYyqBF3lnLOII8q1GKqdStQ3rTh5MStwXX5O/nE1metGQzPHUH6JatA1OppQ8u1eUbpX44tO4GY5vM5Z9sduFgOfG1GwUOK6VFzaSAmrWCSfzGCuuT/O+bi6QwRdTtqXN2keJ4/ejgkJ5HedRARkbkGe6ARulgMWQ+Wc3cDAWohhoZdcue7ifJ7crfP6Me8dELd0Mv8U2begC2k9SHd3t+NnNm7cqKwRbiYUkykqvlZlmOYVLIq5bHRep46JzotOc9BhuFc0ZHGLph+CJIaXr1FZSIfxsdBiN1+LpALEK2By61Aqs0rwtV7DNBU3BMCYixYTLU6C8bM5hBwum0k1mesBpmPtlj+qXFenFsAgCVLon9DYeIxUnmh05HCdBIkCVRP6ussiepVZJZXIutCHwt2I0YGY2Kiz3AIyeG5aLNooVULQBbHy1/nAK2oEtEanheil+GO3aFg0FnwSilNC4q6OrXzywc0XCy1WMaFu/tgrCBLRuWpHuP+n1zqmRXFN0GAnwKgHeW1E1C/86UDJHFKptATZMPZTafbLXHtN3OPixKRC4ev4GwB2Gy6JxhQNEYul+KoKp79RMaGqKzy9ovzt27c7pidVZtYAGJMYOP7u6bdK1mLI1GQ+/ogSZBahwKuLO2jSZt0odw65xrUhAMNrZskLsGiIXz72F3bTjV+ixvtbWcMQr3NWCbog5VyXAIy63PLrqpJITIqHkcD9P7suSiYbG53wvTLKDbr8WBbjZqIF4F3PD3ItRn1eQd5CBF3lCM5RAIYfVp0/dgZ8SvbJ2/l8MmlvNw+8qJTjm+drWQwaAXO9KMuWncc1GBMXKkGeV/pU5ZxFIsTvzovOCu3HvDnOE7NTu3rLr+PE8fy6+IEX9947YM4n/+LbPT/88R8QqoYAuVSDrZLFKcYso2AcLBIeGDPu6h3M+yqvIE/4Y6w4LdUfi+jcr86L75KvC9+PcbVfd1hCi6U7Innwk1/+Q5rcoetsdyBg3s9aCmivBsNFifGfG9zCJUFiztmpEXAbqhMgr6SLWBPu9R1enRfm1ktrC6cVYWH+/Mqg43x6sYK1edaCex7vkRZHZkF+6P6NkXvvi/TpLNBUaqTtdcsoLtIrVTcem2EHDh7m2uq0ikMINBvafOmazzt+BkGMW9CF70DndPsOaJqb38Y1oXjdCYHOiqwbPofrKid6thMAlnxxPtMy6w4K0ubNhq73U5wd5PtVleCTd+50D2CEafLloqixyv0ufMcOGq64CVaMYN2119gfAdPpuscKOxWgCMDwxfm0pvzBhx9siRLoFt3ca7Ikf+x2yygaYzHdTSi7IT9y8fMJ2Lpdhg+ZCPA2+f05d1A88mBLHzQaoA1dL6ohVLJGi+1uQj8XQMyHIMgaGT6eDxuozMkD294LRaB7CPI27DLHQSskSFRvGa30O/zndF4fF0DMhwa//9//iZ2DcILqN7xBHn1oUweNn7eJ3WO9QHvdMlrMsphKEj8XQPgpuHVVMtGOgF0hC9CGTqbb2kHOzXx73aKiuiymEv2x22ICMYYeWSALBQ7RQ0fkoZIr4DnRtS3ohzf1dNzTG9d0PcwMLahZO8UyKTMm38wteratSVtkplq4oWj0PcfrEinPhYg14H+hvdIwCVs1bvb6O+UBMYFGl90d0LRGLRDgoHEUwYnXDniQStocTVUwfPLaKQGA/RoWOmkvtnsaG8unK+PWMKlH5e+Lznp03N27RdO0TkxmYNZKszYBlyfI3RpjsQkmMOo8ls4Wsx1EKcEVAEvayyNoeRzsO2RI+93PNRLesGYtNpBhL4l/prlgZz5ob0mbtZVFhWC301d0EuQgAHPgS7D9hssTHKyMbRfLptF213NBDRuoaqxNA2yh2VUBDnxJ1M1yRW6gOgt2x64gqXK7ht1yOWyW1+wl7bYXvhUygQXgit4KuVDuBGzSbA2bmmtayNzpRgJOGu7XosHFChZzvrGTiUKt5UMiVsmbmtsCb3+2lZmwm3hFNsA/CiYdKyfhYx3Aws8urp8nsJM72naGCG8zYwZMecjk/WHVVRbsMwU6tBVQsWJS2sNDlrgVTO0RE/vzKQtuN2+/85k5PxlUaL75D3BZwKss+JUqSFRAO/F7Eqlkmj+2gbrgYE8rZFluu+P3pOGsyWCG/Y9/GR8exC+vYfc5flxgzRdDGsDEz/8AJsxwQcBUKPCtmKOMFJO8OKMgF8r3b3sKkAm69TN+2OZCAm5ID/g9XPypwX29ufWgudq0urrKes/8nPkxgy1bdg6z/or/SFc2mzV/xs+6HwySTmdYJp2dpaWKEregYrVfn9/B0xkD2U6+e+sOaHqImTfLrycUOIZM1hJwC3oemPXbi/y5PnsrJ136bUa8pxu69BklmANWwDRkgR1wmwVaglyi3Nz6JLQ+ZG5NxQsgNdAhmIfJN7wxgoWg9fxzPQ+c/g9YAIXgeUKCyipJO4uR/wswAOIwB/5IgxvbAAAAAElFTkSuQmCC" +#define PHP_EGG_LOGO_DATA_URI "data:image/gif;base64,R0lGODlheQBAAOZ/AB0BAHB0r0xPkMmMdtjXu9CYh2sxAquv1pJsTmUCAKyQaaVnA6lwVYOGvJM1ANvbwYlPMJubzVYCAGgRAJhqLm9BCq99aLetkqpMAKJCAJdvYqtzHZZWAnNsmIUjAHdKNW8bALqST3ABAJpjEVYnA08xU5JLBG1FU8fKtIhcS4d0kYJFBLiQgkABAIQwAd3h0eDm2sXCpdXYxIiKwG05M7CtuH4UAVNGdNPWwJ5dAcB+ZOjv6NrdxqRMAN7ZuH1qeXZYYszQunp9toxRBJ2dz5yHaa6ANoVYHrWgebK54M28jdfbxpGTxpWWyY8tAJqFl6hHANzUr5J+UqOm0Z47AI9eG9LKolo1IEASAkNIjJSczVkUAYyPw1NNTqSdrYNgZ3hMGK9XAa5KAJNKGaGdv3k6BVgZE6BTGmVopNrezIJhNGgeFpJCKFogM9DTvpiQrm1afpiYxZxQClZZmKJSBaNGAWsnItLQscC8p7NaEI47BpdhQGwVFy0bH18LAJmZzCH5BAEAAH8ALAAAAAB5AEAAAAf/gH+Cg4SFhoeIiYIRRERTj48HkgeQU40Rf3FNm5yLEZ+YhnFeTYqmp6ipioyOU5OSSbGys0mTkERaTUxcM729XExMpaCYTTU+NaWqy8yoo3Gtk7SxlGRvT08qPz9f3UBAX0A/KuQNXOfnMw0NQu3t5n+YNQ9RXs33+IOfeFE1B7MHyGTjdoLGGjN+JChcyLChHz981tixQ+MEEDhwOgRoFyAAmo1C3rh5gEdZvpOnHB2Y56ZGkilvfpyws6WFzRYMH+rcOaGnz58+/UwQ2lPiiYxokqLpgIKHlSeXUEolpPLfgRgv8KQw6CdBAoU3cUp4OHanWbNA06aleOIGGjw8/x4gQSOkCZFQU+9FcPWv1hsvBF4g6fpwKNiwDRMvPMu4sdk1F+IqgZNFABoujPDmTemK2pOZWyKnKVK4Z8KwYhXnHLvYsWudSNLQ+5KltoA5Qv7c3axIZSwyKuwstBMkLgKipv2gVpjw9Vm1yNWajv3gAYUtbW7UzoLbLm9DRGAleUIjYQKyCNLwwKEG6OmbzBlLTwtiPlAQ+CdQ5xGiPog1JWwngBCMfKdbZweoUF5ZO8XGwx0QIEcWYqVF9xMILtyHX349bejhh/ghERcPSHjgIYDacdfAJ5t1Np5w551lRwxpLGEFGNG9J5aFaq2wAYge+gQkkBfI9oASZXw4VP+AtaHhHUrhxfIGDa2ZJcEHbvBgI44/6cicWkFWYcSQHE5ApodlxLBEdVasoGRXZjA54G74IPiFYlYisISWN+YoAXxjgbnhBBT0ZyaQQx16JghgBFHdA3dU8eZXEmTX5JPMdPbEGsw15NWnEmjAQ1wQJpCcjjgVxhNQRoRggIb1NafokBMggMMDa95BwZtfgsDkHDMQscxektzZqQSfeoWsskUYecceySrbAgA2MRhtshO0WoYEIng1galDyXpmTwrI8AAPBBBAQYemLXRoAm3Y1oCwqBBLBg2pqdYQC6M+QAAD0f5J4bXRghBCCCssS3CgIPbUrVcX4IruvwG7G6v/QiUIkIUQ9JriSBxt5JvQQoAudMGe/iqQ2HJdUaqYAQeboNBXyi503qz1PfzVGjFInC4CoDaUn8tMzmvKXm/wIYIIEzDdU9AuM3dyXAQM1tByyJJc7UJlGLEBByNrXa1QSlJqEwIEnLsEAVEgIHa1Zo58U8Ybd3wIEW+wYYMHfPftgQ2ABy444HigTIASeizddIw6PV1z1BKUscACOYBwNXxEefjVTWZckLaWBDx7GLXUtlDf6DYFKAAXdg8ShxZxsOGEA7TX7sTtuOeOux6F93uHER444ffwfA8uOAhl5LBB5QnYIILzDzO9oYlDK5uCGwTsuQQOpb5NFKo2aTdH/xOa/bGJFinMXvv66jvQvu28S+wvEnrYjrv77Ot++wqFhrCBCSAI3u36pjsXuGCAfkNC2s4lAxzEYAzG6xDfQGCDpz0kAXzQDhpaxwQtaOB96wuhCGmnh5OtyV9WoID6bjfCEbqgAmBQgxQUoIYKkAALIGwh+xhwh8+thwB4GIP+cHdA3fmNBrUxmiCCMYO/8c2AUDQg3+7nAD1Y8YoXkIHhohAC/OVOh7SjggGwcAUjrIAEN7yhC6gARhGeQQnpekCNcIAD+rURjOIjn/m4oIUTLG1pftjCFu4zqydKEQky0GJ1CJDCvf3NkQSkogNWYAADgEEKBiiDCVZgAgNgqP+NbGSjHhT4uTm6QQE5vGPtylAbjkVgFypQWAKmBYDSoQZrCtFAIlHmgygowQM6+9QfB5dJTnLABENYAAdykIMVlMGTASTeFIXnBAX0sDppSIMM3BAECghQdyS84gipQIUTZGGDfwDGCa5Wy1rS0p3tbOdNUoADLcall1ycwJ/2abMELC0BWzCACUzAzMkpcwQcoMMxDbCFlkXrYR6wQA8/94LtuSEGegPch55oABd0NIDRdEEVkbi6JsyAC21gpzzjyVKWXgEFu6wOPkNwy5IF1Jg5MKgyc8CBZXLgjDWpaQs+cIEoxPEBL3hBA4OABH1m7ZZYiKpUWyBVQYKABNr/CQAvhOBQf4pAJ6wRGE5ustIWZNGe94xCFJCAr5pKIKBlOMIQlpnTyXFgBENg5k9dQIKatNMMNEAAEqxg1AWmAQZL2GYQ9gCod7b0se0MEBp6oQLBCXB4FOxJBSvYpYQgwA27vCc+rRCCD5hBrG8lQRlWMIS5Us6gd6XrT58pyCsUAQlKIGwvCeCD6vAABtrEgRsusIZbQva4tezDbRowgy+Q87nQfa77vjhCJ4whBvVcAsoe4IPu9tIKSkACEsZw1UyWYa50hS1e9brJZ5YBCdxVa3cXeC4YKFW4QUBATZF7XOUKYB3OzYCAB0xgAUe3wASmAhLckN1+ydS7vVXC/wIqUIFiznUIIzBCMimHUMod05mrDQF3e/soXB0Wsfi9QBlq9jaBwROyfagMgKmA4BrbuMBUoAAKGIzWuDy4u0agwAoqvNqecqAKajDA5HiazGNucgWsNcKtSoyrF+xgB4nFQRBQsAf9+S2a1PMQ4CZQwYfE678NCPCN12zjBdezxz5GqhKMgAAwEBkMHEjmCI4wgg0sYAQddjKUh3CEDVghLtrdEwyuHFxu0i/BNM5AdKVbO3LSDnckXccPqFCHTnu6DgMGNZsLfIYY8BjOcYEBEqRAATBU0gAryPMCNkBrP+N1BMoc6KCrQIEi7SkNL1g0lhvIzQuMIdI2FnUGQP/d6Rt/gDszEEIH9NCDalv72tX+tLa3DWoG7PjN2h0VD9QjBSkcwYYGqEAVWjvrWucA0Lh28mqHUIUqKGAJSRU2YokdBDzswQFrbnaoPW1jc86BCe2ggR4GynCGy8EEcpADtieO7TooIAinTvQSYBCDctuQBOmWKwfaTWtAVyGnFAYxvdWAABRc+cr7xq+/HaDsAn9awNyucVb/IIQGlEBRJuooFMtQBhdcUQ9QbnjDHy4HJGCcx4lWtRTUcIU+AMCS6+ZArUsO6MlVGOQkgKEMLwDzRgeh3/+GArc9rfZtt13tOK8DFNhQmxlEINpw8OofFee0n1Rwo5W8KsgreXH/jGd3CaMpQpLRmO5193kDXtvACCjA668N4eNhl2ERkppI/AbhAhAAOIHrQPHSX5vtUDD4JxAuhDbofe+wj33sN1c6P7TcDbiXQRpQUO4roLECZahAax9vBK8hNAdVQOgQKPn7GEoBBdrk5pYVYIdDmcgDRh9oxOVAh+7TYfveD3/45aAdjgmiHR1owetlz/7Zw6cFKbjA2d2QBjyUGwxXgOERKECBIVCA1sW3AYVCAUbQZ3jlTBQGBmBAVGlwdp+HAEFFISBQSURXBkd3gWNgAhmYgQxnTgLABJjwSu1QAgDALe13grH3fmZQBDEQBDJwAWpQQxUGQzBUBZLHa17D/2uUdwRHAAaU9GowpIB4cFFFYAaP9X5YECiD8zyD4zc2YAcaY36L0AAdYXUmmCwoyH4lcyVFgAJFgEaMl3IrMAL1FgL8t3WS11o/CIZYgEZqUAQf4Fjy9H7IkoWyJz6agQntgAbU4k8EQzB/tH4SQC0MgRMfAAFt2IbpBgaERnlqQEMh0CqRRwE5sHzPBIYkcAWl8ydHmC92KHt0wzqFEAFN0A5zgBN/mIrC9EeDaEtjFTljBHL6t39HQGeCFV5IEIn8VwVQdolYAAZGYAC21IoshRjr94nxkgVKNIpcsBFwsCzBpIoPNUvFeBMhcASKGENqoIBgcARqQAEIgAD8h/8AVcCDdvZ1NwQGFIAF7mQTR0g66vdPWPh6WNgGGhMArUMIEdCMQgAHLuCExrNZ7ceJLTVUaOR7QdiNPMhy4RiOu1iOllhJNxRVAIAFQdWJ7uRVgBiNCcAkAcAiiXB3G6ECxyZpk8ZG04VAxIMfVlUfE7AFUZV5e7AHDMAAFnCTLJCTOWkBNbkHEPCTdiaR7EhVQ+mO03JLsiSNXkE3aACSq9CMGwEBUDCVVAkFGHCVVZmVU3lzBQYCZJQCNqkDOjAAZEmWBXCWaHmWAyCWOsCTDIAAKQAGE7kYp0IWwqSUXuEHKYKP5ROSCNcRKQAFYmCVV1mYhjmVhpmYislXYGn/AWwplmWZlgVQlo8pljX5llcQVSAgSbkDkIHzPLJnKXPCDKQoBCMplYqZmqqpmCZwBY3pmGUZmWpplmSpAwzAlpe5B5qIBVQgBoO5lYSZlaJ2kuSkB+YEbflYLxFAhR3xBWcgBqsZnalpAGAZjrc5AJKZnWt5mbfJkzO5m78JnNKplWJQBx+QIk6SnKpQmh0RACmAAdApnfK5AofIcimQAjSJnZJpmxqwBw2JADTplhBgdSQQnlQpn4Q5mBCQIv9FJyeBCdHWER2QAnIQn/KZmnnwAR9wnxrQoRoKlpFpARqQAh9AAynQoXAJljWpiR/AABmglYIZnb6JAQtqGwGA/ylTgQnMCZjPaaEXepUZ+gEacJMpEA5AwKFrWQA8eZ9F2qE3qQE2iYgAcJts8KJZuZq+CQU12iRM4KC8QYo7GgA/sAcx+qMYEAZlkAIsYAE0IA5X0AVF0KFoKaL3+QNv2gU0wAAswAA0AAEf0Ad7oANsQAVZ6aNX6ZtiMAZtYRuX4aUG8glNEKYTegY9YKiqGQYGIKQIoKFf0AU/0KEpYAGTeZ/hqAKe+gUfgAAaYKIWgIhUSqhVGZ+IigFjsKWV0ah9aSCekE6m2Z4d8AUQQAfwGZ1jQKIMsAcc2qEasKEDwABCKqKqOqIpgACOaZt+OpmDGp6I6puKmiK10R2Oqv+rh7B67NCeAfCrM3kGYbCu7LquNokANnmT8moBV8AAa+ma88qTN1kAlgkBGjCZepAB21oHtbqo2zEHaLAi4SquIUmuHfERH9EB3CCOW2cEPXmbY0mWzmqvOnCiZKmTFoAAYymWezAGgcoAhFoHbPABBnuwAWB3jcCw+MAiTBChSqEUErsNnzqvbbmWPmmZNJmxssmvx/oB4AAEbeGt30oXDaAb6imzpEmz5XqzVNsBHUAOKoAN3XCZRWoB2PC124ARAqAx2yEglvGydhEVUPsdoPAHuxChHoEGczC3dFu3c3sbY0u2Zbu3t/ERQnBSaeuUayuzoLAbTcALU6sUdnsSt2Nrt0mxETPABE57Cbmqq4EAADs=" +#define ZEND_LOGO_DATA_URI "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAAvCAYAAADKH9ehAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAEWJJREFUeNrsXQl0VNUZvjNJSAgEAxHCGsNitSBFxB1l0boUW1pp3VAUrKLWKgUPUlEB13K0Yq1alaXWuh5EadWK1F0s1gJaoaCgQDRKBBJDVhKSzPR+zPfg5vLevCUzmZnwvnP+k8ybN3fevfff73/vBAJTHxc+khL5kr6T1ODk5nAgTRTWloghFVtEg/zfh2PkSvq9pJGSKiX9SdKittbJoD/PSYkrJD0vKeB4IsNNotfuUtHk/CM+IvijpF9KGiDpGEkLJZ3lC7qPeKKTpD9IWiDpUOfWPCi61ZeLvD2VIhTwp9QlTjK5NsIXdB/xxHmSpvD/OucWPSAyQw2+LfeG1SbXVra1Tqb785xUaNdMel0g7Iu5V1zPv6dJqpD0kKR/+ILuI55o8oeg1bFT0kWSOkraQxK+oPvw0TZR3ZY758foyQXf//ZxUFh0Q/GEfNf9gHkaJ6m7pHJJSyTt9tnXhxtBR2EGlnHCMbZMaHuHzX19JZ0u6VRJh0k6hM+BpMjnklZIelPSNhff3V5StkNlEWBMFm+3LcC+BW3GuZP2GvfmiEiCCMUzxZIKRGSt9zeML/fdGAW9JB3O8c6SlMZ+b5f0qaQiF7EpnieXY1auvZfG7zhSUk8RSS428F7M5xfsh1eAV/vxOzoq16sklZBqbdpo5H2qDPRQXoP3Ki0+20FSFyrZUgt+Rt/7KH2vZb8/t/iMG2Sy/0dI6sbvgHGoV8a3xErQb5Q0iTfHCplkzlkW7w+VNF3ST7QJUzFK0pVkDFiw+yV95uC7r5Z0k3CW2ApwIkrJ9B9IelfSh2SIlqC/pDFUZAVk0rQoMhk2GYswx+AtWvMKPtcyEckW37pPwsIHNAuBniDpYhEpBMmJwvibJL0gIlVh39r0C8UlczkXQ/mM6OtEzuf3RfPVAxUY47f5PStcGKPxpOMldbbxiBptPMavJX1PuQ/P/olyz12S7rD4PLyqBTQ8gyXVSOot6VK+dxR53wyl7POjkv7pkpcwpleJSCHP4eQjM0BB/ZuG4Hl9EO8mQx4ZQ0FfL+k+k+t4wNlULpkO24IGnSzpQklzKPDRAMvZ1eXz9uXfH/Pvx5Ie44C5zYQXUgDPj6LEnMCQ3AFkjjupjGF9/kJmxPw1oiquz+6dalXcCRSmYxwK0kDSRI71azb3Y+6GiMi6P/5ey3F3YpExjxdQoG61uX8gBetkh2OWFkUIVGUT1pS9yosZNu1nkl8uZH+mikhxkx1wz7mkB0WkXsKJFw1ZuSWKotY9wjNJS6mUy41JK5P0c2qCnBgIeQWZvEK7Dnf6WUljTT5TS7d0KwezkJShdWIeGeuKKJo7FktUQylcl0i6RtL/HH4OjP+wB0UTLTGHfubRDWyi1g7SaoZQ495z9w7RpaHKqHEfLeklEyWzk+7dl3TTu1KQCpV7+pBB4IWstFFAgvOpJnTL6DoW0xPbw3k/nIYkW+kbmHeXhUEABklazrBDBdzTDfyuBo5DPq1eoUk7ZbSk70l6n3MZjUdCDpQvMF/rezn7/hX7Xs8wsj/7rsrWdQxnZtrwwENUosJkDDZxTjOUkEH1ds6lzJyDZzGScRsonGNcMCIG+WgRKTRQ8Su2p7uRi/mlKjZKekREChS2KIOcTvfqp3RZDlM+cxnfv8Thc75Pt8kqo92VzNTbxBqcQlceivAdByHDIxbvFTMOLovyHAGGK3qc/jJDoDc4hpjABzBm4UAglBFqEAOqt8mB29ss4uJnNCHfSK/tVZMYEfMykt7Bcco1eDLDHCT8gmzzRdLHZL6wRSgzg6GIgVl8Xj2uhPA+oQn53yTdK2mVMC8NzuJ8zaSyM/ApxyzWCFJRvUQ3eQ29BTNFcRgt+FTl2g30zDZZtD/ZRMifE5ES6Y9MxqAHQ7XZikI9nd97j5p1f83GZTPr6Crt2sOcOB1zTYT8HrqjVRZx4wbSAt47SXn/YsZV9zp4zuvJgNGQRaszmoN1rBY6IH4dHiVHcA5dZd2zeIbPv8ZBkghYTQFTx/h1WvSz6c3kM5ewGG8Prvxc5DZWS2u+dypnM5Y3sIJMXmbxfXW0misZN56oxITnWsyl2fg+6+C+zWTefMWr68RwaYF271htHBZqCsKqL28wB/ACjYShrE9nUjfWmEU33A7woqbR4k5UlNk4yoYOzOHvtGs30KO1QgnlZC2VohGOIGn7WEvW0ZdoMeCHfBgdo8X++m3V+s2wEHKzJMblJom92+ne2SHDwT1gknUispPpJLrrVZqwLxTmy5F5jOdVS72F/b6UwlbrcEytrD00+a8l/ZUM82jEZd8peu8uNYS8JxNWqis5IYqQCy1rPUULh8Y7fOYal3zzmPb6aJN7zlf+32bBV9ESclNE85WUX4j4oNbl/fM1b2eoxX3jyXNqiDTP4Xe8Rm9ItfSjvAr6DM0d+o5MXW/CuHO0a7eZTLYT3KF9LktYZ/WdCI+IkoV+lFZ6l3J9OF14HdM0F3MrhXxFjJmqhh5FBera24XqxaCqL0UosK97Z2ku+yJaEqf4D62ByoROcjZuN78Xaa9zTBSzKvxvC+vlrmgWVPU2h4j4FCO5lZ+vNBnpYHHfOOX/PfR83eApTaGM8CLop5l88WSLWAOu4AiNme5owcBO1xhlLGO/eGAFkyYqrtFe5zKzqU7KBE5o/BAIiv7VJSK7qV4GhEF1XtSk0YseWl6lWYI+cXj6pigJLkH3Vk0qfebxe4q0JGOGSDxCWn/Nchk9qJgMfGKS87LDes1IHeVW0LszgaC6sPMYE5lBt4CzRcuy4lVMLKlWfWwcJ+YpxtcGjtOYfzRjTgNIlv0rnpyCveeHNFSJ/jUlonH/3nNYqyOU28qYhHOLbzVPqFc81JQDKxnQ5twLdmjfmQzlxU6eoZ/mma3y8D3VonlhUr6bElhMwJ81RseSxW+jfOYULdYGAw5s4WBtpeU0ijKwxnp/HCfn70piCNlMFEUU8/WpmnZe1Bq80r96m5yMkIwx9nnNHTWFs114q0ArM1HsiUY7j5/rKFIThdrrzR7agHyoy9vd3Ag64uEfKa+xjIKlLqtTUBB7FWgJrQ9joFl1d2cQ2wzHaeDXa6/ztO9Wx+OT+FrzSAKuV12ptOZp+ljnaVawk8uxDpnMZXYCGB3PXqe5sl7QQ5ubhhQR9B4mQpvjIR+gJgrbOxV0rK/rVUyXmyRWdI2a2YLEhVP3BwmN9sJ9BtQpKkxiSDOrUeUhaeQaPevKzKQ3oIVTSGatcynoRl29sIkh440a8pURNoz00Ab4Ts1obxCps1FKl8k5IpKbcmsgu6nz6ETQC+iSqoKKOPmVJBmYnDjHX4EozB9s7TgwykkyYS13URAHpmstYIloOP/HEi6Wx5a4+DwSpH2V18tTyHUPm3iQeS1s09ai4/0ntVgNRQmzHTRulGwaQNnei3FgHqPcMBEJlXrNioAaE8AcupKBd7ElBu1uTxCzg+dmKB4TahiQNX/OxssAb00Uzdeci4S3FYhEQdfkWCrc1cI2K+2EDhsP1OUxZGUnOWTmcgphV0UgZ4jUR1hLlBiuJfqJpb61CXimOrq8RqiEeu6TU3iMwdzYgWhUnWHDDKr0ptLar6USqmOfYYiGMMTUN/KgziGVTo+pNJHBBfF0zVAQc6N2DUL+tcO2Yc1Rk2ss+yBmOko43yCSCljJXAWA7PD4eAt6MBy2yiNACRvVVN05t40pPLYPsT+zlRDpOLG/Jt8OSGKhmnBpivV7q/Y6JkucVgkyWKb52rVZwl0tvNDi+AzRvKjfK1Dnjvpd1FhPEc1LBVsbqENXN35cFaPY2BIVGdlWYZKqgPPj/RythNtpcNycpoOxwAae0bGwhAkAQg01cfiDWDRqZtHhCqFQ5FAtOXKXh/Yh6Ci2N5YMUDW2SHg/N3scn02N++cnMIZCBdwS9gtApRxqDc6OlzWtSrdc8cJGlzP5fzZDri1tQNixISWL/5fSQvcVzfe/wzXfSG8Kuw03pHB/t5KMik+EYJ1EC1d0zCw6fofqRI2ZJwpvyxN4uPs0q/6UR2szyESobxatf3aa7jvfrT0DGPNpYV3H3CI0BYLGllQdy7TX14rUP/zzDHpuRp0EPLnJvH68Qij/RXnyIyku5Ea+5S3NO7s01q77eMY1qqY8T7Qs+4qtq+o2UWhjZO6HuWhjJBlZXWbAHvbFSTAxqMW+RbuG3VfviAP36tshujINh6Tr3kE0BNMl5x8Qq6+mVTdwrMlzpRrGaGPzVpw9NDNFngjoFZZzRCS/FRPXHRZT31X2MgfYTQYX1WE1moaaQJfKEFTs/camkXnUwt9YtNWPiuc67VmRlb0yiRgS/cAe7is0QXuTAm9kikM2DNc5OkeGRaMU8tq0TJHbUCOtezMeRfITiSv1PLLbGE5gb/NOB/1AuR1KlLETDltidyR4XIPasyEnc6eIbRa9kfNifFeXJOAnVJBiKfFCvobcLKccLHWojHJpIPH3iXQlpoNLrdcH44sucvmQOHHjZ9rDrGdbixVmbk/XGy4mtiKuoQDjmQpFJLs6wuSZvqKmL0ky6zOZLry+420UKUaue5ooyeqy9+iopgM989cp1Dcp16bSU1tOJbyFyjedTID5wOk6OAUFFXUDKFRLkmBM3xH7fzIJwPLsxexDMWP2b8g38DqN45ywCuH0VNuv+XmjwOYCjtUakbg6AkGlNoQGBMB5A9g8hh2g7zFE2U4F35FxfHfmwwbxcz3Yl32C/oAwPwDAS6UXdpOhXPZ27Trc9R/SLTla0zzGoXl2QAexnLVZJB/CZMpV7HthfL4lJIrb54u+tdv3/rCiSbw+k88yM9ZxXgKwlHmZycq13iSr0KeMHmUZw6r1VICrLT4D5fy4wq/5DAvfjaWC9oAd9KxwTNUJynUjL+EqpwSTME1zOWMBuIxmZ7p9RCsNq+NmdxW09I1MdNkJeYZNHsIt0qKEO2Z4kvmHadS+Xqv2cqzc93rpuhdl54tg2DISuJljBW3uZjMHrAPqHOYK6zPIM23G2+14Rts4cyLbdxo3Y667UskOo/W/m/PwRhQBwZFkT2vXzDbTtLMZCyfP1155bbfDrpjKZoYH41bO+d97jmEgMPVxFMF0iHESIkiNtDhKuwV058cw0dBZNP+lFsSU/6VWf0E4P/x+IF2eJnokr4uW/2jAKPYjjRb7Cxef70c3qsCl0im1Gj/Uu2eF6sWo0rUiTQq7zS+pYjywnXYwcyOZfI4mKgHj9N2ttHqbRfSlQXhjw5XXy4S7ZbzOovkxVRsphHp8ia3HlyleZS1zHcvoVrdjuNFdEe7edGHzSbpSria/WZ3+cxYV5DCx/4w7FUfyfTW0WO+i7x2YrzKUXZFw/sut+OxJDGkHUxEZPwgCquQcIgxZR9oXekDQk8FF60bqwocupaIoEz6EmaC3C+0Ro6Wgp4eb2tpPJqN+4xXFXQ3TfUfCc5PDNnLZDpLIV1NADKyjZa87mHgmWX57bYdIfIY3pdCGf43xQUXI62kBn3fZxi4SPC8crIjDQ4yzFAaz/XcPJn7xf03VRzIB5Z7qCbBzPQi5jga2E9bCD+ELug8ficEZCk/Cmj8Ro3aLtLxDR1/QffhIHNRTUZCf+S5G7SJBp2b7G31B9+EjcVAFEInZQ2LU7jiN1zf4gu7DR+KwTvkfO9bGx6BNnEQ8XXmN5cT3fEH34SNxwN4A9dgknIEwyWNbeRTwV7WYHBVwFQfbwKb7vOUjiYAiKVT1PczXqCLD/n5UbuLcNxTKoCgExSFNmsFCHI6iJBQFnUbqqbWPHyFceDAOrC/oPpIN+FVaVLrNUa6dLPbvoEQdO4pd1OUylBVkCutsOkqosbNvwcE6qL6g+0hG3MY4ejots1pT3kE4P9QDdfuLKeDfHswD6gu6j2TF2yQcLoqEGurre9EdP1QTfmxJRdn0NlrvD+jmY69Egz+UQvxfgAEALJ4EcRDa/toAAAAASUVORK5CYII=" BEGIN_EXTERN_C() PHP_FUNCTION(phpversion); @@ -84,3 +85,4 @@ void register_phpinfo_constants(INIT_FUNC_ARGS); END_EXTERN_C() #endif /* INFO_H */ + diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index f8d7bda482..76f77ebf7b 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -63,6 +63,12 @@ php_stream_ops php_stream_output_ops = { NULL /* set_option */ }; +typedef struct php_stream_input { /* {{{ */ + php_stream **body_ptr; + off_t position; +} php_stream_input_t; +/* }}} */ + static size_t php_stream_input_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */ { return -1; @@ -71,42 +77,36 @@ static size_t php_stream_input_write(php_stream *stream, const char *buf, size_t static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */ { - off_t *position = (off_t*)stream->abstract; - size_t read_bytes = 0; - - if (!stream->eof) { - if (SG(request_info).raw_post_data) { /* data has already been read by a post handler */ - read_bytes = SG(request_info).raw_post_data_length - *position; - if (read_bytes <= count) { - stream->eof = 1; - } else { - read_bytes = count; - } - if (read_bytes) { - memcpy(buf, SG(request_info).raw_post_data + *position, read_bytes); - } - } else if (sapi_module.read_post) { - read_bytes = sapi_module.read_post(buf, count TSRMLS_CC); - if (read_bytes <= 0) { - stream->eof = 1; - read_bytes = 0; - } - /* Increment SG(read_post_bytes) only when something was actually read. */ - SG(read_post_bytes) += read_bytes; - } else { - stream->eof = 1; + php_stream_input_t *input = stream->abstract; + size_t read; + + if (!SG(post_read) && SG(read_post_bytes) < input->position + count) { + /* read requested data from SAPI */ + int read_bytes = sapi_read_post_block(buf, count TSRMLS_CC); + + if (read_bytes > 0) { + php_stream_seek(*input->body_ptr, 0, SEEK_END); + php_stream_write(*input->body_ptr, buf, read_bytes); } } - *position += read_bytes; + php_stream_seek(*input->body_ptr, input->position, SEEK_SET); + read = php_stream_read(*input->body_ptr, buf, count); + + if (!read || read == (size_t) -1) { + stream->eof = 1; + } else { + input->position += read; + } - return read_bytes; + return read; } /* }}} */ static int php_stream_input_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */ { efree(stream->abstract); + stream->abstract = NULL; return 0; } @@ -118,13 +118,27 @@ static int php_stream_input_flush(php_stream *stream TSRMLS_DC) /* {{{ */ } /* }}} */ +static int php_stream_input_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */ +{ + php_stream *inner = stream->abstract; + + if (inner) { + int sought = php_stream_seek(inner, offset, whence); + *newoffset = inner->position; + return sought; + } + + return -1; +} +/* }}} */ + php_stream_ops php_stream_input_ops = { php_stream_input_write, php_stream_input_read, php_stream_input_close, php_stream_input_flush, "Input", - NULL, /* seek */ + php_stream_input_seek, NULL, /* cast */ NULL, /* stat */ NULL /* set_option */ @@ -157,7 +171,8 @@ static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, i } /* }}} */ -php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ +php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, + char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ { int fd = -1; int mode_rw = 0; @@ -203,13 +218,23 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch } if (!strcasecmp(path, "input")) { + php_stream_input_t *input; + if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); } return NULL; } - return php_stream_alloc(&php_stream_input_ops, ecalloc(1, sizeof(off_t)), 0, "rb"); + + input = ecalloc(1, sizeof(*input)); + if (*(input->body_ptr = &SG(request_info).request_body)) { + php_stream_rewind(*input->body_ptr); + } else { + *input->body_ptr = php_stream_temp_create(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE); + } + + return php_stream_alloc(&php_stream_input_ops, input, 0, "rb"); } if (!strcasecmp(path, "stdin")) { @@ -258,8 +283,8 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch fd = dup(STDERR_FILENO); } } else if (!strncasecmp(path, "fd/", 3)) { - char *start, - *end; + const char *start; + char *end; long fildes_ori; int dtablesize; diff --git a/ext/standard/php_fopen_wrappers.h b/ext/standard/php_fopen_wrappers.h index 5f78256bcb..366a1295b3 100644 --- a/ext/standard/php_fopen_wrappers.h +++ b/ext/standard/php_fopen_wrappers.h @@ -23,8 +23,8 @@ #ifndef PHP_FOPEN_WRAPPERS_H #define PHP_FOPEN_WRAPPERS_H -php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); -php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +php_stream *php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); extern PHPAPI php_stream_wrapper php_stream_http_wrapper; extern PHPAPI php_stream_wrapper php_stream_ftp_wrapper; extern php_stream_wrapper php_stream_php_wrapper; diff --git a/ext/standard/string.c b/ext/standard/string.c index b9d7427eb9..2f05b65bb9 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -13,7 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@php.net> | - | Stig Sæther Bakken <ssb@php.net> | + | Stig S�ther Bakken <ssb@php.net> | | Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ @@ -23,11 +23,6 @@ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ #include <stdio.h> -#ifdef PHP_WIN32 -# include "win32/php_stdint.h" -#else -# include <stdint.h> -#endif #include "php.h" #include "php_rand.h" #include "php_string.h" diff --git a/ext/standard/tests/dir/chdir_basic.phpt b/ext/standard/tests/dir/chdir_basic.phpt index 5fc0e5b886..81d3c7c9d1 100644 --- a/ext/standard/tests/dir/chdir_basic.phpt +++ b/ext/standard/tests/dir/chdir_basic.phpt @@ -14,40 +14,40 @@ Test chdir() function : basic functionality echo "*** Testing chdir() : basic functionality ***\n"; $base_dir_path = dirname(__FILE__); -$level_one_dir_name = "level_one"; -$level_one_dir_path = "$base_dir_path/$level_one_dir_name"; +$level1_one_dir_name = "level1_one"; +$level1_one_dir_path = "$base_dir_path/$level1_one_dir_name"; -$level_two_dir_name = "level_two"; -$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name"; +$level1_two_dir_name = "level1_two"; +$level1_two_dir_path = "$base_dir_path/$level1_one_dir_name/$level1_two_dir_name"; // create directories -mkdir($level_one_dir_path); -mkdir($level_two_dir_path); +mkdir($level1_one_dir_path); +mkdir($level1_two_dir_path); echo "\n-- Testing chdir() with absolute path: --\n"; chdir($base_dir_path); -var_dump(chdir($level_one_dir_path)); +var_dump(chdir($level1_one_dir_path)); var_dump(getcwd()); echo "\n-- Testing chdir() with relative paths: --\n"; -var_dump(chdir($level_two_dir_name)); +var_dump(chdir($level1_two_dir_name)); var_dump(getcwd()); ?> ===DONE=== --CLEAN-- <?php $file_path = dirname(__FILE__); -rmdir("$file_path/level_one/level_two"); -rmdir("$file_path/level_one"); +rmdir("$file_path/level1_one/level1_two"); +rmdir("$file_path/level1_one"); ?> --EXPECTF-- *** Testing chdir() : basic functionality *** -- Testing chdir() with absolute path: -- bool(true) -string(%d) "%slevel_one" +string(%d) "%slevel1_one" -- Testing chdir() with relative paths: -- bool(true) -string(%d) "%slevel_one%elevel_two" +string(%d) "%slevel1_one%elevel1_two" ===DONE=== diff --git a/ext/standard/tests/dir/chdir_variation2.phpt b/ext/standard/tests/dir/chdir_variation2.phpt index fa70f9e104..9ca6a97748 100644 --- a/ext/standard/tests/dir/chdir_variation2.phpt +++ b/ext/standard/tests/dir/chdir_variation2.phpt @@ -15,32 +15,32 @@ echo "*** Testing chdir() : usage variations ***\n"; $base_dir_path = dirname(__FILE__); -$level_one_dir_name = "level_one"; -$level_one_dir_path = "$base_dir_path/$level_one_dir_name"; +$level2_one_dir_name = "level2_one"; +$level2_one_dir_path = "$base_dir_path/$level2_one_dir_name"; -$level_two_dir_name = "level_two"; -$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name"; +$level2_two_dir_name = "level2_two"; +$level2_two_dir_path = "$base_dir_path/$level2_one_dir_name/$level2_two_dir_name"; // create directories -mkdir($level_one_dir_path); -mkdir($level_two_dir_path); +mkdir($level2_one_dir_path); +mkdir($level2_two_dir_path); -echo "\n-- \$directory = './level_one': --\n"; +echo "\n-- \$directory = './level2_one': --\n"; var_dump(chdir($base_dir_path)); -var_dump(chdir("./$level_one_dir_name")); +var_dump(chdir("./$level2_one_dir_name")); var_dump(getcwd()); -echo "\n-- \$directory = 'level_one/level_two': --\n"; +echo "\n-- \$directory = 'level2_one/level2_two': --\n"; var_dump(chdir($base_dir_path)); -var_dump(chdir("$level_one_dir_name/$level_two_dir_name")); +var_dump(chdir("$level2_one_dir_name/$level2_two_dir_name")); var_dump(getcwd()); echo "\n-- \$directory = '..': --\n"; var_dump(chdir('..')); var_dump(getcwd()); -echo "\n-- \$directory = 'level_two', '.': --\n"; -var_dump(chdir($level_two_dir_path)); +echo "\n-- \$directory = 'level2_two', '.': --\n"; +var_dump(chdir($level2_two_dir_path)); var_dump(chdir('.')); var_dump(getcwd()); @@ -49,13 +49,13 @@ var_dump(chdir('../')); var_dump(getcwd()); echo "\n-- \$directory = './': --\n"; -var_dump(chdir($level_two_dir_path)); +var_dump(chdir($level2_two_dir_path)); var_dump(chdir('./')); var_dump(getcwd()); -echo "\n-- \$directory = '../../'level_one': --\n"; -var_dump(chdir($level_two_dir_path)); -var_dump(chdir("../../$level_one_dir_name")); +echo "\n-- \$directory = '../../'level2_one': --\n"; +var_dump(chdir($level2_two_dir_path)); +var_dump(chdir("../../$level2_one_dir_name")); var_dump(getcwd()); ?> @@ -63,42 +63,42 @@ var_dump(getcwd()); --CLEAN-- <?php $file_path = dirname(__FILE__); -rmdir("$file_path/level_one/level_two"); -rmdir("$file_path/level_one"); +rmdir("$file_path/level2_one/level2_two"); +rmdir("$file_path/level2_one"); ?> --EXPECTF-- *** Testing chdir() : usage variations *** --- $directory = './level_one': -- +-- $directory = './level2_one': -- bool(true) bool(true) -string(%d) "%slevel_one" +string(%d) "%slevel2_one" --- $directory = 'level_one/level_two': -- +-- $directory = 'level2_one/level2_two': -- bool(true) bool(true) -string(%d) "%slevel_one%elevel_two" +string(%d) "%slevel2_one%elevel2_two" -- $directory = '..': -- bool(true) -string(%d) "%slevel_one" +string(%d) "%slevel2_one" --- $directory = 'level_two', '.': -- +-- $directory = 'level2_two', '.': -- bool(true) bool(true) -string(%d) "%slevel_one%elevel_two" +string(%d) "%slevel2_one%elevel2_two" -- $directory = '../': -- bool(true) -string(%d) "%slevel_one" +string(%d) "%slevel2_one" -- $directory = './': -- bool(true) bool(true) -string(%d) "%slevel_one%elevel_two" +string(%d) "%slevel2_one%elevel2_two" --- $directory = '../../'level_one': -- +-- $directory = '../../'level2_one': -- bool(true) bool(true) -string(%d) "%slevel_one" +string(%d) "%slevel2_one" ===DONE=== diff --git a/ext/standard/tests/file/bug41655_2.phpt b/ext/standard/tests/file/bug41655_2.phpt index d406f1ba04..96f5cc86f0 100644 --- a/ext/standard/tests/file/bug41655_2.phpt +++ b/ext/standard/tests/file/bug41655_2.phpt @@ -5,11 +5,13 @@ open_basedir=/ --FILE-- <?php $dir = dirname(__FILE__); - $a=glob($dir . "/test.*"); + $a=glob($dir . "/test*csv"); print_r($a); ?> --EXPECTF-- Array ( [0] => %stest.csv + [1] => %stest2.csv + [2] => %stest3.csv ) diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index 7ea8d36153..bfa1db9397 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -25,7 +25,7 @@ $space1 = disk_free_space($file_path.$dir); var_dump( $space1 ); $fh = fopen($file_path.$dir."/disk_free_space.tmp", "a"); -$data = str_repeat("x", 4096); +$data = str_repeat("x", 0xffff); fwrite($fh, (binary)$data); fclose($fh); @@ -35,8 +35,10 @@ var_dump( $space2 ); if( $space1 > $space2 ) echo "\n Free Space Value Is Correct\n"; -else +else { echo "\n Free Space Value Is Incorrect\n"; + var_dump($space1, $space2); +} echo "*** Testing with Binary Input ***\n"; var_dump( disk_free_space(b"$file_path") ); diff --git a/ext/standard/tests/file/fopen_include_path.inc b/ext/standard/tests/file/fopen_include_path.inc index 7d6723a815..5bc9b6ce3b 100644 --- a/ext/standard/tests/file/fopen_include_path.inc +++ b/ext/standard/tests/file/fopen_include_path.inc @@ -1,6 +1,6 @@ <?php $pwd = getcwd(); -$f = basename(__FILE__); +$f = basename(current(get_included_files()), ".php"); $dir1 = $pwd."/".$f.".dir1"; $dir2 = $pwd."/".$f.".dir2"; $dir3 = $pwd."/".$f.".dir3"; diff --git a/ext/standard/tests/file/fopen_variation16.phpt b/ext/standard/tests/file/fopen_variation16.phpt index 3f220aa7c0..e14f2e1c16 100644 --- a/ext/standard/tests/file/fopen_variation16.phpt +++ b/ext/standard/tests/file/fopen_variation16.phpt @@ -32,7 +32,7 @@ rmdir($thisTestDir); function runtest() { global $dir1; - $extraDir = "extraDir"; + $extraDir = "extraDir16"; mkdir($dir1.'/'.$extraDir); mkdir($extraDir); diff --git a/ext/standard/tests/file/fopen_variation17.phpt b/ext/standard/tests/file/fopen_variation17.phpt index bc75c11c90..8abae0fbe5 100644 --- a/ext/standard/tests/file/fopen_variation17.phpt +++ b/ext/standard/tests/file/fopen_variation17.phpt @@ -32,7 +32,7 @@ rmdir($thisTestDir); function runtest() { global $dir1; - $extraDir = "extraDir"; + $extraDir = "extraDir17"; mkdir($dir1.'/'.$extraDir); mkdir($extraDir); diff --git a/ext/standard/tests/file/fscanf_variation53.phpt b/ext/standard/tests/file/fscanf_variation53.phpt index b65bccf8fd..a553a96693 100644 --- a/ext/standard/tests/file/fscanf_variation53.phpt +++ b/ext/standard/tests/file/fscanf_variation53.phpt @@ -30,7 +30,7 @@ $counter = 1; foreach($modes as $mode) { // create an empty file - $filename = "$file_path/fscanf_variation52.tmp"; + $filename = "$file_path/fscanf_variation53.tmp"; $file_handle = fopen($filename, "w"); if($file_handle == false) exit("Error:failed to open file $filename"); diff --git a/ext/standard/tests/file/glob_variation3.phpt b/ext/standard/tests/file/glob_variation3.phpt index 9e1e28baf9..c50f8a81b8 100644 --- a/ext/standard/tests/file/glob_variation3.phpt +++ b/ext/standard/tests/file/glob_variation3.phpt @@ -5,15 +5,29 @@ Test glob() function: ensure no platform difference $path = dirname(__FILE__); ini_set('open_basedir', NULL); -var_dump(glob("$path/*.none")); -ini_set('open_basedir', $path); var_dump(glob("$path/*.none")); +var_dump(glob("$path/?.none")); +var_dump(glob("$path/*{hello,world}.none")); +var_dump(glob("$path/*/nothere")); +var_dump(glob("$path/[aoeu]*.none")); +var_dump(glob("$path/directly_not_exists")); +var_dump(empty(ini_get('open_basedir'))); ?> ==DONE== --EXPECT-- array(0) { } -bool(false) +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +bool(true) ==DONE== diff --git a/ext/standard/tests/file/glob_variation4.phpt b/ext/standard/tests/file/glob_variation4.phpt new file mode 100644 index 0000000000..00d8f648aa --- /dev/null +++ b/ext/standard/tests/file/glob_variation4.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test glob() function: ensure no platform difference, variation 2 +--FILE-- +<?php +$path = dirname(__FILE__); + +ini_set('open_basedir', $path); + +var_dump(glob("$path/*.none")); +var_dump(glob("$path/?.none")); +var_dump(glob("$path/*{hello,world}.none")); +var_dump(glob("$path/*/nothere")); +var_dump(glob("$path/[aoeu]*.none")); +var_dump(glob("$path/directly_not_exists")); + +var_dump($path == ini_get('open_basedir')); +?> +==DONE== +--EXPECT-- +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +bool(true) +==DONE== diff --git a/ext/standard/tests/file/glob_variation5.phpt b/ext/standard/tests/file/glob_variation5.phpt new file mode 100644 index 0000000000..10db40099b --- /dev/null +++ b/ext/standard/tests/file/glob_variation5.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test glob() function: ensure no platform difference, variation 3 +--SKIPIF-- +<?php if( substr(PHP_OS, 0, 3) == "WIN" ) {die('skip not valid on Windows');} ?> +--FILE-- +<?php +$path = dirname(__FILE__); + +ini_set('open_basedir', '/tmp'); + +var_dump(glob("$path/*.none")); +var_dump(glob("$path/?.none")); +var_dump(glob("$path/*{hello,world}.none")); +var_dump(glob("$path/*/nothere")); +var_dump(glob("$path/[aoeu]*.none")); +var_dump(glob("$path/directly_not_exists")); + +var_dump('/tmp' == ini_get('open_basedir')); +?> +==DONE== +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +==DONE== diff --git a/ext/standard/tests/file/glob_variation6.phpt b/ext/standard/tests/file/glob_variation6.phpt new file mode 100644 index 0000000000..9cd9c2b353 --- /dev/null +++ b/ext/standard/tests/file/glob_variation6.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test glob() function: ensure no platform difference, variation 4 +--SKIPIF-- +<?php if( substr(PHP_OS, 0, 3) != "WIN" ) {die('skip only valid on Windows');} ?> +--FILE-- +<?php +$path = dirname(__FILE__); + +ini_set('open_basedir', 'c:\\windows'); + +var_dump(glob("$path/*.none")); +var_dump(glob("$path/?.none")); +var_dump(glob("$path/*{hello,world}.none")); +var_dump(glob("$path/*/nothere")); +var_dump(glob("$path/[aoeu]*.none")); +var_dump(glob("$path/directly_not_exists")); + +var_dump('c:\\windows' == ini_get('open_basedir')); +?> +==DONE== +--EXPECT-- +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +bool(true) +==DONE== diff --git a/ext/standard/tests/file/rename_variation1.phpt b/ext/standard/tests/file/rename_variation1.phpt index 0f7321e205..54338d7460 100644 --- a/ext/standard/tests/file/rename_variation1.phpt +++ b/ext/standard/tests/file/rename_variation1.phpt @@ -16,16 +16,16 @@ $file_path = dirname(__FILE__); echo "\n*** Testing rename() : renaming directory across directories ***\n"; $src_dirs = array ( /* Testing simple directory tree */ - "$file_path/rename_variation/", + "$file_path/rename_variation1/", /* Testing a dir with trailing slash */ - "$file_path/rename_variation/", + "$file_path/rename_variation1/", /* Testing dir with double trailing slashes */ - "$file_path//rename_variation//", + "$file_path//rename_variation1//", ); -$dest_dir = "$file_path/rename_variation_dir"; +$dest_dir = "$file_path/rename_variation1_dir"; // create the $dest_dir mkdir($dest_dir); @@ -35,7 +35,7 @@ foreach($src_dirs as $src_dir) { echo "-- Iteration $counter --\n"; // create the src dir - mkdir("$file_path/rename_variation/"); + mkdir("$file_path/rename_variation1/"); // rename the src dir to a new dir in dest dir var_dump( rename($src_dir, $dest_dir."/new_dir") ); // ensure that dir was renamed @@ -52,7 +52,7 @@ echo "Done\n"; --CLEAN-- <?php $file_path = dirname(__FILE__); -rmdir($file_path."/rename_variation_dir"); +rmdir($file_path."/rename_variation1_dir"); ?> --EXPECTF-- *** Testing rename() : renaming directory across directories *** diff --git a/ext/standard/tests/file/rename_variation2-win32.phpt b/ext/standard/tests/file/rename_variation2-win32.phpt index 87f4e7ddb1..9627a9fa53 100644 --- a/ext/standard/tests/file/rename_variation2-win32.phpt +++ b/ext/standard/tests/file/rename_variation2-win32.phpt @@ -15,27 +15,27 @@ if (substr(PHP_OS, 0, 3) != 'WIN') { require dirname(__FILE__).'/file.inc'; $file_path = dirname(__FILE__); -mkdir("$file_path/rename_variation_dir"); +mkdir("$file_path/rename_variation2_dir"); /* Renaming a file and directory to numeric name */ echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n"; -$fp = fopen($file_path."/rename_variation.tmp", "w"); +$fp = fopen($file_path."/rename_variation2.tmp", "w"); fclose($fp); // renaming existing file to numeric name -var_dump( rename($file_path."/rename_variation.tmp", $file_path."/12345") ); +var_dump( rename($file_path."/rename_variation2.tmp", $file_path."/12345") ); // ensure that rename worked fine -var_dump( file_exists($file_path."/rename_variation.tmp" ) ); // expecting false +var_dump( file_exists($file_path."/rename_variation2.tmp" ) ); // expecting false var_dump( file_exists($file_path."/12345" ) ); // expecting true unlink($file_path."/12345"); // renaming a directory to numeric name -var_dump( rename($file_path."/rename_variation_dir/", $file_path."/12345") ); +var_dump( rename($file_path."/rename_variation2_dir/", $file_path."/12345") ); // ensure that rename worked fine -var_dump( file_exists($file_path."/rename_variation_dir" ) ); // expecting false +var_dump( file_exists($file_path."/rename_variation2_dir" ) ); // expecting false var_dump( file_exists($file_path."/12345" ) ); // expecting true rmdir($file_path."/12345"); @@ -45,9 +45,9 @@ echo "Done\n"; --CLEAN-- <?php $file_path = dirname(__FILE__); -unlink($file_path."/rename_variation_link.tmp"); -unlink($file_path."/rename_variation.tmp"); -rmdir($file_path."/rename_variation_dir"); +unlink($file_path."/rename_variation2_link.tmp"); +unlink($file_path."/rename_variation2.tmp"); +rmdir($file_path."/rename_variation2_dir"); ?> --EXPECTF-- *** Testing rename() by renaming a file and directory to numeric name *** diff --git a/ext/standard/tests/file/rename_variation2.phpt b/ext/standard/tests/file/rename_variation2.phpt index fa3ee1e017..1e0a5d9edd 100644 --- a/ext/standard/tests/file/rename_variation2.phpt +++ b/ext/standard/tests/file/rename_variation2.phpt @@ -11,7 +11,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $file_path = dirname(__FILE__); -$dest_dir = "$file_path/rename_variation_dir"; +$dest_dir = "$file_path/rename_variation2_dir"; // create the $dest_dir mkdir($dest_dir); @@ -23,11 +23,11 @@ $filename = $file_path."/rename_variation2.tmp"; var_dump(touch($filename)); // create the soft links to the file -$linkname = $file_path."/rename_variation_soft_link1.tmp"; +$linkname = $file_path."/rename_variation2_soft_link1.tmp"; var_dump(symlink($filename, $linkname)); //rename the link to a new name in the same dir -$dest_linkname = $file_path."/rename_variation_soft_link2.tmp"; +$dest_linkname = $file_path."/rename_variation2_soft_link2.tmp"; var_dump( rename( $linkname, $dest_linkname) ); //ensure that link was renamed clearstatcache(); @@ -35,14 +35,14 @@ var_dump( file_exists($linkname) ); // expecting false var_dump( file_exists($dest_linkname) ); // expecting true // rename a link across dir -var_dump( rename($dest_linkname, $dest_dir."/rename_variation_soft_link2.tmp")); +var_dump( rename($dest_linkname, $dest_dir."/rename_variation2_soft_link2.tmp")); //ensure that link got renamed clearstatcache(); var_dump( file_exists($dest_linkname) ); // expecting false -var_dump( file_exists($dest_dir."/rename_variation_soft_link2.tmp") ); // expecting true +var_dump( file_exists($dest_dir."/rename_variation2_soft_link2.tmp") ); // expecting true // delete the link file now -unlink($dest_dir."/rename_variation_soft_link2.tmp"); +unlink($dest_dir."/rename_variation2_soft_link2.tmp"); echo "Done\n"; ?> @@ -50,7 +50,7 @@ echo "Done\n"; <?php $file_path = dirname(__FILE__); unlink($file_path."/rename_variation2.tmp"); -rmdir($file_path."/rename_variation_dir"); +rmdir($file_path."/rename_variation2_dir"); ?> --EXPECTF-- *** Testing rename() on soft links *** diff --git a/ext/standard/tests/file/rename_variation3.phpt b/ext/standard/tests/file/rename_variation3.phpt index ce8921630b..7c47040729 100644 --- a/ext/standard/tests/file/rename_variation3.phpt +++ b/ext/standard/tests/file/rename_variation3.phpt @@ -11,41 +11,41 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $file_path = dirname(__FILE__); -$dest_dir = "$file_path/rename_variation_dir"; +$dest_dir = "$file_path/rename_variation3_dir"; // create the $dest_dir mkdir($dest_dir); echo "\n*** Testing rename() on hard links ***\n"; -$filename = $file_path."/rename_variation1.tmp"; +$filename = $file_path."/rename_variation31.tmp"; @unlink($filename); var_dump(touch($filename)); -$linkname = $file_path."/rename_variation_hard_link1.tmp"; +$linkname = $file_path."/rename_variation3_hard_link1.tmp"; var_dump(link($filename, $linkname)); //rename the link to a new name in the same dir -$dest_linkname = $file_path."/rename_variation_hard_link2.tmp"; +$dest_linkname = $file_path."/rename_variation3_hard_link2.tmp"; var_dump( rename( $filename, $dest_linkname) ); //ensure that link was renamed var_dump( file_exists($filename) ); // expecting false var_dump( file_exists($dest_linkname) ); // expecting true // rename a hard link across dir -var_dump( rename($dest_linkname, $dest_dir."/rename_variation_hard_link2.tmp") ); +var_dump( rename($dest_linkname, $dest_dir."/rename_variation3_hard_link2.tmp") ); //ensure that link got renamed var_dump( file_exists($dest_linkname) ); // expecting false -var_dump( file_exists($dest_dir."/rename_variation_hard_link2.tmp") ); // expecting true +var_dump( file_exists($dest_dir."/rename_variation3_hard_link2.tmp") ); // expecting true // delete the link file now -unlink($dest_dir."/rename_variation_hard_link2.tmp"); +unlink($dest_dir."/rename_variation3_hard_link2.tmp"); echo "Done\n"; ?> --CLEAN-- <?php $file_path = dirname(__FILE__); -unlink($file_path."/rename_variation_hard_link1.tmp"); -rmdir($file_path."/rename_variation_dir"); +unlink($file_path."/rename_variation3_hard_link1.tmp"); +rmdir($file_path."/rename_variation3_dir"); ?> --EXPECTF-- *** Testing rename() on hard links *** diff --git a/ext/standard/tests/file/rename_variation4.phpt b/ext/standard/tests/file/rename_variation4.phpt index 2965f7534a..69753bc322 100644 --- a/ext/standard/tests/file/rename_variation4.phpt +++ b/ext/standard/tests/file/rename_variation4.phpt @@ -15,22 +15,22 @@ require dirname(__FILE__).'/file.inc'; /* Renaming a file, link and directory to numeric name */ echo "\n*** Testing rename() by renaming a file, link and directory to numeric name ***\n"; -$fp = fopen($file_path."/rename_variation.tmp", "w"); +$fp = fopen($file_path."/rename_variation4.tmp", "w"); fclose($fp); // renaming existing file to numeric name -var_dump( rename($file_path."/rename_variation.tmp", $file_path."/12345") ); +var_dump( rename($file_path."/rename_variation4.tmp", $file_path."/12345") ); // ensure that rename worked fine -var_dump( file_exists($file_path."/rename_variation.tmp" ) ); // expecting false +var_dump( file_exists($file_path."/rename_variation4.tmp" ) ); // expecting false var_dump( file_exists($file_path."/12345" ) ); // expecting true // remove the file unlink($file_path."/12345"); -mkdir($file_path."/rename_variation_dir"); +mkdir($file_path."/rename_variation4_dir"); // renaming a directory to numeric name -var_dump( rename($file_path."/rename_variation_dir/", $file_path."/12345") ); +var_dump( rename($file_path."/rename_variation4_dir/", $file_path."/12345") ); // ensure that rename worked fine -var_dump( file_exists($file_path."/rename_variation_dir" ) ); // expecting false +var_dump( file_exists($file_path."/rename_variation4_dir" ) ); // expecting false var_dump( file_exists($file_path."/12345" ) ); // expecting true echo "Done\n"; diff --git a/ext/standard/tests/file/rename_variation5.phpt b/ext/standard/tests/file/rename_variation5.phpt index bf43e49510..2518cf48ea 100644 --- a/ext/standard/tests/file/rename_variation5.phpt +++ b/ext/standard/tests/file/rename_variation5.phpt @@ -13,14 +13,14 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { and one another */ // create a dir $file_path = dirname(__FILE__); -$dirname = "$file_path/rename_variation_dir"; +$dirname = "$file_path/rename_variation5_dir"; mkdir($dirname); //create a file -$filename = "$file_path/rename_variation.tmp"; +$filename = "$file_path/rename_variation5.tmp"; $fp = fopen($filename, "w"); fclose($fp); // create a link -$linkname = "$file_path/rename_variation_link.tmp"; +$linkname = "$file_path/rename_variation5_link.tmp"; symlink($filename, $linkname); echo "\n-- Renaming link to same link name --\n"; @@ -54,9 +54,9 @@ echo "Done\n"; --CLEAN-- <?php $file_path = dirname(__FILE__); -unlink($file_path."/rename_variation_link.tmp"); -unlink($file_path."/rename_variation.tmp"); -rmdir($file_path."/rename_variation_dir"); +unlink($file_path."/rename_variation5_link.tmp"); +unlink($file_path."/rename_variation5.tmp"); +rmdir($file_path."/rename_variation5_dir"); ?> --EXPECTF-- -- Renaming link to same link name -- diff --git a/ext/standard/tests/http/bug65634.phpt b/ext/standard/tests/http/bug65634.phpt new file mode 100644 index 0000000000..8f358cc6cf --- /dev/null +++ b/ext/standard/tests/http/bug65634.phpt @@ -0,0 +1,81 @@ +--TEST-- +Bug #65634 (HTTP wrapper is very slow with protocol_version 1.1) +--INI-- +allow_url_fopen=1 +--SKIPIF-- +<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?> +--FILE-- +<?php +require 'server.inc'; + +function do_test($version, $connection) { + $options = [ + 'http' => [ + 'protocol_version' => $version, + ], + ]; + + if ($connection) { + $options['http']['header'] = "Connection: $connection"; + } + + $ctx = stream_context_create($options); + + $responses = ["data://text/plain,HTTP/$version 204 No Content\r\n\r\n"]; + $pid = http_server('tcp://127.0.0.1:12342', $responses, $output); + + $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx); + fseek($output, 0, SEEK_SET); + echo stream_get_contents($output); + + http_server_kill($pid); +} + +echo "HTTP/1.0, default behaviour:\n"; +do_test('1.0', null); + +echo "HTTP/1.0, connection: close:\n"; +do_test('1.0', 'close'); + +echo "HTTP/1.0, connection: keep-alive:\n"; +do_test('1.0', 'keep-alive'); + +echo "HTTP/1.1, default behaviour:\n"; +do_test('1.1', null); + +echo "HTTP/1.1, connection: close:\n"; +do_test('1.1', 'close'); + +echo "HTTP/1.1, connection: keep-alive:\n"; +do_test('1.1', 'keep-alive'); +?> +--EXPECT-- +HTTP/1.0, default behaviour: +GET / HTTP/1.0 +Host: 127.0.0.1:12342 + +HTTP/1.0, connection: close: +GET / HTTP/1.0 +Host: 127.0.0.1:12342 +Connection: close + +HTTP/1.0, connection: keep-alive: +GET / HTTP/1.0 +Host: 127.0.0.1:12342 +Connection: keep-alive + +HTTP/1.1, default behaviour: +GET / HTTP/1.1 +Host: 127.0.0.1:12342 +Connection: close + +HTTP/1.1, connection: close: +GET / HTTP/1.1 +Host: 127.0.0.1:12342 +Connection: close + +HTTP/1.1, connection: keep-alive: +GET / HTTP/1.1 +Host: 127.0.0.1:12342 +Connection: keep-alive + diff --git a/ext/standard/tests/serialize/serialization_error_001.phpt b/ext/standard/tests/serialize/serialization_error_001.phpt index da6f50cc02..c6c17512f3 100644 --- a/ext/standard/tests/serialize/serialization_error_001.phpt +++ b/ext/standard/tests/serialize/serialization_error_001.phpt @@ -21,7 +21,7 @@ var_dump( unserialize() ); //Test serialize with one more than the expected number of arguments var_dump( serialize(1,2) ); -var_dump( unserialize(1,2) ); +var_dump( unserialize(1,$x,2) ); echo "Done"; ?> @@ -31,12 +31,12 @@ echo "Done"; Warning: serialize() expects exactly 1 parameter, 0 given in %s on line 16 NULL -Warning: unserialize() expects exactly 1 parameter, 0 given in %s on line 17 +Warning: unserialize() expects at least 1 parameter, 0 given in %s on line 17 bool(false) Warning: serialize() expects exactly 1 parameter, 2 given in %s on line 20 NULL -Warning: unserialize() expects exactly 1 parameter, 2 given in %s on line 21 +Warning: unserialize() expects at most 2 parameters, 3 given in %s on line 21 bool(false) Done diff --git a/ext/standard/tests/serialize/unserialize_consumed.phpt b/ext/standard/tests/serialize/unserialize_consumed.phpt new file mode 100644 index 0000000000..6cc11e273f --- /dev/null +++ b/ext/standard/tests/serialize/unserialize_consumed.phpt @@ -0,0 +1,27 @@ +--TEST-- +Unserialization of partial strings +--FILE-- +<?php +$data = [123,4.56,true]; +$ser = serialize($data); +$serlen = strlen($ser); + +$unser = unserialize($ser, $consumed); +echo "Consume full string: "; +var_dump($serlen == $consumed); +echo "Return original data: "; +var_dump($unser === $data); + +$ser .= "junk\x01data"; +$unser = unserialize($ser, $consumed); +echo "Consume full string(junk): "; +var_dump($serlen == $consumed); +echo "Return original data(junk): "; +var_dump($unser === $data); + +--EXPECT-- +Consume full string: bool(true) +Return original data: bool(true) +Consume full string(junk): bool(true) +Return original data(junk): bool(true) + diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt index 86056114b8..86c9cd77c8 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt @@ -3,7 +3,7 @@ stream_get_meta_data() on a udp socket --FILE-- <?php -$tcp_socket = stream_socket_server('tcp://127.0.0.1:31337'); +$tcp_socket = stream_socket_server('tcp://127.0.0.1:31330'); var_dump(stream_get_meta_data($tcp_socket)); fclose($tcp_socket); diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt index 16b38d9a1b..88d354b378 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt @@ -4,10 +4,10 @@ Testing stream_get_meta_data() "unread_bytes" field on a udp socket <?php /* Setup socket server */ -$server = stream_socket_server('tcp://127.0.0.1:31337'); +$server = stream_socket_server('tcp://127.0.0.1:31331'); /* Connect to it */ -$client = fsockopen('tcp://127.0.0.1:31337'); +$client = fsockopen('tcp://127.0.0.1:31331'); if (!$client) { die("Unable to create socket"); } diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt index d30fec7056..e8e39209c9 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt @@ -4,10 +4,10 @@ Testing stream_get_meta_data() "timed_out" field on a udp socket <?php /* Setup socket server */ -$server = stream_socket_server('tcp://127.0.0.1:31337'); +$server = stream_socket_server('tcp://127.0.0.1:31332'); /* Connect to it */ -$client = fsockopen('tcp://127.0.0.1:31337'); +$client = fsockopen('tcp://127.0.0.1:31332'); if (!$client) { die("Unable to create socket"); } diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt index 0b079ccf7c..5b68eba25d 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt @@ -4,10 +4,10 @@ Testing stream_get_meta_data() "blocked" field on a udp socket <?php /* Setup socket server */ -$server = stream_socket_server('tcp://127.0.0.1:31337'); +$server = stream_socket_server('tcp://127.0.0.1:31333'); /* Connect to it */ -$client = fsockopen('tcp://127.0.0.1:31337'); +$client = fsockopen('tcp://127.0.0.1:31333'); if (!$client) { die("Unable to create socket"); } diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt index f9ef747987..e3f59d10dc 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt @@ -4,10 +4,10 @@ Testing stream_get_meta_data() "eof" field on a udp socket <?php /* Setup socket server */ -$server = stream_socket_server('tcp://127.0.0.1:31337'); +$server = stream_socket_server('tcp://127.0.0.1:31334'); /* Connect to it */ -$client = fsockopen('tcp://127.0.0.1:31337'); +$client = fsockopen('tcp://127.0.0.1:31334'); if (!$client) { die("Unable to create socket"); } diff --git a/ext/standard/tests/url/parse_url_basic_001.phpt b/ext/standard/tests/url/parse_url_basic_001.phpt index 1edc32eaba..4c5b0944c6 100644 --- a/ext/standard/tests/url/parse_url_basic_001.phpt +++ b/ext/standard/tests/url/parse_url_basic_001.phpt @@ -743,6 +743,13 @@ echo "Done"; string(1) ":" } +--> http://::#: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) ":" +} + --> x://::6.5: array(3) { ["scheme"]=> string(1) "x" @@ -856,6 +863,8 @@ echo "Done"; --> http://?: bool(false) +--> http://#: bool(false) + --> http://?:: bool(false) --> http://:?: bool(false) @@ -863,4 +872,4 @@ echo "Done"; --> http://blah.com:123456: bool(false) --> http://blah.com:abcdef: bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_002.phpt b/ext/standard/tests/url/parse_url_basic_002.phpt index 464e977ffc..ed0f08a84f 100644 --- a/ext/standard/tests/url/parse_url_basic_002.phpt +++ b/ext/standard/tests/url/parse_url_basic_002.phpt @@ -96,6 +96,7 @@ echo "Done"; --> x:/blah.com : string(1) "x" --> x://::abc/? : bool(false) --> http://::? : string(4) "http" +--> http://::# : string(4) "http" --> x://::6.5 : string(1) "x" --> http://?:/ : string(4) "http" --> http://@?:/ : string(4) "http" @@ -118,8 +119,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_003.phpt b/ext/standard/tests/url/parse_url_basic_003.phpt index 57f182bfa3..a2bbfa6482 100644 --- a/ext/standard/tests/url/parse_url_basic_003.phpt +++ b/ext/standard/tests/url/parse_url_basic_003.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : NULL --> x://::abc/? : bool(false) --> http://::? : string(1) ":" +--> http://::# : string(1) ":" --> x://::6.5 : string(1) ":" --> http://?:/ : string(1) "?" --> http://@?:/ : string(1) "?" @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_004.phpt b/ext/standard/tests/url/parse_url_basic_004.phpt index 6abf4ed453..839ebee554 100644 --- a/ext/standard/tests/url/parse_url_basic_004.phpt +++ b/ext/standard/tests/url/parse_url_basic_004.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : NULL --> x://::abc/? : bool(false) --> http://::? : NULL +--> http://::# : NULL --> x://::6.5 : int(6) --> http://?:/ : NULL --> http://@?:/ : NULL @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_005.phpt b/ext/standard/tests/url/parse_url_basic_005.phpt index 3bcc89106d..c113461fe7 100644 --- a/ext/standard/tests/url/parse_url_basic_005.phpt +++ b/ext/standard/tests/url/parse_url_basic_005.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : NULL --> x://::abc/? : bool(false) --> http://::? : NULL +--> http://::# : NULL --> x://::6.5 : NULL --> http://?:/ : NULL --> http://@?:/ : string(0) "" @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_006.phpt b/ext/standard/tests/url/parse_url_basic_006.phpt index 741a424a61..24de1cc233 100644 --- a/ext/standard/tests/url/parse_url_basic_006.phpt +++ b/ext/standard/tests/url/parse_url_basic_006.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : NULL --> x://::abc/? : bool(false) --> http://::? : NULL +--> http://::# : NULL --> x://::6.5 : NULL --> http://?:/ : NULL --> http://@?:/ : NULL @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_007.phpt b/ext/standard/tests/url/parse_url_basic_007.phpt index bf8f98042e..d4006879f4 100644 --- a/ext/standard/tests/url/parse_url_basic_007.phpt +++ b/ext/standard/tests/url/parse_url_basic_007.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : string(9) "/blah.com" --> x://::abc/? : bool(false) --> http://::? : NULL +--> http://::# : NULL --> x://::6.5 : NULL --> http://?:/ : string(1) "/" --> http://@?:/ : string(1) "/" @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_008.phpt b/ext/standard/tests/url/parse_url_basic_008.phpt index a61fd06943..b283829c46 100644 --- a/ext/standard/tests/url/parse_url_basic_008.phpt +++ b/ext/standard/tests/url/parse_url_basic_008.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : NULL --> x://::abc/? : bool(false) --> http://::? : NULL +--> http://::# : NULL --> x://::6.5 : NULL --> http://?:/ : NULL --> http://@?:/ : NULL @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/parse_url_basic_009.phpt b/ext/standard/tests/url/parse_url_basic_009.phpt index 5302388f6f..a7d70f34da 100644 --- a/ext/standard/tests/url/parse_url_basic_009.phpt +++ b/ext/standard/tests/url/parse_url_basic_009.phpt @@ -95,6 +95,7 @@ echo "Done"; --> x:/blah.com : NULL --> x://::abc/? : bool(false) --> http://::? : NULL +--> http://::# : NULL --> x://::6.5 : NULL --> http://?:/ : NULL --> http://@?:/ : NULL @@ -117,8 +118,9 @@ echo "Done"; --> http://@:/ : bool(false) --> http://:/ : bool(false) --> http://? : bool(false) +--> http://# : bool(false) --> http://?: : bool(false) --> http://:? : bool(false) --> http://blah.com:123456 : bool(false) --> http://blah.com:abcdef : bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/standard/tests/url/urls.inc b/ext/standard/tests/url/urls.inc index 27521c8520..4192f4a869 100644 --- a/ext/standard/tests/url/urls.inc +++ b/ext/standard/tests/url/urls.inc @@ -75,6 +75,7 @@ $urls = array( 'x:/blah.com', 'x://::abc/?', 'http://::?', +'http://::#', 'x://::6.5', 'http://?:/', 'http://@?:/', @@ -99,6 +100,7 @@ $urls = array( 'http://@:/', 'http://:/', 'http://?', +'http://#', 'http://?:', 'http://:?', 'http://blah.com:123456', @@ -106,4 +108,4 @@ $urls = array( ); -?>
\ No newline at end of file +?> diff --git a/ext/standard/var.c b/ext/standard/var.c index cd868bb50f..c1e7c2f3ee 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -945,7 +945,7 @@ PHP_FUNCTION(serialize) } /* }}} */ -/* {{{ proto mixed unserialize(string variable_representation) +/* {{{ proto mixed unserialize(string variable_representation[, int &consumed]) Takes a string representation of variable and recreates it */ PHP_FUNCTION(unserialize) { @@ -953,8 +953,9 @@ PHP_FUNCTION(unserialize) int buf_len; const unsigned char *p; php_unserialize_data_t var_hash; + zval *consumed = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &buf, &buf_len, &consumed) == FAILURE) { RETURN_FALSE; } @@ -973,6 +974,11 @@ PHP_FUNCTION(unserialize) RETURN_FALSE; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + + if (consumed) { + zval_dtor(consumed); + ZVAL_LONG(consumed, ((char*)p) - buf); + } } /* }}} */ diff --git a/ext/zip/lib/zipconf.h b/ext/zip/lib/zipconf.h index 2b4340c861..646c0bde53 100644 --- a/ext/zip/lib/zipconf.h +++ b/ext/zip/lib/zipconf.h @@ -13,11 +13,7 @@ #define LIBZIP_VERSION_MINOR 10 #define LIBZIP_VERSION_MICRO 0 -#ifdef PHP_WIN32 -#include <win32/php_stdint.h> -#else -#include <inttypes.h> -#endif +#include <php_stdint.h> typedef int8_t zip_int8_t; #define ZIP_INT8_MIN INT8_MIN diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 7297523aaa..969bac1aa6 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -417,7 +417,7 @@ static int php_zip_parse_options(zval *options, long *remove_all_path, ze_zip_object *obj = (ze_zip_object*) zend_object_store_get_object(object TSRMLS_CC); \ intern = obj->za; \ if (!intern) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized Zip object"); \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or uninitialized Zip object"); \ RETURN_FALSE; \ } \ } diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h index 7dd9ff09d0..dace407d14 100644 --- a/ext/zip/php_zip.h +++ b/ext/zip/php_zip.h @@ -81,8 +81,8 @@ typedef struct _ze_zip_object { int filename_len; } ze_zip_object; -php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); -php_stream *php_stream_zip_open(char *filename, char *path, char *mode STREAMS_DC TSRMLS_DC); +php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC TSRMLS_DC); extern php_stream_wrapper php_stream_zip_wrapper; #endif diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index 400edd6e6c..79b54cbbb0 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -185,7 +185,7 @@ php_stream_ops php_stream_zipio_ops = { }; /* {{{ php_stream_zip_open */ -php_stream *php_stream_zip_open(char *filename, char *path, char *mode STREAMS_DC TSRMLS_DC) +php_stream *php_stream_zip_open(const char *filename, const char *path, const char *mode STREAMS_DC TSRMLS_DC) { struct zip_file *zf = NULL; int err = 0; @@ -235,8 +235,8 @@ php_stream *php_stream_zip_open(char *filename, char *path, char *mode STREAMS_D /* {{{ php_stream_zip_opener */ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, - char *path, - char *mode, + const char *path, + const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 6b1d0cd80c..3e4b9381e7 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -58,7 +58,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) 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); +php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); extern php_stream_ops php_stream_gzio_ops; extern php_stream_wrapper php_stream_gzip_wrapper; extern php_stream_filter_factory php_zlib_filter_factory; diff --git a/ext/zlib/tests/bug65391.phpt b/ext/zlib/tests/bug65391.phpt index 3ba5350810..439473fc5d 100644 --- a/ext/zlib/tests/bug65391.phpt +++ b/ext/zlib/tests/bug65391.phpt @@ -25,4 +25,3 @@ Array [2] => Vary: Accept-Encoding ) Done - diff --git a/ext/zlib/tests/gzseek_basic2.phpt b/ext/zlib/tests/gzseek_basic2.phpt index a815b8ff41..82d305d0fb 100644 --- a/ext/zlib/tests/gzseek_basic2.phpt +++ b/ext/zlib/tests/gzseek_basic2.phpt @@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -$f = "temp3.txt.gz"; +$f = "gzseek_basic2.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; @@ -39,4 +39,4 @@ reading the output file This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/zlib/tests/gzseek_variation1.phpt b/ext/zlib/tests/gzseek_variation1.phpt index 301b57d151..b260783f11 100644 --- a/ext/zlib/tests/gzseek_variation1.phpt +++ b/ext/zlib/tests/gzseek_variation1.phpt @@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -$f = "temp3.txt.gz"; +$f = "gzseek_variation1.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; @@ -30,4 +30,4 @@ unlink($f); This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/zlib/tests/gzseek_variation4.phpt b/ext/zlib/tests/gzseek_variation4.phpt index fc641f6c82..3d0cf67ceb 100644 --- a/ext/zlib/tests/gzseek_variation4.phpt +++ b/ext/zlib/tests/gzseek_variation4.phpt @@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -$f = "temp3.txt.gz"; +$f = "gzseek_variation5.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; @@ -39,4 +39,4 @@ reading the output file This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/zlib/tests/gzseek_variation5.phpt b/ext/zlib/tests/gzseek_variation5.phpt index 0167e204c2..93fb19fdbb 100644 --- a/ext/zlib/tests/gzseek_variation5.phpt +++ b/ext/zlib/tests/gzseek_variation5.phpt @@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -$f = "temp3.txt.gz"; +$f = "gzseek_variation5.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; @@ -39,4 +39,4 @@ reading the output file This is the first line. string(40) "0000000000000000000000000000000000000000" This is the second line. -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/zlib/tests/gzseek_variation7.phpt b/ext/zlib/tests/gzseek_variation7.phpt index aab0834652..a365272ba2 100644 --- a/ext/zlib/tests/gzseek_variation7.phpt +++ b/ext/zlib/tests/gzseek_variation7.phpt @@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) { ?> --FILE-- <?php -$f = "temp3.txt.gz"; +$f = "gzseek_variation7.gz"; $h = gzopen($f, 'w'); $str1 = "This is the first line."; $str2 = "This is the second line."; @@ -44,4 +44,4 @@ tell=int(47) reading the output file This is the first line.This is the second line. -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index 1b00eb8713..2fd9dc7766 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -106,7 +106,7 @@ php_stream_ops php_stream_gzio_ops = { NULL /* set_option */ }; -php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, +php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) { struct php_gz_stream_data_t *self; |
