Compare commits

..
155 Commits
Author SHA1 Message Date
SVN Migration 28a2ff8d47 This commit was manufactured by cvs2svn to create tag 'php_4_3_5'. 2004-03-25 13:57:02 +00:00
Ilia Alshanetsky 3263cdd42e Go with 4.3.5 2004-03-25 13:57:01 +00:00
Ilia Alshanetsky c6a2f0628d Prepare NEWS file for 4.3.5 release. 2004-03-23 19:53:27 +00:00
Frank M. Kromann 39dc110f91 MFH Fix for #26589. Crash when selecting many columns of type Money 2004-03-19 18:47:02 +00:00
Greg Beaver a3b179d916 MFH update to 1.3.1dev 2004-03-19 03:16:45 +00:00
Greg Beaver 84b6a9dfb3 MFH new PEAR_ErrorStack and tests 2004-03-19 00:55:53 +00:00
SVN Migration c6b98d3891 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-03-19 00:48:40 +00:00
Ilia Alshanetsky 8621923a5e Back to dev. 2004-03-18 18:02:42 +00:00
Ilia Alshanetsky c096e54196 Go for PHP 4.3.5RC4 2004-03-18 17:17:25 +00:00
Ilia Alshanetsky 663841fd31 MFH: Fixed bug #27633 (Incorrect EOL translation by ftp_get() in ASCII
mode).
2004-03-18 17:15:47 +00:00
Uwe Schindler 02ab9ce41d hint to raise stacksize (bug #27231) 2004-03-18 13:37:41 +00:00
Ard Biesheuvel 442c6c9c6f Added myself 2004-03-18 10:55:35 +00:00
Ilia Alshanetsky 5df1e69be1 MFH: Fixed bug #27300 (Improved regex for pg_convert()). 2004-03-18 01:35:50 +00:00
Pierre Joye f7226bcc2d - Add entry, crash in imagecolortransparent 2004-03-17 17:26:13 +00:00
Pierre Joye 0b9b69be38 - MFH (crash in imagecolortransparent with invalid color index) 2004-03-17 17:25:24 +00:00
Ilia Alshanetsky 5888fd4024 MFH: Fixed bug #27498 (bogus safe_mode error on nonexistent directories for
chdir() and opendir() functions).
2004-03-16 23:23:26 +00:00
Ilia Alshanetsky 1b2b9a6a0d MFH:
Fixed bug #27580 (pre-initialization errors in ap2 handler are not
	being written to vhost error log).
	Stop using depreciated and ignored APLOG_NOERRNO directive.
	Make file not found & directory as script invocation error messages
	more descriptive.
2004-03-16 22:38:17 +00:00
Stanislav Malyshev a207ace664 MFH registry fixes:
fix off-by-one in registry per-dir values
add IniFilePath value for setting php.ini path via registry
2004-03-16 18:27:55 +00:00
Stanislav Malyshev 38b637bdfc MFH: export session globals 2004-03-16 18:21:02 +00:00
Ilia Alshanetsky a96582f13b MFH: Fixed bug #27600 (GCC 3.0.4 does not like __attribute__ directive). 2004-03-16 16:38:00 +00:00
Ilia Alshanetsky 8cf790dea1 MFH: Fixed bug #27559 (Corrected open_basedir resolving logic). 2004-03-16 00:32:09 +00:00
Jay Smith e58b48e89c MFH: Fixed bug #27291 (get_browser matches browscap.ini patterns
incorrectly).
2004-03-15 21:27:01 +00:00
Frank M. Kromann 210d34a088 MFH: Fix for #27594. Comuted columns does not return a column source 2004-03-15 19:45:39 +00:00
Rasmus Lerdorf ed5a974ab0 Forgot to add NEWS entries for these 2004-03-15 18:20:16 +00:00
Jon Parise bb7f2e4210 MFH 1.243:
Fixed crash in php_ini_scanned_files() when no additional INI files were
actually parsed.
2004-03-15 16:39:53 +00:00
foobar 31b2848051 BFN 2004-03-15 16:07:57 +00:00
Zeev Suraski 5ebe7edcb3 Add misisng library path 2004-03-15 10:04:12 +00:00
Ilia Alshanetsky ed68bc6095 Bug fixing news. 2004-03-14 20:12:17 +00:00
Sascha Schumann 6a9e52543b Renaming cvsclean target -- IRIX make seems to ignore the .PHONY target. 2004-03-14 17:43:46 +00:00
foobar f1c31423d7 reorder 2004-03-14 10:45:51 +00:00
Pierre Joye 441dc97d75 - missing restoreAlphaBleding declaration 2004-03-14 00:46:45 +00:00
Pierre Joye 8378373527 - entry for fix #27582 2004-03-13 23:41:00 +00:00
Pierre Joye d76514d892 - MFH bug #27582 (imagefilltoborder crashes) 2004-03-13 23:36:29 +00:00
SVN Migration 2bbfddb533 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-03-13 23:22:57 +00:00
Greg Beaver 85e5585a1c oops 2004-03-13 18:29:29 +00:00
Greg Beaver e6840ed921 fix #1008: safe mode raises warning
fix register_argc_argv in pear.bat
2004-03-13 17:34:36 +00:00
Sara Golemon cb20f5cafe BFN 2004-03-12 21:49:01 +00:00
Ilia Alshanetsky a95a14cebf MFH: Add checks of return values from user callback functions. 2004-03-12 17:43:17 +00:00
Rasmus Lerdorf 8b9cc5ba81 MFH
getopt() doesn't work if variables_order does not include "S" because it
  only looks in $_SERVER for argv.  So, if we don't find argv in $_SERVER
  fall back to looking in the global symbol table where register_argc_argv
  would have put it.
2004-03-12 17:42:09 +00:00
Rasmus Lerdorf 259a07f733 Fix/workaround for http://bugs.php.net/27533 2004-03-12 17:27:55 +00:00
Ilia Alshanetsky a9674113d1 MFH: Fixed bug #22127 (Invalid response code when force-cgi-redirect safety
mechanism is triggered).
2004-03-12 14:07:14 +00:00
Sara Golemon 168786cfcf Test getaddrinfo() for brokenness. Pretend it doesn't exist if it misbehaves. 2004-03-12 00:16:38 +00:00
Sara Golemon 3f43cfbb6a BFN 2004-03-11 18:44:26 +00:00
Moriyoshi Koizumi 93578a5789 - MFH (r-1.212): Revert ini setting patch as I notified in... 2004-03-10 20:56:07 +00:00
Rasmus Lerdorf 89eaec22b5 Make curl_setopt($ch,CURLOPT_RETURNTRANSFER,0) reset the RETURNTRANSFER to
stdout as is implied in the documentation.  Currently it simply does
absolutely nothing and there is no way to reset it to stdout.
2004-03-09 17:06:53 +00:00
foobar a99c6916f3 test for bug #27457 2004-03-09 14:20:14 +00:00
SVN Migration 30c8d9b166 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-03-09 14:19:51 +00:00
foobar 5a6d9048e5 order 2004-03-09 12:52:08 +00:00
Ilia Alshanetsky 0e9275fb37 MFH: Fixed bug #27530 (broken http auth when safe_mode is on and PCRE is
disabled).
2004-03-09 02:24:20 +00:00
Ard Biesheuvel b08b041503 Possible fix for #27408 (wordsize/alignment issue) 2004-03-08 18:52:40 +00:00
Ilia Alshanetsky 9c340ef86f MFH: Fixed bug #27424 (headers missing on flush() in apache 2 SAPIs). 2004-03-08 03:16:13 +00:00
Marcus Boerger baf702a009 MFH: recognize db-4.2.x 2004-03-08 00:01:03 +00:00
Ilia Alshanetsky 65ab4040fc MFH: Fixed bug #27421 (mbstring.func_overload should be system ini setting) 2004-03-06 19:30:35 +00:00
Ilia Alshanetsky c3d0c735b8 MFH: Fixed bug #27460 (base64_decode() does not handle extra padding). 2004-03-06 19:06:12 +00:00
Ilia Alshanetsky 1a5342e468 MFH: Fixed bug #27505 (htmlentities() does not handle BIG5 correctly). 2004-03-06 18:35:53 +00:00
Ilia Alshanetsky eeaaaf7fce Fixed bug #27437 (wrong freetype include inside GD library). 2004-03-06 18:26:06 +00:00
Pierre Joye 5dd18df5eb - Add #27238 entry 2004-03-06 17:47:16 +00:00
Pierre Joye 6deb70d17d - MFH #27238 fix (ilia ok) 2004-03-06 17:41:31 +00:00
Sara Golemon 5babe27344 MFH: Don't rely on ANSI tmpfile(), use the streams layer instead, it'll deal with platform issues. 2004-03-04 22:29:23 +00:00
Christian Stocker ac4adcc2f7 MFH (fix a linefeed problem, if more than one configureoption) 2004-03-04 13:38:10 +00:00
Derick Rethans 46e793d8dc - MFH: Fixed bug #27443 (defined() returns wrong type). 2004-03-01 08:11:46 +00:00
SVN Migration cc2149097f This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-03-01 08:07:26 +00:00
Anil Madhavapeddy cdb852e21f MFH 'pear install -R' fix, ilia@ ok 2004-02-29 15:59:18 +00:00
Ilia Alshanetsky c18cbd0f35 MFH: Remove unused variable. 2004-02-28 22:59:03 +00:00
Ilia Alshanetsky 40fe027642 MFH: Memory allocation check. 2004-02-28 21:00:40 +00:00
Greg Beaver 2184a5a584 MFH 2004-02-27 02:27:12 +00:00
foobar b2f06ce507 Remove bogus test: see bug #20993 2004-02-26 01:07:32 +00:00
foobar 80553d8fc7 typofix 2004-02-26 00:13:02 +00:00
Ilia Alshanetsky 5b4eeb628c MFH: Handle situation where feof() occurs before the HTTP header is
retrieved.
2004-02-26 00:03:57 +00:00
Ilia Alshanetsky 2af0c3bbdf MFH:
Fixed bug #21760 (Use of uninitialized pointer inside php_read()).
	Fixed 3 possible crashes due to integer overflow or invalid user input
	inside the sockets extension.
2004-02-25 22:12:03 +00:00
foobar d4e86c36ed MFH: Test for bug #27395 2004-02-25 18:54:33 +00:00
SVN Migration fe4a118383 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-25 18:54:16 +00:00
foobar ada04f382d MFH: ZTS build fix 2004-02-25 13:20:31 +00:00
foobar e1505662ad MFH: Fixed bug #27384 (unpack() misbehaves with 1 char string). (GeorgeS) 2004-02-25 12:36:24 +00:00
Ilia Alshanetsky 3766f870d4 MFH: Fixed bug #27383 (Potential crash inside fopen_wrapper, while parsing
response code).
2004-02-24 21:53:57 +00:00
Christian Stocker e4c30e6b89 fix for bug 27349 "Invalid parsing of CDATA sections in XSL templates" 2004-02-24 14:26:27 +00:00
foobar 9543e9c111 MFH: - Fixed bug #26005 (Random "cannot change the session ini settings" errors). 2004-02-24 08:49:41 +00:00
Ilia Alshanetsky d0551c2a7c MFH: Fixed bug #27341 (HEAD requests fail to return data). 2004-02-23 19:50:47 +00:00
foobar 66df106383 MFH: fixed bug #27337 (missing sapi_shutdown()) 2004-02-23 19:15:05 +00:00
Christian Stocker 4c6e92bdb8 skip test, if no XSLT support is compiled in 2004-02-23 10:33:51 +00:00
Derick Rethans b2732089f2 - MFH: Fixed bug #27354 (Modulus operator crashes PHP). 2004-02-22 20:07:17 +00:00
SVN Migration 8e8f8ece29 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-22 20:04:31 +00:00
Ilia Alshanetsky 7275b5a177 MFH: wbmp conversion warning fix. 2004-02-22 18:03:24 +00:00
Sara Golemon 5f0305e605 MFH 2004-02-21 19:37:59 +00:00
Sara Golemon 2a0e69c111 MFH: long is not always 32-bit 2004-02-20 21:09:08 +00:00
Greg Beaver 74c2e50253 stupid oversight, no 4.2 dep 2004-02-20 17:17:04 +00:00
Pierre Joye cb915e0498 - Update to DB-1.6.0 2004-02-20 15:38:29 +00:00
SVN Migration 3379ffa7ed This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-20 15:36:25 +00:00
Pierre Joye 0053324a83 - 1.3b6=>1.3 stable, prepare stable release 2004-02-20 15:33:59 +00:00
Ilia Alshanetsky a0c001aa70 MFH: missing safe_mode & open_basedir checks. 2004-02-20 01:09:25 +00:00
Greg Beaver 7b6a710bd0 MFH 2004-02-19 15:55:37 +00:00
Ilia Alshanetsky 221d4b346b MFH: Fixed possible resource/memory leak. 2004-02-19 02:20:14 +00:00
foobar 1e60e670ba MFH: emalloc -> safe_emalloc 2004-02-19 02:13:39 +00:00
foobar fdec1ab00e MFH: improve error message 2004-02-19 01:54:44 +00:00
Ilia Alshanetsky 1aac6063a4 MFH: Fixed bug #27295 (memory leak inside sscanf()). 2004-02-18 19:49:17 +00:00
SVN Migration 0808ccd417 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-18 19:48:14 +00:00
foobar 61c00477b4 MFH 2004-02-18 00:01:05 +00:00
SVN Migration 9ea8c7ddd4 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-18 00:00:37 +00:00
Ilia Alshanetsky d6cc9d4f01 MFH: Fixed bug #27293 (two crashes inside image2wbmp()). 2004-02-17 21:30:57 +00:00
Ard Biesheuvel c07cd30cd0 Really disallow persistent connections if ini option is set 2004-02-17 20:57:26 +00:00
foobar c9af2f28e2 - Fixed bug #26753 (zend_fetch_list_dtor_id() does not check NULL strings). 2004-02-17 10:39:17 +00:00
foobar ea54e26972 MFH 2004-02-16 17:44:55 +00:00
foobar 0ac2170517 typofix :) 2004-02-16 17:42:22 +00:00
Ilia Alshanetsky bd6b53c1d8 MFH: Fixed bug #27278 (*printf() functions treat arguments as if passed by
reference).
2004-02-16 17:09:52 +00:00
foobar ca90ec2cac MFH 2004-02-16 16:51:23 +00:00
SVN Migration 91abce9917 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-16 16:50:54 +00:00
Sergey Kartashoff 4cc252ca16 - A fix to make UDM_LIMIT_DATE work was applied. Thanks to
d.rousseau at nnx.com
2004-02-16 16:40:27 +00:00
Ilia Alshanetsky 1ed5d89106 Back to dev. 2004-02-16 16:03:35 +00:00
Ilia Alshanetsky c262cf962c Go with RC3 2004-02-16 15:34:16 +00:00
Ilia Alshanetsky 8e510ef9b9 Bug fixing news. 2004-02-16 15:15:22 +00:00
Ilia Alshanetsky 1aaadf3ca3 MFH: Better gmp fix. 2004-02-16 15:13:49 +00:00
Derick Rethans ca98ed755c - Update news too 2004-02-16 14:29:31 +00:00
Derick Rethans 2fe16812bd - MFH: Fixed zero bytes memory allocation when no extra ini files are found in
the --with-config-file-scan-dir specified directory. (Eric Colinet, Derick)
2004-02-16 14:29:07 +00:00
Pierre Joye a300b68b08 - DB 1.6RC6 2004-02-15 23:07:30 +00:00
Pierre Joye b9d98f0098 - remove DB 1.6RC1 2004-02-15 23:06:56 +00:00
Ard Biesheuvel deb89ce2f4 CS/WS 2004-02-15 20:47:21 +00:00
Ard Biesheuvel 405101d10d MFH 2004-02-15 18:45:56 +00:00
Ard Biesheuvel bc11725188 MFH reverted fix for #26777 2004-02-15 18:43:46 +00:00
Ilia Alshanetsky 938e964beb MFH: Fixed bug #27258 (moved FPE check to correct location).
Fixed several possible FPE.
2004-02-15 17:23:11 +00:00
Timm Friebe 49118556bb - Fixed bug #26407 (Result set fetching broken around transactions) 2004-02-15 10:55:55 +00:00
Timm Friebe 47d30e40e4 - Changed initialization of function arguments to message handler
# Hopefully fixes bug #27157 (Compile Failure on Solaris 8), user does
# not know how to use patch and therefore couldn't verify this works.
2004-02-15 10:38:57 +00:00
Greg Beaver 4135978add re-add as binary 2004-02-14 20:30:31 +00:00
Greg Beaver 86bdf2b049 remove in order to re-add binary 2004-02-14 20:29:45 +00:00
Greg Beaver 1d6cca1b2f MFH 2004-02-14 20:29:10 +00:00
Ard Biesheuvel 1e12ed5e1a BFN 2004-02-13 10:51:02 +00:00
Ard Biesheuvel 6fe6810c8a Fixed bug #27235 (NUMERIC x.0 field returns empty string on 0)
CS/WS
# MFB not necessary, bug doesn't apply to HEAD
2004-02-13 10:43:24 +00:00
Stefan Esser 408c183013 MFH 2004-02-12 18:36:57 +00:00
SVN Migration cdb4683c30 This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-12 14:09:54 +00:00
foobar 3a6eb48e1e BFN 2004-02-12 01:35:49 +00:00
foobar 2706fda4a6 MFH: ws fix 2004-02-12 01:32:40 +00:00
foobar fafe8a19b8 MFH: - Fixed bug #23467 (Showing incorrect Time Zone)
# patch by scottmacvicar at ntlworld dot com
2004-02-12 01:29:13 +00:00
Marcus Boerger 69eaab8aac MFH: Bug #27104 CLI/CGI SAPI module variable name conflict 2004-02-11 22:00:38 +00:00
Ilia Alshanetsky 6035439314 MFH: 'Touch' the file to make sure re2c is not needed. 2004-02-11 17:32:41 +00:00
Ilia Alshanetsky 79ed81e971 Fixed bug #27183 (userland stream wrapper segfaults on stream_write). 2004-02-11 17:09:09 +00:00
Ilia Alshanetsky ca53f68729 MFH: Fixed bug #26862 (ob_flush() followed by output_reset_rewrite_vars()
may result in data loss).
2004-02-11 17:00:56 +00:00
SVN Migration 2b66aa860f This commit was manufactured by cvs2svn to create branch 'PHP_4_3'. 2004-02-11 17:00:49 +00:00
Ilia Alshanetsky 17cef37fd1 MFH: fixed a compilation error. 2004-02-11 16:53:03 +00:00
Ilia Alshanetsky fa2f1ac2a4 Back to dev tree (forgot to restore versions). 2004-02-11 16:49:24 +00:00
Ilia Alshanetsky a9e21b0a18 MFH: Win32 build fix. 2004-02-11 14:52:34 +00:00
Ilia Alshanetsky 353b838a13 MFH:
Fixed win32 build.
	Added missing headers needed for wait().
	Removed duplicate signal.h header.
2004-02-10 17:44:44 +00:00
Ilia Alshanetsky a68c033bf9 MFH: Fixed bug #26653 (open_basedir incorrectly resolved on win32). 2004-02-10 16:09:56 +00:00
foobar 8c7af900cf typos 2004-02-10 02:00:02 +00:00
Ilia Alshanetsky 8e46f4b273 MFH: Fixed bug #26758 (FastCGI exits immediately with status 255). 2004-02-10 00:30:03 +00:00
Ilia Alshanetsky 86337bac18 MFH: Fixed bug #27026 (Added cgi.nph that allows forcing of the Status: 200
header that is not normally needed).
2004-02-10 00:03:44 +00:00
Ilia Alshanetsky 125d5a2b73 MFH: Fixed bug #27196 (Missing content_length initialization in apache 2
sapis).
2004-02-09 23:28:48 +00:00
Frank M. Kromann de23ffbee3 Delay creation of exec handle til it's needed 2004-02-09 17:58:24 +00:00
Ilia Alshanetsky 6af73a9f5e MFH: Fixed bug #27172 (Possible floating point exception in gmp_powm()). 2004-02-09 04:28:07 +00:00
Ilia Alshanetsky df8c668559 Bug fixing news. 2004-02-09 04:08:25 +00:00
Ilia Alshanetsky c346be31a1 MFH: Fixed bug #27175 (tzset() is not being called by PHP on startup). 2004-02-09 04:05:56 +00:00
foobar a360d7d794 MFH: fixed bug #27171 2004-02-07 19:15:09 +00:00
Ilia Alshanetsky a9b6b75a02 MFH: Fixed possible memory leak with INI values. 2004-02-06 03:08:39 +00:00
Ilia Alshanetsky fa8c24ff7a MFH: Fixed bug #27135 (Possible crash inside mb_strlen()).
# Patch by Moriyoshi
2004-02-06 02:28:38 +00:00
foobar fb4f76e78d MFH: emalloc -> safe_emalloc 2004-02-05 12:19:32 +00:00
Antony Dovgal f261a8f571 MFH:
fix bug #27149
2004-02-05 08:30:17 +00:00
Ilia Alshanetsky 5bffdef46d MFH: Parse command line ini directives passed using -d before -i, to ensure
correct settings output.
2004-02-04 22:49:55 +00:00
155 changed files with 13233 additions and 1084 deletions

No files matched your search

+159 -71
View File
@@ -1,52 +1,24 @@
PHP 4 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
03 Feb 2004, Version 4.3.5RC2
?? Mar 2004, Version 4.3.5
- Fixed possible crash using an invalid color index with a palette image in
imagecolortransparent (Pierre)
- Fixed php-cgi to not ignore command-line switches when run in a web context.
This fixes our test cases allowing INI with GET sections to work (Rasmus)
- Fixed getopt() so it works without $_SERVER (Rasmus, bfrance)
- Fixed crash in php_ini_scanned_files() when no additional INI files were
actually parsed. (Jon)
- Fixed possible crashes inside socket extension, due to missing check inside
allocation functions. (Ilia)
- Fixed zero bytes memory allocation when no extra ini files are found in the
--with-config-file-scan-dir specified directory. (Eric Colinet, Derick)
- Changed "allow_url_fopen" php.ini option to be PHP_INI_SYSTEM. (Sara)
- Improved the sybase_ct module: (Timm)
. Added ability to define a message handler not only globally, but also per
. Added ability to define a message handler not only globally, but also per
connection.
. Added "sybct.packet_size" php.ini option.
. Changed "sybct.login_timeout" php.ini option changeable at runtime.
. Fixed memory leak in sybase_set_message_handler().
- Fixed bug #27058 (crash in sybase_connect() with 2 arguments). (Ilia)
- Fixed bug #27056 (ints used instead of longs inside some GD functions).
(Ilia)
- Fixed bug #27040 (passing an array of form-fields to CURLOPT_POSTFIELDS
does not work). (Ilia, Jani)
- Fixed bug #27037 (fixed possible crash in apache2handler output code). (Ilia)
- Fixed bug #27011 (64bit int/long confusion in preg_match*() functions).
(Ilia)
- Fixed bug #27007 (missing connection closure when connect fails in pgsql).
(Ilia)
- Fixed bug #26974 (rename() doesn't check the destination file against
safe_mode/open_basedir). (Ilia)
- Fixed bug #26973 (*printf() '+' modifier broken). (Jani)
- Fixed bug #26969 (--with-openssl=shared build fails). (Jani)
- Fixed bug #26968 (Segfault with Interbase module built as shared). (Ard)
- Fixed bug #26949 (rand(min,max) always returns min when ZTS enabled). (Jani)
- Fixed bug #26937 (Warning in xml.c). (Jani)
- Fixed Bug #26927 (preg_quote() does not escape \0). (Ilia)
- Fixed bug #26923 (ext/imap: pam and crypt libraries missing when build as
shared extension). (Jani)
- Fixed bug #26909 (crash in imap_mime_header_decode() when no encoding is
used). (Ilia)
- Fixed bug #26892 (ORA-21301 in ocinewcollection() call). (Antony)
- Fixed bug #26878 (problem with multiple references to the same variable
with different types). (Ilia)
- Fixed bug #26896 (ext/ftp does not work as shared extension). (Jani)
- Fixed bug #26814 (When included file has a parse error, terminate script
execution). (Ilia)
- Fixed bug #26772, #26967 (file operations return NULL instead of FALSE).
(Wez, Ilia)
- Fixed bug #26381 (rand() without srand() doesn't work with certain php.ini).
(Jani)
- Fixed bug #25753 (php.ini settings "leak" from vhosts/.htaccess files).
(Patch by: rover at tob dot ru)
- Fixed bug #22403 (PHP crashes when executing a sql procedure without
parameters). (Timm)
- Fixed bug #21513 (shutdown functions not executed if timed out). (Zeev)
12 Jan 2004, Version 4.3.5RC1
- Synchronized bundled GD library with GD 2.0.17
- Upgraded PCRE library to version 4.5. (Andrei)
- Updated bundled PostgreSQL library to version 7.4 in Windows distribution.
@@ -56,27 +28,123 @@ PHP 4 NEWS
- Added a warning when creating temp stream fails with ftp_(n)list(). (Sara)
- Fixed header handler in NSAPI SAPI module (header->replace was ignored,
send_default_content_type now sends value from php.ini). (Uwe Schindler)
- Fixed bug #27633 (Incorrect EOL translation by ftp_get() in ASCII mode).
(Ilia)
- Fixed bug #27600 (GCC 3.0.4 does not like __attribute__ directive). (Sascha)
- Fixed bug #27590 (crash during shutdown when freeing persistent resources in
ZTS mode). (Ilia)
- Fixed bug #27582 (possible crashes in imagefilltoborder()). (Pierre)
- Fixed bug #27580 (pre-initialization errors in ap2 handler are not being
written to vhost error log). (Ilia)
- Fixed bug #27559 (Corrected open_basedir resolving logic). (Ilia)
- Fixed bug #27530 (broken http auth when safe_mode is on and PCRE is disabled).
(Ilia)
- Fixed bug #27509 (broken getaddrinfo() causes fsockopen() error). (Sara)
- Fixed bug #27505 (htmlentities() does not handle BIG5 correctly). (Ilia,
ywliu at hotmail dot com)
- Fixed bug #27498 (bogus safe_mode error on nonexistent directories for
chdir() and opendir() functions). (Ilia)
- Fixed bug #27460 (base64_decode() does not handle extra padding).
(Ilia, naish at klanen dot net)
- Fixed bug #27443 (defined() returns wrong type). (Derick)
- Fixed bug #27437 (wrong freetype include inside GD library). (Ilia)
- Fixed bug #27424 (headers missing on flush() in apache 2 SAPIs). (Ilia)
- Fixed bug #27421 (mbstring.func_overload should be system ini setting).
(Ilia)
- Fixed bug #27384 (unpack() misbehaves with 1 char string). (GeorgeS)
- Fixed bug #27383 (Potential crash inside fopen_wrapper, while
parsing response code). (Ilia)
- Fixed bug #27354 (Modulus operator crashes PHP). (Derick)
- Fixed bug #27341 (HEAD requests fail to return data). (Ilia)
- Fixed bug #27337 (missing sapi_shutdown() in sapi/isapi causes memory leak).
(Jani, msisolak at yahoo dot com)
- Fixed bug #27328 (ftp extension relies on 32-bit longs). (Sara)
- Fixed bug #27300 (Improved regex for pg_convert()).
(benjcarson at digitaljunkies dot ca, Ilia)
- Fixed bug #27295 (memory leak inside sscanf()). (Ilia)
- Fixed bug #27293 (two crashes inside image2wbmp()). (Ilia)
- Fixed bug #27291 (get_browser matches browscap.ini patterns incorrectly).
(Jay)
- Fixed bug #27278 (*printf() functions treat arguments as if passed by
reference). (Ilia)
- Fixed bug #27238 (iptcparse() function misses some fields). (Pierre)
- Fixed bug #27235 (Interbase NUMERIC x.0 field returns empty string on 0).
(Ard)
- Fixed bug #27196 (Missing content_length initialization in apache 2 sapis).
(Ilia, pdoru at kappa dot ro)
- Fixed bug #27183 (userland stream wrapper segfaults on stream_write).
(Moriyoshi)
- Fixed bug #27175 (tzset() is not being called by PHP on startup).
(Ilia, sagawa at sohgoh dot net)
- Fixed bug #27172 (Possible floating point exception in gmp_powm()).
(Ilia)
- Fixed bug #27171 (crash inside gmp_hamdist()). (Jani)
- Fixed bug #27157 (Compile Failure on Solaris 8). (Timm)
- Fixed bug #27149 (broken CLOB support in oci8 extension). (Antony)
- Fixed bug #27135 (Possible crash inside mb_strlen()). (Moriyoshi)
- Fixed bug #27104 (CLI/CGI SAPI module variable name conflict). (Marcus)
- Fixed bug #27058 (crash in sybase_connect() with 2 arguments). (Ilia)
- Fixed bug #27056 (ints used instead of longs inside some GD functions).
(Ilia)
- Fixed bug #27040 (passing an array of form-fields to CURLOPT_POSTFIELDS
does not work). (Ilia, Jani)
- Fixed bug #27037 (fixed possible crash in apache2handler output code).
(Ilia)
- Fixed bug #27026 (Added "cgi.nph" php.ini option to allow forcing of the
'Status: 200' header that is not normally needed). (Ilia)
- Fixed bug #27011 (64bit int/long confusion in preg_match*() functions).
(Ilia)
- Fixed bug #27007 (missing connection closure when connect fails in pgsql).
(Ilia)
- Fixed bug #26974 (rename() doesn't check the destination file against
safe_mode/open_basedir). (Ilia)
- Fixed bug #26973 (*printf() '+' modifier broken). (Jani)
- Fixed bug #26969 (--with-openssl=shared build fails). (Jani)
- Fixed bug #26968 (Segfault with Interbase module built as shared). (Ard)
- Fixed bug #26949 (rand(min,max) always returns min when ZTS enabled). (Jani)
- Fixed bug #26937 (Warning in xml.c). (Jani)
- Fixed bug #26927 (preg_quote() does not escape \0). (Ilia)
- Fixed bug #26923 (ext/imap: pam and crypt libraries missing when build as
shared extension). (Jani)
- Fixed bug #26909 (crash in imap_mime_header_decode() when no encoding is
used). (Ilia)
- Fixed bug #26896 (ext/ftp does not work as shared extension). (Jani)
- Fixed bug #26892 (ORA-21301 in ocinewcollection() call). (Antony)
- Fixed bug #26878 (problem with multiple references to the same variable with
different types). (Ilia)
- Fixed bug #26864 (pg_(update|delete) ignore PGSQL_DML_EXEC option). (Ilia)
- Fixed bug #26862 (ob_flush() followed by output_reset_rewrite_vars() may
result in data loss). (Ilia, scottmacvicar at ntlworld dot com)
- Fixed bug #26847 (memory leak in mail() when to/subject contain only spaces).
(Ilia)
- Fixed bug #26814 (When included file has a parse error, terminate script
execution). (Ilia)
- Fixed bug #26777 (ext/interbase: Let DB handle NULL params). (Ard)
- Fixed bug #26755 (CLI now overrides php.ini settings and switches off
output buffering). (Edin)
- Fixed bug #26752 (Silent unterminated loop when length parameter for
fgets(), fread() and fgetss() is 0). (Ilia)
- Fixed bug #26772, #26967 (file operations return NULL instead of FALSE).
(Wez, Ilia)
- Fixed bug #26758 (FastCGI exits immediately with status 255).
(Ilia, tcarter at noggin dot com dot au)
- Fixed bug #26755 (CLI now overrides php.ini settings and switches off output
buffering). (Edin)
- Fixed bug #26753 (zend_fetch_list_dtor_id() doesn't check NULL strings).
(Jani, Markus dot Lidel at shadowconnect dot com)
- Fixed bug #26752 (Silent unterminated loop when length parameter for fgets(),
fread() and fgetss() is 0). (Ilia)
- Fixed bug #26751 (PHP can't find the MySQL socket on a case sensitive file
system). (Derick)
- Fixed Bug #26703 (Certain characters inside strings incorrectly treated as
keywords). (vrana [at] php [dot] net, Ilia)
- Fixed bug #26703 (Certain characters inside strings incorrectly treated
as keywords). (vrana [at] php [dot] net, Ilia)
- Fixed bug #26699 (mbstring doesn't identify "binary" as a valid encoding).
(nirva-php at ishiboo dot com, Moriyoshi)
- Fixed bug #26667 (Added safety checks to ip2long()). (Ilia)
- Fixed bug #26653 (open_basedir incorrectly resolved on win32).
(Ilia, scottmacvicar at ntlworld dot com)
- Fixed bug #26639 (mb_convert_variables() clutters variables beyond the
references). (Moriyoshi)
- Fixed bug #26635 (fixed look up for fonts in the current directory w/ZTS).
(Ilia)
- Fixed Bug #26625 (pg_convert sets NULL incorrectly for character data
types). (Ilia)
- Fixed bug #26625 (pg_convert sets NULL incorrectly for character data types).
(Ilia)
- Fixed bug #26604 (Apache2 SAPIs implicitly disable Keep-Alive). (Ilia)
- Fixed bug #26595 (ext/domxml: XSLT_NAMESPACE undeclared). (Christian)
- Fixed bug #26565 (strtotime("this month") resolving to the wrong month).
@@ -86,24 +154,25 @@ PHP 4 NEWS
- Fixed bug #26531 (ext/domxml: get_elements_by_tag_name() wildcard fails).
(Rob Richards)
- Fixed bug #26488 (Missing declaration of CRTSCTS in ext/dio/dio.c). (Jani)
- Fixed bug #26467 (flock() does not force the "wouldblock" parameter to be
- Fixed bug #26467 (flock() does not force the "wouldblock" parameter to be
passed by reference). (Wez)
- Fixed bug #26463 (Incorrect handling of semicolons after heredoc). (Ilia)
- Fixed bug #26462 (phpize + ext/bcmath -> compile error). (Jani)
- Fixed bug #26461 (-lssl missing from LIBS). (Jani)
- Fixed bug #26458 (var_dump(), var_export(), debug_zval_dump() not binary
safe for array keys). (Ilia)
- Fixed bug #26458 (var_dump(), var_export(), debug_zval_dump() not binary safe
for array keys). (Ilia)
- Fixed bug #26447 (--with-openssl=shared causes compile errors). (Jani)
- Fixed bug #26446 (domxml_open_file() returns an empty error-Array). (Rob)
- Fixed bug #26440 (MFH missing context options). (Ilia)
- Fixed bug #26438 (error in thttpd SAPI installation). (Jani)
- Fixed bug #26391 (parse_url() destroys strings that contain a character
in range of \x80-\xff)). (Moriyoshi)
- Fixed bug #26415 (Updated bundled OpenSSL DLLs in the Windows
distribution to 0.9.7c). (Edin)
- Fixed bug #25963 (PostgreSQL error message include \n characters).
(Marcus, Ilia)
- Fixed bug #26415 (Updated bundled OpenSSL DLLs in the Windows distribution
to 0.9.7c). (Edin)
- Fixed bug #26407 (Result set fetching broken around transactions). (Timm)
- Fixed bug #26391 (parse_url() destroys strings that contain a character in
range of \x80-\xff)). (Moriyoshi)
- Fixed bug #26384 (crash in domxslt->process()). (Christian)
- Fixed bug #26381 (rand() without srand() doesn't work with certain php.ini).
(Jani)
- Fixed bug #26376 (typo in ext/odbc/config.m4: DBMaker test fails). (Jani)
- Fixed bug #26355 (flock() doesn't initialize the wouldblock argument). (Ilia)
- Fixed bug #26309 (Fixed argument parsing for imageftbbox()). (Ilia)
@@ -120,36 +189,55 @@ PHP 4 NEWS
- Fixed bug #26194 (iconv() not properly defined with libiconv).
(Steph, Frank, Moriyoshi)
- Fixed bug #26176 (Fixed handling of numeric keys in INI files). (Ilia)
- Fixed bug #26168 (shtool availability check in phpize).
- Fixed bug #26168 (shtool availability check in phpize).
(robbat2 at gentoo dot org, Ilia)
- Fixed bug #26148 (Print the notice before modifying variable on type
mismatch). (morten-bugs dot php dot net at afdelingp dot dk, Ilia)
- Fixed bug #26128 (mbstring prints out wrong information on phpinfo()).
(Moriyoshi)
- Fixed bug #26113 (remove leftover local file when ftp_get/ftp_nb_get fails).
(Ilia)
- Fixed bug #26105 (Compile failure on gcc version 3.0.X). (Ilia)
- Fixed bug #26113 (remove leftover local file when ftp_get/ftp_nb_get
fails). (Ilia)
- Fixed bug #26105 (Compile failure on GCC version 3.0.X). (Ilia)
- Fixed bug #26103 (ext/mime_magic causes compile failure in ext/mssql). (Jani)
- Fixed bug #26097 (gdImageColorClosestAlpha() returns incorrect results).
(sprice at wisc dot edu, Ilia)
- Fixed bug #26042 (memory leak if mcrypt_generic_deinit() is not called
after every mcrypt_generic_init() call). (Ilia)
- Fixed bug #26042 (memory leak if mcrypt_generic_deinit() is not called after
every mcrypt_generic_init() call). (Ilia)
- Fixed bug #26025 (Segfault on glob() without GLOB_NOCHECK or GLOB_NOMAGIC
under *BSD platforms). (Moriyoshi)
- Fixed bug #26005 (Random "cannot change the session ini settings" errors).
(Jani, jsnajdr at kerio dot com)
- Fixed bug #26003 (Make fgetcsv() binary safe). (Ilia, Moriyoshi)
- Fixed bug #25963 (PostgreSQL error message include \n characters).
(Marcus, Ilia)
- Fixed bug #25939 (feof() not working correctly for sockets). (Wez)
- Fixed bug #25916 (get_browser() -> PHP Fatal error: Nesting level
too deep - recursive dependency?). (Uwe Schindler)
- Fixed bug #25916 (get_browser() -> PHP Fatal error: Nesting level too
deep - recursive dependency?). (Uwe Schindler)
- Fixed bug #25794 (Cannot open existing hash db3 file with write" ext/dba).
(Marcus)
- Fixed Bug #25694 (round() and number_format() give inconsistent results).
- Fixed bug #25753 (php.ini settings "leak" from vhosts/.htaccess files).
(Patch by: rover at tob dot ru)
- Fixed bug #25694 (round() and number_format() give inconsistent results).
(Ilia)
- Fixed bug #25664 (calling ITypeInfo::Invoke with bogus params). (Wez)
- Fixed bug #25581 (getimagesize () return incorrect values on bitmap
(os2) files). (Marcus)
- Fixed bug #25329 (sqlite_create_function with method and reference to $this).
(Marcus).
- Fixed bug #25581 (getimagesize () return incorrect values on bitmap (os2)
files). (Marcus)
- Fixed bug #25329 (sqlite_create_function with method and reference to
$this). (Marcus).
- Fixed bug #24773 (unsetting string as array causes a crash). (Sara)
- Fixed bug #24773 (Unsetting string offsets crashes PHP). (Moriyoshi, Sara)
- Fixed bug #24582 (extensions can't be loaded dynamically in Solaris/iPlanet).
(Jani)
- Fixed bug #23467 (date('T') outputs incorrect Time Zone).
(Jani, scottmacvicar at ntlworld dot com)
- Fixed bug #22403 (PHP crashes when executing a sql procedure without
parameters). (Timm)
- Fixed bug #22127 (Invalid response code when force-cgi-redirect safety
mechanism is triggered). (Ilia, scottmacvicar at ntlworld dot com)
- Fixed bug #21760 (Use of uninitialized pointer inside php_read()).
(Ilia, uce at ftc dot gov)
- Fixed bug #21513 (shutdown functions not executed if timed out). (Zeev)
- Fixed bug #21070 (ftp_genlist/ANSI-tmpfile() fail w/ some platform). (Sara)
3 Nov 2003, Version 4.3.4
- Made MCVE extension available on win32. (Jani)
+1 -1
View File
@@ -65,7 +65,7 @@ snapshot:
md5sum $$distname.tar.bz2; \
bzip2 -t $$distname.tar.bz2
cvsclean:
cvsclean-work:
@for i in `find . -name .cvsignore`; do \
(cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore | grep -v config.nice` *.o *.a .libs || true); \
done
+38 -3
View File
@@ -41,7 +41,7 @@ AC_CONFIG_HEADER(main/php_config.h)
MAJOR_VERSION=4
MINOR_VERSION=3
RELEASE_VERSION=5
EXTRA_VERSION="RC2"
EXTRA_VERSION=""
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
dnl Define where extension directories are located in the configure context
@@ -521,10 +521,45 @@ vsnprintf \
)
dnl Check for getaddrinfo, should be a better way, but...
dnl Also check for working getaddrinfo
AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
[AC_TRY_LINK([#include <netdb.h>],
[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);],
ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no)])
[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);],
AC_TRY_RUN([
#include <netdb.h>
#include <sys/types.h>
int main(void) {
struct addrinfo *ai, *pai, hints;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
if (getaddrinfo("127.0.0.1", NULL, &hints, &ai) < 0) {
exit(1);
}
if (ai == NULL) {
exit(1);
}
pai = ai;
while (pai) {
if (pai->ai_family != AF_INET) {
/* 127.0.0.1/NUMERICHOST should only resolve ONE way */
exit(1);
}
if (pai->ai_addr->sa_family != AF_INET) {
/* 127.0.0.1/NUMERICHOST should only resolve ONE way */
exit(1);
}
pai = pai->ai_next;
}
freeaddrinfo(ai);
exit(0);
}
],ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no),
ac_cv_func_getaddrinfo=no)])
if test "$ac_cv_func_getaddrinfo" = yes; then
AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
fi
+1 -1
View File
@@ -1,3 +1,3 @@
#! /bin/sh
${MAKE:-make} -f build/build.mk cvsclean
${MAKE:-make} -f build/build.mk cvsclean-work
+1
View File
@@ -476,6 +476,7 @@ PHP_FUNCTION(cpdf_open)
php_error(E_WARNING, "%s(): Writing to stdout as described in the ClibPDF manual is not possible if php is used as an Apache module. Write to a memory stream and use cpdf_output_buffer() instead.", get_active_function_name(TSRMLS_C));
#endif
if (php_check_open_basedir(Z_STRVAL_P(arg2) TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(Z_STRVAL_P(arg2), "rb+", CHECKUID_CHECK_MODE_PARAM))) {
cpdf_close(cpdf);
RETURN_FALSE;
}
+24 -16
View File
@@ -368,6 +368,9 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
length = -1;
}
else {
if (Z_TYPE_P(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
length = Z_LVAL_P(retval);
}
@@ -400,7 +403,6 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
case PHP_CURL_USER: {
zval *argv[3];
zval *retval;
int length;
int error;
TSRMLS_FETCH();
@@ -422,11 +424,9 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Cannot call the CURLOPT_READFUNCTION",
get_active_function_name(TSRMLS_C));
length = -1;
}
else {
memcpy(data, Z_STRVAL_P(retval), size * nmemb);
length = Z_STRLEN_P(retval);
} else if (Z_TYPE_P(retval) == IS_STRING) {
length = MIN(size * nmemb, Z_STRLEN_P(retval));
memcpy(data, Z_STRVAL_P(retval), length);
}
zval_ptr_dtor(&argv[0]);
@@ -485,6 +485,9 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
length = -1;
}
else {
if (Z_TYPE_P(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
length = Z_LVAL_P(retval);
}
zval_ptr_dtor(&argv[0]);
@@ -492,8 +495,12 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
zval_ptr_dtor(&retval);
break;
}
case PHP_CURL_IGNORE:
return length;
default:
return -1;
}
return length;
}
@@ -508,7 +515,7 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
zval *argv[3];
zval *retval = NULL;
int error;
int ret = 0;
int ret = -1;
TSRMLS_FETCH();
MAKE_STD_ZVAL(argv[0]);
@@ -526,17 +533,15 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
retval, 2, argv TSRMLS_CC);
if (error == FAILURE) {
php_error(E_WARNING, "%s(): Couldn't call the CURLOPT_PASSWDFUNCTION", get_active_function_name(TSRMLS_C));
ret = -1;
}
else {
} else if (Z_TYPE_P(retval) == IS_STRING) {
if (Z_STRLEN_P(retval) > buflen) {
php_error(E_WARNING, "%s(): Returned password is too long for libcurl to handle",
get_active_function_name(TSRMLS_C));
ret = -1;
}
else {
strlcpy(buf, Z_STRVAL_P(retval), buflen);
} else {
strlcpy(buf, Z_STRVAL_P(retval), Z_STRLEN_P(retval));
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "User handler '%s' did not return a string.", Z_STRVAL_P(func));
}
zval_ptr_dtor(&argv[0]);
@@ -802,7 +807,9 @@ PHP_FUNCTION(curl_setopt)
if (Z_LVAL_PP(zvalue)) {
ch->handlers->write->method = PHP_CURL_RETURN;
}
} else {
ch->handlers->write->method = PHP_CURL_STDOUT;
}
break;
case CURLOPT_BINARYTRANSFER:
convert_to_long_ex(zvalue);
@@ -1020,7 +1027,8 @@ PHP_FUNCTION(curl_exec)
error = curl_easy_perform(ch->cp);
SAVE_CURL_ERROR(ch, error);
if (error != CURLE_OK) {
/* CURLE_PARTIAL_FILE is returned by HEAD requests */
if (error != CURLE_OK && error != CURLE_PARTIAL_FILE) {
if (ch->handlers->write->buf.len > 0) {
smart_str_free(&ch->handlers->write->buf);
}
+2 -2
View File
@@ -198,7 +198,7 @@ AC_ARG_WITH(db4,
[ --with-db4[=DIR] DBA: Include Berkeley DB4 support],[
if test "$withval" != "no"; then
PHP_DBA_STD_BEGIN
for i in $withval /usr/local/BerkeleyDB.4.1 /usr/local/BerkeleyDB.4.0 /usr/local /usr; do
for i in $withval /usr/local/BerkeleyDB.4.2 /usr/local/BerkeleyDB.4.1 /usr/local/BerkeleyDB.4.0 /usr/local /usr; do
if test -f "$i/db4/db.h"; then
THIS_PREFIX=$i
THIS_INCLUDE=$i/db4/db.h
@@ -221,7 +221,7 @@ AC_ARG_WITH(db4,
break
fi
done
PHP_DBA_DB_CHECK(4, db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
PHP_DBA_DB_CHECK(4, db-4.2 db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
fi
])
AC_DBA_STD_RESULT(db4,Berkeley DB4)
+4
View File
@@ -163,6 +163,10 @@ PHP_FUNCTION(dio_open)
return;
}
if (php_check_open_basedir(file_name TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(file_name, "wb+", CHECKUID_CHECK_MODE_PARAM))) {
RETURN_FALSE;
}
if (ZEND_NUM_ARGS() == 3) {
fd = open(file_name, flags, mode);
} else {
+3
View File
@@ -3981,6 +3981,9 @@ static xmlDocPtr domxml_document_parser(int mode, int loadtype, char *source, vo
ctxt->sax->error = domxml_error_ext;
ctxt->sax->warning = domxml_error_ext;
#if LIBXML_VERSION >= 20600
ctxt->sax->cdataBlock = NULL;
#endif
ctxt->vctxt.userData= (void *) &errorCtxt;
ctxt->vctxt.error = (xmlValidityErrorFunc) domxml_error_validate;
ctxt->vctxt.warning = (xmlValidityWarningFunc) domxml_error_validate;
+3 -1
View File
@@ -1,7 +1,9 @@
--TEST--
Bug #26384 (domxslt->process causes segfault with xsl:key)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipif.inc');
if (!function_exists("domxml_xslt_stylesheet_file")) { die("skip No XSLT support found");};
?>
--FILE--
<?php
$xml = domxml_open_mem(file_get_contents(dirname(__FILE__)."/area_name.xml"));
+68 -75
View File
@@ -83,30 +83,28 @@ typedef struct PHPFBLink PHPFBLink;
required buffereing from of results.
In the PHP code the 3 above a data structures are referenced by means of integers in the
range from 1 to som configurable maximum. You can put a limit to the number of links, databases
and results. The integer identifications is implemented by insertion in the list, which is passed
range from 1 to som configurable maximum. You can put a limit to the number of links, databases
and results. The integer identifications is implemented by insertion in the list, which is passed
as an argument to all the functions, please note the list is polymorph.
Database objects and link objects are all reused, base on the host name user name, host name database name
user name. So connecting twice to the same database as the same user will return the same database id.
user name. So connecting twice to the same database as the same user will return the same database id.
We use the same coding for that as fbsql does, explioiting the underlying implementation of the lists.
Persistent objects are put in the persistent list as well, but only by name, if you connect to a persistent object
and it is not in the list it is simply added and get a new index, and refcounted. Tricky, tricky ...
and it is not in the list it is simply added and get a new index, and refcounted. Tricky, tricky ...
*/
/* Some functions which should be exported from FBCAccess */
void* fbaObjectAtIndex();
void fbaRelease();
unsigned int fbaCount();
void* fbaObjectAtIndex();
void fbaRelease();
unsigned int fbaCount();
struct FBCAutoStartInfo {
FBArray* infoLines;
FBArray* infoLines;
};
struct PHPFBResult
{
PHPFBLink* link; /* The link for the result, may be NULL if no link */
@@ -115,7 +113,7 @@ struct PHPFBResult
FBCMetaData* ResultmetaData; /* The metadata describing the result */
FBCRowHandler* rowHandler; /* The row handler, the Frontbase structure used for accessing rows in the result */
unsigned int batchSize; /* The number of row to fetch when expanding the number of rows in the row handler */
unsigned int rowCount; /* The number of rows in the results set. The number of row is not in */
unsigned int rowCount; /* The number of rows in the results set. The number of row is not in */
/* general known when the select is done, one typically needs to fetch all the row
to figure out how many row you got. When the rowCount is unknown the value is
0x7ffffffff */
@@ -280,10 +278,10 @@ static void phpfbReleaseResult(zend_rsrc_list_entry *rsrc TSRMLS_DC)
FBCMetaData *md = fbcdcCancelFetch(result->link->connection, result->fetchHandle);
fbcmdRelease(md);
}
if (result->rowHandler) fbcrhRelease(result->rowHandler);
if (result->ResultmetaData) fbcmdRelease(result->ResultmetaData);
if (result->list) fbcplRelease(result->list);
if (result->array) fbaRelease(result->array);
if (result->rowHandler) fbcrhRelease(result->rowHandler);
if (result->ResultmetaData) fbcmdRelease(result->ResultmetaData);
if (result->list) fbcplRelease(result->list);
if (result->array) fbaRelease(result->array);
efree(result);
}
}
@@ -389,7 +387,7 @@ static void php_fbsql_init_globals(zend_fbsql_globals *fbsql_globals)
fbsql_globals->persistentCount = 0;
fbsql_globals->linkCount = 0;
}
PHP_MINIT_FUNCTION(fbsql)
{
ZEND_INIT_MODULE_GLOBALS(fbsql, php_fbsql_init_globals, NULL);
@@ -397,7 +395,7 @@ PHP_MINIT_FUNCTION(fbsql)
REGISTER_INI_ENTRIES();
fbcInitialize();
fbcehSetMultiThreaded(True);
le_result = zend_register_list_destructors_ex(phpfbReleaseResult, NULL, "fbsql result", module_number);
le_link = zend_register_list_destructors_ex(phpfbReleaseLink, NULL, "fbsql link", module_number);
le_plink = zend_register_list_destructors_ex(NULL, phpfbReleasePLink, "fbsql plink", module_number);
@@ -497,12 +495,12 @@ static void php_fbsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (argc >= 2)
{
convert_to_string_ex(argv[1]);
userName = Z_STRVAL_PP(argv[1]);
}
userName = Z_STRVAL_PP(argv[1]);
}
if (argc == 3)
{
convert_to_string_ex(argv[2]);
userPassword = Z_STRVAL_PP(argv[2]);
userPassword = Z_STRVAL_PP(argv[2]);
}
if (hostName == NULL) hostName = FB_SQL_G(hostName);
@@ -543,7 +541,7 @@ static void php_fbsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
phpLink->userPassword = strdup(userPassword);
phpLink->databasePassword = strdup(FB_SQL_G(databasePassword));
phpLink->databaseName = NULL;
phpLink->execHandler = fbcehHandlerForHost(hostName, 128);
phpLink->execHandler = NULL;
phpLink->affectedRows = 0;
phpLink->autoCommit = FB_SQL_G(autoCommit);
phpLink->errorNo = 0;
@@ -604,7 +602,7 @@ static void php_fbsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
phpLink->userPassword = strdup(userPassword);
phpLink->databasePassword = strdup(FB_SQL_G(databasePassword));
phpLink->databaseName = NULL;
phpLink->execHandler = fbcehHandlerForHost(hostName, 128);
phpLink->execHandler = NULL;
phpLink->affectedRows = 0;
phpLink->autoCommit = FB_SQL_G(autoCommit);
phpLink->errorNo = 0;
@@ -613,7 +611,7 @@ static void php_fbsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
ZEND_REGISTER_RESOURCE(return_value, phpLink, le_link);
le.ptr = (void *)Z_LVAL_P(return_value);
le.ptr = (void *)Z_LVAL_P(return_value);
Z_TYPE(le) = le_index_ptr;
if (zend_hash_update(&EG(regular_list), name, strlen(name) + 1, &le, sizeof(le), NULL)==FAILURE)
{
@@ -751,7 +749,7 @@ static int php_fbsql_select_db(char *databaseName, PHPFBLink *link TSRMLS_DC)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No message");
}
link->errorText = strdup(emg);
link->errorNo = fbcemdErrorCodeAtIndex(emd, 0);;
link->errorNo = fbcemdErrorCodeAtIndex(emd, 0);;
free(emg);
fbcemdRelease(emd);
fbcmdRelease(md);
@@ -786,7 +784,7 @@ static int php_fbsql_select_db(char *databaseName, PHPFBLink *link TSRMLS_DC)
void phpfbestrdup(const char * s, int* length, char** value)
{
int l = s?strlen(s):0;
int l = s?strlen(s):0;
if (value)
{
char* r = emalloc(l+1);
@@ -794,7 +792,7 @@ void phpfbestrdup(const char * s, int* length, char** value)
strcpy(r, s);
else
r[0] = 0;
*value = r;
*value = r;
}
*length = l;
}
@@ -1290,7 +1288,7 @@ PHP_FUNCTION(fbsql_username)
/* {{{ proto string fbsql_password(resource link_identifier [, string password])
Get or set the user password used with a connection */
PHP_FUNCTION(fbsql_password)
{
{
PHPFBLink* phpLink = NULL;
zval **fbsql_link_index = NULL, **password = NULL;
@@ -1359,17 +1357,6 @@ PHP_FUNCTION(fbsql_select_db)
}
ZEND_FETCH_RESOURCE2(phpLink, PHPFBLink *, fbsql_link_index, id, "FrontBase-Link", le_link, le_plink);
if (phpLink->execHandler == NULL)
{
int port = atoi(name);
if (port == 0 || port > 64535) {
if (FB_SQL_G(generateWarnings)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot connect to FBExec for database '%s'. (%s)", name, fbcehClassErrorMessage());
}
RETURN_FALSE;
}
}
if (!php_fbsql_select_db(name, phpLink TSRMLS_CC)) {
RETURN_FALSE;
}
@@ -1469,6 +1456,7 @@ PHP_FUNCTION(fbsql_create_db)
convert_to_string_ex(database_name);
databaseName = Z_STRVAL_PP(database_name);
if (phpLink->execHandler == NULL) phpLink->execHandler = fbcehHandlerForHost(phpLink->hostName, 128);
status = fbcehStatusForDatabaseNamed(phpLink->execHandler, databaseName);
if (status != FBUnknownStatus)
{
@@ -1542,6 +1530,7 @@ PHP_FUNCTION(fbsql_drop_db)
convert_to_string_ex(database_name);
databaseName = Z_STRVAL_PP(database_name);
if (phpLink->execHandler == NULL) phpLink->execHandler = fbcehHandlerForHost(phpLink->hostName, 128);
status = fbcehStatusForDatabaseNamed(phpLink->execHandler, databaseName);
if (status != FBStopped)
{
@@ -1616,6 +1605,7 @@ PHP_FUNCTION(fbsql_start_db)
convert_to_string_ex(database_name);
databaseName = Z_STRVAL_PP(database_name);
if (phpLink->execHandler == NULL) phpLink->execHandler = fbcehHandlerForHost(phpLink->hostName, 128);
status = fbcehStatusForDatabaseNamed(phpLink->execHandler, databaseName);
if ((status != FBStopped) && (status != FBRunning) && (status != FBStarting))
{
@@ -1752,6 +1742,7 @@ PHP_FUNCTION(fbsql_db_status)
convert_to_string_ex(database_name);
databaseName = Z_STRVAL_PP(database_name);
if (phpLink->execHandler == NULL) phpLink->execHandler = fbcehHandlerForHost(phpLink->hostName, 128);
if (phpLink->execHandler) {
RETURN_LONG(fbcehStatusForDatabaseNamed(phpLink->execHandler, databaseName));
}
@@ -1795,7 +1786,7 @@ int mdOk(PHPFBLink* link, FBCMetaData* md, char* sql)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No message");
}
link->errorText = strdup(emg);
link->errorNo = fbcemdErrorCodeAtIndex(emd, 0);;
link->errorNo = fbcemdErrorCodeAtIndex(emd, 0);;
free(emg);
fbcemdRelease(emd);
result = 0;
@@ -1806,7 +1797,7 @@ int mdOk(PHPFBLink* link, FBCMetaData* md, char* sql)
static void phpfbQuery(INTERNAL_FUNCTION_PARAMETERS, char* sql, PHPFBLink* link)
{
PHPFBResult* result = NULL;
PHPFBResult* result = NULL;
FBCMetaData* md, *meta;
char* tp;
char* fh;
@@ -1827,7 +1818,7 @@ static void phpfbQuery(INTERNAL_FUNCTION_PARAMETERS, char* sql, PHPFBLink* link)
else
md = meta;
tp = fbcmdStatementType(md);
tp = fbcmdStatementType(md);
if ((tp[0] == 'C') || (tp[0] == 'R'))
{
@@ -1866,7 +1857,7 @@ static void phpfbQuery(INTERNAL_FUNCTION_PARAMETERS, char* sql, PHPFBLink* link)
fbcrhConvertToOutputCharSet(fbcdcOutputCharacterSet(link->connection), (unsigned char *)r);
if ((result->list = fbcplParse(r)))
{
result->rowCount = fbcplCount(result->list);
result->rowCount = fbcplCount(result->list);
result->columnCount = 7;
}
}
@@ -1964,7 +1955,7 @@ PHP_FUNCTION(fbsql_db_query)
Retreive a list of all databases on the server */
PHP_FUNCTION(fbsql_list_dbs)
{
PHPFBResult* phpResult;
PHPFBResult* phpResult;
PHPFBLink* phpLink = NULL;
zval **fbsql_link_index = NULL;
int id;
@@ -1986,6 +1977,7 @@ PHP_FUNCTION(fbsql_list_dbs)
}
ZEND_FETCH_RESOURCE2(phpLink, PHPFBLink *, fbsql_link_index, id, "FrontBase-Link", le_link, le_plink);
if (phpLink->execHandler == NULL) phpLink->execHandler = fbcehHandlerForHost(phpLink->hostName, 128);
phpResult = emalloc(sizeof(PHPFBResult));
phpResult->link = phpLink;
phpResult->fetchHandle = NULL;
@@ -2053,10 +2045,10 @@ PHP_FUNCTION(fbsql_list_tables)
PHP_FUNCTION(fbsql_list_fields)
{
PHPFBLink* phpLink = NULL;
zval **fbsql_link_index = NULL, **database_name, **table_name;
zval **fbsql_link_index = NULL, **database_name, **table_name;
int id;
char *databaseName, *tableName;
char sql[1024];
char sql[1024];
switch (ZEND_NUM_ARGS()) {
case 2:
@@ -2160,8 +2152,8 @@ PHP_FUNCTION(fbsql_errno)
Enable or disable FrontBase warnings */
PHP_FUNCTION(fbsql_warnings)
{
int argc = ARG_COUNT(ht);
zval **argv[1];
int argc = ARG_COUNT(ht);
zval **argv[1];
if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT;
if (zend_get_parameters_ex(argc, &argv[0])==FAILURE) RETURN_FALSE;
@@ -2265,12 +2257,12 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
phpfbestrdup("True", length, value);
}
break;
case FB_PrimaryKey:
case FB_Integer:
{
int v = *((int*)data);
char b[128];
int v = *((int*)data);
char b[128];
sprintf(b, "%d", v);
phpfbestrdup(b, length, value);
}
@@ -2278,8 +2270,8 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
#ifdef FB_TinyInteger
case FB_TinyInteger:
{
short int v = *((FBTinyInteger*)data);
char b[128];
short int v = *((FBTinyInteger*)data);
char b[128];
sprintf(b, "%d", v);
phpfbestrdup(b, length, value);
}
@@ -2289,7 +2281,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
case FB_LongInteger:
{
FBLongInteger v = *((FBLongInteger*)data);
char b[128];
char b[128];
#ifdef PHP_WIN32
sprintf(b, "%I64i", v);
#else
@@ -2302,7 +2294,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
case FB_SmallInteger:
{
short v = *((short*)data);
char b[128];
char b[128];
sprintf(b, "%d", v);
phpfbestrdup(b, length, value);
}
@@ -2315,7 +2307,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
case FB_Decimal:
{
double v = *((double*)data);
char b[128];
char b[128];
sprintf(b, "%f", v);
phpfbestrdup(b, length, value);
}
@@ -2332,13 +2324,13 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
case FB_Bit:
case FB_VBit:
{
const FBCColumnMetaData* clmd = fbcmdColumnMetaDataAtIndex(md, column);
const FBCColumnMetaData* clmd = fbcmdColumnMetaDataAtIndex(md, column);
struct bitValue
{
unsigned int nBytes;
unsigned int nBytes;
unsigned char* bytes;
};
struct bitValue* ptr = data;
struct bitValue* ptr = data;
unsigned nBits = ptr->nBytes * 8;
if (dtc == FB_Bit) nBits = fbcdmdLength(fbccmdDatatype(clmd));
@@ -2349,7 +2341,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
*length = l*2+3+1;
if (value)
{
char* r = emalloc(l*2+3+1);
char* r = emalloc(l*2+3+1);
r[0] = 'X';
r[1] = '\'';
for (i = 0; i < nBits / 8; i++)
@@ -2361,7 +2353,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
}
r[i*2+2] = '\'';
r[i*2+3] = 0;
*value = r;
*value = r;
}
}
else
@@ -2371,7 +2363,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
*length = l*2+3+1;
if (value)
{
char* r = emalloc(l*2+3+1);
char* r = emalloc(l*2+3+1);
r[0] = 'B';
r[1] = '\'';
for (i = 0; i < nBits; i++)
@@ -2382,7 +2374,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
}
r[i*2+2] = '\'';
r[i*2+3] = 0;
*value = r;
*value = r;
}
}
}
@@ -2402,7 +2394,7 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
case FB_YearMonth:
{
char b[128];
int v = *((unsigned int*)data);
int v = *((unsigned int*)data);
sprintf(b, "%d", v);
phpfbestrdup(b, length, value);
}
@@ -2455,14 +2447,14 @@ void phpfbColumnAsString(PHPFBResult* result, int column, void* data , int* leng
/* {{{ phpfbSqlResult
*/
void phpfbSqlResult(INTERNAL_FUNCTION_PARAMETERS, PHPFBResult* result, int rowIndex, int columnIndex)
void phpfbSqlResult(INTERNAL_FUNCTION_PARAMETERS, PHPFBResult* result, int rowIndex, int columnIndex)
{
void** row;
if (result->list)
{
FBCPList* columns = (FBCPList*)fbcplValueForKey(result->list, "COLUMNS");
FBCPList* column = (FBCPList*)fbcplValueAtIndex(columns, result->rowIndex);
if (columnIndex == 0)
if (columnIndex == 0)
{ /* Name */
FBCPList* name = (FBCPList*)fbcplValueForKey(column, "NAME");
RETURN_STRING((char *)fbcplString((FBCPList*)name), 1);
@@ -2521,7 +2513,7 @@ void phpfbSqlResult(INTERNAL_FUNCTION_PARAMETERS, PHPFBResult* result, int rowIn
}
}
/* }}} */
/* {{{ proto mixed fbsql_result(int result [, int row [, mixed field]])
??? */
PHP_FUNCTION(fbsql_result)
@@ -2560,7 +2552,7 @@ PHP_FUNCTION(fbsql_result)
rowIndex = Z_LVAL_PP(row);
}
columnIndex = result->columnIndex;
columnIndex = result->columnIndex;
if (field)
{
if ((Z_TYPE_PP(field) == IS_STRING) && (result->metaData))
@@ -2584,8 +2576,8 @@ PHP_FUNCTION(fbsql_result)
RETURN_FALSE;
}
}
}
}
phpfbSqlResult(INTERNAL_FUNCTION_PARAM_PASSTHRU, result, rowIndex, columnIndex);
result->columnIndex++;
@@ -2616,9 +2608,9 @@ PHP_FUNCTION(fbsql_next_result)
}
ZEND_FETCH_RESOURCE(result, PHPFBResult *, fbsql_result_index, -1, "FrontBase-Result", le_result);
result->currentResult++;
result->currentResult++;
if (result->currentResult < result->selectResults) {
if (result->fetchHandle) {
if (result->fetchHandle) {
FBCMetaData *md = fbcdcCancelFetch(result->link->connection, result->fetchHandle);
fbcmdRelease(md);
}
@@ -2927,7 +2919,7 @@ static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
{
if (row[i])
{
char* value;
char* value;
unsigned int length;
unsigned int c = 0;
phpfbColumnAsString(result, i, row[i], &length, &value TSRMLS_CC);
@@ -3023,7 +3015,7 @@ PHP_FUNCTION(fbsql_fetch_lengths)
if (array_init(return_value)==FAILURE) RETURN_FALSE;
for (i=0; i < result->columnCount; i++)
{
unsigned length = 0;
unsigned length = 0;
if (result->row[i]) phpfbColumnAsString(result, i, result->row[i], &length, NULL TSRMLS_CC);
add_index_long(return_value, i, length);
}
@@ -3414,9 +3406,9 @@ PHP_FUNCTION(fbsql_field_flags)
PHP_FUNCTION(fbsql_table_name)
{
PHPFBResult* result = NULL;
zval **fbsql_result_index = NULL, **table_index;
zval **fbsql_result_index = NULL, **table_index;
unsigned index;
char* value;
char* value;
unsigned int length;
void** row;
@@ -3502,6 +3494,7 @@ PHP_FUNCTION(fbsql_get_autostart_info)
}
ZEND_FETCH_RESOURCE2(phpLink, PHPFBLink *, fbsql_link_index, id, "FrontBase-Link", le_link, le_plink);
if (phpLink->execHandler == NULL) phpLink->execHandler = fbcehHandlerForHost(phpLink->hostName, 128);
if (phpLink->execHandler == NULL) {
if (FB_SQL_G(generateWarnings))
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No valid Exec handler available for this connection");
+42 -28
View File
@@ -108,7 +108,7 @@ static char** ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRM
/* IP and port conversion box */
union ipbox {
unsigned long l[2];
struct in_addr ia[2];
unsigned short s[4];
unsigned char c[8];
};
@@ -638,9 +638,8 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
sin = (struct sockaddr_in *) sa;
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = ipbox.l[0];
sin->sin_addr = ipbox.ia[0];
sin->sin_port = ipbox.s[2];
ftp->pasv = 2;
return 1;
@@ -653,7 +652,6 @@ int
ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos)
{
databuf_t *data = NULL;
char *ptr;
int lastch;
size_t rcvd;
char arg[11];
@@ -704,12 +702,39 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
}
if (type == FTPTYPE_ASCII) {
for (ptr = data->buf; rcvd; rcvd--, ptr++) {
if (lastch == '\r' && *ptr != '\n')
char *s;
char *ptr = data->buf;
char *e = ptr + rcvd;
/* logic depends on the OS EOL
* Win32 -> \r\n
* Everything Else \n
*/
#ifdef PHP_WIN32
while ((s = strpbrk(ptr, "\r\n"))) {
if (*s == '\n') {
php_stream_putc(outstream, '\r');
if (*ptr != '\r')
php_stream_putc(outstream, *ptr);
lastch = *ptr;
} else if (*s == '\r' && *(s + 1) == '\n') {
s++;
}
s++;
php_stream_write(outstream, ptr, (s - ptr));
if (*(s - 1) == '\r') {
php_stream_putc(outstream, '\n');
}
ptr = s;
}
#else
while ((s = memchr(ptr, '\r', (e - ptr)))) {
php_stream_write(outstream, ptr, (s - ptr));
if (*(s + 1) == '\n') {
s++;
}
php_stream_putc(outstream, '\n');
ptr = s + 1;
}
#endif
if (ptr < e) {
php_stream_write(outstream, ptr, (e - ptr));
}
}
else {
@@ -718,9 +743,6 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
}
}
if (type == FTPTYPE_ASCII && lastch == '\r')
php_stream_putc(outstream, '\r');
ftp->data = data = data_close(ftp, data);
if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {
@@ -1328,7 +1350,7 @@ ftp_getdata(ftpbuf_t *ftp TSRMLS_DC)
#endif
/* send the PORT */
ipbox.l[0] = ((struct sockaddr_in*) sa)->sin_addr.s_addr;
ipbox.ia[0] = ((struct sockaddr_in*) sa)->sin_addr;
ipbox.s[2] = ((struct sockaddr_in*) &addr)->sin_port;
sprintf(arg, "%u,%u,%u,%u,%u,%u",
ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3],
@@ -1454,7 +1476,7 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
char**
ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
{
FILE *tmpfp = NULL;
php_stream *tmpstream = NULL;
databuf_t *data = NULL;
char *ptr;
int ch, lastch;
@@ -1464,7 +1486,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
char **entry;
char *text;
if ((tmpfp = tmpfile()) == NULL) {
if ((tmpstream = php_stream_fopen_tmpfile()) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create temporary file. Check permissions in temporary files directory.");
return NULL;
}
@@ -1492,7 +1514,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
if (rcvd == -1)
goto bail;
fwrite(data->buf, rcvd, 1, tmpfp);
php_stream_write(tmpstream, data->buf, rcvd);
size += rcvd;
for (ptr = data->buf; rcvd; rcvd--, ptr++) {
@@ -1506,12 +1528,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
ftp->data = data = data_close(ftp, data);
if (ferror(tmpfp))
goto bail;
rewind(tmpfp);
php_stream_rewind(tmpstream);
ret = emalloc((lines + 1) * sizeof(char**) + size * sizeof(char*));
@@ -1519,7 +1536,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
text = (char*) (ret + lines + 1);
*entry = text;
lastch = 0;
while ((ch = getc(tmpfp)) != EOF) {
while ((ch = php_stream_getc(tmpstream)) != EOF) {
if (ch == '\n' && lastch == '\r') {
*(text - 1) = 0;
*++entry = text;
@@ -1531,10 +1548,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
}
*entry = NULL;
if (ferror(tmpfp))
goto bail;
fclose(tmpfp);
php_stream_close(tmpstream);
if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {
efree(ret);
@@ -1544,7 +1558,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
return ret;
bail:
ftp->data = data_close(ftp, data);
fclose(tmpfp);
php_stream_close(tmpstream);
if (ret)
efree(ret);
return NULL;
+16 -2
View File
@@ -1617,9 +1617,14 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
switch(image_type) {
case PHP_GDIMG_CONVERT_WBM:
if(q<0||q>255) {
if (q == -1) {
q = 0;
} else if (q < 0 || q > 255) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q);
q = 0;
}
gdImageWBMP(im, q, fp);
break;
case PHP_GDIMG_TYPE_JPG:
(*func_p)(im, fp, q);
break;
@@ -1659,9 +1664,14 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
switch(image_type) {
case PHP_GDIMG_CONVERT_WBM:
if(q<0||q>255) {
if (q == -1) {
q = 0;
} else if (q < 0 || q > 255) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q);
q = 0;
}
gdImageWBMP(im, q, tmp);
break;
case PHP_GDIMG_TYPE_JPG:
(*func_p)(im, tmp, q);
break;
@@ -3625,6 +3635,10 @@ static void _php_image_bw_convert( gdImagePtr im_org, gdIOCtx *out, int threshol
return;
}
if (im_org->trueColor) {
gdImageTrueColorToPalette(im_org, 1, 256);
}
for (y = 0; y < dest_height; y++) {
for (x = 0; x < dest_width; x++) {
color_org = gdImageGetPixel (im_org, x, y);
+13 -2
View File
@@ -571,7 +571,7 @@ void gdImageColorTransparent (gdImagePtr im, int color)
if (im->transparent != -1) {
im->alpha[im->transparent] = gdAlphaOpaque;
}
if (color > -1 && color<=gdMaxColors) {
if (color > -1 && color<im->colorsTotal && color<=gdMaxColors) {
im->alpha[color] = gdAlphaTransparent;
} else {
return;
@@ -1762,13 +1762,18 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
int lastBorder;
/* Seek left */
int leftLimit = -1, rightLimit;
int i;
int i, restoreAlphaBleding=0;
if (border < 0) {
/* Refuse to fill to a non-solid border */
return;
}
if (im->alphaBlendingFlag) {
restoreAlphaBleding = 1;
im->alphaBlendingFlag = 0;
}
if (x >= im->sx) {
x = im->sx - 1;
}
@@ -1784,6 +1789,9 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
leftLimit = i;
}
if (leftLimit == -1) {
if (restoreAlphaBleding) {
im->alphaBlendingFlag = 1;
}
return;
}
/* Seek right */
@@ -1827,6 +1835,9 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
}
}
}
if (restoreAlphaBleding) {
im->alphaBlendingFlag = 1;
}
}
+1 -1
View File
@@ -62,7 +62,7 @@ gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
#include "gdcache.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include "freetype/ftglyph.h"
#include FT_GLYPH_H
/* number of fonts cached before least recently used is replaced */
#define FONTCACHESIZE 6
+23
View File
@@ -0,0 +1,23 @@
--TEST--
gdimagefill() function (Bug #19366 (fixed in bundled libgd))
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
if (!GD_BUNDLED) die('skip external GD libraries always fail');
?>
--FILE--
<?php
/* $id$ */
$dest = dirname(realpath(__FILE__)) . 'bug27582.png';
@unlink($dest);
$im = ImageCreateTrueColor(10, 10);
imagealphablending($im, true);
imagesavealpha($im, false);
$bordercolor=ImageColorAllocateAlpha($im, 0, 0, 0, 2);
$color = ImageColorAllocateAlpha($im, 0, 0, 0, 1);
ImageFillToBorder($im, 5, 5, $bordercolor, $color);
imagepng($im, $dest);
echo md5_file($dest) . "\n";
?>
--EXPECT--
08287f8f5d406946009df5f04ca83dc0
+92
View File
@@ -0,0 +1,92 @@
--TEST--
Bug #24594 (Filling an area using tiles).
--SKIPIF--
<?php
if (!extension_loaded('gd')) {
die("skip gd extension not available\n");
}
if (!GD_BUNDLED) {
die('skip external GD libraries may fail');
}
?>
--FILE--
<?php
/* $id */
/*
* This test segfaults with the current imagefilltoborder
* implementation. A rewrite of this function is required
* to fix it. The algorithm used in gdImageFill (and the
* privat function for tiled fill) may help here. pierre.
*/
$tile = imagecreate(36,36);
$base = imagecreate(150,150);
$white = imagecolorallocate($tile,255,255,255);
$black = imagecolorallocate($tile,0,0,0);
$white = imagecolorallocate($base,255,255,255);
$black = imagecolorallocate($base,0,0,0);
/* create the dots pattern */
for ($x=0;$x<36;$x+=2) {
for ($y=0;$y<36;$y+=2) {
imagesetpixel($tile,$x,$y,$black);
}
}
imagesettile($base,$tile);
imagerectangle($base, 9,9,139,139,$black);
imageline($base, 9,9,139,139,$black);
imagefill($base,11,12,IMG_COLOR_TILED);
$res = imagecolorat($base,0,10)==$black?'1':'0';
$res .= imagecolorat($base,0,20)==$black?'1':'0';
$res .= imagecolorat($base,0,30)==$black?'1':'0';
$res .= imagecolorat($base,0,40)==$black?'1':'0';
$res .= imagecolorat($base,0,50)==$black?'1':'0';
$res .= imagecolorat($base,0,60)==$black?'1':'0';
$res .= imagecolorat($base,11,12)==$white?'1':'0';
$res .= imagecolorat($base,12,13)==$white?'1':'0';
$res .= imagecolorat($base,13,14)==$white?'1':'0';
$res .= imagecolorat($base,14,15)==$white?'1':'0';
$res .= imagecolorat($base,15,16)==$white?'1':'0';
$res .= imagecolorat($base,16,17)==$white?'1':'0';
$res .= imagecolorat($base,10,12)==$black?'1':'0';
$res .= imagecolorat($base,11,13)==$black?'1':'0';
$res .= imagecolorat($base,12,14)==$black?'1':'0';
$res .= imagecolorat($base,13,15)==$black?'1':'0';
$res .= imagecolorat($base,14,16)==$black?'1':'0';
$res .= imagecolorat($base,15,17)==$black?'1':'0';
echo "$res\n";
imagefilledrectangle($base,0,0,149,149,$white);
imagerectangle($base, 9,9,139,139,$black);
imageline($base, 9,9,139,139,$black);
imagefilltoborder($base,0,0,$black,IMG_COLOR_TILED);
$res = imagecolorat($base,0,10)==$black?'1':'0';
$res .= imagecolorat($base,0,20)==$black?'1':'0';
$res .= imagecolorat($base,0,30)==$black?'1':'0';
$res .= imagecolorat($base,0,40)==$black?'1':'0';
$res .= imagecolorat($base,0,50)==$black?'1':'0';
$res .= imagecolorat($base,0,60)==$black?'1':'0';
$res .= imagecolorat($base,11,12)==$white?'1':'0';
$res .= imagecolorat($base,12,13)==$white?'1':'0';
$res .= imagecolorat($base,13,14)==$white?'1':'0';
$res .= imagecolorat($base,14,15)==$white?'1':'0';
$res .= imagecolorat($base,15,16)==$white?'1':'0';
$res .= imagecolorat($base,16,17)==$white?'1':'0';
$res .= imagecolorat($base,0,16)==$black?'1':'0';
$res .= imagecolorat($base,2,42)==$black?'1':'0';
$res .= imagecolorat($base,4,44)==$black?'1':'0';
$res .= imagecolorat($base,146,146)==$black?'1':'0';
$res .= imagecolorat($base,148,146)==$black?'1':'0';
$res .= imagecolorat($base,0,0)==$black?'1':'0';
echo "$res\n";
?>
--EXPECT--
000000111111101010
111111111111111111
+14 -1
View File
@@ -309,6 +309,10 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv
FETCH_GMP_ZVAL(gmpnum_b, b_arg);
}
if (!Z_LVAL_PP(b_arg)) {
RETURN_FALSE;
}
INIT_GMP_NUM(gmpnum_result);
if(use_ui && gmp_ui_op) {
if(allow_ui_return) {
@@ -348,6 +352,10 @@ static inline void gmp_zval_binary_ui_op2_ex(zval *return_value, zval **a_arg, z
FETCH_GMP_ZVAL(gmpnum_b, b_arg);
}
if (!Z_LVAL_PP(b_arg)) {
RETURN_FALSE;
}
INIT_GMP_NUM(gmpnum_result1);
INIT_GMP_NUM(gmpnum_result2);
@@ -822,6 +830,11 @@ ZEND_FUNCTION(gmp_powm)
}
FETCH_GMP_ZVAL(gmpnum_mod, mod_arg);
convert_to_long_ex(mod_arg);
if (!Z_LVAL_PP(mod_arg)) {
RETURN_FALSE;
}
INIT_GMP_NUM(gmpnum_result);
if(use_ui) {
mpz_powm_ui(*gmpnum_result, *gmpnum_base, (unsigned long)Z_LVAL_PP(exp_arg), *gmpnum_mod);
@@ -1219,7 +1232,7 @@ ZEND_FUNCTION(gmp_hamdist)
zval **a_arg, **b_arg;
mpz_t *gmpnum_a, *gmpnum_b;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(1, &a_arg, &b_arg) == FAILURE){
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &a_arg, &b_arg) == FAILURE){
WRONG_PARAM_COUNT;
}
+1 -1
View File
@@ -1,2 +1,2 @@
InterBase
Jouni Ahto, Andrew Avdeev
Jouni Ahto, Andrew Avdeev, Ard Biesheuvel
+26 -18
View File
@@ -945,7 +945,7 @@ PHP_FUNCTION(ibase_connect)
Open a persistent connection to an InterBase database */
PHP_FUNCTION(ibase_pconnect)
{
_php_ibase_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
_php_ibase_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, IBG(allow_persistent));
}
/* }}} */
@@ -1214,6 +1214,12 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, ibase_qu
var->sqlind = &buf[i].sqlind;
if (Z_TYPE_P(b_var) == IS_NULL) {
if ((var->sqltype & 1) != 1) {
_php_ibase_module_error("Parameter %d must have a value" TSRMLS_CC, i+1);
rv = FAILURE;
}
buf[i].sqlind = -1;
} else {
buf[i].sqlind = 0;
@@ -1836,32 +1842,34 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, int sca
}
break;
#ifdef SQL_INT64
case SQL_INT64:
case SQL_INT64: {
ISC_INT64 n = *(ISC_INT64 *) data;
Z_TYPE_P(val) = IS_STRING;
if (scale < 0 ){
short j = 0;
ISC_INT64 n, f = 1;
n = (ISC_INT64) *(ISC_INT64 *) data;
for (j = 0; j < -scale; j++) {
if (scale < 0) {
short j;
ISC_INT64 f = 1;
for (j = 0; j < -scale; ++j) {
f *= 10;
}
if ( n >= 0){
Z_STRLEN_P(val) = sprintf (string_data, "%" ISC_INT64_FORMAT "d.%0*" ISC_INT64_FORMAT "d",
(ISC_INT64) n / f, -scale, (ISC_INT64) n % f );
}else if ((n/f) != 0 ){
Z_STRLEN_P(val) = sprintf (string_data, "%" ISC_INT64_FORMAT "d.%0*" ISC_INT64_FORMAT "d",
(ISC_INT64) n / f, -scale, (ISC_INT64) -(n % f) );
}else{
Z_STRLEN_P(val) = sprintf (string_data, "%s.%0*" ISC_INT64_FORMAT "d",
"-0", -scale, (ISC_INT64) -(n % f) );
if (n >= 0) {
Z_STRLEN_P(val) = sprintf (string_data,
"%" ISC_INT64_FORMAT "d.%0*" ISC_INT64_FORMAT "d", n / f, -scale, n % f);
} else if (n < -f) {
Z_STRLEN_P(val) = sprintf (string_data,
"%" ISC_INT64_FORMAT "d.%0*" ISC_INT64_FORMAT "d", n / f, -scale, -n % f);
} else {
Z_STRLEN_P(val) = sprintf (string_data,
"-0.%0*" ISC_INT64_FORMAT "d", -scale, -n % f);
}
} else {
Z_STRLEN_P(val) =sprintf (string_data, "%.0" ISC_INT64_FORMAT "d",
(ISC_INT64) *(ISC_INT64 *) data);
Z_STRLEN_P(val) = sprintf (string_data, "%" ISC_INT64_FORMAT "d", n);
}
Z_STRVAL_P(val) = estrdup(string_data);
break;
}
#endif
#ifndef SQL_TIMESTAMP
case SQL_DATE:
+12 -12
View File
@@ -7,21 +7,21 @@ InterBase: connect, close and pconnect
--FILE--
<?php /* $Id$ */
require("interbase.inc");
ibase_connect($test_base);
out_table("test1");
ibase_close();
require("interbase.inc");
$con = ibase_connect($test_base);
$pcon1 = ibase_pconnect($test_base);
$pcon2 = ibase_pconnect($test_base);
ibase_close($con);
ibase_close($pcon1);
ibase_connect($test_base);
out_table("test1");
ibase_close();
out_table("test1");
$con = ibase_connect($test_base);
$pcon1 = ibase_pconnect($test_base);
$pcon2 = ibase_pconnect($test_base);
ibase_close($con);
ibase_close($pcon1);
ibase_close($pcon2);
out_table("test1");
ibase_close($pcon2);
?>
--EXPECT--
--- test1 ---
+121 -116
View File
@@ -5,127 +5,132 @@ InterBase: misc sql types (may take a while)
--POST--
--GET--
--FILE--
<?php
<?php /* $Id$ */
require("interbase.inc");
ibase_connect($test_base);
ibase_query(
"create table test3 (
iter integer,
v_char char(1000),
v_date timestamp,
v_decimal4_2 decimal(4,2),
v_decimal4_0 decimal(4,0),
v_decimal7_2 decimal(7,2),
v_decimal7_0 decimal(7,0),
v_numeric15_15 numeric(15,15),
v_numeric15_0 numeric(15,0),
v_double double precision,
v_float float,
v_integer integer,
v_smallint smallint,
v_varchar varchar(10000)
)");
ibase_commit();
require("interbase.inc");
/* if timefmt is not supported, suppress error here */
@ibase_timefmt("%m/%d/%Y %H:%M:%S");
ibase_connect($test_base);
for($iter = 0; $iter < 10; $iter++){
/* prepare data */
$v_char = rand_str(1000);
$v_date = rand_datetime();
$v_decimal4_2 = rand_number(4,2);
$v_decimal4_0 = rand_number(4,0);
$v_decimal7_2 = rand_number(7,2);
$v_decimal7_0 = rand_number(7,0);
$v_numeric15_15 = rand_number(15,15);
$v_numeric15_0 = rand_number(15,0);
$v_double = rand_number(18);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_smallint = rand_number(5) % 32767;
$v_varchar = rand_str(10000);
ibase_query(
"CREATE TABLE test3 (
iter integer not null,
v_char char(1000),
v_date timestamp,
v_decimal4_2 decimal(4,2),
v_decimal4_0 decimal(4,0),
v_decimal7_2 decimal(7,2),
v_decimal7_0 decimal(7,0),
v_numeric15_15 numeric(15,15),
v_numeric15_0 numeric(15,0),
v_double double precision,
v_float float,
v_integer integer,
v_smallint smallint,
v_varchar varchar(10000)
)");
ibase_commit();
ibase_query(
"insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar)
values ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0,$v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')");
$sel = ibase_query("select * from test3 where iter = $iter");
$row = ibase_fetch_object($sel);
if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){
echo " CHAR fail:\n";
echo " in: $v_char\n";
echo " out: $row->V_CHAR\n";
}
if($row->V_DATE != $v_date){
echo " DATE fail\n";
echo " in: $v_date\n";
echo " out: $row->V_DATE\n";
}
if($row->V_DECIMAL4_2 != $v_decimal4_2){
echo " DECIMAL4_2 fail\n";
echo " in: $v_decimal4_2\n";
echo " out: $row->V_DECIMAL4_2\n";
}
if($row->V_DECIMAL4_0 != $v_decimal4_0){
echo " DECIMAL4_0 fail\n";
echo " in: $v_decimal4_0\n";
echo " out: $row->V_DECIMAL4_0\n";
}
if($row->V_DECIMAL7_2 != $v_decimal7_2){
echo " DECIMAL7_2 fail\n";
echo " in: $v_decimal7_2\n";
echo " out: $row->V_DECIMAL7_2\n";
}
if($row->V_DECIMAL7_0 != $v_decimal7_0){
echo " DECIMAL7_0 fail\n";
echo " in: $v_decimal7_0\n";
echo " out: $row->V_DECIMAL7_0\n";
}
if($row->V_NUMERIC15_15 != $v_numeric15_15){
echo " NUMERIC15_15 fail\n";
echo " in: $v_numeric15_15\n";
echo " out: $row->V_NUMERIC15_15\n";
}
if($row->V_NUMERIC15_0 != $v_numeric15_0){
echo " NUMERIC15_0 fail\n";
echo " in: $v_numeric15_0\n";
echo " out: $row->V_NUMERIC15_0\n";
}
if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){
echo " DOUBLE fail\n";
echo " in: $v_double\n";
echo " out: $row->V_DOUBLE\n";
}
if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){
echo " FLOAT fail\n";
echo " in: $v_float\n";
echo " out: $row->V_FLOAT\n";
}
if($row->V_INTEGER != $v_integer){
echo " INTEGER fail\n";
echo " in: $v_integer\n";
echo " out: $row->V_INTEGER\n";
}
if($row->V_SMALLINT != $v_smallint){
echo " SMALLINT fail\n";
echo " in: $v_smallint\n";
echo " out: $row->V_SMALLINT\n";
}
if(substr($row->V_VARCHAR,0,strlen($v_varchar)) != $v_varchar){
echo " VARCHAR fail:\n";
echo " in: $v_varchar\n";
echo " out: $row->V_VARCHAR\n";
}
ibase_free_result($sel);
} /* for($iter) */
/* should fail, but gracefully */
@ibase_query("INSERT INTO test3 (iter) VALUES (?)", null);
ibase_close();
echo "end of test\n";
/* if timefmt is not supported, suppress error here */
@ibase_timefmt("%m/%d/%Y %H:%M:%S");
for ($iter = 0; $iter < 10; ++$iter) {
/* prepare data */
$v_char = rand_str(1000);
$v_date = rand_datetime();
$v_decimal4_2 = rand_number(4,2);
$v_decimal4_0 = rand_number(4,0);
$v_decimal7_2 = rand_number(7,2);
$v_decimal7_0 = rand_number(7,0);
$v_numeric15_15 = rand_number(15,15);
$v_numeric15_0 = $iter ? rand_number(15,0) : 0;
$v_double = rand_number(18);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_smallint = rand_number(5) % 32767;
$v_varchar = rand_str(10000);
ibase_query(
"INSERT INTO test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,
v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar)
VALUES ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0,
$v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')");
$sel = ibase_query('SELECT * FROM test3 WHERE iter = ?',$iter);
$row = ibase_fetch_object($sel);
if (substr($row->V_CHAR,0,strlen($v_char)) != $v_char) {
echo " CHAR fail:\n";
echo " in: $v_char\n";
echo " out: $row->V_CHAR\n";
}
if ($row->V_DATE != $v_date) {
echo " DATE fail\n";
echo " in: $v_date\n";
echo " out: $row->V_DATE\n";
}
if ($row->V_DECIMAL4_2 != $v_decimal4_2) {
echo " DECIMAL4_2 fail\n";
echo " in: $v_decimal4_2\n";
echo " out: $row->V_DECIMAL4_2\n";
}
if ($row->V_DECIMAL4_0 != $v_decimal4_0) {
echo " DECIMAL4_0 fail\n";
echo " in: $v_decimal4_0\n";
echo " out: $row->V_DECIMAL4_0\n";
}
if ($row->V_DECIMAL7_2 != $v_decimal7_2) {
echo " DECIMAL7_2 fail\n";
echo " in: $v_decimal7_2\n";
echo " out: $row->V_DECIMAL7_2\n";
}
if ($row->V_DECIMAL7_0 != $v_decimal7_0) {
echo " DECIMAL7_0 fail\n";
echo " in: $v_decimal7_0\n";
echo " out: $row->V_DECIMAL7_0\n";
}
if ($row->V_NUMERIC15_15 != $v_numeric15_15) {
echo " NUMERIC15_15 fail\n";
echo " in: $v_numeric15_15\n";
echo " out: $row->V_NUMERIC15_15\n";
}
if ($row->V_NUMERIC15_0 != (string)$v_numeric15_0) {
echo " NUMERIC15_0 fail\n";
echo " in: $v_numeric15_0\n";
echo " out: $row->V_NUMERIC15_0\n";
}
if (abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)) {
echo " DOUBLE fail\n";
echo " in: $v_double\n";
echo " out: $row->V_DOUBLE\n";
}
if (abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)) {
echo " FLOAT fail\n";
echo " in: $v_float\n";
echo " out: $row->V_FLOAT\n";
}
if ($row->V_INTEGER != $v_integer) {
echo " INTEGER fail\n";
echo " in: $v_integer\n";
echo " out: $row->V_INTEGER\n";
}
if ($row->V_SMALLINT != $v_smallint) {
echo " SMALLINT fail\n";
echo " in: $v_smallint\n";
echo " out: $row->V_SMALLINT\n";
}
if (substr($row->V_VARCHAR,0,strlen($v_varchar)) != $v_varchar) {
echo " VARCHAR fail:\n";
echo " in: $v_varchar\n";
echo " out: $row->V_VARCHAR\n";
}
ibase_free_result($sel);
} /* for($iter) */
ibase_close();
echo "end of test\n";
?>
--EXPECT--
end of test
+91 -89
View File
@@ -5,116 +5,118 @@ InterBase: BLOB test
--POST--
--GET--
--FILE--
<?php
<?php /* $Id$ */
require("interbase.inc");
ibase_connect($test_base);
require("interbase.inc");
ibase_query(
"create table test4 (
v_integer integer,
v_blob blob)");
ibase_commit();
ibase_connect($test_base);
/* create 100k blob file */
$blob_str = rand_binstr(100*1024);
ibase_query(
"CREATE TABLE test4 (
v_integer integer,
v_blob blob)");
ibase_commit();
$name = tempnam(dirname(__FILE__),"blob.tmp");
$ftmp = fopen($name,"w");
fwrite($ftmp,$blob_str);
fclose($ftmp);
/* create 100k blob file */
$blob_str = rand_binstr(100*1024);
echo "import blob 1\n";
$ftmp = fopen($name,"r");
$bl_s = ibase_blob_import($ftmp);
ibase_query("insert into test4 (v_integer, v_blob) values (1, ?)", $bl_s);
$name = tempnam(dirname(__FILE__),"blob.tmp");
$ftmp = fopen($name,"w");
fwrite($ftmp,$blob_str);
fclose($ftmp);
echo "test blob 1\n";
$q = ibase_query("select v_blob from test4 where v_integer = 1");
$row = ibase_fetch_object($q);
$bl_h = ibase_blob_open($row->V_BLOB);
echo "import blob 1\n";
$blob = '';
while($piece = ibase_blob_get($bl_h, 1 + rand() % 1024))
$blob .= $piece;
if($blob != $blob_str)
echo " BLOB 1 fail (1)\n";
ibase_blob_close($bl_h);
$ftmp = fopen($name,"r");
$bl_s = ibase_blob_import($ftmp);
ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (1, ?)", $bl_s);
$bl_h = ibase_blob_open($row->V_BLOB);
echo "test blob 1\n";
$blob = '';
while($piece = ibase_blob_get($bl_h, 100 * 1024))
$blob .= $piece;
if($blob != $blob_str)
echo " BLOB 1 fail (2)\n";
ibase_blob_close($bl_h);
ibase_free_result($q);
unset($blob);
$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 1");
$row = ibase_fetch_object($q);
$bl_h = ibase_blob_open($row->V_BLOB);
echo "create blob 2\n";
$blob = '';
while ($piece = ibase_blob_get($bl_h, 1 + rand() % 1024))
$blob .= $piece;
if ($blob != $blob_str)
echo " BLOB 1 fail (1)\n";
ibase_blob_close($bl_h);
ibase_query("insert into test4 (v_integer, v_blob) values (2, ?)", $blob_str);
$bl_h = ibase_blob_open($row->V_BLOB);
echo "test blob 2\n";
$blob = '';
while ($piece = ibase_blob_get($bl_h, 100 * 1024))
$blob .= $piece;
if ($blob != $blob_str)
echo " BLOB 1 fail (2)\n";
ibase_blob_close($bl_h);
ibase_free_result($q);
unset($blob);
$q = ibase_query("select v_blob from test4 where v_integer = 2");
$row = ibase_fetch_object($q,IBASE_TEXT);
echo "create blob 2\n";
if($row->V_BLOB != $blob_str)
echo " BLOB 2 fail\n";
ibase_free_result($q);
unset($blob);
ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (2, ?)", $blob_str);
echo "test blob 2\n";
echo "create blob 3\n";
$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 2");
$row = ibase_fetch_object($q,IBASE_TEXT);
$bl_h = ibase_blob_create();
if ($row->V_BLOB != $blob_str)
echo " BLOB 2 fail\n";
ibase_free_result($q);
unset($blob);
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n");
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n");
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n");
ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n");
ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n");
ibase_blob_add($bl_h, "| any later version. |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n");
ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n");
ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n");
ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n");
ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n");
ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n");
ibase_blob_add($bl_h, "| contact core@php.net. |\n");
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
$bl_s = ibase_blob_close($bl_h);
ibase_query("insert into test4 (v_integer, v_blob) values (3, ?)", $bl_s);
echo "create blob 3\n";
echo "echo blob 3\n";
$bl_h = ibase_blob_create();
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n");
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n");
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n");
ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n");
ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n");
ibase_blob_add($bl_h, "| any later version. |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n");
ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n");
ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n");
ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n");
ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n");
ibase_blob_add($bl_h, "| |\n");
ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n");
ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n");
ibase_blob_add($bl_h, "| contact core@php.net. |\n");
ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
$bl_s = ibase_blob_close($bl_h);
ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (3, ?)", $bl_s);
$q = ibase_query("select v_blob from test4 where v_integer = 3");
$row = ibase_fetch_object($q);
ibase_blob_echo($row->V_BLOB);
ibase_free_result($q);
echo "fetch blob 3\n";
$q = ibase_query("select v_blob from test4 where v_integer = 3");
$row = ibase_fetch_object($q,IBASE_TEXT);
echo $row->V_BLOB;
ibase_free_result($q);
echo "echo blob 3\n";
ibase_close();
unlink($name);
echo "end of test\n";
$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3");
$row = ibase_fetch_object($q);
ibase_blob_echo($row->V_BLOB);
ibase_free_result($q);
echo "fetch blob 3\n";
$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3");
$row = ibase_fetch_object($q,IBASE_TEXT);
echo $row->V_BLOB;
ibase_free_result($q);
ibase_close();
unlink($name);
echo "end of test\n";
?>
--EXPECT--
import blob 1
+143 -143
View File
@@ -5,19 +5,19 @@ InterBase: transactions
--POST--
--GET--
--FILE--
<?php
<?php /* $Id$ */
require("interbase.inc");
ibase_connect($test_base);
require("interbase.inc");
@ibase_query("create table test5 (i integer)");
@ibase_query("delete from test5");
ibase_close();
ibase_connect($test_base);
@ibase_query("CREATE TABLE test5 (i integer)");
@ibase_query("DELETE FROM test5");
ibase_close();
echo "default transaction:\n";
echo "default transaction:\n";
/*
Difference between default and other transactions:
default commited when you call ibase_close().
@@ -32,35 +32,35 @@ ibase_blob_create(), ibase_blob_import() first time.
/*
simple default transaction test without ibase_trans()
*/
ibase_connect($test_base);
echo "empty table\n";
ibase_connect($test_base);
/* out_table call ibase_query()
and ibase_query() start default transaction */
out_table("test5");
echo "empty table\n";
/* in default transaction context */
ibase_query("insert into test5 (i) values (1)");
/* out_table call ibase_query()
and ibase_query() start default transaction */
out_table("test5");
echo "one row\n";
out_table("test5");
/* in default transaction context */
ibase_query("INSERT INTO test5 (i) VALUES (1)");
ibase_rollback(); /* default rolled */
echo "one row\n";
out_table("test5");
echo "after rollback table empty again\n";
out_table("test5"); /* started new default transaction */
ibase_query("insert into test5 (i) values (2)");
ibase_rollback(); /* default rolled */
ibase_close(); /* commit here! */
ibase_connect($test_base);
echo "one row\n";
out_table("test5");
ibase_close();
echo "after rollback table empty again\n";
out_table("test5"); /* started new default transaction */
ibase_query("INSERT INTO test5 (i) VALUES (2)");
ibase_close(); /* commit here! */
ibase_connect($test_base);
echo "one row\n";
out_table("test5");
ibase_close();
/*
default transaction on default link
@@ -68,145 +68,145 @@ First open transaction on link will be default.
$tr_def_l1 may be ommited. All queryes without link and trans
parameters run in this context
*/
$link_def = ibase_connect($test_base);
$tr_def_l1 = ibase_trans(IBASE_READ); /* here transaction start */
/* all default */
$res = ibase_query("select * from test5");
echo "one row\n";
out_result($res,"test5");
ibase_free_result($res);
$link_def = ibase_connect($test_base);
/* specify transaction context... */
$res = ibase_query($tr_def_l1, "select * from test5");
echo "one row... again.\n";
out_result($res,"test5");
$tr_def_l1 = ibase_trans(IBASE_READ); /* here transaction start */
ibase_free_result($res);
/* specify default transaction on link */
$res = ibase_query($link_def, "select * from test5");
echo "one row.\n";
out_result($res,"test5");
/* all default */
$res = ibase_query("SELECT * FROM test5");
ibase_free_result($res);
echo "one row\n";
out_result($res,"test5");
ibase_rollback($link_def); /* just for example */
ibase_free_result($res);
/* specify transaction context... */
$res = ibase_query($tr_def_l1, "SELECT * FROM test5");
echo "one row... again.\n";
out_result($res,"test5");
ibase_free_result($res);
/* specify default transaction on link */
$res = ibase_query($link_def, "SELECT * FROM test5");
echo "one row.\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_rollback($link_def); /* just for example */
ibase_close();
ibase_close();
/*
three transaction on default link
*/
ibase_connect($test_base);
$tr_1 = ibase_trans(); /* this default transaction also */
$tr_2 = ibase_trans(IBASE_READ);
$tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT);
$tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT);
$res = ibase_query("select * from test5");
echo "one row\n";
out_result($res,"test5");
ibase_connect($test_base);
ibase_free_result($res);
$tr_1 = ibase_trans(); /* this default transaction also */
$tr_2 = ibase_trans(IBASE_READ);
$tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT);
$tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT);
/* insert in first transaction context... */
/* as default */
ibase_query("insert into test5 (i) values (3)");
/* specify context */
ibase_query($tr_1, "insert into test5 (i) values (4)");
$res = ibase_query("select * from test5");
echo "three rows\n";
out_result($res,"test5");
$res = ibase_query("select * from test5");
ibase_free_result($res);
$res = ibase_query($tr_1, "select * from test5");
echo "three rows again\n";
out_result($res,"test5");
echo "one row\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_commit($tr_1);
ibase_free_result($res);
$tr_1 = ibase_trans();
ibase_query($tr_1, "insert into test5 (i) values (5)");
/* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */
$res = ibase_query($tr_2, "select * from test5");
echo "one row in second transaction\n";
out_result($res,"test5");
/* insert in first transaction context... */
/* as default */
ibase_query("INSERT INTO test5 (i) VALUES (3)");
/* specify context */
ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (4)");
ibase_free_result($res);
$res = ibase_query("SELECT * FROM test5");
/* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */
$res = ibase_query($tr_3, "select * from test5");
echo "three rows in third transaction\n";
out_result($res,"test5");
echo "three rows\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_free_result($res);
/* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */
$res = ibase_query($tr_4, "select * from test5");
echo "three rows in fourth transaction with deadlock\n";
out_result_trap_error($res,"test5");
$res = ibase_query($tr_1, "SELECT * FROM test5");
ibase_free_result($res);
ibase_rollback($tr_1);
ibase_close();
echo "three rows again\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_commit($tr_1);
$tr_1 = ibase_trans();
ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (5)");
/* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */
$res = ibase_query($tr_2, "SELECT * FROM test5");
echo "one row in second transaction\n";
out_result($res,"test5");
ibase_free_result($res);
/* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */
$res = ibase_query($tr_3, "SELECT * FROM test5");
echo "three rows in third transaction\n";
out_result($res,"test5");
ibase_free_result($res);
/* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */
$res = ibase_query($tr_4, "SELECT * FROM test5");
echo "three rows in fourth transaction with deadlock\n";
out_result_trap_error($res,"test5");
ibase_free_result($res);
ibase_rollback($tr_1);
ibase_close();
/*
transactions on second link
*/
$link_1 = ibase_pconnect($test_base);
$link_2 = ibase_pconnect($test_base);
$tr_1 = ibase_trans(IBASE_DEFAULT, $link_2); /* this default transaction also */
$tr_2 = ibase_trans(IBASE_COMMITTED, $link_2);
$res = ibase_query($tr_1, "select * from test5");
echo "three rows\n";
out_result($res,"test5");
$link_1 = ibase_pconnect($test_base);
$link_2 = ibase_pconnect($test_base);
ibase_free_result($res);
$tr_1 = ibase_trans(IBASE_DEFAULT, $link_2); /* this default transaction also */
$tr_2 = ibase_trans(IBASE_COMMITTED, $link_2);
ibase_query($tr_1, "insert into test5 (i) values (5)");
$res = ibase_query($tr_1, "select * from test5");
echo "four rows\n";
out_result($res,"test5");
$res = ibase_query($tr_1, "SELECT * FROM test5");
ibase_free_result($res);
ibase_commit($tr_1);
$res = ibase_query($tr_2, "select * from test5");
echo "four rows again\n";
out_result($res,"test5");
echo "three rows\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_close($link_1);
ibase_close($link_2);
ibase_free_result($res);
echo "end of test\n";
ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (5)");
$res = ibase_query($tr_1, "SELECT * FROM test5");
echo "four rows\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_commit($tr_1);
$res = ibase_query($tr_2, "SELECT * FROM test5");
echo "four rows again\n";
out_result($res,"test5");
ibase_free_result($res);
ibase_close($link_1);
ibase_close($link_2);
echo "end of test\n";
?>
--EXPECT--
default transaction:
+165 -169
View File
@@ -5,200 +5,196 @@ InterBase: binding (may take a while)
--POST--
--GET--
--FILE--
<?php
<?php /* $Id$ */
require("interbase.inc");
ibase_connect($test_base);
ibase_query(
"create table test6 (
iter integer,
v_char char(1000),
v_date timestamp,
v_decimal decimal(12,3),
v_double double precision,
v_float float,
v_integer integer,
v_numeric numeric(4,2),
v_smallint smallint,
v_varchar varchar(10000)
)");
ibase_commit();
require("interbase.inc");
/* if timefmt not supported, hide error */
@ibase_timefmt("%m/%d/%Y %H:%M:%S");
ibase_connect($test_base);
echo "insert\n";
ibase_query(
"CREATE TABLE test6 (
iter integer,
v_char char(1000),
v_date timestamp,
v_decimal decimal(12,3),
v_double double precision,
v_float float,
v_integer integer,
v_numeric numeric(4,2),
v_smallint smallint,
v_varchar varchar(10000)
)");
ibase_commit();
for($iter = 0; $iter < 3; $iter++){
/* prepare data */
$v_char = rand_str(1000);
$v_date = rand_datetime();
$v_decimal = rand_number(12,3);
$v_double = rand_number(20);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_numeric = rand_number(4,2);
$v_smallint = rand_number(5) % 32767;
$v_varchar = rand_str(10000);
/* if timefmt not supported, hide error */
@ibase_timefmt("%m/%d/%Y %H:%M:%S");
ibase_query("insert into test6
(iter,v_char,v_date,v_decimal,v_double,v_float,
v_integer,v_numeric,v_smallint,v_varchar)
values (?,?,?,?,?,?,?,?,?,?)",
$iter, $v_char, $v_date, $v_decimal, $v_double, $v_float,
$v_integer, $v_numeric, $v_smallint, $v_varchar);
$sel = ibase_query("select * from test6 where iter = $iter");
echo "insert\n";
$row = ibase_fetch_object($sel);
if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){
echo " CHAR fail:\n";
echo " in: $v_char\n";
echo " out: $row->V_CHAR\n";
}
if($row->V_DATE != $v_date){
echo " DATE fail\n";
echo " in: $v_date\n";
echo " out: $row->V_DATE\n";
}
if($row->V_DECIMAL != $v_decimal){
echo " DECIMAL fail\n";
echo " in: $v_decimal\n";
echo " out: $row->V_DECIMAL\n";
}
if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){
echo " DOUBLE fail\n";
echo " in: $v_double\n";
echo " out: $row->V_DOUBLE\n";
}
if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){
echo " FLOAT fail\n";
echo " in: $v_float\n";
echo " out: $row->V_FLOAT\n";
}
if($row->V_INTEGER != $v_integer){
echo " INTEGER fail\n";
echo " in: $v_integer\n";
echo " out: $row->V_INTEGER\n";
}
if ($row->V_NUMERIC != $v_numeric){
echo " NUMERIC fail\n";
echo " in: $v_numeric\n";
echo " out: $row->V_NUMERIC\n";
}
if ($row->V_SMALLINT != $v_smallint){
echo " SMALLINT fail\n";
echo " in: $v_smallint\n";
echo " out: $row->V_SMALLINT\n";
}
if ($row->V_VARCHAR != $v_varchar){
echo " VARCHAR fail:\n";
echo " in: $v_varchar\n";
echo " out: $row->V_VARCHAR\n";
}
ibase_free_result($sel);
}/* for($iter)*/
for ($iter = 0; $iter < 3; ++$iter) {
/* prepare data */
$v_char = rand_str(1000);
$v_date = rand_datetime();
$v_decimal = rand_number(12,3);
$v_double = rand_number(20);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_numeric = rand_number(4,2);
$v_smallint = rand_number(5) % 32767;
$v_varchar = rand_str(10000);
echo "select\n";
for($iter = 0; $iter < 3; $iter++){
/* prepare data */
$v_char = rand_str(1000);
$v_date = rand_datetime();
$v_decimal = rand_number(12,3);
$v_double = rand_number(20);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_numeric = rand_number(4,2);
$v_smallint = rand_number(5) % 32767;
$v_varchar = rand_str(10000);
ibase_query("INSERT INTO test6
(iter,v_char,v_date,v_decimal,v_double,v_float, v_integer,
v_numeric,v_smallint,v_varchar) VALUES (?,?,?,?,?,?,?,?,?,?)",
$iter, $v_char, $v_date, $v_decimal, $v_double, $v_float,
$v_integer, $v_numeric, $v_smallint, $v_varchar);
$sel = ibase_query("SELECT * FROM test6 WHERE iter = $iter");
/* clear table*/
ibase_query("delete from test6");
$row = ibase_fetch_object($sel);
if (substr($row->V_CHAR,0,strlen($v_char)) != $v_char) {
echo " CHAR fail:\n";
echo " in: $v_char\n";
echo " out: $row->V_CHAR\n";
}
if ($row->V_DATE != $v_date) {
echo " DATE fail\n";
echo " in: $v_date\n";
echo " out: $row->V_DATE\n";
}
if ($row->V_DECIMAL != $v_decimal) {
echo " DECIMAL fail\n";
echo " in: $v_decimal\n";
echo " out: $row->V_DECIMAL\n";
}
if (abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)) {
echo " DOUBLE fail\n";
echo " in: $v_double\n";
echo " out: $row->V_DOUBLE\n";
}
if (abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)) {
echo " FLOAT fail\n";
echo " in: $v_float\n";
echo " out: $row->V_FLOAT\n";
}
if ($row->V_INTEGER != $v_integer) {
echo " INTEGER fail\n";
echo " in: $v_integer\n";
echo " out: $row->V_INTEGER\n";
}
if ($row->V_NUMERIC != $v_numeric) {
echo " NUMERIC fail\n";
echo " in: $v_numeric\n";
echo " out: $row->V_NUMERIC\n";
}
if ($row->V_SMALLINT != $v_smallint) {
echo " SMALLINT fail\n";
echo " in: $v_smallint\n";
echo " out: $row->V_SMALLINT\n";
}
if ($row->V_VARCHAR != $v_varchar) {
echo " VARCHAR fail:\n";
echo " in: $v_varchar\n";
echo " out: $row->V_VARCHAR\n";
}
ibase_free_result($sel);
} /* for($iter) */
/* make one record */
ibase_query("insert into test6
(iter, v_char,v_date,v_decimal,
v_integer,v_numeric,v_smallint,v_varchar)
values (666, '$v_char','$v_date',$v_decimal, $v_integer,
$v_numeric, $v_smallint, '$v_varchar')");
echo "select\n";
for ($iter = 0; $iter < 3; ++$iter) {
/* prepare data */
$v_char = rand_str(1000);
$v_date = rand_datetime();
$v_decimal = rand_number(12,3);
$v_double = rand_number(20);
$v_float = rand_number(7);
$v_integer = rand_number(9,0);
$v_numeric = rand_number(4,2);
$v_smallint = rand_number(5) % 32767;
$v_varchar = rand_str(10000);
/* test all types */
if(!($sel = ibase_query(
"select iter from test6 where v_char = ?", $v_char)))
echo "CHAR fail\n";
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test6 where v_date = ?", $v_date)))
echo "DATE fail\n";
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test6 where v_decimal = ?", $v_decimal)))
echo "DECIMAL fail\n";
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test6 where v_integer = ?", $v_integer)))
echo "INTEGER fail\n";
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test6 where v_numeric = ?", $v_numeric)))
echo "NUMERIC fail\n";
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test6 where v_smallint = ?", $v_smallint)))
echo "SMALLINT fail\n";
ibase_free_result($sel);
if(!($sel = ibase_query(
"select iter from test6 where v_varchar = ?", $v_varchar)))
echo "VARCHAR fail\n";
ibase_free_result($sel);
}/*for iter*/
/* clear table*/
ibase_query("DELETE FROM test6");
echo "prepare and exec insert\n";
/* make one record */
ibase_query("INSERT INTO test6 (iter, v_char,v_date,v_decimal,v_integer,v_numeric,
v_smallint,v_varchar) VALUES (666, '$v_char','$v_date',$v_decimal, $v_integer,
$v_numeric, $v_smallint, '$v_varchar')");
/* prepare table */
ibase_query("delete from test6");
/* test all types */
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_char = ?", $v_char)))
echo "CHAR fail\n";
ibase_free_result($sel);
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_date = ?", $v_date)))
echo "DATE fail\n";
ibase_free_result($sel);
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_decimal = ?", $v_decimal)))
echo "DECIMAL fail\n";
ibase_free_result($sel);
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_integer = ?", $v_integer)))
echo "INTEGER fail\n";
ibase_free_result($sel);
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_numeric = ?", $v_numeric)))
echo "NUMERIC fail\n";
ibase_free_result($sel);
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_smallint = ?", $v_smallint)))
echo "SMALLINT fail\n";
ibase_free_result($sel);
if (!($sel = ibase_query(
"SELECT iter FROM test6 WHERE v_varchar = ?", $v_varchar)))
echo "VARCHAR fail\n";
ibase_free_result($sel);
} /* for ($iter) */
/* prepare query */
$query = ibase_prepare(
"insert into test6 (v_integer) values (?)");
echo "prepare and exec insert\n";
for($i = 0; $i < 10; $i++)
ibase_execute($query, $i);
/* prepare table */
ibase_query("DELETE FROM test6");
out_table("test6");
/* prepare query */
$query = ibase_prepare(
"INSERT INTO test6 (v_integer) VALUES (?)");
ibase_free_query($query);
for($i = 0; $i < 10; $i++)
ibase_execute($query, $i);
out_table("test6");
ibase_free_query($query);
echo "prepare and exec select\n";
echo "prepare and exec select\n";
/* prepare query */
$query = ibase_prepare("select * from test6
where v_integer between ? and ?");
/* prepare query */
$query = ibase_prepare("SELECT * FROM test6 WHERE v_integer BETWEEN ? AND ?");
$low_border = 2;
$high_border = 6;
$low_border = 2;
$high_border = 6;
$res = ibase_execute($query, $low_border, $high_border);
out_result($res, "test6");
ibase_free_result($res);
$res = ibase_execute($query, $low_border, $high_border);
out_result($res, "test6");
ibase_free_result($res);
$low_border = 0;
$high_border = 4;
$res = ibase_execute($query, $low_border, $high_border);
out_result($res, "test6");
ibase_free_result($res);
$low_border = 0;
$high_border = 4;
$res = ibase_execute($query, $low_border, $high_border);
out_result($res, "test6");
ibase_free_result($res);
$res = ibase_execute($query, "5", 7.5);
out_result($res, "test6");
ibase_free_result($res);
$res = ibase_execute($query, "5", 7.5);
out_result($res, "test6");
ibase_free_result($res);
ibase_free_query($query);
ibase_free_query($query);
ibase_close();
echo "end of test\n";
ibase_close();
echo "end of test\n";
?>
--EXPECT--
insert
@@ -67,7 +67,7 @@ static const char *mbfl_encoding_html_ent_aliases[] = {"HTML", "html", NULL};
const mbfl_encoding mbfl_encoding_html_ent = {
mbfl_no_encoding_html_ent,
"HTML-ENTITIES",
"US-ASCII",
"HTML-ENTITIES",
(const char *(*)[])&mbfl_encoding_html_ent_aliases,
NULL, /* mblen_table_html, Do not use table instead calulate length based on entities actually used */
MBFL_ENCTYPE_HTML_ENT
+46 -4
View File
@@ -1394,6 +1394,48 @@ DLEXPORT PHP_FUNCTION(udm_add_search_limit)
stl_info.t1=(time_t)(atol(val+1));
UdmAddTimeLimit(Agent->Conf,&stl_info);
}
#elif UDM_VERSION_ID >= 30210
{
struct tm *d_tm;
time_t d_t;
char *d_val2;
char d_db[20], d_de[20];
d_t = atol (val+1);
d_tm = localtime (&d_t);
if (val[0] == '>') {
UdmVarListReplaceStr(&Agent->Conf->Vars,"dt","er");
UdmVarListReplaceStr(&Agent->Conf->Vars,"dx","1");
sprintf (d_db, "%d", d_tm->tm_mday);
UdmVarListReplaceStr(&Agent->Conf->Vars,"dd",d_db);
sprintf (d_db, "%d", d_tm->tm_mon);
UdmVarListReplaceStr(&Agent->Conf->Vars,"dm",d_db);
sprintf (d_db, "%d", d_tm->tm_year+1900);
UdmVarListReplaceStr(&Agent->Conf->Vars,"dy",d_db);
RETURN_TRUE;
} else if (val[0] == '<') {
UdmVarListReplaceStr(&Agent->Conf->Vars,"dt","er");
UdmVarListReplaceStr(&Agent->Conf->Vars,"dx","-1");
sprintf (d_db, "%d", d_tm->tm_mday);
UdmVarListReplaceStr(&Agent->Conf->Vars,"dd",d_db);
sprintf (d_db, "%d", d_tm->tm_mon);
UdmVarListReplaceStr(&Agent->Conf->Vars,"dm",d_db);
sprintf (d_db, "%d", d_tm->tm_year+1900);
UdmVarListReplaceStr(&Agent->Conf->Vars,"dy",d_db);
RETURN_TRUE;
} else if ( (val[0]=='#') && (d_val2 = strchr(val,',')) ){
UdmVarListReplaceStr(&Agent->Conf->Vars,"dt","range");
sprintf (d_db, "%d/%d/%d", d_tm->tm_mday, d_tm->tm_mon+1, d_tm->tm_year+1900);
d_t = atol (d_val2+1);
d_tm = localtime (&d_t);
sprintf (d_de, "%d/%d/%d", d_tm->tm_mday, d_tm->tm_mon+1, d_tm->tm_year+1900);
UdmVarListReplaceStr(&Agent->Conf->Vars,"db",d_db);
UdmVarListReplaceStr(&Agent->Conf->Vars,"de",d_de);
RETURN_TRUE;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Incorrect date limit format");
RETURN_FALSE;
}
}
#endif
break;
default:
@@ -2200,9 +2242,9 @@ DLEXPORT PHP_FUNCTION(udm_get_res_param)
{
int len,i;
for(len = i = 0; i < Res->WWList.nwords; i++)
len += Res->WWList.Word[i].len;
len += Res->WWList.Word[i].len + 64;
{
size_t wsize=(1+len*15)*sizeof(char);
size_t wsize=(1+len)*sizeof(char);
char *wordinfo = (char*) malloc(wsize);
*wordinfo = '\0';
@@ -2230,9 +2272,9 @@ DLEXPORT PHP_FUNCTION(udm_get_res_param)
{
int len,i,j;
for(len = i = 0; i < Res->WWList.nwords; i++)
len += Res->WWList.Word[i].len;
len += Res->WWList.Word[i].len + 64;
{
size_t wsize=(1+len*15)*sizeof(char);
size_t wsize=(1+len)*sizeof(char);
char *wordinfo = (char*) malloc(wsize);
int corder = (size_t)-1, ccount = 0;
+25 -4
View File
@@ -796,10 +796,13 @@ static void php_mssql_get_column_content_with_type(mssql_link *mssql_ptr,int off
Z_TYPE_P(result) = IS_STRING;
break;
}
case SQLMONEY4:
case SQLFLT4:
Z_DVAL_P(result) = (double) floatcol4(offset);
Z_TYPE_P(result) = IS_DOUBLE;
break;
case SQLMONEY:
case SQLMONEYN:
case SQLFLT8:
Z_DVAL_P(result) = (double) floatcol8(offset);
Z_TYPE_P(result) = IS_DOUBLE;
@@ -898,8 +901,19 @@ static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int
if ((column_type != SQLDATETIME && column_type != SQLDATETIM4) || MS_SQL_G(datetimeconvert)) {
if (column_type == SQLDATETIM4) res_length += 14;
if (column_type == SQLDATETIME) res_length += 10;
switch (column_type) {
case SQLDATETIM4 :
res_length += 14;
break;
case SQLDATETIME :
res_length += 10;
break;
case SQLMONEY :
case SQLMONEY4 :
case SQLMONEYN :
res_length += 5;
break;
}
res_buf = (unsigned char *) emalloc(res_length+1);
res_length = dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset), res_length, SQLCHAR, res_buf, -1);
@@ -956,6 +970,9 @@ static void _mssql_get_sp_result(mssql_link *mssql_ptr, mssql_statement *stateme
case SQLFLT4:
case SQLFLT8:
case SQLFLTN:
case SQLMONEY4:
case SQLMONEY:
case SQLMONEYN:
convert_to_double_ex(&bind->zval);
Z_DVAL_P(bind->zval) = *((double *)(dbretdata(mssql_ptr->link,i)));
break;
@@ -996,6 +1013,7 @@ static int _mssql_fetch_batch(mssql_link *mssql_ptr, mssql_result *result, int r
column_types = (int *) emalloc(sizeof(int) * result->num_fields);
for (i=0; i<result->num_fields; i++) {
char *source = NULL;
char *fname = (char *)dbcolname(mssql_ptr->link,i+1);
if (*fname) {
@@ -1010,8 +1028,11 @@ static int _mssql_fetch_batch(mssql_link *mssql_ptr, mssql_result *result, int r
j++;
}
result->fields[i].max_length = dbcollen(mssql_ptr->link,i+1);
result->fields[i].column_source = estrdup(dbcolsource(mssql_ptr->link,i+1));
if (!result->fields[i].column_source) {
source = (char *)dbcolsource(mssql_ptr->link,i+1);
if (source) {
result->fields[i].column_source = estrdup(source);
}
else {
result->fields[i].column_source = empty_string;
}
+6 -2
View File
@@ -3118,11 +3118,11 @@ PHP_FUNCTION(ocisavelob)
if (offparam == -1) {
offset = curloblen;
} else if (offparam >= curloblen) {
} else if ((ub4)offparam >= curloblen) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is bigger than current LOB-Size - appending");
offset = curloblen;
} else {
offset = offparam;
offset = (ub4)offparam;
}
} else if (zend_get_parameters_ex(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -3136,6 +3136,10 @@ PHP_FUNCTION(ocisavelob)
RETURN_FALSE;
}
if (offset <= 0) {
offset = 1;
}
CALL_OCI_RETURN(connection->error, OCILobWrite(
connection->pServiceContext,
connection->pError,
+2 -3
View File
@@ -1952,7 +1952,7 @@ PHP_FUNCTION(pdf_open_image_file)
PHP_FUNCTION(pdf_open_memory_image)
{
zval **arg1, **arg2;
int i, j, color, count;
int i, j, color;
int pdf_image;
gdImagePtr im;
unsigned char *buffer, *ptr;
@@ -1970,8 +1970,7 @@ PHP_FUNCTION(pdf_open_memory_image)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, arg2, -1, "Image", le_gd);
count = 3 * im->sx * im->sy;
buffer = (unsigned char *) emalloc(count);
buffer = (unsigned char *) safe_emalloc(3 * im->sx, im->sy, 0);
ptr = buffer;
for(i=0; i<im->sy; i++) {
+51 -4
View File
@@ -3853,16 +3853,63 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
ZVAL_STRING(new_val, "NULL", 1);
}
else {
/* FIXME: better regex must be used */
if (php_pgsql_convert_match(Z_STRVAL_PP(val), "^[+-]{0,1}[ \\t]+((second|seconds|minute|minute|hour|hour|day|days|week|weeks|month|monthes|year|years|decade|decades|century|centuries|millennium|millenniums){1,1}[ \\t]+)+([ \\t]+ago){0,1}$", 1 TSRMLS_CC) == FAILURE &&
php_pgsql_convert_match(Z_STRVAL_PP(val), "^@[ \\t]+[+-]{0,1}[ \\t]+(second|seconds|minute|minute|hour|hour|day|days|week|weeks|month|monthes|year|years|decade|decades|century|centuries|millennium|millenniums){1,1}[ \\t]+)+([ \\t]+ago$", 1 TSRMLS_CC) == FAILURE) {
/* From the Postgres docs:
interval values can be written with the following syntax:
[@] quantity unit [quantity unit...] [direction]
Where: quantity is a number (possibly signed); unit is second, minute, hour,
day, week, month, year, decade, century, millennium, or abbreviations or
plurals of these units [note not *all* abbreviations] ; direction can be
ago or empty. The at sign (@) is optional noise.
...
Quantities of days, hours, minutes, and seconds can be specified without explicit
unit markings. For example, '1 12:59:10' is read the same as '1 day 12 hours 59 min 10
sec'.
*/
if (php_pgsql_convert_match(Z_STRVAL_PP(val),
"^(@?[ \\t]+)?("
/* Textual time units and their abbreviations: */
"(([-+]?[ \\t]+)?"
"[0-9]+(\\.[0-9]*)?[ \\t]*"
"(millenniums|millennia|millennium|mil|mils|"
"centuries|century|cent|c|"
"decades|decade|dec|decs|"
"years|year|y|"
"months|month|mon|"
"weeks|week|w|"
"days|day|d|"
"hours|hour|hr|hrs|h|"
"minutes|minute|mins|min|m|"
"seconds|second|secs|sec|s))+|"
/* Textual time units plus (dd)* hh[:mm[:ss]] */
"((([-+]?[ \\t]+)?"
"[0-9]+(\\.[0-9]*)?[ \\t]*"
"(millenniums|millennia|millennium|mil|mils|"
"centuries|century|cent|c|"
"decades|decade|dec|decs|"
"years|year|y|"
"months|month|mon|"
"weeks|week|w|"
"days|day|d))+"
"([-+]?[ \\t]+"
"([0-9]+[ \\t]+)+" /* dd */
"(([0-9]{1,2}:){0,2}[0-9]{0,2})" /* hh:[mm:[ss]] */
")?))"
"([ \\t]+ago)?$",
1 TSRMLS_CC) == FAILURE) {
err = 1;
}
else {
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
}
}
}
break;
case IS_NULL:
+1 -1
View File
@@ -224,7 +224,7 @@ PHPAPI void php_session_start(TSRMLS_D);
} \
} while(0)
ZEND_EXTERN_MODULE_GLOBALS(ps)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(ps)
void php_session_auto_start(void *data);
void php_session_shutdown(void *data);
+16 -4
View File
@@ -79,7 +79,7 @@ function_entry session_functions[] = {
};
/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(ps);
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps);
static ps_module *_php_find_ps_module(char *name TSRMLS_DC);
static const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC);
@@ -596,7 +596,7 @@ static void php_session_initialize(TSRMLS_D)
/* Open session handler first */
if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name) TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to initialize storage module.");
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path));
return;
}
@@ -1369,7 +1369,7 @@ PHP_FUNCTION(session_register)
if (argc <= 0)
RETURN_FALSE
else
args = (zval ***)emalloc(argc * sizeof(zval **));
args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
@@ -1612,14 +1612,26 @@ PHP_RSHUTDOWN_FUNCTION(session)
}
/* }}} */
static void php_minit_session_globals(php_ps_globals *ps_globals)
{
ps_globals->save_path = NULL;
ps_globals->session_name = NULL;
ps_globals->id = NULL;
ps_globals->mod = NULL;
ps_globals->mod_data = NULL;
ps_globals->session_status = php_session_none;
ps_globals->http_session_vars = NULL;
}
PHP_MINIT_FUNCTION(session)
{
#ifdef ZTS
php_ps_globals *ps_globals;
ts_allocate_id(&ps_globals_id, sizeof(php_ps_globals), NULL, NULL);
ts_allocate_id(&ps_globals_id, sizeof(php_ps_globals), (ts_allocate_ctor) php_minit_session_globals, NULL);
ps_globals = ts_resource(ps_globals_id);
#else
php_minit_session_globals(&ps_globals);
#endif
zend_register_auto_global("_SESSION", sizeof("_SESSION")-1 TSRMLS_CC);
+21
View File
@@ -0,0 +1,21 @@
--TEST--
Bug #26862 (ob_flush() before output_reset_rewrite_vars() results in data loss)
--SKIPIF--
<?php include('skipif.inc'); ?>
--INI--
register_globals=0
html_errors=0
--FILE--
<?php
session_start();
output_add_rewrite_var('var', 'value');
echo '<a href="file.php">link</a>';
ob_flush();
output_reset_rewrite_vars();
echo '<a href="file.php">link</a>';
?>
--EXPECT--
<a href="file.php?var=value">link</a><a href="file.php">link</a>
+15 -1
View File
@@ -294,6 +294,7 @@ static int php_read(int bsd_socket, void *buf, size_t maxlen, int flags)
set_errno(0);
*t = '\0';
while (*t != '\n' && *t != '\r' && n < maxlen) {
if (m > 0) {
t++;
@@ -808,7 +809,10 @@ PHP_FUNCTION(socket_read)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &length, &type) == FAILURE)
return;
if(length<0) RETURN_FALSE;
/* overflow check */
if((length + 1) < 2) {
RETURN_FALSE;
}
tmpbuf = emalloc(length + 1);
ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
@@ -1372,6 +1376,11 @@ PHP_FUNCTION(socket_recv)
ZEND_FETCH_RESOURCE(php_sock, php_socket *, &php_sock_res, -1, le_socket_name, le_socket);
/* overflow check */
if ((len + 1) < 2) {
RETURN_FALSE;
}
recv_buf = emalloc(len + 1);
memset(recv_buf, 0, len + 1);
@@ -1446,6 +1455,11 @@ PHP_FUNCTION(socket_recvfrom)
if(arg3<0) RETURN_FALSE;
/* overflow check */
if ((arg3 + 2) < 3) {
RETURN_FALSE;
}
recv_buf = emalloc(arg3 + 2);
memset(recv_buf, 0, arg3 + 2);
-1
View File
@@ -188,7 +188,6 @@ PHPAPI unsigned char *php_base64_decode(const unsigned char *str, int length, in
/* mop things up if we ended on a boundary */
if (ch == base64_pad) {
switch(i % 4) {
case 0:
case 1:
efree(result);
return NULL;
+2 -2
View File
@@ -1442,8 +1442,8 @@ PHP_FUNCTION(getopt)
* in order to be on the safe side, even though it is also available
* from the symbol table.
*/
if (zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"),
(void **) &args) != FAILURE) {
if (zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), (void **) &args) != FAILURE ||
zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void **) &args) != FAILURE) {
int pos = 0;
zval **arg;
+85 -23
View File
@@ -22,6 +22,7 @@
#include "php_regex.h"
#include "php_browscap.h"
#include "php_ini.h"
#include "php_string.h"
#include "zend_globals.h"
@@ -47,9 +48,13 @@ static void convert_browscap_pattern(zval *pattern)
register int i, j;
char *t;
t = (char *) malloc(Z_STRLEN_P(pattern)*2 + 1);
php_strtolower(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern));
for (i=0, j=0; i<Z_STRLEN_P(pattern); i++, j++) {
t = (char *) malloc(Z_STRLEN_P(pattern)*2 + 3);
t[0] = '^';
for (i=0, j=1; i<Z_STRLEN_P(pattern); i++, j++) {
switch (Z_STRVAL_P(pattern)[i]) {
case '?':
t[j] = '.';
@@ -68,9 +73,7 @@ static void convert_browscap_pattern(zval *pattern)
}
}
if (j && (t[j-1] == '.')) {
t[j++] = '*';
}
t[j++] = '$';
t[j]=0;
Z_STRVAL_P(pattern) = t;
@@ -181,36 +184,89 @@ PHP_MSHUTDOWN_FUNCTION(browscap)
}
/* }}} */
/* {{{ browser_reg_compare
*/
static int browser_reg_compare(zval **browser, int num_args, va_list args, zend_hash_key *key)
{
zval **browser_name, **current;
zval **browser_regex, **previous_match;
regex_t r;
char *lookup_browser_name = va_arg(args, char *);
zval **found_browser_entry = va_arg(args, zval **);
if (zend_hash_find(Z_ARRVAL_PP(browser), "browser_name_regex", sizeof("browser_name_regex"), (void **) &browser_name) == FAILURE) {
/* See if we have an exact match, if so, we're done... */
if (*found_browser_entry) {
if (zend_hash_find(Z_ARRVAL_PP(found_browser_entry), "browser_name_pattern", sizeof("browser_name_pattern"), (void**) &previous_match) == FAILURE) {
return 0;
}
else if (!strcasecmp(Z_STRVAL_PP(previous_match), lookup_browser_name)) {
return 0;
}
}
if (zend_hash_find(Z_ARRVAL_PP(browser), "browser_name_regex", sizeof("browser_name_regex"), (void **) &browser_regex) == FAILURE) {
return 0;
}
if (*found_browser_entry) {
/* If we've found a possible browser, check it's length. Longer user
agent strings are assumed to be more precise, so use them. */
if (zend_hash_find(Z_ARRVAL_PP(found_browser_entry), "browser_name_regex", sizeof("browser_name_regex"), (void**) &current) == FAILURE) {
return 0;
}
else if (Z_STRLEN_PP(current) > Z_STRLEN_PP(browser_name)) {
return 0;
}
}
if (regcomp(&r, Z_STRVAL_PP(browser_name), REG_NOSUB)!=0) {
if (regcomp(&r, Z_STRVAL_PP(browser_regex), REG_NOSUB)!=0) {
return 0;
}
if (regexec(&r, lookup_browser_name, 0, NULL, 0)==0) {
*found_browser_entry = *browser;
/* If we've found a possible browser, we need to do a comparison of the
number of characters changed in the user agent being checked versus
the previous match found and the current match. */
if (*found_browser_entry) {
int i, prev_len = 0, curr_len = 0, ua_len;
zval **current_match;
if (zend_hash_find(Z_ARRVAL_PP(browser), "browser_name_pattern", sizeof("browser_name_pattern"), (void**) &current_match) == FAILURE) {
regfree(&r);
return 0;
}
ua_len = strlen(lookup_browser_name);
for (i = 0; i < Z_STRLEN_PP(previous_match); i++) {
switch (Z_STRVAL_PP(previous_match)[i]) {
case '?':
case '*':
/* do nothing, ignore these characters in the count */
break;
default:
++prev_len;
}
}
for (i = 0; i < Z_STRLEN_PP(current_match); i++) {
switch (Z_STRVAL_PP(current_match)[i]) {
case '?':
case '*':
/* do nothing, ignore these characters in the count */
break;
default:
++curr_len;
}
}
/* Pick which browser pattern replaces the least amount of
characters when compared to the original user agent string... */
if (ua_len - prev_len > ua_len - curr_len) {
*found_browser_entry = *browser;
}
}
else {
*found_browser_entry = *browser;
}
}
regfree(&r);
if (&r) {
regfree(&r);
}
return 0;
}
/* }}} */
@@ -235,7 +291,7 @@ PHP_FUNCTION(get_browser)
if (ZEND_NUM_ARGS() > 2 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &agent_name, &retarr) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
if (agent_name == NULL || Z_TYPE_PP(agent_name) == IS_NULL) {
if (!PG(http_globals)[TRACK_VARS_SERVER]
|| zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &agent_name)==FAILURE) {
@@ -245,20 +301,22 @@ PHP_FUNCTION(get_browser)
}
convert_to_string_ex(agent_name);
lookup_browser_name = estrndup(Z_STRVAL_PP(agent_name), Z_STRLEN_PP(agent_name));
php_strtolower(lookup_browser_name, strlen(lookup_browser_name));
if (ZEND_NUM_ARGS() == 2) {
convert_to_boolean_ex(retarr);
return_array = Z_BVAL_PP(retarr);
}
if (zend_hash_find(&browser_hash, Z_STRVAL_PP(agent_name), Z_STRLEN_PP(agent_name)+1, (void **) &agent)==FAILURE) {
lookup_browser_name = Z_STRVAL_PP(agent_name);
if (zend_hash_find(&browser_hash, lookup_browser_name, strlen(lookup_browser_name)+1, (void **) &agent)==FAILURE) {
found_browser_entry = NULL;
zend_hash_apply_with_arguments(&browser_hash, (apply_func_args_t) browser_reg_compare, 2, lookup_browser_name, &found_browser_entry);
if (found_browser_entry) {
agent = &found_browser_entry;
} else if (zend_hash_find(&browser_hash, DEFAULT_SECTION_NAME, sizeof(DEFAULT_SECTION_NAME), (void **) &agent)==FAILURE) {
efree(lookup_browser_name);
RETURN_FALSE;
}
}
@@ -284,6 +342,10 @@ PHP_FUNCTION(get_browser)
zend_hash_merge(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *), 0);
}
}
if (lookup_browser_name) {
efree(lookup_browser_name);
}
}
/* }}} */
+13 -3
View File
@@ -161,7 +161,7 @@ void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
ta->tm_year = Z_LVAL_PP(arguments[5])
- ((Z_LVAL_PP(arguments[5]) > 1000) ? 1900 : 0);
/* fall-through */
case 5: /* day in month (1-baesd) */
case 5: /* day in month (1-based) */
val = (*arguments[4])->value.lval;
if (val < 1) {
chgsecs += (1-val) * 60*60*24;
@@ -192,8 +192,14 @@ void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
/* fall-through */
case 1: /* hour */
val = (*arguments[0])->value.lval;
if (val < 1) {
chgsecs += (1-val) * 60*60; val = 1;
/*
We don't use 1 here to work around problems in some mktime implementations
when it comes to daylight savings time. Setting it to 2 and working back from
there with the chgsecs offset makes us immune to these problems.
See http://bugs.php.net/27533 for more info.
*/
if (val < 2) {
chgsecs += (2-val) * 60*60; val = 2;
}
ta->tm_hour = val;
/* fall-through */
@@ -324,6 +330,10 @@ php_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
} else {
tname[0] = "???";
}
if (tzname[1] != NULL) {
tname[1] = tzname[1];
}
#endif
}
+1 -1
View File
@@ -275,7 +275,7 @@ PHP_FUNCTION(chdir)
RETURN_FALSE;
}
if (PG(safe_mode) && !php_checkuid(str, NULL, CHECKUID_ALLOW_ONLY_FILE)) {
if (PG(safe_mode) && !php_checkuid(str, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
RETURN_FALSE;
}
ret = VCWD_CHDIR(str);
+1
View File
@@ -613,6 +613,7 @@ php_formatted_print(int ht, int *len, int use_array TSRMLS_DC)
*tmp = **(args[argnum]);
zval_copy_ctor(tmp);
} else {
SEPARATE_ZVAL(args[argnum]);
tmp = *(args[argnum]);
}
+2 -2
View File
@@ -544,10 +544,10 @@ inline static unsigned short get_next_char(enum entity_charset charset,
case cs_big5hkscs:
{
/* check if this is the first of a 2-byte sequence */
if (this_char >= 0xa1 && this_char <= 0xf9) {
if (this_char >= 0xa1 && this_char <= 0xfe) {
/* peek at the next char */
unsigned char next_char = str[pos];
if ((next_char >= 0x40 && next_char <= 0x73) ||
if ((next_char >= 0x40 && next_char <= 0x7e) ||
(next_char >= 0xa1 && next_char <= 0xfe)) {
/* yes, this a wide char */
this_char <<= 8;
+16 -4
View File
@@ -339,17 +339,22 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
}
if (!php_stream_eof(stream)) {
if (!php_stream_eof(stream)) {
size_t tmp_line_len;
/* get response header */
if (php_stream_gets(stream, tmp_line, sizeof(tmp_line)-1) != NULL) {
if (_php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len TSRMLS_CC) != NULL) {
zval *http_response;
int response_code;
MAKE_STD_ZVAL(http_response);
ZVAL_NULL(http_response);
response_code = atoi(tmp_line + 9);
if (tmp_line_len > 9) {
response_code = atoi(tmp_line + 9);
} else {
response_code = 0;
}
switch(response_code) {
case 200:
case 302:
@@ -361,11 +366,15 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
tmp_line, response_code);
break;
default:
/* safety net in the event tmp_line == NULL */
if (!tmp_line_len) {
tmp_line[0] = '\0';
}
php_stream_notify_error(context, PHP_STREAM_NOTIFY_FAILURE,
tmp_line, response_code);
}
Z_STRLEN_P(http_response) = strlen(tmp_line);
Z_STRLEN_P(http_response) = tmp_line_len;
Z_STRVAL_P(http_response) = estrndup(tmp_line, Z_STRLEN_P(http_response));
if (Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=='\n') {
Z_STRVAL_P(http_response)[Z_STRLEN_P(http_response)-1]=0;
@@ -378,6 +387,9 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
Z_TYPE_P(http_response) = IS_STRING;
zend_hash_next_index_insert(Z_ARRVAL_PP(response_header), &http_response, sizeof(zval *), NULL);
}
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed, unexpected end of socket!");
goto out;
}
/* read past HTTP headers */
+1 -1
View File
@@ -974,7 +974,7 @@ PHP_FUNCTION(php_uname)
/* {{{ proto string php_ini_scanned_files(void)
Return comma-separated string of .ini files parsed from the additional ini dir */
PHP_FUNCTION(php_ini_scanned_files) {
if(strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
if(strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
RETURN_STRING(php_ini_scanned_files,1);
} else RETURN_FALSE;
}
+1 -1
View File
@@ -320,7 +320,7 @@ PHP_FUNCTION(iptcparse)
tagsfound = 0; /* number of tags already found */
while (inx < length) { /* find 1st tag */
if ((buffer[inx] == 0x1c) && (buffer[inx+1] == 0x02)){
if ((buffer[inx] == 0x1c) && ((buffer[inx+1] == 0x01) || (buffer[inx+1] == 0x02))){
break;
} else {
inx++;
+1 -1
View File
@@ -642,7 +642,7 @@ PHP_FUNCTION(unpack)
/* Space for name + number, safe as namelen is ensured <= 200 */
char n[256];
if (arg != 1) {
if (arg != 1 || namelen == 0) {
/* Need to add element number to name */
sprintf(n, "%.*s%d", namelen, name, i + 1);
} else {
+1 -1
View File
@@ -923,7 +923,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
if (!(flags & SCAN_SUPPRESS)) {
if (numVars) {
current = args[objIndex++];
convert_to_string( *current );
zval_dtor( *current );
ZVAL_STRINGL( *current, string, end-string, 1);
} else {
add_index_stringl(*return_value, objIndex++, string, end-string, 1);
+30
View File
@@ -0,0 +1,30 @@
--TEST--
Bug #27183 (userland stream wrapper segfaults on stream_write)
--FILE--
<?php
stream_wrapper_register("one", "StreamOne");
$fd = fopen("one://tmp/bla", "w");
fwrite($fd, "hmm");
fclose($fd);
class StreamOne {
function stream_open ($path, $mode, $options, &$opened_path)
{
$this->b = 'mmh';
return true;
}
function stream_write($data)
{
$this->a = $data;
}
function stream_close()
{
debug_zval_dump($this->a);
debug_zval_dump($this->b);
return true;
}
}
?>
--EXPECT--
string(3) "hmm" refcount(2)
string(3) "mmh" refcount(2)
+21
View File
@@ -0,0 +1,21 @@
--TEST--
Bug #27278 (*printf() functions treat arguments as if passed by reference)
--FILE--
<?php
function foo ($a)
{
$a=sprintf("%02d",$a);
var_dump($a);
}
$x="02";
var_dump($x);
foo($x);
var_dump($x);
?>
--EXPECT--
string(2) "02"
string(2) "02"
string(2) "02"
+14
View File
@@ -0,0 +1,14 @@
--TEST--
Bug #27295 (memory leak inside sscanf())
--FILE--
<?php
$strings = array("foo = bar", "bar = foo");
foreach( $strings as $string )
{
sscanf( $string, "%s = %[^[]]", $var, $val );
echo "$var = $val\n";
}
?>
--EXPECT--
foo = bar
bar = foo
+21
View File
@@ -0,0 +1,21 @@
--TEST--
Bug #27457 (Problem with strtr() and translation array)
--FILE--
<?php
$test = "Dot in brackets [.]\n";
echo $test;
$test = strtr($test, array('.' => '0'));
echo $test;
$test = strtr($test, array('0' => '.'));
echo $test;
$test = strtr($test, '.', '0');
echo $test;
$test = strtr($test, '0', '.');
echo $test;
?>
--EXPECT--
Dot in brackets [.]
Dot in brackets [0]
Dot in brackets [.]
Dot in brackets [0]
Dot in brackets [.]
+3 -3
View File
@@ -1,5 +1,5 @@
/* Generated by re2c 0.5 on Thu Apr 17 02:53:49 2003 */
#line 1 "/usr/src/web/php/php4/ext/standard/url_scanner_ex.re"
/* Generated by re2c 0.5 on Wed Feb 11 11:33:22 2004 */
#line 1 "/home/php4/ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
@@ -918,7 +918,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
size_t len;
if (BG(url_adapt_state_ex).url_app.len != 0) {
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode&PHP_OUTPUT_HANDLER_END ? 1 : 0) TSRMLS_CC);
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END|PHP_OUTPUT_HANDLER_CONT) ? 1 : 0) TSRMLS_CC);
if (sizeof(uint) < sizeof(size_t)) {
if (len > UINT_MAX)
len = UINT_MAX;
+1 -1
View File
@@ -417,7 +417,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
size_t len;
if (BG(url_adapt_state_ex).url_app.len != 0) {
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode&PHP_OUTPUT_HANDLER_END ? 1 : 0) TSRMLS_CC);
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END|PHP_OUTPUT_HANDLER_CONT) ? 1 : 0) TSRMLS_CC);
if (sizeof(uint) < sizeof(size_t)) {
if (len > UINT_MAX)
len = UINT_MAX;
+2 -2
View File
@@ -136,7 +136,7 @@ PHP_FUNCTION(var_dump)
argc = ZEND_NUM_ARGS();
args = (zval ***)emalloc(argc * sizeof(zval **));
args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
WRONG_PARAM_COUNT;
@@ -234,7 +234,7 @@ PHP_FUNCTION(debug_zval_dump)
argc = ZEND_NUM_ARGS();
args = (zval ***)emalloc(argc * sizeof(zval **));
args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
WRONG_PARAM_COUNT;
+43 -27
View File
@@ -243,30 +243,43 @@ static int _call_message_handler(zval *callback_name, CS_SERVERMSG *srvmsg TSRML
int handled = 0;
if (callback_name) {
zval *retval = NULL;
zval severity, msgnumber, state, line, text;
zval *ptrs[5]= {&msgnumber, &severity, &state, &line, &text};
zval **args[5]= {&ptrs[0], &ptrs[1], &ptrs[2], &ptrs[3], &ptrs[4]};
zval *msgnumber, *severity, *state, *line, *text, *retval = NULL;
zval **args[5];
INIT_ZVAL(msgnumber);
INIT_ZVAL(severity);
INIT_ZVAL(state);
INIT_ZVAL(line);
INIT_ZVAL(text);
ZVAL_LONG(&msgnumber, srvmsg->msgnumber);
ZVAL_LONG(&severity, srvmsg->severity);
ZVAL_LONG(&state, srvmsg->state);
ZVAL_LONG(&line, srvmsg->line);
ZVAL_STRING(&text, srvmsg->text, 0);
MAKE_STD_ZVAL(msgnumber);
ZVAL_LONG(msgnumber, srvmsg->msgnumber);
args[0] = &msgnumber;
MAKE_STD_ZVAL(severity);
ZVAL_LONG(severity, srvmsg->severity);
args[1] = &severity;
MAKE_STD_ZVAL(state);
ZVAL_LONG(state, srvmsg->state);
args[2] = &state;
MAKE_STD_ZVAL(line);
ZVAL_LONG(line, srvmsg->line);
args[3] = &line;
MAKE_STD_ZVAL(text);
ZVAL_STRING(text, srvmsg->text, 1);
args[4] = &text;
if (call_user_function_ex(EG(function_table), NULL, callback_name, &retval, 5, args, 0, NULL TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase: Cannot call the messagehandler %s", Z_STRVAL_P(callback_name));
}
if (retval) {
handled= ((Z_TYPE_P(retval) != IS_BOOL) || (Z_BVAL_P(retval) != 0));
zval_ptr_dtor(&retval);
}
zval_ptr_dtor(&msgnumber);
zval_ptr_dtor(&severity);
zval_ptr_dtor(&state);
zval_ptr_dtor(&line);
zval_ptr_dtor(&text);
}
return handled;
@@ -1078,8 +1091,8 @@ static int php_sybase_fetch_result_row (sybase_result *result, int numrows)
CS_INT retcode;
/* We've already fetched everything */
if (result->last_retcode == CS_END_DATA) {
return CS_END_DATA;
if (result->last_retcode == CS_END_DATA || result->last_retcode == CS_END_RESULTS) {
return result->last_retcode;
}
if (numrows!=-1) numrows+= result->num_rows;
@@ -1130,7 +1143,6 @@ static int php_sybase_fetch_result_row (sybase_result *result, int numrows)
}
result->last_retcode= retcode;
switch (retcode) {
case CS_END_DATA:
retcode = php_sybase_finish_results(result);
@@ -1265,12 +1277,13 @@ static sybase_result * php_sybase_fetch_result_set (sybase_link *sybase_ptr, int
result->fields[i].numeric = result->numerics[i];
Z_TYPE(result->fields[i]) = result->types[i];
}
retcode= php_sybase_fetch_result_row(result, buffered ? 1 : -1);
if (retcode == CS_FAIL) {
return NULL;
}
result->last_retcode = retcode;
return result;
}
@@ -1399,7 +1412,6 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase: Cannot read results");
RETURN_FALSE;
}
switch ((int) restype) {
case CS_CMD_FAIL:
default:
@@ -1437,6 +1449,7 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
/* Check for left-over results */
if (!buffered && status != Q_RESULT) {
while ((retcode = ct_results(sybase_ptr->cmd, &restype))==CS_SUCCEED) {
switch ((int) restype) {
case CS_CMD_SUCCEED:
case CS_CMD_DONE:
@@ -1458,6 +1471,7 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
RETURN_FALSE;
}
status = Q_RESULT;
retcode = result->last_retcode;
} else {
/* Unexpected results, cancel them. */
ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_CURRENT);
@@ -1475,8 +1489,10 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
if (status == Q_FAILURE) {
ct_cancel(NULL, sybase_ptr->cmd, CS_CANCEL_ALL);
}
if (retcode == CS_END_RESULTS) {
break;
}
}
switch (retcode) {
case CS_END_RESULTS:
/* Normal. */
@@ -1500,7 +1516,7 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
break;
}
}
/* Retry deadlocks up until deadlock_retry_count times */
if (sybase_ptr->deadlock && SybCtG(deadlock_retry_count) != -1 && ++deadlock_count > SybCtG(deadlock_retry_count)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase: Retried deadlock %d times [max: %ld], giving up\n", deadlock_count- 1, SybCtG(deadlock_retry_count));
@@ -1654,7 +1670,7 @@ PHP_FUNCTION(sybase_fetch_row)
ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", le_result);
/* Unbuffered? */
if (result->last_retcode != CS_END_DATA) {
if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS) {
php_sybase_fetch_result_row(result, 1);
}
@@ -1691,7 +1707,7 @@ static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int numerics)
ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase result", le_result);
/* Unbuffered ? Fetch next row */
if (result->last_retcode != CS_END_DATA) {
if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS) {
php_sybase_fetch_result_row(result, 1);
}
@@ -1804,7 +1820,7 @@ PHP_FUNCTION(sybase_data_seek)
convert_to_long_ex(offset);
/* Unbuffered ? */
if (result->last_retcode != CS_END_DATA && Z_LVAL_PP(offset)>=result->num_rows) {
if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS && Z_LVAL_PP(offset)>=result->num_rows) {
php_sybase_fetch_result_row(result, Z_LVAL_PP(offset));
}
@@ -1932,7 +1948,7 @@ PHP_FUNCTION(sybase_field_seek)
field_offset = Z_LVAL_PP(offset);
/* Unbuffered ? */
if (result->last_retcode != CS_END_DATA && field_offset>=result->num_rows) {
if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS && field_offset>=result->num_rows) {
php_sybase_fetch_result_row(result, field_offset);
}
@@ -1965,7 +1981,7 @@ PHP_FUNCTION(sybase_result)
convert_to_long_ex(row);
/* Unbuffered ? */
if (result->last_retcode != CS_END_DATA && Z_LVAL_PP(row) >= result->num_rows) {
if (result->last_retcode != CS_END_DATA && result->last_retcode != CS_END_RESULTS && Z_LVAL_PP(row) >= result->num_rows) {
php_sybase_fetch_result_row(result, Z_LVAL_PP(row));
}
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug #27287 (segfault with deserializing object data)
--FILE--
<?php
class foo {
}
$foo = new foo();
$foo->abc = 'def';
$string = wddx_serialize_value($foo);
$bar = wddx_deserialize($string);
echo "OK\n";
?>
--EXPECT--
OK
+3 -3
View File
@@ -57,11 +57,11 @@ static char* convert(const char* src, int src_len, int *new_len, const char* fro
char* outbuf = 0;
if(src && src_len && from_enc && to_enc) {
int outlenleft = src_len;
size_t outlenleft = src_len;
size_t inlenleft = src_len;
int outlen = src_len;
int inlenleft = src_len;
iconv_t ic = iconv_open(to_enc, from_enc);
char* src_ptr = (char*)src;
char const *src_ptr = src;
char* out_ptr = 0;
if(ic != (iconv_t)-1) {
+2 -7
View File
@@ -647,14 +647,9 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
#else
{
myuid = php_getuid();
result = emalloc(sizeof("WWW-Authenticate: ")+20);
newlen = sprintf(result, "WWW-Authenticate: %ld", myuid);
newheader = estrndup(result,newlen);
efree(header_line);
sapi_header.header = newheader;
sapi_header.header_len = newlen;
efree(result);
}
sapi_header.header_len = spprintf(&sapi_header.header, 0, "WWW-Authenticate: Basic realm=\"%ld\"", myuid);
}
#endif
}
if (sapi_header.header==header_line) {
+7 -5
View File
@@ -132,15 +132,17 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
if ((expand_filepath(path, resolved_name TSRMLS_CC) != NULL) && (expand_filepath(local_open_basedir, resolved_basedir TSRMLS_CC) != NULL)) {
/* Handler for basedirs that end with a / */
resolved_basedir_len = strlen(resolved_basedir);
if (basedir[strlen(basedir)-1] == PHP_DIR_SEPARATOR && resolved_basedir[resolved_basedir_len -1] != PHP_DIR_SEPARATOR) {
resolved_basedir[resolved_basedir_len] = '/';
resolved_basedir[++resolved_basedir_len] = '\0';
if (basedir[strlen(basedir) - 1] == PHP_DIR_SEPARATOR) {
if (resolved_basedir[resolved_basedir_len - 1] == '/') {
resolved_basedir[resolved_basedir_len - 1] = PHP_DIR_SEPARATOR;
resolved_basedir[++resolved_basedir_len] = '\0';
}
}
if (path[strlen(path)-1] == PHP_DIR_SEPARATOR) {
resolved_name_len = strlen(resolved_name);
if (resolved_name[resolved_name_len - 1] != PHP_DIR_SEPARATOR) {
resolved_name[resolved_name_len] = '/';
resolved_name[resolved_name_len] = PHP_DIR_SEPARATOR;
resolved_name[++resolved_name_len] = '\0';
}
}
+4
View File
@@ -1138,6 +1138,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
setlocale(LC_CTYPE, "");
#endif
#if HAVE_TZSET
tzset();
#endif
#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
/* start up winsock services */
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
+8 -6
View File
@@ -441,12 +441,14 @@ int php_init_config()
* Don't need an extra byte for the \0 in this malloc as the last
* element will not get a trailing , which gives us the byte for the \0
*/
php_ini_scanned_files = (char *) malloc(total_l);
*php_ini_scanned_files = '\0';
for (element = scanned_ini_list.head; element; element = element->next) {
strcat(php_ini_scanned_files, *(char **)element->data);
strcat(php_ini_scanned_files, element->next ? ",\n" : "\n");
}
if (total_l) {
php_ini_scanned_files = (char *) malloc(total_l);
*php_ini_scanned_files = '\0';
for (element = scanned_ini_list.head; element; element = element->next) {
strcat(php_ini_scanned_files, *(char **)element->data);
strcat(php_ini_scanned_files, element->next ? ",\n" : "\n");
}
}
zend_llist_destroy(&scanned_ini_list);
}
}
+2 -2
View File
@@ -3,5 +3,5 @@
#define PHP_MAJOR_VERSION 4
#define PHP_MINOR_VERSION 3
#define PHP_RELEASE_VERSION 5
#define PHP_EXTRA_VERSION "RC2"
#define PHP_VERSION "4.3.5RC2"
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "4.3.5"
+3
View File
@@ -89,6 +89,9 @@ void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int
if (*num_vars>=*num_vars_max){
php_mb_gpc_realloc_buffer(pval_list, plen_list, num_vars_max,
16 TSRMLS_CC);
/* in case realloc relocated the buffer */
val_list = *pval_list;
len_list = *plen_list;
}
val_list[*num_vars] = (char *)estrdup(param);
+1 -1
View File
@@ -2395,7 +2395,7 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char
return NULL;
}
if (PG(safe_mode) &&(!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
if (PG(safe_mode) &&(!php_checkuid(path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
return NULL;
}
+5 -3
View File
@@ -382,15 +382,15 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
int call_result;
php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
zval **args[1];
zval zbuff, *zbufptr;
zval *zbufptr;
size_t didwrite = 0;
assert(us != NULL);
ZVAL_STRINGL(&func_name, USERSTREAM_WRITE, sizeof(USERSTREAM_WRITE)-1, 0);
ZVAL_STRINGL(&zbuff, (char*)buf, count, 0);
zbufptr = &zbuff;
MAKE_STD_ZVAL(zbufptr);
ZVAL_STRINGL(zbufptr, (char*)buf, count, 1);
args[0] = &zbufptr;
call_result = call_user_function_ex(NULL,
@@ -400,6 +400,8 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
1, args,
0, NULL TSRMLS_CC);
zval_ptr_dtor(&zbufptr);
didwrite = 0;
if (call_result == SUCCESS && retval != NULL) {
convert_to_long(retval);
+10 -1
View File
@@ -40,6 +40,15 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
define('PEAR_OS', 'Unix'); // blatant assumption
}
// instant backwards compatibility
if (!defined('PATH_SEPARATOR')) {
if (OS_WINDOWS) {
define('PATH_SEPARATOR', ';');
} else {
define('PATH_SEPARATOR', ':');
}
}
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
$GLOBALS['_PEAR_destructor_object_list'] = array();
@@ -184,7 +193,7 @@ class PEAR
/**
* If you have a class that's mostly/entirely static, and you need static
* properties, you can use this method to simulate them. Eg. in your method(s)
* do this: $myVar = &PEAR::getStaticProperty('myVar');
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
* You MUST use a reference, or they will not persist!
*
* @access public
+1 -1
View File
@@ -162,7 +162,7 @@ class PEAR_Autoloader extends PEAR
$classname = strtolower($classname);
reset($this->_method_map);
while (list($method, $obj) = each($this->_method_map)) {
if (get_class($obj) == $classname) {
if (is_a($obj, $classname)) {
unset($this->_method_map[$method]);
$ok = true;
}
+1 -1
View File
@@ -218,7 +218,7 @@ class PEAR_Builder extends PEAR_Common
($r == 'yes' || $r == 'autodetect')) {
$configure_command .= " --$o[name]";
} else {
$configure_command .= " --$o[name]=$r";
$configure_command .= " --$o[name]=".trim($r);
}
}
}
+1 -1
View File
@@ -160,7 +160,7 @@ class PEAR_Command
function &setFrontendClass($uiclass)
{
if (is_object($GLOBALS['_PEAR_Command_uiobject']) &&
strtolower($uiclass) == get_class($GLOBALS['_PEAR_Command_uiobject'])) {
is_a($GLOBALS['_PEAR_Command_uiobject'], $uiclass)) {
return $GLOBALS['_PEAR_Command_uiobject'];
}
if (!class_exists($uiclass)) {
+16 -4
View File
@@ -435,8 +435,10 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
function doRunTests($command, $options, $params)
{
$cwd = getcwd();
$php = PHP_BINDIR . '/php' . (OS_WINDOWS ? '.exe' : '');
$php = $this->config->get('php_bin');
putenv("TEST_PHP_EXECUTABLE=$php");
// all core PEAR tests use this constant to determine whether they should be run or not
putenv("PHP_PEAR_RUNTESTS=1");
$ip = ini_get("include_path");
$ps = OS_WINDOWS ? ';' : ':';
$run_tests = $rtsts = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . 'run-tests.php';
@@ -447,9 +449,19 @@ Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
"file from the sources of your PHP distribution to $rtsts");
}
}
$plist = implode(" ", $params);
$cmd = "$php -C -d include_path=$cwd$ps$ip -f $run_tests -- $plist";
system($cmd);
if (OS_WINDOWS) {
// note, this requires a slightly modified version of run-tests.php
// for some setups
// unofficial download location is in the pear-dev archives
$argv = $params;
array_unshift($argv, $run_tests);
$argc = count($argv);
include $run_tests;
} else {
$plist = implode(' ', $params);
$cmd = "$php -d include_path=$cwd$ps$ip -f $run_tests -- $plist";
system($cmd);
}
return true;
}
+14
View File
@@ -612,6 +612,20 @@ class PEAR_Downloader extends PEAR_Common
$this->ui->_downloadCallback($msg, $params);
}
// }}}
// {{{ _prependPath($path, $prepend)
function _prependPath($path, $prepend)
{
if (strlen($prepend) > 0) {
if (OS_WINDOWS && preg_match('/^[a-z]:/i', $path)) {
$path = $prepend . substr($path, 2);
} else {
$path = $prepend . $path;
}
}
return $path;
}
// }}}
// {{{ pushError($errmsg, $code)
+889
View File
@@ -0,0 +1,889 @@
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 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_0.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: Gregory Beaver <cellog@php.net> |
// | |
// +----------------------------------------------------------------------+
//
// $Id$
/**
* Error Stack Implementation
*
* This is an incredibly simple implementation of a very complex error handling
* facility. It contains the ability
* to track multiple errors from multiple packages simultaneously. In addition,
* it can track errors of many levels, save data along with the error, context
* information such as the exact file, line number, class and function that
* generated the error, and if necessary, it can raise a traditional PEAR_Error.
* It has built-in support for PEAR::Log, to log errors as they occur
*
* Since version 0.2alpha, it is also possible to selectively ignore errors,
* through the use of an error callback, see {@link pushCallback()}
*
* Since version 0.3alpha, it is possible to specify the exception class
* returned from {@link push()}
* @author Greg Beaver <cellog@php.net>
* @version 0.6alpha
* @package PEAR_ErrorStack
* @category Debugging
* @license http://www.php.net/license/3_0.txt PHP License v3.0
*/
/**
* Singleton storage
*
* Format:
* <pre>
* array(
* 'package1' => PEAR_ErrorStack object,
* 'package2' => PEAR_ErrorStack object,
* ...
* )
* </pre>
* @access private
* @global array $GLOBALS['_PEAR_ERRORSTACK_SINGLETON']
*/
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array();
/**
* Global error callback (default)
*
* This is only used
* @see PEAR_ErrorStack::setDefaultCallback()
* @access private
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK']
*/
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'] = false;
/**
* Global Log object (default)
*
* This is only used
* @see PEAR_ErrorStack::setDefaultLogger()
* @access private
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']
*/
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = false;
/**#@+
* One of four possible return values from the error Callback
* @see PEAR_ErrorStack::_errorCallback()
*/
/**
* If this is returned, then the error will be both pushed onto the stack
* and logged.
*/
define('PEAR_ERRORSTACK_PUSHANDLOG', 1);
/**
* If this is returned, then the error will only be pushed onto the stack,
* and not logged.
*/
define("PEAR_ERRORSTACK_PUSH", 2);
/**
* If this is returned, then the error will only be logged, but not pushed
* onto the error stack.
*/
define("PEAR_ERRORSTACK_LOG", 3);
/**
* If this is returned, then the error is completely ignored.
*/
define("PEAR_ERRORSTACK_IGNORE", 4);
/**#@-*/
/**
* Error code for an attempt to instantiate a non-class as a PEAR_ErrorStack in
* the singleton method.
*/
define("PEAR_ERRORSTACK_ERR_NONCLASS", 1);
/**
* Error code for an attempt to pass an object into {@link PEAR_ErrorStack::getMessage()}
* that has no __toString() method
*/
define('PEAR_ERRORSTACK_ERR_OBJTOSTRING', 2);
/**
* Error Stack Implementation
*
* Usage:
* <code>
* // global error stack
* $global_stack = &PEAR_ErrorStack::singleton('MyPackage');
* // local error stack
* $local_stack = new PEAR_ErrorStack('MyPackage');
* </code>
* @copyright 2004 Gregory Beaver
* @package PEAR_ErrorStack
* @license http://www.php.net/license/3_0.txt PHP License
*/
class PEAR_ErrorStack {
/**
* Errors are stored in the order that they are pushed on the stack.
* @since 0.4alpha Errors are no longer organized by error level.
* This renders pop() nearly unusable, and levels could be more easily
* handled in a callback anyway
* @var array
* @access private
*/
var $_errors = array();
/**
* Package name this error stack represents
* @var string
* @access protected
*/
var $_package;
/**
* Determines whether a PEAR_Error is thrown upon every error addition
* @var boolean
* @access private
*/
var $_compat = false;
/**
* If set to a valid callback, this will be used to generate the error
* message from the error code, otherwise the message passed in will be
* used
* @var false|string|array
* @access private
*/
var $_msgCallback = false;
/**
* If set to a valid callback, this will be used to generate the error
* context for an error. For PHP-related errors, this will be a file
* and line number as retrieved from debug_backtrace(), but can be
* customized for other purposes. The error might actually be in a separate
* configuration file, or in a database query.
* @var false|string|array
* @access protected
*/
var $_contextCallback = false;
/**
* If set to a valid callback, this will be called every time an error
* is pushed onto the stack. The return value will be used to determine
* whether to allow an error to be pushed or logged.
*
* The return value must be one an PEAR_ERRORSTACK_* constant
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @var false|string|array
* @access protected
*/
var $_errorCallback = array();
/**
* PEAR::Log object for logging errors
* @var false|Log
* @access protected
*/
var $_logger = false;
/**
* Class name to use for a PHP 5 exception that will be returned
* @var string
* @access protected
*/
var $_exceptionClass = 'Exception';
/**
* Error messages - designed to be overridden
* @var array
* @abstract
*/
var $_errorMsgs = array();
/**
* Set up a new error stack
*
* @param string $package name of the package this error stack represents
* @param callback $msgCallback callback used for error message generation
* @param callback $contextCallback callback used for context generation,
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
* @param string $exceptionClass exception class to instantiate if
* in PHP 5
*/
function PEAR_ErrorStack($package, $msgCallback = false, $contextCallback = false,
$throwPEAR_Error = false, $exceptionClass = 'Exception')
{
$this->_package = $package;
$this->setMessageCallback($msgCallback);
$this->setContextCallback($contextCallback);
$this->_compat = $throwPEAR_Error;
$this->_exceptionClass = $exceptionClass;
}
/**
* Return a single error stack for this package.
*
* Note that all parameters are ignored if the stack for package $package
* has already been instantiated
* @param string $package name of the package this error stack represents
* @param callback $msgCallback callback used for error message generation
* @param callback $contextCallback callback used for context generation,
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
* @param string $exceptionClass exception class to instantiate if
* in PHP 5
* @param string $stackClass class to instantiate
* @static
* @return PEAR_ErrorStack
*/
function &singleton($package, $msgCallback = false, $contextCallback = false,
$throwPEAR_Error = false, $exceptionClass = 'Exception',
$stackClass = 'PEAR_ErrorStack')
{
if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
}
if (!class_exists($stackClass)) {
$trace = debug_backtrace();
PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_NONCLASS,
'exception', array('stackclass' => $stackClass),
'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)',
false, $trace);
}
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
&new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error,
$exceptionClass);
}
/**
* Internal error handler for PEAR_ErrorStack class
*
* Dies if the error is an exception (and would have died anyway)
* @access private
*/
function _handleError($err)
{
if ($err['level'] == 'exception') {
$message = $err['message'];
if (isset($_SERVER['REQUEST_URI'])) {
echo '<br />';
} else {
echo "\n";
}
var_dump($err['context']);
die($message);
}
}
/**
* Set up a PEAR::Log object for all error stacks that don't have one
* @param Log $log
* @static
*/
function setDefaultLogger(&$log)
{
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
}
/**
* Set up a PEAR::Log object for this error stack
* @param Log $log
*/
function setLogger(&$log)
{
$this->_logger = &$log;
}
/**
* Set an error code => error message mapping callback
*
* This method sets the callback that can be used to generate error
* messages for any instance
* @param string $package Package Name
* @param array|string Callback function/method
*/
function setMessageCallback($msgCallback)
{
if (!$msgCallback) {
$this->_msgCallback = array(&$this, 'getErrorMessage');
} else {
if (is_callable($msgCallback)) {
$this->_msgCallback = $msgCallback;
}
}
}
/**
* Get an error code => error message mapping callback
*
* This method returns the current callback that can be used to generate error
* messages
* @return array|string|false Callback function/method or false if none
*/
function getMessageCallback()
{
return $this->_msgCallback;
}
/**
* Sets a default callback to be used by all error stacks
*
* This method sets the callback that can be used to generate error
* messages for a singleton
* @param array|string Callback function/method
* @static
*/
function setDefaultCallback($callback = false)
{
if (!is_callable($callback)) {
$callback = false;
}
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'] = $callback;
}
/**
* Set an error code => error message mapping callback
*
* This method sets the callback that can be used to generate error
* messages for any PEAR_ErrorStack instance
* @param string $package Package Name
* @param array|string Callback function/method
*/
function setContextCallback($contextCallback)
{
if (!$contextCallback) {
$this->_contextCallback = array(&$this, 'getFileLine');
} else {
if (is_callable($contextCallback)) {
$this->_contextCallback = $contextCallback;
}
}
}
/**
* Set an error Callback
* If set to a valid callback, this will be called every time an error
* is pushed onto the stack. The return value will be used to determine
* whether to allow an error to be pushed or logged.
*
* The return value must be one of the ERRORSTACK_* constants.
*
* This functionality can be used to emulate PEAR's pushErrorHandling, and
* the PEAR_ERROR_CALLBACK mode, without affecting the integrity of
* the error stack or logging
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @see popCallback()
* @param string|array $cb
*/
function pushCallback($cb)
{
array_push($this->_errorCallback, $cb);
}
/**
* Remove a callback from the error callback stack
* @see pushCallback()
* @return array|string|false
*/
function popCallback()
{
if (!count($this->_errorCallback)) {
return false;
}
return array_pop($this->_errorCallback);
}
/**
* Set an error Callback for every package error stack
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @see staticPopCallback(), pushCallback()
* @param string|array $cb
* @static
*/
function staticPushCallback($cb)
{
foreach($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $unused) {
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->pushCallback($cb);
}
}
/**
* Remove a callback from every error callback stack
* @see staticPushCallback()
* @return array|string|false
*/
function staticPopCallback()
{
foreach($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $unused) {
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->popCallback();
}
}
/**
* Add an error to the stack
*
* If the message generator exists, it is called with 2 parameters.
* - the current Error Stack object
* - an array that is in the same format as an error. Available indices
* are 'code', 'package', 'time', 'params', 'level', and 'context'
*
* Next, if the error should contain context information, this is
* handled by the context grabbing method.
* Finally, the error is pushed onto the proper error stack
* @param int $code Package-specific error code
* @param string $level Error level. This is NOT spell-checked
* @param array $params associative array of error parameters
* @param string $msg Error message, or a portion of it if the message
* is to be generated
* @param array $repackage If this error re-packages an error pushed by
* another package, place the array returned from
* {@link pop()} in this parameter
* @param array $backtrace Protected parameter: use this to pass in the
* {@link debug_backtrace()} that should be used
* to find error context
* @return PEAR_Error|array|Exception
* if compatibility mode is on, a PEAR_Error is also
* thrown. If the class Exception exists, then one
* is returned to allow code like:
* <code>
* throw ($stack->push(MY_ERROR_CODE, 'error', array('username' => 'grob')));
* </code>
*
* The errorData property of the exception class will be set to the array
* that would normally be returned. If a PEAR_Error is returned, the userinfo
* property is set to the array
*
* Otherwise, an array is returned in this format:
* <code>
* array(
* 'code' => $code,
* 'params' => $params,
* 'package' => $this->_package,
* 'level' => $level,
* 'time' => time(),
* 'context' => $context,
* 'message' => $msg,
* //['repackage' => $err] repackaged error array
* );
* </code>
*/
function push($code, $level = 'error', $params = array(), $msg = false,
$repackage = false, $backtrace = false)
{
$context = false;
// grab error context
if ($this->_contextCallback) {
if (!$backtrace) {
$backtrace = debug_backtrace();
}
$context = call_user_func($this->_contextCallback, $code, $params, $backtrace);
}
// save error
$time = explode(' ', microtime());
$time = $time[1] + $time[0];
$err = array(
'code' => $code,
'params' => $params,
'package' => $this->_package,
'level' => $level,
'time' => $time,
'context' => $context,
'message' => $msg,
);
// set up the error message, if necessary
if ($this->_msgCallback) {
$msg = call_user_func_array($this->_msgCallback,
array(&$this, $err));
$err['message'] = $msg;
}
if ($repackage) {
$err['repackage'] = $repackage;
}
$push = $log = true;
$callback = $this->popCallback();
if (is_callable($callback)) {
$this->pushCallback($callback);
switch(call_user_func($callback, $err)){
case PEAR_ERRORSTACK_IGNORE:
return $err;
break;
case PEAR_ERRORSTACK_PUSH:
$log = false;
break;
case PEAR_ERRORSTACK_LOG:
$push = false;
break;
// anything else returned has the same effect as pushandlog
}
} elseif (is_callable($GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'])) {
switch(call_user_func($GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'], $err)){
case PEAR_ERRORSTACK_IGNORE:
return $err;
break;
case PEAR_ERRORSTACK_PUSH:
$log = false;
break;
case PEAR_ERRORSTACK_LOG:
$push = false;
break;
// anything else returned has the same effect as pushandlog
}
}
if ($push) {
array_unshift($this->_errors, $err);
}
if ($log) {
if ($this->_logger || $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']) {
$this->_log($err);
}
}
if ($this->_compat && $push) {
return $this->raiseError($msg, $code, null, null, $err);
}
if (class_exists($this->_exceptionClass)) {
$exception = $this->_exceptionClass;
$ret = new $exception($msg, $code);
$ret->errorData = $err;
}
return $err;
}
/**
* Static version of {@link push()}
*
* @param string $package Package name this error belongs to
* @param int $code Package-specific error code
* @param string $level Error level. This is NOT spell-checked
* @param array $params associative array of error parameters
* @param string $msg Error message, or a portion of it if the message
* is to be generated
* @param array $repackage If this error re-packages an error pushed by
* another package, place the array returned from
* {@link pop()} in this parameter
* @param array $backtrace Protected parameter: use this to pass in the
* {@link debug_backtrace()} that should be used
* to find error context
* @return PEAR_Error|null|Exception
* if compatibility mode is on, a PEAR_Error is also
* thrown. If the class Exception exists, then one
* is returned to allow code like:
* <code>
* throw ($stack->push(MY_ERROR_CODE, 'error', array('username' => 'grob')));
* </code>
* @static
*/
function staticPush($package, $code, $level = 'error', $params = array(),
$msg = false, $repackage = false, $backtrace = false)
{
$s = &PEAR_ErrorStack::singleton($package);
if ($s->_contextCallback) {
if (!$backtrace) {
$backtrace = debug_backtrace();
}
}
return $s->push($code, $level, $params, $msg, $repackage, $backtrace);
}
/**
* Log an error using PEAR::Log
* @param array $err Error array
* @param array $levels Error level => Log constant map
* @access protected
*/
function _log($err, $levels = array(
'exception' => PEAR_LOG_CRIT,
'alert' => PEAR_LOG_ALERT,
'critical' => PEAR_LOG_CRIT,
'error' => PEAR_LOG_ERR,
'warning' => PEAR_LOG_WARNING,
'notice' => PEAR_LOG_NOTICE,
'info' => PEAR_LOG_INFO,
'debug' => PEAR_LOG_DEBUG))
{
if (isset($levels[$err['level']])) {
$level = $levels[$err['level']];
} else {
$level = PEAR_LOG_INFO;
}
if ($this->_logger) {
$this->_logger->log($err['message'], $level, $err);
} else {
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']->log($err['message'], $level, $err);
}
}
/**
* Pop an error off of the error stack
*
* @return false|array
* @since 0.4alpha it is no longer possible to specify a specific error
* level to return - the last error pushed will be returned, instead
*/
function pop()
{
return @array_shift($this->_errors);
}
/**
* Determine whether there are any errors on the stack
* @return boolean
*/
function hasErrors()
{
return count($this->_errors);
}
/**
* Retrieve all errors since last purge
*
* @param boolean $purge set in order to empty the error stack
* @return array
*/
function getErrors($purge = false)
{
if (!$purge) {
return $this->_errors;
}
$ret = $this->_errors;
$this->_errors = array();
return $ret;
}
/**
* Determine whether there are any errors on any error stack
* @return boolean
* @static
*/
function staticHasErrors()
{
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
if ($obj->hasErrors()) {
return true;
}
}
return false;
}
/**
* Get a list of all errors since last purge, organized by package
* @param boolean $clearStack Set to purge the error stack of existing errors
* @param boolean $merge Set to return a flat array, not organized by package
* @param array $sortfunc Function used to sort a merged array - default
* sorts by time, and should be good for most cases
* @static
* @return array
*/
function staticGetErrors($purge = false, $merge = false, $sortfunc = array('PEAR_ErrorStack', '_sortErrors'))
{
$ret = array();
if (!is_callable($sortfunc)) {
$sortfunc = array('PEAR_ErrorStack', '_sortErrors');
}
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
$test = $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->getErrors($purge);
if ($test) {
if ($merge) {
$ret = array_merge($ret, $test);
} else {
$ret[$package] = $test;
}
}
}
if ($merge) {
usort($ret, $sortfunc);
}
return $ret;
}
/**
* Error sorting function, sorts by time
* @access private
*/
function _sortErrors($a, $b)
{
if ($a['time'] == $b['time']) {
return 0;
}
if ($a['time'] < $b['time']) {
return 1;
}
return -1;
}
/**
* Standard file/line number/function/class context callback
*
* This function uses a backtrace generated from {@link debug_backtrace()}
* and so will not work at all in PHP < 4.3.0. The frame should
* reference the frame that contains the source of the error.
* @return array|false either array('file' => file, 'line' => line,
* 'function' => function name, 'class' => class name) or
* if this doesn't work, then false
* @param array Results of debug_backtrace()
* @param unused
* @param integer backtrace frame.
* @static
*/
function getFileLine($code, $params, $backtrace = null)
{
if ($backtrace === null) {
return false;
}
$frame = 0;
$functionframe = 1;
if (!isset($backtrace[1])) {
$functionframe = 0;
} else {
while (isset($backtrace[$functionframe]['function']) &&
$backtrace[$functionframe]['function'] == 'eval' &&
isset($backtrace[$functionframe + 1])) {
$functionframe++;
}
}
if (isset($backtrace[$frame])) {
if (!isset($backtrace[$frame]['file'])) {
$frame++;
}
$funcbacktrace = $backtrace[$functionframe];
$filebacktrace = $backtrace[$frame];
$ret = array('file' => $filebacktrace['file'],
'line' => $filebacktrace['line']);
// rearrange for eval'd code or create function errors
if (strpos($filebacktrace['file'], '(') &&
preg_match(';^(.*?)\((\d+)\) : (.*?)$;', $filebacktrace['file'],
$matches)) {
$ret['file'] = $matches[1];
$ret['line'] = $matches[2] + 0;
}
if (isset($funcbacktrace['function']) && isset($backtrace[1])) {
if ($funcbacktrace['function'] != 'eval') {
if ($funcbacktrace['function'] == '__lambda_func') {
$ret['function'] = 'create_function() code';
} else {
$ret['function'] = $funcbacktrace['function'];
}
}
}
if (isset($funcbacktrace['class']) && isset($backtrace[1])) {
$ret['class'] = $funcbacktrace['class'];
}
return $ret;
}
return false;
}
/**
* Standard error message generation callback
*
* This method may also be called by a custom error message generator
* to fill in template values from the params array, simply
* set the third parameter to the error message template string to use
*
* The special variable %__msg% is reserved: use it only to specify
* where a message passed in by the user should be placed in the template,
* like so:
*
* Error message: %msg% - internal error
*
* If the message passed like so:
*
* <code>
* $stack->push(ERROR_CODE, 'error', array(), 'server error 500');
* </code>
*
* The returned error message will be "Error message: server error 500 -
* internal error"
* @param PEAR_ErrorStack
* @param array
* @param string|false Pre-generated error message template
* @static
* @return string
*/
function getErrorMessage(&$stack, $err, $template = false)
{
if ($template) {
$mainmsg = $template;
} else {
$mainmsg = $stack->getErrorMessageTemplate($err['code']);
}
$mainmsg = str_replace('%__msg%', $err['message'], $mainmsg);
if (count($err['params'])) {
foreach ($err['params'] as $name => $val) {
if (is_array($val)) {
$val = implode(', ', $val);
}
if (is_object($val)) {
if (method_exists($val, '__toString')) {
$val = $val->__toString();
} else {
PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_OBJTOSTRING,
'warning', array('obj' => get_class($val)),
'object %obj% passed into getErrorMessage, but has no __toString() method');
$val = 'Object';
}
}
$mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
}
}
return $mainmsg;
}
/**
* Standard Error Message Template generator from code
* @return string
*/
function getErrorMessageTemplate($code)
{
if (!isset($this->_errorMsgs[$code])) {
return '%__msg%';
}
return $this->_errorMsgs[$code];
}
/**
* Set the Error Message Template array
*
* The array format must be:
* <pre>
* array(error code => 'message template',...)
* </pre>
*
* Error message parameters passed into {@link push()} will be used as input
* for the error message. If the template is 'message %foo% was %bar%', and the
* parameters are array('foo' => 'one', 'bar' => 'six'), the error message returned will
* be 'message one was six'
* @return string
*/
function setErrorMessageTemplate($template)
{
$this->_errorMsgs = $template;
}
/**
* emulate PEAR::raiseError()
*
* @return PEAR_Error
*/
function raiseError()
{
require_once 'PEAR.php';
$args = func_get_args();
return call_user_func_array(array('PEAR', 'raiseError'), $args);
}
}
$stack = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$stack->pushCallback(array('PEAR_ErrorStack', '_handleError'));
?>
-15
View File
@@ -539,21 +539,6 @@ class PEAR_Installer extends PEAR_Downloader
return parent::mkDirHier($dir);
}
// }}}
// {{{ _prependPath($path, $prepend)
function _prependPath($path, $prepend)
{
if (strlen($prepend) > 0) {
if (OS_WINDOWS && preg_match('/^[a-z]:/i', $path)) {
$path = $prepend . substr($path, 2);
} else {
$path = $prepend . $path;
}
}
return $path;
}
// }}}
// {{{ download()
+36 -13
View File
@@ -47,20 +47,21 @@
</maintainer>
</maintainers>
<release>
<version>1.3b6</version>
<date>2004-01-26</date>
<state>beta</state>
<version>1.3.1dev</version>
<date>2004-03-18</date>
<state>devel</state>
<notes>
PEAR Installer:
* Bug #171 --alldeps with a rel=&quot;eq&quot; should install the required version, if possible
* Bug #249 installing from an url doesnt work
* Bug #248 --force command does not work as expected
* Bug #293 [Patch] PEAR_Error not calling static method callbacks for error-handler
* Bug #324 pear -G gives Fatal Error (PHP-GTK not installed, but error is at engine level)
* Bug #594 PEAR_Common::analyzeSourceCode fails on string with $var and {
* Moved download code into its own class
* Fully unit tested the installer, packager, downloader, and PEAR_Common
* Bug #521 Incorrect filename in naming warnings
* Bug #933 CMD Usability Patch
* Bug #1008 safe mode raises warning
PEAR_ErrorStack:
* Added experimental error handling, designed to eventually replace
PEAR_Error. It should be considered experimental until explicitly marked
stable. require_once 'PEAR/ErrorStack.php' to use.
</notes>
<provides type="class" name="OS_Guess" />
<provides type="class" name="System" />
@@ -88,6 +89,7 @@ PEAR Installer:
<file role="php" name="Config.php"/>
<file role="php" name="Dependency.php"/>
<file role="php" name="Downloader.php"/>
<file role="php" name="ErrorStack.php"/>
<dir name="Frontend">
<file role="php" name="CLI.php"/>
</dir>
@@ -121,7 +123,7 @@ PEAR Installer:
</dir>
</filelist>
<deps>
<dep type="php" rel="ge" version="4.1"/>
<dep type="php" rel="ge" version="4.2"/>
<dep type="pkg" rel="ge" version="1.1">Archive_Tar</dep>
<dep type="pkg" rel="ge" version="1.2">Console_Getopt</dep>
<dep type="pkg" rel="ge" version="1.0.4">XML_RPC</dep>
@@ -129,4 +131,25 @@ PEAR Installer:
<dep type="ext" rel="has">pcre</dep>
</deps>
</release>
<changelog>
<release>
<version>1.3</version>
<date>2004-02-20</date>
<state>stable</state>
<notes>
PEAR Installer:
* Bug #171 --alldeps with a rel=&quot;eq&quot; should install the required version, if possible
* Bug #249 installing from an url doesnt work
* Bug #248 --force command does not work as expected
* Bug #293 [Patch] PEAR_Error not calling static method callbacks for error-handler
* Bug #324 pear -G gives Fatal Error (PHP-GTK not installed, but error is at engine level)
* Bug #594 PEAR_Common::analyzeSourceCode fails on string with $var and {
* Bug #521 Incorrect filename in naming warnings
* Moved download code into its own class
* Fully unit tested the installer, packager, downloader, and PEAR_Common
</notes>
</release>
</changelog>
</package>
+69 -69
View File
@@ -1,69 +1,69 @@
@ECHO OFF
REM ----------------------------------------------------------------------
REM PHP version 4
REM ----------------------------------------------------------------------
REM Copyright (c) 1997-2004 The PHP Group
REM ----------------------------------------------------------------------
REM This source file is subject to version 3.0 of the PHP license,
REM that is bundled with this package in the file LICENSE, and is
REM available at through the world-wide-web at
REM http://www.php.net/license/3_0.txt.
REM If you did not receive a copy of the PHP license and are unable to
REM obtain it through the world-wide-web, please send a note to
REM license@php.net so we can mail you a copy immediately.
REM ----------------------------------------------------------------------
REM Authors: Alexander Merz (alexmerz@php.net)
REM ----------------------------------------------------------------------
REM
REM $Id: pear.bat,v 1.18 2004/01/08 17:33:14 sniper Exp $
REM change this lines to match the paths of your system
REM -------------------
@ECHO OFF
:: Check PEAR global ENV, set them if they do not exist
IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"
:: Check Folders and files
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
:: launch pearcmd
GOTO RUN
:PEAR_INSTALL_ERROR
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_INSTALL_DIR%
GOTO END
:PEAR_INSTALL_ERROR2
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
ECHO pearcmd.php could not be found there.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_INSTALL_DIR%
GOTO END
:PEAR_BIN_ERROR
ECHO PHP_PEAR_BIN_DIR is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_BIN_DIR%
GOTO END
:PEAR_PHPBIN_ERROR
ECHO PHP_PEAR_PHP_BIN is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_PHP_BIN%
GOTO END
:RUN
"%PHP_PEAR_PHP_BIN%" -C -d output_buffering=1 -d include_path="%PHP_PEAR_INSTALL_DIR%" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
:END
@ECHO ON
@ECHO OFF
REM ----------------------------------------------------------------------
REM PHP version 5
REM ----------------------------------------------------------------------
REM Copyright (c) 1997-2004 The PHP Group
REM ----------------------------------------------------------------------
REM This source file is subject to version 3.0 of the PHP license,
REM that is bundled with this package in the file LICENSE, and is
REM available at through the world-wide-web at
REM http://www.php.net/license/3_0.txt.
REM If you did not receive a copy of the PHP license and are unable to
REM obtain it through the world-wide-web, please send a note to
REM license@php.net so we can mail you a copy immediately.
REM ----------------------------------------------------------------------
REM Authors: Alexander Merz (alexmerz@php.net)
REM ----------------------------------------------------------------------
REM
REM Last updated 3/13/2004 ($Id$ is not replaced if the file is binary)
REM change this lines to match the paths of your system
REM -------------------
@ECHO OFF
:: Check PEAR global ENV, set them if they do not exist
IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=@include_path@"
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=@bin_dir@"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=@php_bin@"
:: Check Folders and files
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%" GOTO PEAR_INSTALL_ERROR
IF NOT EXIST "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" GOTO PEAR_INSTALL_ERROR2
IF NOT EXIST "%PHP_PEAR_BIN_DIR%" GOTO PEAR_BIN_ERROR
IF NOT EXIST "%PHP_PEAR_PHP_BIN%" GOTO PEAR_PHPBIN_ERROR
:: launch pearcmd
GOTO RUN
:PEAR_INSTALL_ERROR
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_INSTALL_DIR%
GOTO END
:PEAR_INSTALL_ERROR2
ECHO PHP_PEAR_INSTALL_DIR is not set correctly.
ECHO pearcmd.php could not be found there.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_INSTALL_DIR%
GOTO END
:PEAR_BIN_ERROR
ECHO PHP_PEAR_BIN_DIR is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_BIN_DIR%
GOTO END
:PEAR_PHPBIN_ERROR
ECHO PHP_PEAR_PHP_BIN is not set correctly.
ECHO Please fix it using your environment variable or modify
ECHO the default value in pear.bat
ECHO The current value is:
ECHO %PHP_PEAR_PHP_BIN%
GOTO END
:RUN
"%PHP_PEAR_PHP_BIN%" -C -d output_buffering=1 -d register_argc_argv=On -d include_path="%PHP_PEAR_INSTALL_DIR%" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
:END
@ECHO ON
+3 -1
View File
@@ -28,7 +28,9 @@ if ('@include_path@' != '@'.'include_path'.'@') {
ini_set('include_path', '@include_path@');
}
ini_set('allow_url_fopen', true);
set_time_limit(0);
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
ob_implicit_flush(true);
ini_set('track_errors', true);
ini_set('html_errors', false);
@@ -0,0 +1,142 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
class testgemessage
{
function __toString()
{
return '__toString() called';
}
}
class testgemessage1 {}
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_getErrorMessage extends PHPUnit_TestCase
{
function PEAR_ErrorStack_TestCase_getErrorMessage($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('test');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function returnsignore($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_IGNORE;
}
function test_basic()
{
if (!$this->_methodExists('getErrorMessage')) {
return;
}
$msg = PEAR_ErrorStack::getErrorMessage($this->stack,
array('message' => 'boo', 'params' => array(), 'code' => 6));
$this->assertEquals('boo', $msg);
}
function test_basic_template()
{
if (!$this->_methodExists('getErrorMessage')) {
return;
}
$msg = PEAR_ErrorStack::getErrorMessage($this->stack,
array('message' => 'boo', 'params' => array()), 'far%__msg%');
$this->assertEquals('farboo', $msg);
}
function test_basic_params()
{
if (!$this->_methodExists('getErrorMessage')) {
return;
}
$msg = PEAR_ErrorStack::getErrorMessage($this->stack, array('message' => '',
'params' => array('bar' => 'hello')), '%bar% foo');
$this->assertEquals('hello foo', $msg, 'string');
$msg = PEAR_ErrorStack::getErrorMessage($this->stack, array('message' => '',
'params' => array('bar' => array('hello', 'there'))), '%bar% foo');
$this->assertEquals('hello, there foo', $msg, 'array');
$msg = PEAR_ErrorStack::getErrorMessage($this->stack, array('message' => '',
'params' => array('bar' => new testgemessage)), '%bar% foo');
$this->assertEquals('__toString() called foo', $msg, 'first object, __toString()');
$msg = PEAR_ErrorStack::getErrorMessage($this->stack, array('message' => '',
'params' => array('bar' => new testgemessage1)), '%bar% foo');
$this->assertEquals('Object foo', $msg, 'second object, no __toString()');
$errs = PEAR_ErrorStack::staticGetErrors();
unset($errs['PEAR_ErrorStack'][0]['context']);
unset($errs['PEAR_ErrorStack'][0]['time']);
$this->assertEquals(
array('PEAR_ErrorStack' =>
array(
array(
'code' => PEAR_ERRORSTACK_ERR_OBJTOSTRING,
'params' => array('obj' => 'testgemessage1'),
'package' => 'PEAR_ErrorStack',
'level' => 'warning',
'message' => 'object testgemessage1 passed into getErrorMessage, but has no __toString() method',
))), $errs, 'warning not raised');
}
function test_basic_params_with_template()
{
if (!$this->_methodExists('getErrorMessage')) {
return;
}
$this->stack->setErrorMessageTemplate(array(6 => '%bar% foo'));
$msg = PEAR_ErrorStack::getErrorMessage($this->stack, array('message' => '',
'params' => array('bar' => 'hello'), 'code' => 6));
$this->assertEquals('hello foo', $msg, 'string');
$msg = PEAR_ErrorStack::getErrorMessage($this->stack, array('message' => '',
'params' => array('bar' => 'hello'), 'code' => 7));
$this->assertEquals('', $msg, 'string');
}
}
?>
@@ -0,0 +1,88 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_getErrorMessageTemplate extends PHPUnit_TestCase
{
function PEAR_ErrorStack_TestCase_getErrorMessageTemplate($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('test');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function returnsignore($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_IGNORE;
}
function test_normal()
{
if (!$this->_methodExists('getErrorMessageTemplate')) {
return;
}
$this->assertEquals('%__msg%', $this->stack->getErrorMessageTemplate(23));
}
function test_normal_hascode()
{
if (!$this->_methodExists('getErrorMessageTemplate')) {
return;
}
if (!$this->_methodExists('setErrorMessageTemplate')) {
return;
}
$this->stack->setErrorMessageTemplate(array(23 => '%foo% has %__msg%'));
$this->assertEquals('%foo% has %__msg%', $this->stack->getErrorMessageTemplate(23));
}
}
?>
@@ -0,0 +1,135 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_getErrors extends PHPUnit_TestCase
{
function PEAR_ErrorStack_TestCase_getErrors($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('test');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function returnsignore($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_IGNORE;
}
function test_none()
{
if (!$this->_methodExists('getErrors')) {
return;
}
$this->assertEquals(array(), $this->stack->getErrors());
$this->assertEquals(array(), $this->stack->getErrors(true));
}
function test_normal()
{
if (!$this->_methodExists('getErrors')) {
return;
}
$this->assertEquals(array(), $this->stack->getErrors());
$this->stack->push(1);
$this->stack->push(2, 'warning');
$this->stack->push(3, 'foo');
$ret = $this->stack->getErrors();
for ($i= 0; $i < 3; $i++) {
unset($ret[$i]['time']);
unset($ret[$i]['context']);
}
$this->assertEquals(
array(
array('code' => 3,
'params' => array(),
'package' => 'test',
'level' => 'foo',
'message' => ''),
array('code' => 2,
'params' => array(),
'package' => 'test',
'level' => 'warning',
'message' => ''),
array('code' => 1,
'params' => array(),
'package' => 'test',
'level' => 'error',
'message' => ''),
), $ret, 'incorrect errors, non-purge');
$ret = $this->stack->getErrors(true);
for ($i= 0; $i < 3; $i++) {
unset($ret[$i]['time']);
unset($ret[$i]['context']);
}
$this->assertEquals(
array(
array('code' => 3,
'params' => array(),
'package' => 'test',
'level' => 'foo',
'message' => ''),
array('code' => 2,
'params' => array(),
'package' => 'test',
'level' => 'warning',
'message' => ''),
array('code' => 1,
'params' => array(),
'package' => 'test',
'level' => 'error',
'message' => ''),
), $ret, 'incorrect errors, purge');
$this->assertEquals(array(), $this->stack->getErrors());
}
}
?>
@@ -0,0 +1,367 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_pushpop extends PHPUnit_TestCase
{
/**
* A PEAR_PackageFileManager object
* @var object
*/
var $packagexml;
function PEAR_ErrorStack_TestCase_pushpop($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('test');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function test_valid_basic()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack->push(1);
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_params()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$z = $this->stack->push(2, 'exception', array('my' => 'param'), 'hello',
array('test'), array(array('file' => 'boof', 'line' => 34)));
$err = $this->stack->pop('exception');
$this->assertEquals($z, $err, 'popped different error');
unset($err['time']);
$this->assertEquals(
array(
'code' => 2,
'params' => array('my' => 'param'),
'package' => 'test',
'message' => 'hello',
'level' => 'exception',
'context' =>
array(
'file' => 'boof',
'line' => 34,
),
'repackage' => array('test'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_paramscompat()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = new PEAR_ErrorStack('test', false, null, true);
$z = $this->stack->push(2, 'exception', array('my' => 'param'), 'hello',
array('test'), array(array('file' => 'boof', 'line' => 34)));
$this->assertEquals('pear_error', strtolower(get_class($z)), 'not pear_error');
$err = $this->stack->pop('exception');
if (is_a($z, 'PEAR_Error')) {
$this->assertEquals($err, $z->getUserInfo(), 'userinfo wrong');
}
unset($err['time']);
$this->assertEquals(
array(
'code' => 2,
'params' => array('my' => 'param'),
'package' => 'test',
'message' => 'hello',
'level' => 'exception',
'context' =>
array(
'file' => 'boof',
'line' => 34,
),
'repackage' => array('test'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function contextcallback($code, $params, $trace)
{
$this->assertEquals(4, $code, 'wrong context code');
$this->assertEquals(array('hello' => 6), $params, 'wrong context params');
$this->wasCalled = true;
return array('hi' => 'there', 'you' => 'fool');
}
function test_valid_contextconstructor()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = new PEAR_ErrorStack('test', false, array(&$this, 'contextcallback'));
$this->wasCalled = false;
$this->stack->push(4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'context callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test',
'message' => '',
'level' => 'error',
'context' => array('hi' => 'there', 'you' => 'fool'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_contextsingleton()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test', false, array(&$this, 'contextcallback'));
$this->wasCalled = false;
$this->stack->push(4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'context callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test',
'message' => '',
'level' => 'error',
'context' => array('hi' => 'there', 'you' => 'fool'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_context_setcontext()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('setContextCallback')) {
return;
}
$this->stack->setContextCallback(array(&$this, 'contextcallback'));
$this->wasCalled = false;
$this->stack->push(4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'context callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test',
'message' => '',
'level' => 'error',
'context' => array('hi' => 'there', 'you' => 'fool'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function messagecallback(&$stack, $err)
{
$this->assertEquals(4, $err['code'], 'wrong message code');
$this->assertEquals(array('hello' => 6), $err['params'], 'wrong message params');
$this->assertEquals('test1', $err['package'], 'wrong error stack');
$this->wasCalled = true;
return 'my silly message';
}
function test_valid_msgcallbackconstructor()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = new PEAR_ErrorStack('test1', array(&$this, 'messagecallback'));
$this->wasCalled = false;
$this->stack->push(4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'message callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
unset($err['context']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test1',
'message' => 'my silly message',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_msgcallbacksingleton()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test1', array(&$this, 'messagecallback'));
$this->wasCalled = false;
$this->stack->push(4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'message callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
unset($err['context']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test1',
'message' => 'my silly message',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_msgcallback_setmsgcallback()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('setContextCallback')) {
return;
}
$this->stack = new PEAR_ErrorStack('test1');
$this->stack->setMessageCallback(array(&$this, 'messagecallback'));
$this->wasCalled = false;
$this->stack->push(4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'message callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
unset($err['context']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test1',
'message' => 'my silly message',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
}
?>
@@ -0,0 +1,320 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_pushpopcallback extends PHPUnit_TestCase
{
/**
* A PEAR_PackageFileManager object
* @var object
*/
var $packagexml;
function PEAR_ErrorStack_TestCase_pushpopcallback($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('test');
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function returnsignore($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_IGNORE;
}
function test_return_ignore()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('pushCallback')) {
return;
}
if (!$this->_methodExists('popCallback')) {
return;
}
$this->stack->pushCallback(array(&$this, 'returnsignore'));
$this->wasCalled = false;
$this->stack->push(1);
$this->assertTrue($this->wasCalled, 'returnsignore not called');
$err = $this->stack->pop();
$this->assertFalse($err, 'error was not ignored!');
$this->stack->popCallback();
$this->wasCalled = false;
$this->stack->push(1);
$this->assertFalse($this->wasCalled, 'returnsignore called');
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function returnsnothing($err)
{
$this->wasCalled = true;
}
function test_return_nothing()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('pushCallback')) {
return;
}
if (!$this->_methodExists('popCallback')) {
return;
}
$this->stack->pushCallback(array(&$this, 'returnsnothing'));
$this->wasCalled = false;
$this->stack->push(1);
$this->assertTrue($this->wasCalled, 'returnsnothing not called');
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else'
);
$this->stack->popCallback();
$this->wasCalled = false;
$this->stack->push(1);
$this->assertFalse($this->wasCalled, 'returnsnothing called');
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function returnspush($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_PUSH;
}
function test_return_push()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('pushCallback')) {
return;
}
if (!$this->_methodExists('popCallback')) {
return;
}
if (!$this->_methodExists('setLogger')) {
return;
}
$this->stack->pushCallback(array(&$this, 'returnspush'));
$log = new BurfLog;
$log->setTestCase($this);
$log->curMethod(__FUNCTION__);
$this->stack->setLogger($log);
$this->wasCalled = false;
$this->stack->push(1);
$this->assertTrue($this->wasCalled, 'returnspush not called');
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else 1'
);
$this->stack->popCallback();
$log->pushExpect('', PEAR_LOG_ERR, array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
));
$this->wasCalled = false;
$this->wasLogged = false;
$this->stack->push(1);
$this->assertFalse($this->wasCalled, 'returnspush called');
$this->assertTrue($this->wasLogged, 'was not logged!');
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else 2'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function returnslog($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_LOG;
}
function test_return_log()
{
if (!$this->_methodExists('push')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('pushCallback')) {
return;
}
if (!$this->_methodExists('popCallback')) {
return;
}
if (!$this->_methodExists('setLogger')) {
return;
}
$this->stack->pushCallback(array(&$this, 'returnslog'));
$log = new BurfLog;
$log->setTestCase($this);
$log->curMethod(__FUNCTION__);
$this->stack->setLogger($log);
$this->wasCalled = false;
$this->wasLogged = false;
$log->pushExpect('', PEAR_LOG_ERR, array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
));
$this->stack->push(1);
$this->assertTrue($this->wasCalled, 'returnslog not called');
$this->assertTrue($this->wasLogged, 'was not logged!');
$err = $this->stack->pop();
$this->assertFalse($err, 'an error was pushed!');
$this->stack->popCallback();
$log->clearExpect();
$log->pushExpect('', PEAR_LOG_ERR, array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
));
$this->wasCalled = false;
$this->wasLogged = false;
$this->stack->push(1);
$this->assertFalse($this->wasCalled, 'returnspush called');
$this->assertTrue($this->wasLogged, 'was not logged!');
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else 2'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
}
?>
@@ -0,0 +1,327 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_pushpopstatic extends PHPUnit_TestCase
{
/**
* A PEAR_PackageFileManager object
* @var object
*/
var $packagexml;
function PEAR_ErrorStack_TestCase_pushpopstatic($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function test_valid_basic()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test');
PEAR_ErrorStack::staticPush('test', 1);
$err = $this->stack->pop();
unset($err['context']);
unset($err['time']);
$this->assertEquals(
array(
'code' => 1,
'params' => array(),
'package' => 'test',
'message' => '',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_params()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test');
$z = PEAR_ErrorStack::staticPush('test', 2, 'exception', array('my' => 'param'), 'hello',
array('test'), array(array('file' => 'boof', 'line' => 34)));
$err = $this->stack->pop('exception');
$this->assertEquals($z, $err, 'popped different error');
unset($err['time']);
$this->assertEquals(
array(
'code' => 2,
'params' => array('my' => 'param'),
'package' => 'test',
'message' => 'hello',
'level' => 'exception',
'context' =>
array(
'file' => 'boof',
'line' => 34,
),
'repackage' => array('test'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_paramscompat()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test', false, null, 'PEAR_ErrorStack', true);
$z = PEAR_ErrorStack::staticPush('test', 2, 'exception', array('my' => 'param'), 'hello',
array('test'), array(array('file' => 'boof', 'line' => 34)));
$this->assertEquals('pear_error', strtolower(get_class($z)), 'not pear_error');
$err = $this->stack->pop('exception');
if (is_a($z, 'PEAR_Error')) {
$this->assertEquals($err, $z->getUserInfo(), 'userinfo wrong');
}
unset($err['time']);
$this->assertEquals(
array(
'code' => 2,
'params' => array('my' => 'param'),
'package' => 'test',
'message' => 'hello',
'level' => 'exception',
'context' =>
array(
'file' => 'boof',
'line' => 34,
),
'repackage' => array('test'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function contextcallback($code, $params, $trace)
{
$this->assertEquals(4, $code, 'wrong context code');
$this->assertEquals(array('hello' => 6), $params, 'wrong context params');
$this->wasCalled = true;
return array('hi' => 'there', 'you' => 'fool');
}
function test_valid_contextsingleton()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test', false, array(&$this, 'contextcallback'));
$this->wasCalled = false;
PEAR_ErrorStack::staticPush('test', 4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'context callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test',
'message' => '',
'level' => 'error',
'context' => array('hi' => 'there', 'you' => 'fool'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_context_setcontext()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('setContextCallback')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test');
$this->stack->setContextCallback(array(&$this, 'contextcallback'));
$this->wasCalled = false;
PEAR_ErrorStack::staticPush('test', 4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'context callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test',
'message' => '',
'level' => 'error',
'context' => array('hi' => 'there', 'you' => 'fool'),
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function messagecallback(&$stack, $err)
{
$this->assertEquals(4, $err['code'], 'wrong message code');
$this->assertEquals(array('hello' => 6), $err['params'], 'wrong message params');
$this->assertEquals('test1', $err['package'], 'wrong error stack');
$this->wasCalled = true;
return 'my silly message';
}
function test_valid_msgcallbacksingleton()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test1', array(&$this, 'messagecallback'));
$this->wasCalled = false;
PEAR_ErrorStack::staticPush('test1', 4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'message callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
unset($err['context']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test1',
'message' => 'my silly message',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
function test_valid_msgcallback_setmsgcallback()
{
if (!$this->_methodExists('staticPush')) {
return;
}
if (!$this->_methodExists('singleton')) {
return;
}
if (!$this->_methodExists('pop')) {
return;
}
if (!$this->_methodExists('setContextCallback')) {
return;
}
$this->stack = &PEAR_ErrorStack::singleton('test1');
$this->stack->setMessageCallback(array(&$this, 'messagecallback'));
$this->wasCalled = false;
PEAR_ErrorStack::staticPush('test1', 4, 'error', array('hello' => 6));
$this->assertTrue($this->wasCalled, 'message callback was not called!');
$err = $this->stack->pop();
unset($err['time']);
unset($err['context']);
$this->assertEquals(
array(
'code' => 4,
'params' => array('hello' => 6),
'package' => 'test1',
'message' => 'my silly message',
'level' => 'error',
),
$err, 'popped something else'
);
$err = $this->stack->pop();
$this->assertFalse($err, 'stack not empty!');
}
}
?>
@@ -0,0 +1,93 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_singleton extends PHPUnit_TestCase
{
/**
* A PEAR_PackageFileManager object
* @var object
*/
var $packagexml;
function PEAR_ErrorStack_TestCase_singleton($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = new PEAR_ErrorStack('');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function test_valid_singleton()
{
if (!$this->_methodExists('singleton')) {
return;
}
$one = &PEAR_ErrorStack::singleton('first');
$two = &PEAR_ErrorStack::singleton('first');
$two->testme = 2;
$this->assertEquals(2, $two->testme, 'duh test');
$one->testme = 4;
$this->assertEquals(4, $one->testme, 'duh test 2');
$this->assertEquals(4, $two->testme, 'same object test');
}
function test_invalid_singleton()
{
if (!$this->_methodExists('singleton')) {
return;
}
$one = &PEAR_ErrorStack::singleton('first');
$two = &PEAR_ErrorStack::singleton('second');
$two->testme = 2;
$this->assertEquals(2, $two->testme, 'duh test');
$one->testme = 4;
$this->assertEquals(4, $one->testme, 'duh test 2');
$this->assertEquals(2, $two->testme, 'not same object test');
}
}
?>
@@ -0,0 +1,225 @@
<?php
/**
* API Unit tests for PEAR_ErrorStack package.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PEAR_ErrorStack
*/
/**
* @package PEAR_ErrorStack
*/
class PEAR_ErrorStack_TestCase_staticGetErrors extends PHPUnit_TestCase
{
function PEAR_ErrorStack_TestCase_staticGetErrors($name)
{
$this->PHPUnit_TestCase($name);
}
function setUp()
{
error_reporting(E_ALL);
$this->errorOccured = false;
set_error_handler(array(&$this, 'errorHandler'));
$this->stack = &PEAR_ErrorStack::singleton('test');
$s = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
$s->pushCallback(array('PEAR_ErrorStack', '_handleError'));
}
function tearDown()
{
unset($this->stack);
unset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']);
}
function _stripWhitespace($str)
{
return preg_replace('/\\s+/', '', $str);
}
function _methodExists($name)
{
if (in_array(strtolower($name), get_class_methods($this->stack))) {
return true;
}
$this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->stack));
return false;
}
function errorHandler($errno, $errstr, $errfile, $errline) {
//die("$errstr in $errfile at line $errline: $errstr");
$this->errorOccured = true;
$this->assertTrue(false, "$errstr at line $errline, $errfile");
}
function returnsignore($err)
{
$this->wasCalled = true;
return PEAR_ERRORSTACK_IGNORE;
}
function test_none()
{
if (!$this->_methodExists('staticGetErrors')) {
return;
}
$this->assertEquals(array(), PEAR_ErrorStack::staticGetErrors());
$this->assertEquals(array(), PEAR_ErrorStack::staticGetErrors(true));
}
function test_normal()
{
if (!$this->_methodExists('staticGetErrors')) {
return;
}
$this->assertEquals(array(), PEAR_ErrorStack::staticGetErrors());
$this->stack->push(1);
$this->stack->push(2, 'warning');
$this->stack->push(3, 'foo');
$ret = PEAR_ErrorStack::staticGetErrors();
for ($i= 0; $i < 3; $i++) {
unset($ret['test'][$i]['time']);
unset($ret['test'][$i]['context']);
}
$this->assertEquals(
array( 'test' => array(
array('code' => 3,
'params' => array(),
'package' => 'test',
'level' => 'foo',
'message' => ''),
array('code' => 2,
'params' => array(),
'package' => 'test',
'level' => 'warning',
'message' => ''),
array('code' => 1,
'params' => array(),
'package' => 'test',
'level' => 'error',
'message' => ''),
)), $ret, 'incorrect errors, non-purge');
$ret = PEAR_ErrorStack::staticGetErrors(true);
for ($i= 0; $i < 3; $i++) {
unset($ret['test'][$i]['time']);
unset($ret['test'][$i]['context']);
}
$this->assertEquals(
array( 'test' => array(
array('code' => 3,
'params' => array(),
'package' => 'test',
'level' => 'foo',
'message' => ''),
array('code' => 2,
'params' => array(),
'package' => 'test',
'level' => 'warning',
'message' => ''),
array('code' => 1,
'params' => array(),
'package' => 'test',
'level' => 'error',
'message' => ''),
)), $ret, 'incorrect errors, purge');
$this->assertEquals(array(), PEAR_ErrorStack::staticGetErrors());
}
function test_merge()
{
if (!$this->_methodExists('staticGetErrors')) {
return;
}
$this->assertEquals(array(), PEAR_ErrorStack::staticGetErrors());
$this->stack->push(1);
for($i=0;$i<10000;$i++);
$this->stack->push(2, 'warning');
for($i=0;$i<10000;$i++);
PEAR_ErrorStack::staticPush('fronk', 3, 'foo');
$ret = PEAR_ErrorStack::staticGetErrors(true, true);
for ($i= 0; $i < 3; $i++) {
unset($ret[$i]['time']);
unset($ret[$i]['context']);
}
$this->assertEquals(
array(
array('code' => 3,
'params' => array(),
'package' => 'fronk',
'level' => 'foo',
'message' => ''),
array('code' => 2,
'params' => array(),
'package' => 'test',
'level' => 'warning',
'message' => ''),
array('code' => 1,
'params' => array(),
'package' => 'test',
'level' => 'error',
'message' => ''),
), $ret, 'incorrect errors, non-purge');
$test = PEAR_ErrorStack::staticGetErrors();
$this->assertEquals(array(), $test, 'normal array');
}
function _sortErrorsRev($a, $b)
{
$this->wasCalled = true;
if ($a['time'] == $b['time']) {
return 0;
}
if ($a['time'] < $b['time']) {
return -1;
}
return 1;
}
function test_merge_sortfunc()
{
if (!$this->_methodExists('staticGetErrors')) {
return;
}
$this->assertEquals(array(), PEAR_ErrorStack::staticGetErrors());
$this->stack->push(1);
for($i=0;$i<10000;$i++);
$this->stack->push(2, 'warning');
for($i=0;$i<10000;$i++);
PEAR_ErrorStack::staticPush('fronk', 3, 'foo');
$this->wasCalled = false;
$ret = PEAR_ErrorStack::staticGetErrors(true, true, array(&$this, '_sortErrorsRev'));
$this->assertTrue($this->wasCalled, '_sortErrorsRev not called!');
for ($i= 0; $i < 3; $i++) {
unset($ret[$i]['time']);
unset($ret[$i]['context']);
}
$this->assertEquals(
array(
array('code' => 1,
'params' => array(),
'package' => 'test',
'level' => 'error',
'message' => ''),
array('code' => 2,
'params' => array(),
'package' => 'test',
'level' => 'warning',
'message' => ''),
array('code' => 3,
'params' => array(),
'package' => 'fronk',
'level' => 'foo',
'message' => ''),
), $ret, 'incorrect errors, non-purge');
$test = PEAR_ErrorStack::staticGetErrors();
$this->assertEquals(array(), $test, 'normal array');
}
}
?>
@@ -0,0 +1,64 @@
<?php
/**
* Provides a nice HTML output for PHPUnit suite tests.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_CSS
*/
class HTML_TestListener extends PHPUnit_TestListener {
function HTML_TestListener() {
$report = <<<EOS
<table cellspacing="1" cellpadding="1" border="0" width="90%" align="center" class="details">
<tr><th>Class</th><th>Function</th><th>Success</th><th>Meta-result</th></tr>
EOS;
echo $report;
}
function addError(&$test, &$t) {
$this->_errors += 1;
}
function addFailure(&$test, &$t) {
$this->_fails += 1;
}
function endTest(&$test) {
/* Report both the test result and, for this special situation
where some tests are expected to fail, a "meta" test result
which indicates whether the test result matches the
expected result.
*/
$expect_failure = preg_match('/fail/i', $test->getName());
$test_passed = ($this->_fails == 0 && $this->_errors == 0);
if ($this->_errors > 0) {
$outcome = "<span class=\"Error\">ERROR</span>";
} else if ($this->_fails > 0) {
$outcome = "<span class=\"Failure\">FAIL</span>";
} else {
$outcome = "<span class=\"Pass\">OK</span>";
}
if ($this->_errors > 0) {
$meta_outcome = '<span class="Unknown">unknown</span>';
} else {
$meta_outcome = ($expect_failure xor $test_passed)
? '<span class="Expected">as expected</span>'
: '<span class="Unexpected">UNEXPECTED</span>';
}
printf("<td>$outcome</td><td>$meta_outcome</td></tr>");
}
function startTest(&$test) {
$this->_fails = 0;
$this->_errors = 0;
printf("<tr><td>%s </td><td>%s </td>", get_class($test), $test->getName());
}
}
?>
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* TestUnit runs a TestSuite and returns a TestResult object.
* And more than PHPUnit attach a listener to TestResult.
*
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_CSS
*/
require_once 'PHPUnit.php';
class TestUnit extends PHPUnit {
function &run(&$suite, $listener) {
$result = new TestResult();
$result->addListener($listener);
$suite->run($result);
return $result;
}
}
class TestResult extends PHPUnit_TestResult {
/* report result of test run */
function report() {
echo "</TABLE>";
$nRun = $this->runCount();
$nErrors = $this->errorCount();
$nFailures = $this->failureCount();
echo "<h2>Summary</h2>";
printf("<p>%s test%s run.<br>", $nRun, ($nRun > 1) ? 's' : '');
printf("%s error%s.<br>\n", $nErrors, ($nErrors > 1) ? 's' : '');
printf("%s failure%s.<br>\n", $nFailures, ($nFailures > 1) ? 's' : '');
if ($nFailures > 0) {
echo "<h2>Failure Details</h2>";
print("<ol>\n");
$failures = $this->failures();
while (list($i, $failure) = each($failures)) {
$failedTest = $failure->failedTest();
printf("<li>%s\n", $failedTest->getName() );
print("<ul>");
printf("<li>%s\n", $failure->thrownException() );
print("</ul>");
}
print("</ol>\n");
}
}
}
?>
@@ -0,0 +1,550 @@
<?php
// $Revision$
/**
* Basic regression test for PEAR_ErrorStack::getFileLine()
*
* phpUnit can't test global code properly because of its design, so I designed
* this instead
* @package PEAR_ErrorStack
* @subpackage tests
* @author Greg Beaver <cellog@php.net>
*/
require_once 'PEAR/ErrorStack.php';
$result = array(
'passed' => array(),
'failed' => array()
);
$stack = &PEAR_ErrorStack::singleton('test');
$testNumber = 1;
// test basic global file/line
$stack->push(3);
$testline = __LINE__ - 1;
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'function' => 'include_once',
'line' => $testline));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test basic in-function file/line #2
function testfunc() { global $stack, $testline;
$stack->push(3);
$testline = __LINE__ - 1;
}
testfunc();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'testfunc'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test basic in-static method file/line #3
class stclass {
function stfunc() { global $stack, $testline;
$stack->push(3);
$testline = __LINE__ - 1;
}
}
stclass::stfunc();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'stfunc',
'class' => 'stclass'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test basic in-method file/line #4
class normalclass {
function normalfunc() { global $stack, $testline;
$stack->push(3);
$testline = __LINE__ - 1;
}
}
$z = new normalclass;
$z->normalfunc();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'normalfunc',
'class' => 'normalclass'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test global eval file/line #5
eval('$stack->push(3);');
$testline = __LINE__ - 1;
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'function' => 'include_once',
'line' => $testline));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test in-function eval file/line #6
function test2() {
global $testline, $stack;
eval('$stack->push(3);');
$testline = __LINE__ - 1;
}
test2();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'test2'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test in-static method eval file/line #7
class test3 {
function test3() {
global $testline, $stack;
eval('$stack->push(3);');
$testline = __LINE__ - 1;
}
}
test3::test3();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'test3',
'class' => 'test3'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test in-method eval file/line #8
class test4 {
function test4() {
global $testline, $stack;
eval('$stack->push(3);');
$testline = __LINE__ - 1;
}
}
$z = new test4;
$z->test4();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'test4',
'class' => 'test4'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test global create_function file/line #9
$a = create_function('', '$GLOBALS["stack"]->push(3);');
$testline = __LINE__ - 1;
$a();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test in-function create_function file/line #10
function test7() { global $a;
$a();
}
test7();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test in-static method create_function file/line #11
class test8 {
function test8() { global $a;
$a();
}
}
test8::test8();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test in-method create_function file/line #12
class test9 {
function test9() { global $a;
$a();
}
}
$z = new test9;
$z->test9();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$result['number'] = $testNumber;
$testNumber++;
// test static basic global file/line #13
PEAR_ErrorStack::staticPush('test', 3);
$testline = __LINE__ - 1;
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'function' => 'include_once',
'line' => $testline));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static basic in-function file/line #14
function testfunc2() { global $stack, $testline;
PEAR_ErrorStack::staticPush('test', 3);
$testline = __LINE__ - 1;
}
testfunc2();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'testfunc2'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static basic in-static method file/line #15
class stclass2 {
function stfunc() { global $stack, $testline;
PEAR_ErrorStack::staticPush('test', 3);
$testline = __LINE__ - 1;
}
}
stclass2::stfunc();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'stfunc',
'class' => 'stclass2'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static basic in-method file/line #16
class normalclass2 {
function normalfunc() { global $stack, $testline;
PEAR_ErrorStack::staticPush('test', 3);
$testline = __LINE__ - 1;
}
}
$z = new normalclass2;
$z->normalfunc();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'normalfunc',
'class' => 'normalclass2'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static global eval file/line #17
eval('PEAR_ErrorStack::staticPush(\'test\', 3);');
$testline = __LINE__ - 1;
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'function' => 'include_once',
'line' => $testline));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static in-function eval file/line #18
function test22() {
global $testline, $stack;
eval('PEAR_ErrorStack::staticPush("test", 3);');
$testline = __LINE__ - 1;
}
test22();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'test22'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static in-static method eval file/line #19
class test32 {
function test3() {
global $testline, $stack;
eval('PEAR_ErrorStack::staticPush(\'test\',3);');
$testline = __LINE__ - 1;
}
}
test32::test3();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'test3',
'class' => 'test32'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static in-method eval file/line #20
class test42 {
function test4() {
global $testline, $stack;
eval('PEAR_ErrorStack::staticPush(\'test\',3);');
$testline = __LINE__ - 1;
}
}
$z = new test42;
$z->test4();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'test4',
'class' => 'test42'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static global create_function file/line #21
$a = create_function('', 'PEAR_ErrorStack::staticPush("test",3);');
$testline = __LINE__ - 1;
$a();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static in-function create_function file/line #22
function test72() { global $a;
$a();
}
test72();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static in-static method create_function file/line #23
class test82 {
function test8() { global $a;
$a();
}
}
test82::test8();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$testNumber++;
// test static in-method create_function file/line #24
class test92 {
function test9() { global $a;
$a();
}
}
$z = new test92;
$z->test9();
$ret = $stack->pop();
$diff = array_diff_assoc($ret['context'],
array('file' => __FILE__,
'line' => $testline,
'function' => 'create_function() code'));
if ($diff !== array()) {
$result['failed'][$testNumber] = $diff;
} else {
$result['passed'][$testNumber] = true;
}
$result['number'] = $testNumber;
return $result;
/**
* Utility function
*/
function isIncludeable($path)
{
if (file_exists(realpath($path)) && is_readable(realpath($path))) {
return true;
}
foreach (explode(PATH_SEPARATOR, get_include_path()) as $prepend) {
$test = realpath($prepend . DIRECTORY_SEPARATOR . $path);
if (file_exists($test) && is_readable($test)) {
return true;
}
}
}
/**
* Mock PHPUnit object
*/
class Mock_PHPUnit {
var $name;
function getName()
{
return 'base regression test ' . $this->name;
}
}
?>
+65
View File
@@ -0,0 +1,65 @@
/* $Id$ */
body {
font:normal 68% verdana,arial,helvetica;
color:#000000;
}
table tr td, table tr th {
font-size: 68%;
}
table.details tr th{
font-weight: bold;
text-align:left;
background:#a6caf0;
}
table.details tr{
background:#eeeee0;
}
p {
line-height:1.5em;
margin-top:0.5em; margin-bottom:1.0em;
}
h1 {
margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
}
h2 {
margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
}
h3 {
margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
}
h4 {
margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
}
h5 {
margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
}
h6 {
margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
}
.Error {
font-weight:bold; color:red;
}
.Failure, .Unexpected {
background:#ff0000; font-weight:bold; color:black;
}
.Unknown {
background:#ffff00; font-weight:bold; color:black;
}
.Pass, .Expected {
background:#00ff00; font-weight:bold; color:black;
}
.Properties {
text-align:right;
}
CODE.expected {
color: green; background: none; font-weight: normal;
}
CODE.actual {
color: red; background: none; font-weight: normal;
}
.typeinfo {
color: gray;
}
+152
View File
@@ -0,0 +1,152 @@
<?php
/**
* HTML output for PHPUnit suite tests.
*
* Copied for PEAR_PackageFileManager from HTML_CSS
* @version $Id$
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_CSS
*/
require_once 'TestUnit.php';
require_once 'HTML_TestListener.php';
require_once 'PEAR/ErrorStack.php';
$title = 'PhpUnit test run, PEAR_ErrorStack package';
?>
<html>
<head>
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
</head>
<body>
<h1><?php echo $title; ?></h1>
<p>
This page runs all the phpUnit self-tests, and produces nice HTML output.
</p>
<p>
Unlike typical test run, <strong>expect many test cases to
fail</strong>. Exactly those with <code>pass</code> in their name
should succeed.
</p>
<p>
For each test we display both the test result -- <span
class="Pass">ok</span>, <span class="Failure">FAIL</span>, or
<span class="Error">ERROR</span> -- and also a meta-result --
<span class="Expected">as expected</span>, <span
class="Unexpected">UNEXPECTED</span>, or <span
class="Unknown">unknown</span> -- that indicates whether the
expected test result occurred. Although many test results will
be 'FAIL' here, all meta-results should be 'as expected', except
for a few 'unknown' meta-results (because of errors) when running
in PHP3.
</p>
<h2>Tests</h2>
<?php
$testcases = array(
'PEAR_ErrorStack_TestCase_singleton',
'PEAR_ErrorStack_TestCase_pushpop',
'PEAR_ErrorStack_TestCase_pushpopstatic',
'PEAR_ErrorStack_TestCase_pushpopcallback',
'PEAR_ErrorStack_TestCase_getErrorMessage',
'PEAR_ErrorStack_TestCase_getErrorMessageTemplate',
'PEAR_ErrorStack_TestCase_getErrors',
'PEAR_ErrorStack_TestCase_staticGetErrors',
);
define('PEAR_LOG_EMERG', 0); /** System is unusable */
define('PEAR_LOG_ALERT', 1); /** Immediate action required */
define('PEAR_LOG_CRIT', 2); /** Critical conditions */
define('PEAR_LOG_ERR', 3); /** Error conditions */
define('PEAR_LOG_WARNING', 4); /** Warning conditions */
define('PEAR_LOG_NOTICE', 5); /** Normal but significant */
define('PEAR_LOG_INFO', 6); /** Informational */
define('PEAR_LOG_DEBUG', 7); /** Debug-level messages */
/**
* Mock Log object
*/
class BurfLog {
var $testcase;
var $method;
var $expect = array();
function setTestCase(&$testcase)
{
$this->testcase = &$testcase;
}
function curMethod($method)
{
$this->method = $method;
}
function pushExpect($message, $priority, $errarray)
{
unset($errarray['time']);
unset($errarray['context']);
array_push($this->expect, array($message, $priority, $errarray));
}
function clearExpect()
{
$this->expect = array();
}
function log($message, $priority, $errarray)
{
$this->testcase->wasLogged = true;
if (!is_a($this->testcase, 'PHPUnit_TestCase')) {
trigger_error('ERROR: burflog never set up', E_USER_ERROR);
return;
}
if (!isset($this->method)) {
$this->testcase->assertFalse(true, 'ERROR: burflog never set up');
return;
}
if (!count($this->expect)) {
$this->testcase->assertFalse(true, "method $this->method: logged, but no log expected");
$this->testcase->assertFalse(true, "method $this->method: log message = $message");
$this->testcase->assertFalse(true, "method $this->method: log priority = $priority");
return;
}
unset($errarray['time']);
unset($errarray['context']);
$expect = array_pop($this->expect);
$this->testcase->assertEquals($expect[0], $message, "method $this->method: wrong message");
$this->testcase->assertEquals($expect[1], $priority, "method $this->method: wrong priority");
$this->testcase->assertEquals($expect[2], $errarray, "method $this->method: wrong errarray");
}
}
$suite = new PHPUnit_TestSuite();
foreach ($testcases as $testcase) {
include_once $testcase . '.php';
$suite->addTestSuite($testcase);
}
$listener = new HTML_TestListener();
$finalresult = TestUnit::run($suite, $listener);
$results = include_once dirname(__FILE__) . '/base_regression.php';
$num = $results['number'];
$failed = $results['failed'];
$passed = $results['passed'];
for ($i = 1; $i <= $num; $i++) {
$bla = new Mock_PHPUnit;
$bla->name = $i;
$listener->startTest($bla);
if (isset($failed[$i])) {
$listener->addFailure($bla, $failed[$i]);
$finalresult->addFailure($bla, $a = 'context had additional ' . serialize($failed[$i]));
}
$listener->endTest($bla);
}
$finalresult->removeListener($listener);
// hack in the base regression test count
$finalresult->_runTests += count($results['failed']) + count($results['passed']);
$finalresult->report();
?>
</body>
</html>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0">
<name>pkg1</name>
<summary>required test for PEAR_Installer</summary>
<description>
fake package
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>fakeuser</user>
<name>Joe Shmoe</name>
<email>nobody@example.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>1.1</version>
<date>2003-09-09</date>
<state>stable</state>
<notes>
required dependency test
</notes>
<deps>
<dep type="pkg" version="1.0" rel="ge">pkg2</dep>
</deps>
<filelist>
<dir name="/" baseinstalldir="grob" role="php">
<file>zoorb.php</file>
<dir name="goompness" role="php">
<file>oggbrzitzkee.php</file>
<file>Mopreeb.php</file>
</dir>
</dir>
</filelist>
</release>
</package>
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0">
<name>pkg2</name>
<summary>required test for PEAR_Installer</summary>
<description>
fake package
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>fakeuser</user>
<name>Joe Shmoe</name>
<email>nobody@example.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>1.1</version>
<date>2003-09-09</date>
<state>stable</state>
<notes>
required dependency test
</notes>
<deps>
<dep type="pkg" version="1.0" rel="ge">pkg3</dep>
<dep type="php" version="1.0" rel="ge" />
</deps>
<filelist>
<dir name="/" baseinstalldir="grob" role="php">
<file>zoorb.php</file>
<dir name="goompness" role="php">
<file>oggbrzitzkee.php</file>
<file>Mopreeb.php</file>
</dir>
</dir>
</filelist>
</release>
</package>
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0">
<name>pkg3</name>
<summary>required test for PEAR_Installer</summary>
<description>
fake package
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>fakeuser</user>
<name>Joe Shmoe</name>
<email>nobody@example.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>1.1</version>
<date>2003-09-09</date>
<state>stable</state>
<notes>
required dependency test
</notes>
<deps>
<dep type="pkg" version="1.0" rel="ge">pkg4</dep>
<dep type="pkg" version="1.0" rel="ge">pkg5</dep>
</deps>
<filelist>
<dir name="/" baseinstalldir="grob" role="php">
<file>zoorb.php</file>
<dir name="goompness" role="php">
<file>oggbrzitzkee.php</file>
<file>Mopreeb.php</file>
</dir>
</dir>
</filelist>
</release>
</package>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0">
<name>pkg4</name>
<summary>required test for PEAR_Installer</summary>
<description>
fake package
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>fakeuser</user>
<name>Joe Shmoe</name>
<email>nobody@example.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>1.1</version>
<date>2003-09-09</date>
<state>stable</state>
<notes>
required dependency test
</notes>
<deps>
<dep type="pkg" version="1.0" rel="ge">pkg6</dep>
</deps>
<filelist>
<dir name="/" baseinstalldir="grob" role="php">
<file>zoorb.php</file>
<dir name="goompness" role="php">
<file>oggbrzitzkee.php</file>
<file>Mopreeb.php</file>
</dir>
</dir>
</filelist>
</release>
</package>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0">
<name>pkg5</name>
<summary>required test for PEAR_Installer</summary>
<description>
fake package
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>fakeuser</user>
<name>Joe Shmoe</name>
<email>nobody@example.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>1.1</version>
<date>2003-09-09</date>
<state>stable</state>
<notes>
required dependency test
</notes>
<deps>
<dep type="pkg" version="1.0" rel="ge">pkg6</dep>
</deps>
<filelist>
<dir name="/" baseinstalldir="grob" role="php">
<file>zoorb.php</file>
<dir name="goompness" role="php">
<file>oggbrzitzkee.php</file>
<file>Mopreeb.php</file>
</dir>
</dir>
</filelist>
</release>
</package>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0">
<name>pkg6</name>
<summary>required test for PEAR_Installer</summary>
<description>
fake package
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>fakeuser</user>
<name>Joe Shmoe</name>
<email>nobody@example.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>1.1</version>
<date>2003-09-09</date>
<state>stable</state>
<notes>
required dependency test
</notes>
<filelist>
<dir name="/" baseinstalldir="grob" role="php">
<file>zoorb.php</file>
<dir name="goompness" role="php">
<file>oggbrzitzkee.php</file>
<file>Mopreeb.php</file>
</dir>
</dir>
</filelist>
</release>
</package>
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff. Show more