Compare commits

..
354 changed files with 10492 additions and 18238 deletions

No files matched your search

+1 -1
View File
@@ -61,7 +61,7 @@ php_lcov.info: lcov-test
lcov-html: php_lcov.info
@echo "Generating lcov HTML"
@$(LTP_GENHTML) --legend --output-directory lcov_html/ --title "PHP Code Coverage" --show-details php_lcov.info
@$(LTP_GENHTML) --legend --no-prefix --output-directory lcov_html/ --title "PHP Code Coverage" --show-details php_lcov.info
lcov-clean:
rm -f php_lcov.info
+5 -5
View File
@@ -25,10 +25,10 @@ install: $(all_targets) $(install_targets)
install-sapi: $(OVERALL_TARGET)
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-@if test ! -r $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME); then \
-@if test ! -r $(phptempdir)/libphp5.$(SHLIB_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME); \
if test -r $(phptempdir)/libphp5.$(SHLIB_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp5.$(SHLIB_SUFFIX_NAME).$$i $(phptempdir)/libphp5.$(SHLIB_SUFFIX_NAME); \
break; \
fi; \
done; \
@@ -44,13 +44,13 @@ install-modules: build-modules
install-headers:
-@if test "$(INSTALL_HEADERS)"; then \
for i in `echo $(INSTALL_HEADERS)`; do \
for i in $(INSTALL_HEADERS); do \
i=`$(top_srcdir)/build/shtool path -d $$i`; \
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
for i in $(INSTALL_HEADERS); do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
else \
+41 -160
View File
@@ -1,18 +1,7 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
04 May 2006, PHP 5.1.4
- Added "capture_peer_cert" and "capture_peer_cert_chain" context options
for SSL streams. (Wez).
- Added PDO::PARAM_EVT_* family of constants. (Sara)
- Fixed possible crash in highlight_string(). (Dmitry)
- Fixed bug #37291 (FastCGI now longer works with isapi_fcgi.dll). (Dmitry)
- Fixed bug #37277 (cloning Dom Documents or Nodes does not work). (Rob)
- Fixed bug #37276 (problems with $_POST array). (Dmitry)
- Fixed bug #36632 (bad error reporting for pdo_odbc exec UPDATE). (Wez).
- Fixed bug #35552 (crash when pdo_odbc prepare fails). (Wez).
28 Apr 2006, PHP 5.1.3
- Updated bundled PCRE library to version 6.6. (Andrei)
09 Mar 2006, PHP 5.1.3RC1
- Updated PCRE to version 6.6. (Andrei)
- Moved extensions to PECL:
. ext/msession (Derick)
- Reimplemented FastCGI interface. (Dmitry)
@@ -20,7 +9,7 @@ PHP NEWS
- Fixed issues with not/double calling of constructors of SPL iterators.
- Fixed issues with info-class/file-class in SPL directory handling classes.
- Fixed ArrayIterator::seek().
- Added SimpleXMLIterator::count().
- Added SimpleXMLElement::count().
- Dropped erroneous RecursiveDirectoryIterator::getSubPathInfo().
- Improved SimpleXML: (Marcus, Rob)
. Added SimpleXMLElement::getName() to retrieve name of element.
@@ -32,172 +21,69 @@ PHP NEWS
. Added ReflectionClass::newInstanceArgs($args).
. Added ability to analyze extension dependency.
. Added ReflectionFunction::isDeprecated() and constant IS_DEPRECATED.
. Added ReflectionParameter::getDeclaringClass().
. Deprecated ReflectionParameter::getClass() and added getDeclaringClass().
. Changed reflection constants to be prefixed with IS_. (Johannes)
- Improved cURL extension: (Ilia)
. Added curl_setopt_array() function that allows setting of multiple
options via an associated array.
. Added curl_setopt_array() function that allows setting of multiple options
via an associated array.
. Added the ability to retrieve the request message sent to the server.
- Improved GD extension: (Pierre)
. Added a weak/tolerant mode to the JPEG loader.
. Added filtering mode option to imagepng() to allow reducing file size.
. Fixed imagecolorallocate() and imagecolorallocatelapha() to return FALSE
. Fixed imagecolorallocate() and imagecolorallocatelapha() to return FALSE
on error.
- Changed get_headers() to retrieve headers also from non-200 responses.
(Ilia)
- Changed get_headers() to retrieve headers also from non-200 responses. (Ilia)
- Changed get_headers() to use the default context. (Ilia)
- Added lchown() and lchgrp() to change user/group ownership of symlinks.
(Derick)
- Added support for exif date format in strtotime(). (Derick)
- Added a check for special characters in the session name. (Ilia)
- Added "consumed" stream filter. (Marcus)
- Added new mysqli constants for BIT and NEW_DECIMAL field types:
- Added new mysqli constants for BIT and NEW_DECIMAL field types:
MYSQLI_TYPE_NEWDECIMAL and MYSQLI_TYPE_BIT. FR #36007. (Georg)
- Added imap_savebody() that allows message body to be written to a
file. (Mike)
- Added overflow checks to wordwrap() function. (Ilia)
- Added support for BINARY_DOUBLE and BINARY_FLOAT to PDO_OCI and OCI8
(also fixes bug #36764). (Tony)
- Eliminated run-time constant fetching for TRUE, FALSE and NULL. (Dmitry)
- Removed the E_STRICT deprecation notice from "var". (Ilia)
- Fixed reading stream filters never notified about EOF. (Mike)
- Fixed tempnam() 2nd parameter to be checked against path components. (Ilia)
- Fixed a bug that would not fill in the fifth argument to preg_replace()
properly, if the variable was not declared previously. (Andrei)
- Fixed safe_mode check for source argument of the copy() function. (Ilia)
- Fixed mysqli bigint conversion under Windows (Georg)
- Fixed XSS inside phpinfo() with long inputs. (Ilia)
- Fixed Apache2 SAPIs header handler modifying header strings. (Mike)
- Fixed 'auto_globals_jit' to work together with 'register_argc_argv'. (Dmitry)
- Fixed offset/length parameter validation in substr_compare() function. (Ilia)
- Fixed debug_zval_dump() to support private and protected members. (Dmitry)
- Fixed SoapFault::getMessage(). (Dmitry)
- Fixed issue with iconv_mime_decode where the "encoding" would only allow
- Added imap_savebody() that allows message body to be written to a file.
(Mike)
- Fixed issue with iconv_mime_decode where the "encoding" would only allow
upper case specifiers. (Derick)
- Fixed tiger hash algorithm generating wrong results on big endian platforms.
(Mike)
- Fixed crash with DOMImplementation::createDocumentType("name:"). (Mike)
- Fixed bug #37205 (Serving binary content/images fails with "comm with server
aborted" FastCGI err). (Dmitry)
- Fixed bug #37192 (cc may complain about non-constant initializers in
hash_adler.c). (Mike)
- Fixed bug #37191 (chmod takes off sticky bit when safe_mode is On). (Tony)
- Fixed bug #37167 (PDO segfaults when throwing exception from the
fetch handler). (Tony)
- Fixed bug #37162 (wddx does not build as a shared extension).
(jdolecek at NetBSD dot org, Ilia)
- Fixed bug #37158 (fread behavior changes after calling
stream_wrapper_register). (Wez)
- Fixed bug #37138 (__autoload tries to load callback'ed self and parent).
(Dmitry)
- Fixed bug #37103 (libmbfl headers not installed). (Jani)
- Fixed bug #37062 (compile failure on ARM architecture). (Tony)
- Fixed bug #37061 (curl_exec() doesn't zero-terminate binary strings). (Tony)
- Fixed bug #37060 (Type of retval of Countable::count() is not checked).
(Johannes)
- Fixed bug #37059 (oci_bind_by_name() doesn't support RAW and LONG RAW
fields). (Tony)
- Fixed bug #37057 (xmlrpc_decode() may produce arrays with numeric strings,
which are unaccessible). (Tony)
- Fixed bug #37055 (incorrect reference counting for persistent OCI8
connections). (Tony)
- Fixed bug #37054 (SoapClient Error Fetching http headers). (Dmitry)
- Fixed bug #37053 (html_errors with internal classes produces wrong links).
(Tony)
- Fixed bug #37046 (foreach breaks static scope). (Dmitry)
- Fixed bug #37045 (Fixed check for special chars for http redirects). (Ilia)
- Fixed bug #37017 (strtotime fails before 13:00:00 with some time zones
identifiers). (Derick)
- Fixed bug #37002 (Have to quote literals in INI when concatenating with
vars). (Dmitry)z
- Fixed bug #36988 (mktime freezes on long numbers). (Derick)
- Fixed bug #36981 (SplFileObject->fgets() ignores max_length). (Tony)
- Fixed bug #36957 (serialize() does not handle recursion). (Ilia)
- Fixed bug #36944 (strncmp & strncasecmp do not return false on negative
string length). (Tony)
- Fixed bug #36941 (ArrayIterator does not clone itself). (Marcus)
- Fixed bug #36934 (OCILob->read() doesn't move internal pointer when
reading 0's). (Tony)
- Fixed bug #36908 (wsdl default value overrides value in soap request).
(Dmitry)
- Fixed bug #36898 (__set() leaks in classes extending internal ones).
(Tony, Dmitry)
- Fixed bug #36886 (User filters can leak buckets in some situations). (Ilia)
- Fixed bug #36878 (error messages are printed even though an exception has
been thrown). (Tony)
- Fixed bug #36875 (is_*() functions do not account for open_basedir). (Ilia)
- Fixed bug #36872 (session_destroy() fails after call to
session_regenerate_id(true)). (Ilia)
- Fixed bug #36869 (memory leak in output buffering when using chunked
output). (Tony)
- Fixed bug #36859 (DOMElement crashes when calling __construct when
cloning). (Tony)
- Fixed bug #36857 (Added support for partial content fetching to the
HTTP streams wrapper). (Ilia)
- Fixed bug #36851 (Documentation and code discrepancies for NULL
data in oci_fetch_*() functions). (Tony)
- Fixed bug #36825 (Exceptions thrown in ArrayObject::offsetGet cause
segfault). (Tony)
- Fixed bug #36820 (Privileged connection with an Oracle password file
fails). (Tony)
- Fixed bug #36809 (__FILE__ behavior changed). (Dmitry)
- Fixed bug #36808 (syslog ident becomes garbage between requests). (Tony)
- Fixed bug #36802 (mysqli_set_charset() crash with a non-open connection).
(Ilia)
- Fixed bug #36756 (DOMDocument::removeChild corrupts node). (Rob)
- Fixed bug #36749 (SOAP: 'Error Fetching http body' when using HTTP Proxy).
(Dmitry)
- Fixed bug #36745 (No error message when load data local file isn't found).
(Georg)
- Fixed bug #36743 (In a class extending XMLReader array properties are not
writable). (Tony)
- Fixed bug #36727 (segfault in pdo_pgsql bindValue() when no parameters are
defined). (Tony)
- Fixed bug #36721 (The SoapServer is not able to send a header that it didn't
receive). (Dmitry)
- Fixed bug #36697 (Transparency is lost when using imagecreatetruecolor).
(Pierre)
- Fixed bug #36689 (Removed arbitrary limit on the length of syslog messages).
(Ilia)
- Fixed bug #36656 (http_build_query generates invalid URIs due to use of
square brackets). (Mike)
- Fixed bug #36638 (strtotime() returns false when 2nd argument < 1). (Derick)
- Fixed bug #36629 (SoapServer::handle() exits on SOAP faults). (Dmitry)
- Fixed bug #36625 (pg_trace() does not work). (iakio at mono-space dot net)
- Fixed bug #36614 (Segfault when using Soap). (Dmitry)
- Fixed bug #36611 (assignment to SimpleXML object attribute changes argument
type to string). (Tony)
- Fixed bug #36606 (pg_query_params() changes arguments type to string). (Tony)
- Fixed bug #36599 (DATE_W3C format constant incorrect). (Derick)
- Fixed bug #36575 (SOAP: Incorrect complex type instantiation with
- Fixed bug #36575 (SOAP: Incorrect complex type instantiation with
hierarchies). (Dmitry)
- Fixed bug #36572 (Added PDO::MYSQL_ATTR_DIRECT_QUERY constant that should
be set when executing internal queries like "show master status" via MySQL).
- Fixed bug #36572 (Added PDO::MYSQL_ATTR_DIRECT_QUERY constant that should be
set when executing internal queries like "show master status" via MySQL).
(Ilia)
- Fixed bug #36568 (memory_limit setting on win32 has no effect). (Dmitry)
- Fixed bug #36513 (comment will be outputted in last line). (Dmitry)
- Fixed bug #36510 (strtotime() fails to parse date strings with tabs).
(Ilia, Derick)
- Fixed bug #36510 (strtotime() fails to parse date strings with tabs). (Ilia,
Derick)
- Fixed bug #36459 (Incorrect adding PHPSESSID to links, which contains \r\n).
(Ilia)
- Fixed bug #36458 (sleep() accepts negative values). (Ilia)
- Fixed bug #36436 (DBA problem with Berkeley DB4). (Marcus)
- Fixed bug #36434 (Improper resolution of declaring class name of an
inherited property). (Ilia)
- Fixed bug #36434 (Improper resolution of declaring class name of an inherited
property). (Ilia)
- Fixed bug #36420 (segfault when access result->num_rows after calling
result->close()). (Ilia,Tony)
- Fixed bug #36403 (oci_execute() no longer supports OCI_DESCRIBE_ONLY). (Tony)
- Fixed bug #36400 (Custom 5xx error does not return correct HTTP response error
code). (Tony)
- Fixed bug #36403 (oci_execute() no longer supports OCI_DESCRIBE_ONLY).
(Tony)
- Fixed bug #36400 (Custom 5xx error does not return correct HTTP response
error code). (Tony)
- Fixed bug #36396 (strtotime() fails to parse dates in dd-mm-yyyy format).
(Derick)
- Fixed bug #36388 (ext/soap crashes when throwing exception and session
- Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB). (Ilia)
- Fixed bug #36388 (ext/soap crashes when throwing exception and session
persistence). (David)
- Fixed bug #36382 (PDO/PgSQL's getColumnMeta() crashes). (Derick)
- Fixed bug #36359 (splFileObject::fwrite() doesn't write when no data
length specified). (Tony)
- Fixed bug #36359 (splFileObject::fwrite() doesn't write when no data length
specified). (Tony)
- Fixed bug #36351 (parse_url() does not parse numeric paths properly). (Ilia)
- Fixed bug #36345 (PDO/MySQL problem loading BLOB over 1MB). (Ilia)
- Fixed bug #36337 (ReflectionProperty fails to return correct visibility).
(Ilia)
- Fixed bug #36334 (Added missing documentation about realpath cache INI
@@ -212,36 +98,36 @@ PHP NEWS
- Fixed bug #36283 (SOAPClient Compression Broken). (Dmitry)
- Fixed bug #36268 (Object destructors called even after fatal errors). (Dmitry)
- Fixed bug #36258 (SplFileObject::getPath() may lead to segfault). (Tony)
- Fixed bug #36250 (PHP causes ORA-07445 core dump in Oracle server 9.2.x).
- Fixed bug #36250 (PHP causes ORA-07445 core dump in Oracle server 9.2.x).
(Tony)
- Fixed bug #36242 (Possible memory corruption in stream_select()). (Tony)
- Fixed bug #36235 (ocicolumnname returns false before a successful fetch).
- Fixed bug #36235 (ocicolumnname returns false before a succesfull fetch).
(Tony)
- Fixed bug #36226 (Inconsistent handling when passing potential arrays).
- Fixed bug #36226 (Inconsistent handling when passing potential arrays).
(Dmitry)
- Fixed bug #36224 (date(DATE_ATOM) gives wrong results).
(Derick, Hannes Magnusson)
- Fixed bug #36224 (date(DATE_ATOM) gives wrong results). (Derick, Hannes
Magnusson)
- Fixed bug #36222 (errorInfo in PDOException is always NULL). (Ilia)
- Fixed bug #36208 (symbol namespace conflicts using bundled gd). (Jakub Moc)
- Fixed bug #36205 (Memory leaks on duplicate cookies). (Dmitry)
- Fixed bug #36185 (str_rot13() crash on non-string parameter). (Pierre)
- Fixed bug #36176 (PDO_PGSQL - PDO::exec() does not return number of rows
affected by the operation). (Ilia)
- Fixed bug #36158 (SIGTERM is not handled correctly when running as a
FastCGI server). (Dmitry)
- Fixed bug #36158 (SIGTERM is not handled correctly when running as a FastCGI
server). (Dmitry)
- Fixed bug #36152 (problems with curl+ssl and pgsql+ssl in same PHP). (Mike)
- Fixed bug #36148 (unpack("H*hex", $data) is adding an extra character to
the end of the string). (Ilia)
- Fixed bug #36148 (unpack("H*hex", $data) is adding an extra character to the
end of the string). (Ilia)
- Fixed bug #36134 (DirectoryIterator constructor failed to detect empty
directory names). (Ilia)
- Fixed bug #36113 (Reading records of unsupported type causes segfault).
- Fixed bug #36113 (Reading records of unsupported type causes segfault).
(Tony)
- Fixed bug #36096 (oci_result() returns garbage after oci_fetch() failed).
- Fixed bug #36096 (oci_result() returns garbage after oci_fetch() failed).
(Tony)
- Fixed bug #36083 (SoapClient waits for responses on one-way operations).
(Dmitry)
- Fixed bug #36071 (Engine Crash related with 'clone'). (Dmitry)
- Fixed bug #36055 (possible OCI8 crash in multi-threaded environment). (Tony)
- Fixed bug #36055 (possible OCI8 crash in multithreaded environment). (Tony)
- Fixed bug #36046 (parse_ini_file() miscounts lines in multi-line values).
(Ilia)
- Fixed bug #36038 (ext/hash compile failure on Mac OSX). (Tony)
@@ -252,20 +138,15 @@ PHP NEWS
- Fixed bug #36010 (Segfault when re-creating and re-executing statements with
bound parameters). (Tony)
- Fixed bug #36006 (Problem with $this in __destruct()). (Dmitry)
- Fixed bug #35999 (recursive mkdir() does not work with relative path
- Fixed bug #35999 (recursive mkdir() does not work with relative path
like "foo/bar"). (Tony)
- Fixed bug #35998 (SplFileInfo::getPathname() returns unix style filenames
- Fixed bug #35998 (SplFileInfo::getPathname() returns unix style filenames
in win32). (Marcus)
- Fixed bug #35988 (Unknown persistent list entry type in module shutdown).
(Dmitry)
- Fixed bug #35954 (Fatal com_exception casting object). (Rob)
- Fixed bug #35900 (stream_select() should warning when tv_sec is negative).
(Ilia)
- Fixed bug #35785 (SimpleXML causes memory read error zend engine). (Marcus)
- Fixed bug #34272 (empty array onto COM object blows up). (Rob)
- Fixed bug #33292 (apache_get_modules() crashes on Windows). (Edin)
- Fixed bug #29476 (sqlite_fetch_column_types() locks the database forever).
(Ilia)
12 Jan 2006, PHP 5.1.2
- Updated libsqlite in ext/sqlite to 2.8.17. (Ilia)
-46
View File
@@ -480,52 +480,6 @@ void ts_free_thread(void)
}
/* frees all resources allocated for all threads except current */
void ts_free_worker_threads(void)
{
tsrm_tls_entry *thread_resources;
int i;
THREAD_T thread_id = tsrm_thread_id();
int hash_value;
tsrm_tls_entry *last=NULL;
tsrm_mutex_lock(tsmm_mutex);
hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
thread_resources = tsrm_tls_table[hash_value];
while (thread_resources) {
if (thread_resources->thread_id != thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
}
}
for (i=0; i<thread_resources->count; i++) {
free(thread_resources->storage[i]);
}
free(thread_resources->storage);
if (last) {
last->next = thread_resources->next;
} else {
tsrm_tls_table[hash_value] = thread_resources->next;
}
free(thread_resources);
if (last) {
thread_resources = last->next;
} else {
thread_resources = tsrm_tls_table[hash_value];
}
} else {
if (thread_resources->next) {
last = thread_resources;
}
thread_resources = thread_resources->next;
}
}
tsrm_mutex_unlock(tsmm_mutex);
}
/* deallocates all occurrences of a given id */
void ts_free_id(ts_rsrc_id id)
{
-3
View File
@@ -106,9 +106,6 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id);
/* frees all resources allocated for the current thread */
TSRM_API void ts_free_thread(void);
/* frees all resources allocated for all threads except current */
void ts_free_worker_threads(void);
/* deallocates all occurrences of a given id */
TSRM_API void ts_free_id(ts_rsrc_id id);
-4
View File
@@ -243,10 +243,8 @@ extern virtual_cwd_globals cwd_globals;
#define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC)
#if !defined(TSRM_WIN32) && !defined(NETWARE)
#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group, 0 TSRMLS_CC)
#if HAVE_LCHOWN
#define VCWD_LCHOWN(path, owner, group) virtual_chown(path, owner, group, 1 TSRMLS_CC)
#endif
#endif
#else
@@ -288,10 +286,8 @@ extern virtual_cwd_globals cwd_globals;
#define VCWD_CHMOD(path, mode) chmod(path, mode)
#if !defined(TSRM_WIN32) && !defined(NETWARE)
#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
#if HAVE_LCHOWN
#define VCWD_LCHOWN(path, owner, group) lchown(path, owner, group)
#endif
#endif
#endif
+1 -1
View File
@@ -1,5 +1,5 @@
--TEST--
Bug #34873 (Segmentation Fault on foreach in object)
bug #34873 (Segmentation Fault on foreach in object)
--FILE--
<?php
class pwa {
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #36513 (comment will be outputed in last line)
--FILE--
<?php
function test($s) {
echo "'".trim(str_replace("&nbsp;", " ", htmlspecialchars_decode(strip_tags(highlight_string($s,1)))))."'\n";
}
eval('echo "1";//2');
eval('echo 3; //{ 4?>5');
echo "\n";
//test('<?php echo "1";//');
test('<?php echo "1";//2');
test('<?php echo "1";//22');
test('<?php echo 3; // 4 ?>5');
?>
--EXPECT--
135
'<?php echo "1";//2'
'<?php echo "1";//22'
'<?php echo 3; // 4 ?>5'
-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #36568 (memory_limit has no effect)
--SKIPIF--
<?php
if (!function_exists('memory_get_usage')) die('skip PHP is configured without memory_limit');
?>
--INI--
memory_limit=16M
--FILE--
<?php
ini_set("memory_limit", "32M");
echo ini_get("memory_limit");
?>
--EXPECT--
32M
-23
View File
@@ -1,23 +0,0 @@
--TEST--
Bug #37046 (foreach breaks static scope)
--FILE--
<?php
function s() {
static $storage = array(array('x', 'y'));
return $storage[0];
}
foreach (s() as $k => $function) {
echo "op1 $k\n";
if ($k == 0) {
foreach (s() as $k => $function) {
echo "op2 $k\n";
}
}
}
?>
--EXPECT--
op1 0
op2 0
op2 1
op1 1
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #37138 (__autoload tries to load callback'ed self and parent)
--FILE--
<?php
function __autoload ($CN) {var_dump ($CN);}
class st {
public static function e () {echo ("EHLO\n");}
public static function e2 () {call_user_func (array ('self', 'e'));}
}
class stch extends st {
public static function g () {call_user_func (array ('parent', 'e'));}
}
st::e ();
st::e2 ();
stch::g ();
?>
--EXPECT--
EHLO
EHLO
EHLO
+3 -3
View File
@@ -877,7 +877,7 @@ static int exec_done_cb(zend_module_entry *module TSRMLS_DC)
void zend_post_deactivate_modules(TSRMLS_D)
{
zend_hash_apply(&module_registry, (apply_func_t) exec_done_cb TSRMLS_CC);
zend_hash_reverse_apply(&module_registry, (apply_func_t) module_registry_unload_temp TSRMLS_CC);
zend_hash_apply(&module_registry, (apply_func_t) module_registry_unload_temp TSRMLS_CC);
}
@@ -1025,7 +1025,7 @@ ZEND_API void zend_error(int type, const char *format, ...)
}
zval_ptr_dtor(&retval);
}
} else if (!EG(exception)) {
} else {
/* The user error handler failed, use built-in error handler */
zend_error_cb(type, error_filename, error_lineno, format, args);
}
@@ -1054,7 +1054,7 @@ ZEND_API void zend_error(int type, const char *format, ...)
}
}
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux)
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
#endif
+2 -2
View File
@@ -91,7 +91,7 @@ const char *zend_mh_bundle_error(void);
#endif /* HAVE_MACH_O_DYLD_H */
#if defined(HAVE_LIBDL) && !defined(HAVE_MACH_O_DYLD_H) && !defined(ZEND_WIN32)
#if defined(HAVE_LIBDL) && !defined(HAVE_MACH_O_DYLD_H)
# ifndef RTLD_LAZY
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
@@ -250,7 +250,7 @@ char *alloca ();
#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux)
# define ZEND_VM_ALWAYS_INLINE __attribute__ ((always_inline))
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
#else
+24 -19
View File
@@ -1855,7 +1855,11 @@ int module_registry_cleanup(zend_module_entry *module TSRMLS_DC)
int module_registry_unload_temp(zend_module_entry *module TSRMLS_DC)
{
return (module->type == MODULE_TEMPORARY) ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_STOP;
switch (module->type) {
case MODULE_TEMPORARY:
return 1;
}
return 0;
}
@@ -2039,16 +2043,18 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze
if ((colon = strstr(Z_STRVAL_P(callable), "::")) != NULL) {
clen = colon - Z_STRVAL_P(callable);
mlen = Z_STRLEN_P(callable) - clen - 2;
lcname = zend_str_tolower_dup(Z_STRVAL_P(callable), clen);
/* caution: lcname is not '\0' terminated */
if (clen == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self") - 1) == 0) {
*ce_ptr = EG(scope);
} else if (clen == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent") - 1) == 0 && EG(active_op_array)->scope) {
*ce_ptr = EG(scope) ? EG(scope)->parent : NULL;
} else if (zend_lookup_class(Z_STRVAL_P(callable), clen, &pce TSRMLS_CC) == SUCCESS) {
if (zend_lookup_class(Z_STRVAL_P(callable), clen, &pce TSRMLS_CC) == SUCCESS) {
*ce_ptr = *pce;
} else {
lcname = zend_str_tolower_dup(Z_STRVAL_P(callable), clen);
/* caution: lcname is not '\0' terminated */
if (clen == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self") - 1) == 0) {
*ce_ptr = EG(scope);
} else if (clen == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent") - 1) == 0 && EG(active_op_array)->scope) {
*ce_ptr = EG(scope) ? EG(scope)->parent : NULL;
}
efree(lcname);
}
efree(lcname);
if (!*ce_ptr) {
return 0;
}
@@ -2116,9 +2122,6 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, uint check_flags, char **
zend_function *fptr_local;
zval **zobj_ptr_local;
if (callable_name) {
*callable_name = NULL;
}
if (callable_name_len == NULL) {
callable_name_len = &callable_name_len_local;
}
@@ -2177,15 +2180,17 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, uint check_flags, char **
return 1;
}
lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
if (Z_STRLEN_PP(obj) == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self")) == 0) {
ce = EG(active_op_array)->scope;
} else if (Z_STRLEN_PP(obj) == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent")) == 0 && EG(active_op_array)->scope) {
ce = EG(active_op_array)->scope->parent;
} else if (zend_lookup_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) {
if (zend_lookup_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) {
ce = *pce;
} else if (EG(active_op_array)) {
lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
if (Z_STRLEN_PP(obj) == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self")) == 0) {
ce = EG(active_op_array)->scope;
} else if (Z_STRLEN_PP(obj) == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent")) == 0 && EG(active_op_array)->scope) {
ce = EG(active_op_array)->scope->parent;
}
efree(lcname);
}
efree(lcname);
} else {
ce = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */
-8
View File
@@ -40,14 +40,6 @@ ZEND_BEGIN_ARG_INFO(fourth_arg_force_ref, 0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO(fifth_arg_force_ref, 0)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO(all_args_by_ref, 1)
ZEND_END_ARG_INFO();
+2 -12
View File
@@ -314,12 +314,6 @@ ZEND_FUNCTION(strncmp)
convert_to_string_ex(s1);
convert_to_string_ex(s2);
convert_to_long_ex(s3);
if (Z_LVAL_PP(s3) < 0) {
zend_error(E_WARNING, "Length must be greater than or equal to 0");
RETURN_FALSE;
}
RETURN_LONG(zend_binary_zval_strncmp(*s1, *s2, *s3));
}
/* }}} */
@@ -353,12 +347,6 @@ ZEND_FUNCTION(strncasecmp)
convert_to_string_ex(s1);
convert_to_string_ex(s2);
convert_to_long_ex(s3);
if (Z_LVAL_PP(s3) < 0) {
zend_error(E_WARNING, "Length must be greater than or equal to 0");
RETURN_FALSE;
}
RETURN_LONG(zend_binary_zval_strncasecmp(*s1, *s2, *s3));
}
/* }}} */
@@ -1710,6 +1698,8 @@ ZEND_FUNCTION(debug_print_backtrace)
}
}
array_init(return_value);
while (ptr) {
char *free_class_name = NULL;
+10 -36
View File
@@ -154,7 +154,6 @@ void zend_init_compiler_data_structures(TSRMLS_D)
void init_compiler(TSRMLS_D)
{
CG(active_op_array) = NULL;
zend_init_compiler_data_structures(TSRMLS_C);
zend_init_rsrc_list(TSRMLS_C);
zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0);
@@ -2941,7 +2940,13 @@ void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC)
}
ALLOC_ZVAL(property);
*property = value->u.constant;
if (value) {
*property = value->u.constant;
} else {
INIT_PZVAL(property);
property->type = IS_NULL;
}
if (zend_hash_add(&CG(active_class_entry)->constants_table, var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, sizeof(zval *), NULL)==FAILURE) {
FREE_ZVAL(property);
@@ -3090,33 +3095,6 @@ void zend_do_end_new_object(znode *result, znode *new_token, znode *argument_lis
*result = CG(active_op_array)->opcodes[new_token->u.opline_num].result;
}
static int zend_constant_ct_subst(znode *result, zval *const_name TSRMLS_DC)
{
zend_constant *c = NULL;
if (zend_hash_find(EG(zend_constants), Z_STRVAL_P(const_name), Z_STRLEN_P(const_name)+1, (void **) &c) == FAILURE) {
char *lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name), Z_STRLEN_P(const_name));
if (zend_hash_find(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name)+1, (void **) &c)==SUCCESS) {
if ((c->flags & CONST_CS) && memcmp(c->name, Z_STRVAL_P(const_name), Z_STRLEN_P(const_name))!=0) {
c = NULL;
}
} else {
c = NULL;
}
efree(lookup_name);
}
if (c && (c->flags & CONST_CT_SUBST)) {
zval_dtor(const_name);
result->op_type = IS_CONST;
result->u.constant = c->value;
zval_copy_ctor(&result->u.constant);
INIT_PZVAL(&result->u.constant);
return 1;
}
return 0;
}
void zend_do_fetch_constant(znode *result, znode *constant_container, znode *constant_name, int mode TSRMLS_DC)
{
switch (mode) {
@@ -3124,15 +3102,13 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
if (constant_container) {
zend_do_fetch_class_name(NULL, constant_container, constant_name TSRMLS_CC);
*result = *constant_container;
result->u.constant.type = IS_CONSTANT;
} else if (!zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) {
} else {
*result = *constant_name;
result->u.constant.type = IS_CONSTANT;
}
result->u.constant.type = IS_CONSTANT;
break;
case ZEND_RT:
if (constant_container ||
!zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) {
{
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_FETCH_CONSTANT;
@@ -3782,8 +3758,6 @@ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC)
}
efree(val->u.constant.value.str.val);
#endif /* ZEND_MULTIBYTE */
} else {
zval_dtor(&val->u.constant);
}
zval_dtor(&var->u.constant);
}
-1
View File
@@ -517,7 +517,6 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC);
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh);
ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC);
ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC);
ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC);
ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
ZEND_API void zend_function_dtor(zend_function *function);
+14 -5
View File
@@ -5,7 +5,7 @@
| Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
@@ -23,9 +23,8 @@
#define ZEND_CONFIG_W32_H
#define USE_ZEND_ALLOC 1
#include <../main/config.w32.h>
#define HAVE_ALLOCA 1
#define HAVE_LIMITS_H 1
#define _CRTDBG_MAP_ALLOC
#include <malloc.h>
@@ -45,9 +44,19 @@
typedef unsigned long ulong;
typedef unsigned int uint;
#undef HAVE_KILL
#define HAVE_GETPID 1
/* #define HAVE_ALLOCA_H 1 */
#define HAVE_MEMCPY 1
#define HAVE_STRDUP 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_STDIOSTR_H 1
#define HAVE_CLASS_ISTDIOSTREAM
#define istdiostream stdiostream
#define HAVE_STDARG_H 1
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
#define HAVE_STRCOLL 1
#define snprintf _snprintf
#define vsnprintf _vsnprintf
@@ -78,7 +87,7 @@ typedef unsigned int uint;
#define ZEND_DLEXPORT __declspec(dllexport)
#define ZEND_DLIMPORT __declspec(dllimport)
/* 0x00200000L is MB_SERVICE_NOTIFICATION, which is only supported under Windows NT
/* 0x00200000L is MB_SERVICE_NOTIFICATION, which is only supported under Windows NT
* (and requires _WIN32_WINNT to be defined, which prevents the resulting executable
* from running under Windows 9x
* Windows 9x should silently ignore it, so it's being used here directly
+15 -18
View File
@@ -55,13 +55,11 @@ void zend_copy_constants(HashTable *target, HashTable *source)
static int clean_non_persistent_constant(zend_constant *c TSRMLS_DC)
{
return (c->flags & CONST_PERSISTENT) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
}
static int clean_non_persistent_constant_full(zend_constant *c TSRMLS_DC)
{
return (c->flags & CONST_PERSISTENT) ? 0 : 1;
if (c->flags & CONST_PERSISTENT) {
return EG(full_tables_cleanup) ? 0 : ZEND_HASH_APPLY_STOP;
} else {
return EG(full_tables_cleanup) ? 1 : ZEND_HASH_APPLY_REMOVE;
}
}
@@ -114,7 +112,8 @@ void zend_register_standard_constants(TSRMLS_D)
{
zend_constant c;
c.flags = CONST_PERSISTENT | CONST_CT_SUBST;
c.value.type = IS_BOOL;
c.flags = CONST_PERSISTENT;
c.module_number = 0;
c.name = zend_strndup(ZEND_STRL("TRUE"));
@@ -129,18 +128,16 @@ void zend_register_standard_constants(TSRMLS_D)
c.value.type = IS_BOOL;
zend_register_constant(&c TSRMLS_CC);
c.name = zend_strndup(ZEND_STRL("NULL"));
c.name_len = sizeof("NULL");
c.value.type = IS_NULL;
zend_register_constant(&c TSRMLS_CC);
c.flags = CONST_PERSISTENT;
c.name = zend_strndup(ZEND_STRL("ZEND_THREAD_SAFE"));
c.name_len = sizeof("ZEND_THREAD_SAFE");
c.value.value.lval = ZTS_V;
c.value.type = IS_BOOL;
zend_register_constant(&c TSRMLS_CC);
c.name = zend_strndup(ZEND_STRL("NULL"));
c.name_len = sizeof("NULL");
c.value.type = IS_NULL;
zend_register_constant(&c TSRMLS_CC);
}
}
@@ -156,7 +153,7 @@ int zend_shutdown_constants(TSRMLS_D)
void clean_non_persistent_constants(TSRMLS_D)
{
if (EG(full_tables_cleanup)) {
zend_hash_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant_full TSRMLS_CC);
zend_hash_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant TSRMLS_CC);
} else {
zend_hash_reverse_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant TSRMLS_CC);
}
@@ -312,8 +309,8 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
if (!(c->flags & CONST_CS)) {
/* keep in mind that c->name_len already contains the '\0' */
lowercase_name = estrndup(c->name, c->name_len-1);
zend_str_tolower(lowercase_name, c->name_len-1);
lowercase_name = estrndup(c->name, c->name_len);
zend_str_tolower(lowercase_name, c->name_len);
name = lowercase_name;
} else {
name = c->name;
-1
View File
@@ -26,7 +26,6 @@
#define CONST_CS (1<<0) /* Case Sensitive */
#define CONST_PERSISTENT (1<<1) /* Persistent */
#define CONST_CT_SUBST (2<<1) /* Allow compile-time substitution */
#define PHP_USER_CONSTANT INT_MAX /* a constant defined in user space */
+20 -28
View File
@@ -51,7 +51,7 @@ static DWORD timeout_thread_id;
static int timeout_thread_initialized=0;
#endif
#if 0&&ZEND_DEBUG
#if ZEND_DEBUG
static void (*original_sigsegv_handler)(int);
static void zend_handle_sigsegv(int dummy)
{
@@ -95,27 +95,23 @@ static void zend_extension_deactivator(zend_extension *extension TSRMLS_DC)
}
static int clean_non_persistent_function(zend_function *function TSRMLS_DC)
static int is_not_internal_function(zend_function *function TSRMLS_DC)
{
return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
if (function->type == ZEND_INTERNAL_FUNCTION) {
return EG(full_tables_cleanup) ? 0 : ZEND_HASH_APPLY_STOP;
} else {
return EG(full_tables_cleanup) ? 1 : ZEND_HASH_APPLY_REMOVE;
}
}
static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC)
static int is_not_internal_class(zend_class_entry **ce TSRMLS_DC)
{
return (function->type != ZEND_INTERNAL_FUNCTION);
}
static int clean_non_persistent_class(zend_class_entry **ce TSRMLS_DC)
{
return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
}
static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC)
{
return ((*ce)->type != ZEND_INTERNAL_CLASS);
if ((*ce)->type == ZEND_INTERNAL_CLASS) {
return EG(full_tables_cleanup) ? 0 : ZEND_HASH_APPLY_STOP;
} else {
return EG(full_tables_cleanup) ? 1 : ZEND_HASH_APPLY_REMOVE;
}
}
@@ -255,22 +251,18 @@ void shutdown_executor(TSRMLS_D)
So we want first of all to clean up all data and then move to tables destruction.
Note that only run-time accessed data need to be cleaned up, pre-defined data can
not contain objects and thus are not probelmatic */
if (EG(full_tables_cleanup)) {
zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
} else {
zend_hash_reverse_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
}
zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data TSRMLS_CC);
zend_ptr_stack_destroy(&EG(argument_stack));
/* Destroy all op arrays */
if (EG(full_tables_cleanup)) {
zend_hash_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);
zend_hash_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);
zend_hash_apply(EG(function_table), (apply_func_t) is_not_internal_function TSRMLS_CC);
zend_hash_apply(EG(class_table), (apply_func_t) is_not_internal_class TSRMLS_CC);
} else {
zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function TSRMLS_CC);
zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class TSRMLS_CC);
zend_hash_reverse_apply(EG(function_table), (apply_func_t) is_not_internal_function TSRMLS_CC);
zend_hash_reverse_apply(EG(class_table), (apply_func_t) is_not_internal_class TSRMLS_CC);
}
while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
@@ -286,7 +278,7 @@ void shutdown_executor(TSRMLS_D)
} zend_end_try();
zend_try {
#if 0&&ZEND_DEBUG
#if ZEND_DEBUG
signal(SIGSEGV, original_sigsegv_handler);
#endif
@@ -819,7 +811,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
zend_error_noreturn(E_ERROR, "Cannot call abstract method %v::%v()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
}
if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
zend_error(E_STRICT, "Function %s%s%s() is deprecated",
+15 -11
View File
@@ -102,14 +102,14 @@ ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
#define UPDATE_DATA(ht, p, pData, nDataSize) \
if (nDataSize == sizeof(void*)) { \
if ((p)->pData != &(p)->pDataPtr) { \
pefree_rel((p)->pData, (ht)->persistent); \
if (!(p)->pDataPtr) { \
pefree_rel((p)->pData, (ht)->persistent); \
} \
memcpy(&(p)->pDataPtr, pData, sizeof(void *)); \
(p)->pData = &(p)->pDataPtr; \
} else { \
if ((p)->pData == &(p)->pDataPtr) { \
(p)->pData = (void *) pemalloc_rel(nDataSize, (ht)->persistent); \
if ((p)->pDataPtr) { \
(p)->pData = (void *) pemalloc_rel(nDataSize, (ht)->persistent); \
(p)->pDataPtr=NULL; \
} else { \
(p)->pData = (void *) perealloc_rel((p)->pData, nDataSize, (ht)->persistent); \
@@ -123,9 +123,9 @@ ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
memcpy(&(p)->pDataPtr, pData, sizeof(void *)); \
(p)->pData = &(p)->pDataPtr; \
} else { \
(p)->pData = (void *) pemalloc_rel(nDataSize, (ht)->persistent);\
(p)->pData = (void *) pemalloc_rel(nDataSize, (ht)->persistent); \
if (!(p)->pData) { \
pefree_rel(p, (ht)->persistent); \
pefree_rel(p, (ht)->persistent); \
return FAILURE; \
} \
memcpy((p)->pData, pData, nDataSize); \
@@ -491,7 +491,7 @@ ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLen
if (ht->pDestructor) {
ht->pDestructor(p->pData);
}
if (p->pData != &p->pDataPtr) {
if (!p->pDataPtr) {
pefree(p->pData, ht->persistent);
}
pefree(p, ht->persistent);
@@ -520,7 +520,7 @@ ZEND_API void zend_hash_destroy(HashTable *ht)
if (ht->pDestructor) {
ht->pDestructor(q->pData);
}
if (q->pData != &q->pDataPtr) {
if (!q->pDataPtr && q->pData) {
pefree(q->pData, ht->persistent);
}
pefree(q, ht->persistent);
@@ -546,7 +546,7 @@ ZEND_API void zend_hash_clean(HashTable *ht)
if (ht->pDestructor) {
ht->pDestructor(q->pData);
}
if (q->pData != &q->pDataPtr) {
if (!q->pDataPtr && q->pData) {
pefree(q->pData, ht->persistent);
}
pefree(q, ht->persistent);
@@ -575,7 +575,7 @@ static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p)
if (ht->pDestructor) {
ht->pDestructor(p->pData);
}
if (p->pData != &p->pDataPtr) {
if (!p->pDataPtr) {
pefree(p->pData, ht->persistent);
}
retval = p->pListNext;
@@ -734,7 +734,11 @@ ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSR
q = p;
p = p->pListLast;
if (result & ZEND_HASH_APPLY_REMOVE) {
zend_hash_apply_deleter(ht, q);
if (q->nKeyLength>0) {
zend_hash_del(ht, q->arKey, q->nKeyLength);
} else {
zend_hash_index_del(ht, q->h);
}
}
if (result & ZEND_HASH_APPLY_STOP) {
break;
+6 -7
View File
@@ -249,26 +249,25 @@ string_or_value:
expr { $$ = $1; }
| CFG_TRUE { $$ = $1; }
| CFG_FALSE { $$ = $1; }
| var_string_list { $$ = $1; }
| '\n' { zend_ini_init_string(&$$); }
| /* empty */ { zend_ini_init_string(&$$); }
;
var_string_list:
cfg_var_ref { $$ = $1; }
| TC_ENCAPSULATED_STRING { $$ = $1; }
| constant_string { $$ = $1; }
| var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
var_string_list cfg_var_ref { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
| var_string_list TC_ENCAPSULATED_STRING { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
| var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); free($2.value.str.val); }
| var_string_list constant_string { zend_ini_add_string(&$$, &$1, &$2); }
| /* empty */ { zend_ini_init_string(&$$); }
;
cfg_var_ref:
TC_DOLLAR_CURLY TC_STRING '}' { zend_ini_get_var(&$$, &$2); free($2.value.str.val); }
TC_DOLLAR_CURLY TC_STRING '}' { zend_ini_get_var(&$$, &$2); }
;
expr:
var_string_list { $$ = $1; }
constant_string { $$ = $1; }
| expr '|' expr { zend_ini_do_op('|', &$$, &$1, &$3); }
| expr '&' expr { zend_ini_do_op('&', &$$, &$1, &$3); }
| '~' expr { zend_ini_do_op('~', &$$, &$2, NULL); }
+1 -1
View File
@@ -287,7 +287,7 @@ static zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce,
if (!ce || !ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && iterator == object)) {
if (!EG(exception))
{
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce ? ce->name : Z_OBJCE_P(object)->name);
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce->name);
}
if (iterator)
{
+1 -1
View File
@@ -501,7 +501,7 @@ method_body:
variable_modifiers:
non_empty_member_modifiers { $$ = $1; }
| T_VAR { $$.u.constant.value.lval = ZEND_ACC_PUBLIC; }
| T_VAR { zend_error(E_STRICT, "var: Deprecated. Please use the public/private/protected modifiers"); $$.u.constant.value.lval = ZEND_ACC_PUBLIC; }
;
method_modifiers:
+2 -2
View File
@@ -1461,7 +1461,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
yymore();
}
<ST_ONE_LINE_COMMENT>[^\n\r?%>]*{ANY_CHAR} {
<ST_ONE_LINE_COMMENT>[^\n\r?%>]+{ANY_CHAR} {
switch (yytext[yyleng-1]) {
case '?': case '%': case '>':
yyless(yyleng-1);
@@ -1491,7 +1491,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
<ST_ONE_LINE_COMMENT>"?>"|"%>" {
if (CG(asp_tags) || yytext[yyleng-2] != '%') { /* asp comment? */
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng-2;
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
yyless(yyleng-2);
BEGIN(ST_IN_SCRIPTING);
-1
View File
@@ -36,7 +36,6 @@ extern struct _zend_arg_info first_arg_force_ref[2];
extern struct _zend_arg_info second_arg_force_ref[3];
extern struct _zend_arg_info third_arg_force_ref[4];
extern struct _zend_arg_info fourth_arg_force_ref[5];
extern struct _zend_arg_info fifth_arg_force_ref[6];
extern struct _zend_arg_info all_args_by_ref[1];
#define ZEND_MODULE_API_NO 20050922
+6 -21
View File
@@ -25,26 +25,6 @@
#include "zend_API.h"
#include "zend_interfaces.h"
ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC)
{
ALLOC_HASHTABLE(object->properties);
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
object->ce = ce;
object->guards = NULL;
}
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC)
{
if (object->guards) {
zend_hash_destroy(object->guards);
FREE_HASHTABLE(object->guards);
}
if (object->properties) {
zend_hash_destroy(object->properties);
FREE_HASHTABLE(object->properties);
}
}
ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC)
{
@@ -108,7 +88,12 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
ZEND_API void zend_objects_free_object_storage(zend_object *object TSRMLS_DC)
{
zend_object_std_dtor(object TSRMLS_CC);
if (object->guards) {
zend_hash_destroy(object->guards);
FREE_HASHTABLE(object->guards);
}
zend_hash_destroy(object->properties);
FREE_HASHTABLE(object->properties);
efree(object);
}
-2
View File
@@ -25,8 +25,6 @@
#include "zend.h"
BEGIN_EXTERN_C()
ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC);
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC);
ZEND_API zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class_type TSRMLS_DC);
ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC);
ZEND_API zend_object *zend_objects_get_address(zval *object TSRMLS_DC);
-1
View File
@@ -33,7 +33,6 @@ ZEND_API void zend_objects_store_init(zend_objects_store *objects, zend_uint ini
objects->top = 1; /* Skip 0 so that handles are true */
objects->size = init_size;
objects->free_list_head = -1;
memset(&objects->object_buckets[0], 0, sizeof(zend_object_store_bucket));
}
ZEND_API void zend_objects_store_destroy(zend_objects_store *objects)
+4 -16
View File
@@ -132,17 +132,7 @@ ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC)
{
if (function->type == ZEND_USER_FUNCTION) {
zend_cleanup_op_array_data((zend_op_array *) function);
return ZEND_HASH_APPLY_KEEP;
} else {
return ZEND_HASH_APPLY_STOP;
}
}
ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC)
{
if (function->type == ZEND_USER_FUNCTION) {
zend_cleanup_op_array_data((zend_op_array *) function);
}
}
return 0;
}
@@ -152,7 +142,7 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC)
/* Clean all parts that can contain run-time data */
/* Note that only run-time accessed data need to be cleaned up, pre-defined data can
not contain objects and thus are not probelmatic */
zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
(*pce)->static_members = NULL;
} else if (CE_STATIC_MEMBERS(*pce)) {
zend_hash_destroy(CE_STATIC_MEMBERS(*pce));
@@ -367,10 +357,8 @@ int pass_two(zend_op_array *op_array TSRMLS_DC)
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array TSRMLS_CC);
}
if (!CG(interactive) && op_array->size != op_array->last) {
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
op_array->size = op_array->last;
}
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
op_array->size = op_array->last;
opline = op_array->opcodes;
end = opline + op_array->last;
-1
View File
@@ -130,7 +130,6 @@ typedef unsigned long int uint32_t;
* but the word order is big endian.
*/
#define IEEE_BIG_ENDIAN
#undef IEEE_LITTLE_ENDIAN
#endif
#ifdef __vax__
+3 -27
View File
@@ -1723,15 +1723,6 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, ANY, CONST|TMP|VAR|UNUSED|CV)
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
EX(object) = NULL;
} else {
if (OP2_TYPE != IS_UNUSED &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
!instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
/* We are calling method of the other (incompatible) class,
but passing $this. This is done for compatibility with php-4. */
zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name);
}
if ((EX(object) = EG(This))) {
EX(object)->refcount++;
}
@@ -3017,20 +3008,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
if (OP1_TYPE == IS_VAR &&
free_op1.var == NULL &&
!array_ptr->is_ref &&
array_ptr->refcount > 1) {
/* non-separated return value from function */
zval *tmp;
ALLOC_ZVAL(tmp);
INIT_PZVAL_COPY(tmp, array_ptr);
zval_copy_ctor(tmp);
array_ptr = tmp;
} else {
array_ptr->refcount++;
}
array_ptr->refcount++;
}
}
@@ -3236,9 +3214,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
key->value.lval = int_key;
key->type = IS_LONG;
break;
default:
ZVAL_NULL(key);
break;
EMPTY_SWITCH_DEFAULT_CASE()
}
}
@@ -3438,8 +3414,8 @@ ZEND_VM_HANDLER(148, ZEND_ISSET_ISEMPTY_PROP_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|C
ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMP|VAR|UNUSED|CV, ANY)
{
zend_op *opline = EX(opline);
if (OP1_TYPE != IS_UNUSED) {
zend_op *opline = EX(opline);
zend_free_op free_op1;
zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
+12 -111
View File
@@ -678,15 +678,6 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
EX(object) = NULL;
} else {
if (IS_CONST != IS_UNUSED &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
!instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
/* We are calling method of the other (incompatible) class,
but passing $this. This is done for compatibility with php-4. */
zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name);
}
if ((EX(object) = EG(This))) {
EX(object)->refcount++;
}
@@ -879,15 +870,6 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
EX(object) = NULL;
} else {
if (IS_TMP_VAR != IS_UNUSED &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
!instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
/* We are calling method of the other (incompatible) class,
but passing $this. This is done for compatibility with php-4. */
zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name);
}
if ((EX(object) = EG(This))) {
EX(object)->refcount++;
}
@@ -1037,15 +1019,6 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
EX(object) = NULL;
} else {
if (IS_VAR != IS_UNUSED &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
!instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
/* We are calling method of the other (incompatible) class,
but passing $this. This is done for compatibility with php-4. */
zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name);
}
if ((EX(object) = EG(This))) {
EX(object)->refcount++;
}
@@ -1194,15 +1167,6 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
EX(object) = NULL;
} else {
if (IS_UNUSED != IS_UNUSED &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
!instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
/* We are calling method of the other (incompatible) class,
but passing $this. This is done for compatibility with php-4. */
zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name);
}
if ((EX(object) = EG(This))) {
EX(object)->refcount++;
}
@@ -1284,15 +1248,6 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
EX(object) = NULL;
} else {
if (IS_CV != IS_UNUSED &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
!instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
/* We are calling method of the other (incompatible) class,
but passing $this. This is done for compatibility with php-4. */
zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name);
}
if ((EX(object) = EG(This))) {
EX(object)->refcount++;
}
@@ -2059,7 +2014,7 @@ static int ZEND_UNSET_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
zend_free_op free_op1;
zval *array_ptr, **array_ptr_ptr;
HashTable *fe_ht;
zend_object_iterator *iter = NULL;
@@ -2100,20 +2055,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
if (IS_CONST == IS_VAR &&
free_op1.var == NULL &&
!array_ptr->is_ref &&
array_ptr->refcount > 1) {
/* non-separated return value from function */
zval *tmp;
ALLOC_ZVAL(tmp);
INIT_PZVAL_COPY(tmp, array_ptr);
zval_copy_ctor(tmp);
array_ptr = tmp;
} else {
array_ptr->refcount++;
}
array_ptr->refcount++;
}
}
@@ -2245,8 +2187,8 @@ static int ZEND_ISSET_ISEMPTY_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
if (IS_CONST != IS_UNUSED) {
zend_op *opline = EX(opline);
zval *ptr = &opline->op1.u.constant;
@@ -4531,20 +4473,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
if (IS_TMP_VAR == IS_VAR &&
free_op1.var == NULL &&
!array_ptr->is_ref &&
array_ptr->refcount > 1) {
/* non-separated return value from function */
zval *tmp;
ALLOC_ZVAL(tmp);
INIT_PZVAL_COPY(tmp, array_ptr);
zval_copy_ctor(tmp);
array_ptr = tmp;
} else {
array_ptr->refcount++;
}
array_ptr->refcount++;
}
}
@@ -4677,8 +4606,8 @@ static int ZEND_ISSET_ISEMPTY_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_EXIT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
if (IS_TMP_VAR != IS_UNUSED) {
zend_op *opline = EX(opline);
zend_free_op free_op1;
zval *ptr = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
@@ -7544,20 +7473,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
if (IS_VAR == IS_VAR &&
free_op1.var == NULL &&
!array_ptr->is_ref &&
array_ptr->refcount > 1) {
/* non-separated return value from function */
zval *tmp;
ALLOC_ZVAL(tmp);
INIT_PZVAL_COPY(tmp, array_ptr);
zval_copy_ctor(tmp);
array_ptr = tmp;
} else {
array_ptr->refcount++;
}
array_ptr->refcount++;
}
}
@@ -7763,9 +7679,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
key->value.lval = int_key;
key->type = IS_LONG;
break;
default:
ZVAL_NULL(key);
break;
EMPTY_SWITCH_DEFAULT_CASE()
}
}
@@ -7830,8 +7744,8 @@ static int ZEND_ISSET_ISEMPTY_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_EXIT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
if (IS_VAR != IS_UNUSED) {
zend_op *opline = EX(opline);
zend_free_op free_op1;
zval *ptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
@@ -14117,8 +14031,8 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_EXIT_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
if (IS_UNUSED != IS_UNUSED) {
zend_op *opline = EX(opline);
zval *ptr = NULL;
@@ -19615,7 +19529,7 @@ static int ZEND_UNSET_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
zend_free_op free_op1;
zval *array_ptr, **array_ptr_ptr;
HashTable *fe_ht;
zend_object_iterator *iter = NULL;
@@ -19656,20 +19570,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
ce = Z_OBJCE_P(array_ptr);
} else {
if (IS_CV == IS_VAR &&
free_op1.var == NULL &&
!array_ptr->is_ref &&
array_ptr->refcount > 1) {
/* non-separated return value from function */
zval *tmp;
ALLOC_ZVAL(tmp);
INIT_PZVAL_COPY(tmp, array_ptr);
zval_copy_ctor(tmp);
array_ptr = tmp;
} else {
array_ptr->refcount++;
}
array_ptr->refcount++;
}
}
@@ -19801,8 +19702,8 @@ static int ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
static int ZEND_EXIT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
if (IS_CV != IS_UNUSED) {
zend_op *opline = EX(opline);
zval *ptr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
+2 -2
View File
@@ -1200,13 +1200,13 @@ function gen_vm($def, $skel) {
if ($kind == "handler") {
$op = $opcodes[$opnames[$name]];
if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
out($f, "{\n\treturn ".$name."_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
} else if ($helpers[$name]["param"] == null) {
$h = $helpers[$name];
if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
out($f, "{\n\treturn ".$name."_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
}
+15 -22
View File
@@ -1877,30 +1877,23 @@ dnl Platform characteristics checks
dnl -------------------------------------------------------------------------
dnl
dnl PHP_SHLIB_SUFFIX_NAMES
dnl PHP_SHLIB_SUFFIX_NAME
dnl
dnl Determines link library suffix SHLIB_SUFFIX_NAME
dnl which can be: .so, .sl or .dylib
dnl Determines shared library suffix
dnl suffix can be: .so, .sl or .dylib
dnl
dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
dnl suffix can be: .so or .sl
dnl
AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
SHLIB_SUFFIX_NAME=so
SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
case $host_alias in
*hpux*[)]
SHLIB_SUFFIX_NAME=sl
SHLIB_DL_SUFFIX_NAME=sl
;;
*darwin*[)]
SHLIB_SUFFIX_NAME=dylib
SHLIB_DL_SUFFIX_NAME=so
;;
esac
AC_DEFUN([PHP_SHLIB_SUFFIX_NAME],[
AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
PHP_SUBST(SHLIB_SUFFIX_NAME)
SHLIB_SUFFIX_NAME=so
case $host_alias in
*hpux*[)]
SHLIB_SUFFIX_NAME=sl
;;
*darwin*[)]
SHLIB_SUFFIX_NAME=dylib
;;
esac
])
dnl
+5 -4
View File
@@ -41,8 +41,8 @@ AC_CONFIG_HEADER(main/php_config.h)
MAJOR_VERSION=5
MINOR_VERSION=1
RELEASE_VERSION=4
EXTRA_VERSION=""
RELEASE_VERSION=3
EXTRA_VERSION="RC1"
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
dnl Define where extension directories are located in the configure context
@@ -224,7 +224,7 @@ dnl -------------------------------------------------------------------------
PTHREADS_CHECK
PHP_HELP_SEPARATOR([SAPI modules:])
PHP_SHLIB_SUFFIX_NAMES
PHP_SHLIB_SUFFIX_NAME
PHP_SAPI=default
PHP_BUILD_PROGRAM
@@ -233,7 +233,7 @@ dnl SAPI configuration.
dnl -------------------------------------------------------------------------
dnl paths to the targets are relative to the build directory
SAPI_SHARED=libs/libphp5.$SHLIB_DL_SUFFIX_NAME
SAPI_SHARED=libs/libphp5.$SHLIB_SUFFIX_NAME
SAPI_STATIC=libs/libphp5.a
SAPI_LIBTOOL=libphp5.la
@@ -1197,6 +1197,7 @@ PHP_SUBST(SHARED_LIBTOOL)
PHP_SUBST(WARNING_LEVEL)
PHP_SUBST(PHP_FRAMEWORKS)
PHP_SUBST(PHP_FRAMEWORKPATH)
PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
PHP_SUBST(INSTALL_HEADERS)
old_CC=$CC
+8 -4
View File
@@ -708,7 +708,8 @@ static void helper_free_storage(void *obj TSRMLS_DC)
if (object->unk) {
IUnknown_Release(object->unk);
}
zend_object_std_dtor(&object->std TSRMLS_CC);
zend_hash_destroy(object->std.properties);
FREE_HASHTABLE(object->std.properties);
efree(object);
}
@@ -721,8 +722,9 @@ static void helper_clone(void *obj, void **clone_ptr TSRMLS_DC)
memcpy(clone, object, sizeof(*object));
*clone_ptr = clone;
zend_object_std_init(&clone->std, object->std.ce TSRMLS_CC);
ALLOC_HASHTABLE(clone->std.properties);
zend_hash_init(clone->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
if (clone->ipf) {
IPersistFile_AddRef(clone->ipf);
}
@@ -745,7 +747,9 @@ static zend_object_value helper_new(zend_class_entry *ce TSRMLS_DC)
helper = emalloc(sizeof(*helper));
memset(helper, 0, sizeof(*helper));
zend_object_std_init(&helper->std, helper_ce TSRMLS_CC);
ALLOC_HASHTABLE(helper->std.properties);
zend_hash_init(helper->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
helper->std.ce = helper_ce;
retval.handle = zend_objects_store_put(helper, NULL, helper_free_storage, helper_clone TSRMLS_CC);
retval.handlers = &helper_handlers;
+7 -9
View File
@@ -1208,8 +1208,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
if (Z_LVAL_PP(zvalue)) {
ch->handlers->write->type = PHP_CURL_BINARY;
} else {
ch->handlers->write->type = PHP_CURL_ASCII;
}
break;
case CURLOPT_WRITEFUNCTION:
@@ -1464,7 +1462,7 @@ PHP_FUNCTION(curl_setopt_array)
void _php_curl_cleanup_handle(php_curl *ch)
{
if (ch->handlers->write->buf.len > 0) {
smart_str_free(&ch->handlers->write->buf);
memset(&ch->handlers->write->buf, 0, sizeof(smart_str));
}
if (ch->header.str_len) {
efree(ch->header.str);
@@ -1499,6 +1497,7 @@ PHP_FUNCTION(curl_exec)
if (ch->handlers->write->buf.len > 0) {
smart_str_free(&ch->handlers->write->buf);
}
RETURN_FALSE;
}
@@ -1506,8 +1505,10 @@ PHP_FUNCTION(curl_exec)
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) {
--ch->uses;
smart_str_0(&ch->handlers->write->buf);
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1);
if (ch->handlers->write->type != PHP_CURL_BINARY) {
smart_str_0(&ch->handlers->write->buf);
}
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 0);
}
--ch->uses;
RETURN_TRUE;
@@ -1738,9 +1739,6 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
zend_llist_clean(&ch->to_free.slist);
zend_llist_clean(&ch->to_free.post);
if (ch->handlers->write->buf.len > 0) {
smart_str_free(&ch->handlers->write->buf);
}
if (ch->handlers->write->func_name) {
zval_ptr_dtor(&ch->handlers->write->func_name);
}
@@ -1756,7 +1754,7 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
if (ch->header.str_len > 0) {
efree(ch->header.str);
}
efree(ch->handlers->write);
efree(ch->handlers->write_header);
efree(ch->handlers->read);
+5 -2
View File
@@ -195,8 +195,11 @@ PHP_FUNCTION(curl_multi_getcontent)
ZEND_FETCH_RESOURCE(ch, php_curl *, &z_ch, -1, le_curl_name, le_curl);
if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) {
smart_str_0(&ch->handlers->write->buf);
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1);
if (ch->handlers->write->type != PHP_CURL_BINARY) {
smart_str_0(&ch->handlers->write->buf);
}
RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 0);
}
}
+9077 -12597
View File
File diff suppressed because it is too large. Load diff
+27 -74
View File
@@ -97,13 +97,13 @@ typedef unsigned char uchar;
#define timelib_string_free free
#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { add_error(s, "Double time specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
#define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; }
#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { add_error(s, "Double date specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
#define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; }
#define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; s->time->relative.weekday_behavior = 0; }
#define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; }
#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { add_warning(s, "Double timezone specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_zone = 1; } }
#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
#define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str
#define TIMELIB_DEINIT timelib_string_free(str)
@@ -140,7 +140,7 @@ typedef struct Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
unsigned int line, len;
struct timelib_error_container *errors;
int errors;
struct timelib_time *time;
timelib_tzdb *tzdb;
@@ -325,24 +325,6 @@ uchar *fill(Scanner *s, uchar *cursor){
}
#endif
static void add_warning(Scanner *s, char *error)
{
s->errors->warning_count++;
s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message));
s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0;
s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0;
s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error);
}
static void add_error(Scanner *s, char *error)
{
s->errors->error_count++;
s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message));
s->errors->error_messages[s->errors->error_count - 1].position = s->tok ? s->tok - s->str : 0;
s->errors->error_messages[s->errors->error_count - 1].character = s->tok ? *s->tok : 0;
s->errors->error_messages[s->errors->error_count - 1].message = strdup(error);
}
static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
{
timelib_sll retval = 0;
@@ -702,11 +684,9 @@ static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_
char *tz_abbr;
t->is_localtime = 1;
t->zone_type = TIMELIB_ZONETYPE_ABBR;
offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found);
if (found) {
t->zone_type = TIMELIB_ZONETYPE_ABBR;
}
#if 0
/* If we found a TimeZone identifier, use it */
if (tz_name) {
@@ -722,7 +702,7 @@ static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_
found++;
}
}
if (found && t->zone_type != TIMELIB_ZONETYPE_ID) {
if (t->zone_type != TIMELIB_ZONETYPE_ID) {
timelib_time_tz_abbr_update(t, tz_abbr);
}
free(tz_abbr);
@@ -768,8 +748,8 @@ minute = [0-5]?[0-9];
minutelz = [0-5][0-9];
second = minute | "60";
secondlz = minutelz | "60";
meridian = ([AaPp] "."? [Mm] "."?) [\000\t ];
tz = "("? [A-Za-z]{1,6} ")"? | [A-Z][a-z]+([_/][A-Z][a-z]+)+;
meridian = [AaPp] "."? [Mm] "."?;
tz = "("? [A-Za-z]{1,4} ")"? | [A-Z][a-z]+([_/][A-Z][a-z]+)+;
tzcorrection = [+-] hour24 ":"? minute?;
daysuf = "st" | "nd" | "rd" | "th";
@@ -800,17 +780,17 @@ timetiny12 = hour12 space? meridian;
timeshort12 = hour12[:.]minutelz space? meridian;
timelong12 = hour12[:.]minute[:.]secondlz space? meridian;
timeshort24 = 't'? hour24[:.]minute;
timelong24 = 't'? hour24[:.]minute[:.]second;
iso8601long = 't'? hour24 [:.] minute [:.] second frac;
timeshort24 = hour24[:.]minute;
timelong24 = hour24[:.]minute[:.]second;
iso8601long = hour24 [:.] minute [:.] second frac;
/* iso8601shorttz = hour24 [:] minutelz space? (tzcorrection | tz); */
iso8601normtz = 't'? hour24 [:.] minute [:.] secondlz space? (tzcorrection | tz);
iso8601normtz = hour24 [:.] minute [:.] secondlz space? (tzcorrection | tz);
/* iso8601longtz = hour24 [:] minute [:] secondlz frac space? (tzcorrection | tz); */
gnunocolon = 't'? hour24lz minutelz;
gnunocolon = hour24lz minutelz;
/* gnunocolontz = hour24lz minutelz space? (tzcorrection | tz); */
iso8601nocolon = 't'? hour24lz minutelz secondlz;
iso8601nocolon = hour24lz minutelz secondlz;
/* iso8601nocolontz = hour24lz minutelz secondlz space? (tzcorrection | tz); */
/* Date formats */
@@ -980,9 +960,7 @@ relativetext = reltextnumber space? reltextunit;
if (*ptr != '\0') {
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->errors += tz_not_found;
}
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
@@ -1003,7 +981,6 @@ relativetext = reltextnumber space? reltextunit;
break;
default:
TIMELIB_DEINIT;
add_error(s, "Double time specification");
return TIMELIB_ERROR;
}
s->time->have_time++;
@@ -1046,9 +1023,7 @@ relativetext = reltextnumber space? reltextunit;
if (*ptr != '\0') {
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->errors += tz_not_found;
}
TIMELIB_DEINIT;
return TIMELIB_ISO_NOCOLON;
@@ -1201,9 +1176,7 @@ relativetext = reltextnumber space? reltextunit;
s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
if (*ptr) { /* timezone is optional */
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->errors += tz_not_found;
}
}
TIMELIB_DEINIT;
@@ -1301,9 +1274,7 @@ relativetext = reltextnumber space? reltextunit;
s->time->i = timelib_get_nr((char **) &ptr, 2);
s->time->s = timelib_get_nr((char **) &ptr, 2);
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->errors += tz_not_found;
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
@@ -1370,11 +1341,8 @@ relativetext = reltextnumber space? reltextunit;
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
TIMELIB_INIT;
TIMELIB_HAVE_TZ();
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->errors += tz_not_found;
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
@@ -1401,9 +1369,7 @@ relativetext = reltextnumber space? reltextunit;
if (*ptr != '\0') {
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->errors += tz_not_found;
}
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
@@ -1438,7 +1404,8 @@ relativetext = reltextnumber space? reltextunit;
any
{
add_error(s, "Unexpected character");
/* printf("unexpected character: #%d, %c ", *s->tok, *s->tok); */
s->errors++;
goto std;
}
*/
@@ -1446,19 +1413,12 @@ relativetext = reltextnumber space? reltextunit;
/*!max:re2c */
timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, timelib_tzdb *tzdb)
timelib_time* timelib_strtotime(char *s, int len, int *errors, timelib_tzdb *tzdb)
{
Scanner in;
int t;
char *e = s + len - 1;
memset(&in, 0, sizeof(in));
in.errors = malloc(sizeof(struct timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;
in.errors->error_messages = NULL;
while (isspace(*s) && s < e) {
s++;
}
@@ -1466,19 +1426,15 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
e--;
}
if (e - s < 1) {
*errors = 1;
in.time = timelib_time_ctor();
add_error(&in, "Empty string");
if (errors) {
*errors = in.errors;
} else {
timelib_error_container_dtor(in.errors);
}
in.time->y = in.time->d = in.time->m = in.time->h = in.time->i = in.time->s = in.time->f = in.time->z = in.time->dst = -1;
in.time->is_localtime = in.time->zone_type = 0;
return in.time;
}
e++;
memset(&in, 0, sizeof(in));
in.str = malloc((e - s) + YYMAXFILL);
memset(in.str, 0, (e - s) + YYMAXFILL);
memcpy(in.str, s, (e - s));
@@ -1494,6 +1450,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
in.time->f = -1;
in.time->z = -1;
in.time->dst = -1;
in.errors = 0;
in.tzdb = tzdb;
in.time->is_localtime = 0;
in.time->zone_type = 0;
@@ -1506,11 +1463,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
} while(t != EOI);
free(in.str);
if (errors) {
*errors = in.errors;
} else {
timelib_error_container_dtor(in.errors);
}
*errors = in.errors;
return in.time;
}
+1 -4
View File
@@ -368,7 +368,6 @@ timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *
timelib_sll timelib_get_current_offset(timelib_time *t)
{
timelib_time_offset *gmt_offset;
timelib_sll retval;
switch (t->zone_type) {
case TIMELIB_ZONETYPE_ABBR:
@@ -377,9 +376,7 @@ timelib_sll timelib_get_current_offset(timelib_time *t)
case TIMELIB_ZONETYPE_ID:
gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info);
retval = gmt_offset->offset;
timelib_time_offset_dtor(gmt_offset);
return retval;
return gmt_offset->offset;
default:
return 0;
-15
View File
@@ -122,21 +122,6 @@ char *timelib_get_tz_abbr_ptr(timelib_time *t)
return t->tz_abbr;
}
void timelib_error_container_dtor(timelib_error_container *errors)
{
int i;
for (i = 0; i < errors->warning_count; i++) {
free(errors->warning_messages[i].message);
}
free(errors->warning_messages);
for (i = 0; i < errors->error_count; i++) {
free(errors->error_messages[i].message);
}
free(errors->error_messages);
free(errors);
}
signed long timelib_date_to_int(timelib_time *d, int *error)
{
timelib_sll ts;
+1 -3
View File
@@ -51,7 +51,7 @@ timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy);
/* From parse_date.re */
timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, timelib_tzdb *tzdb);
timelib_time *timelib_strtotime(char *s, int len, int *errors, timelib_tzdb *tzdb);
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst);
timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void);
@@ -90,8 +90,6 @@ void timelib_time_dtor(timelib_time* t);
timelib_time_offset* timelib_time_offset_ctor();
void timelib_time_offset_dtor(timelib_time_offset* t);
void timelib_error_container_dtor(timelib_error_container *errors);
signed long timelib_date_to_int(timelib_time *d, int *error);
void timelib_dump_date(timelib_time *d, int options);
+3 -17
View File
@@ -147,19 +147,6 @@ typedef struct timelib_time {
* 2 TimeZone abbreviation */
} timelib_time;
typedef struct timelib_error_message {
int position;
char character;
char *message;
} timelib_error_message;
typedef struct timelib_error_container {
int warning_count;
struct timelib_error_message *warning_messages;
int error_count;
struct timelib_error_message *error_messages;
} timelib_error_container;
typedef struct _timelib_tz_lookup_table {
char *name;
int type;
@@ -183,10 +170,9 @@ typedef struct _timelib_tzdb {
#define TIMELIB_ZONETYPE_ABBR 2
#define TIMELIB_ZONETYPE_ID 3
#define SECS_PER_ERA 12622780800L
#define SECS_PER_DAY 86400
#define DAYS_PER_YEAR 365
#define DAYS_PER_LYEAR 366
#define SECS_PER_DAY 86400
#define DAYS_PER_YEAR 365
#define DAYS_PER_LYEAR 366
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
-7
View File
@@ -135,13 +135,6 @@ static timelib_sll do_years(timelib_sll year)
{
timelib_sll i;
timelib_sll res = 0;
timelib_sll eras;
eras = (year - 1970) / 400;
if (eras != 0) {
year = year - (eras * 400);
res += (SECS_PER_ERA * eras);
}
if (year >= 1970) {
for (i = year - 1; i >= 1970; i--) {
+29 -137
View File
@@ -51,7 +51,6 @@ zend_function_entry date_functions[] = {
#ifdef EXPERIMENTAL_DATE_SUPPORT
/* Advanced Interface */
PHP_FE(date_create, NULL)
PHP_FE(date_parse, NULL)
PHP_FE(date_format, NULL)
PHP_FE(date_modify, NULL)
PHP_FE(date_timezone_get, NULL)
@@ -64,7 +63,6 @@ zend_function_entry date_functions[] = {
PHP_FE(timezone_open, NULL)
PHP_FE(timezone_name_get, NULL)
PHP_FE(timezone_name_from_abbr, NULL)
PHP_FE(timezone_offset_get, NULL)
PHP_FE(timezone_transistions_get, NULL)
PHP_FE(timezone_identifiers_list, NULL)
@@ -271,7 +269,6 @@ PHP_MINIT_FUNCTION(date)
REGISTER_STRING_CONSTANT("DATE_RFC1036", DATE_FORMAT_RFC1036, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_RFC1123", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_RFC2822", DATE_FORMAT_RFC2822, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_RFC3339", DATE_FORMAT_RFC3339, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_RSS", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_W3C", DATE_FORMAT_RFC3339, CONST_CS | CONST_PERSISTENT);
@@ -796,14 +793,14 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
PHPAPI signed long php_parse_date(char *string, signed long *now)
{
timelib_time *parsed_time;
int error2;
int error1, error2;
signed long retval;
parsed_time = timelib_strtotime(string, strlen(string), NULL, DATE_TIMEZONEDB);
parsed_time = timelib_strtotime(string, strlen(string), &error1, DATE_TIMEZONEDB);
timelib_update_ts(parsed_time, NULL);
retval = timelib_date_to_int(parsed_time, &error2);
timelib_time_dtor(parsed_time);
if (error2) {
if (error1 || error2) {
return -1;
}
return retval;
@@ -811,13 +808,12 @@ PHPAPI signed long php_parse_date(char *string, signed long *now)
/* }}} */
/* {{{ proto int strtotime(string time [, int now ])
/* {{{ proto int strtotime(string time, int now)
Convert string representation of date and time to a timestamp */
PHP_FUNCTION(strtotime)
{
char *times, *initial_ts;
int time_len, error1, error2;
struct timelib_error_container *error;
long preset_ts, ts;
timelib_time *t, *now;
@@ -831,7 +827,7 @@ PHP_FUNCTION(strtotime)
initial_ts = emalloc(25);
snprintf(initial_ts, 24, "@%ld", preset_ts);
t = timelib_strtotime(initial_ts, strlen(initial_ts), NULL, DATE_TIMEZONEDB); /* we ignore the error here, as this should never fail */
t = timelib_strtotime(initial_ts, strlen(initial_ts), &error1, DATE_TIMEZONEDB); /* we ignore the error here, as this should never fail */
timelib_update_ts(t, tzi);
now->tz_info = tzi;
now->zone_type = TIMELIB_ZONETYPE_ID;
@@ -848,9 +844,7 @@ PHP_FUNCTION(strtotime)
RETURN_FALSE;
}
t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB);
error1 = error->error_count;
timelib_error_container_dtor(error);
t = timelib_strtotime(times, time_len, &error1, DATE_TIMEZONEDB);
timelib_fill_holes(t, now, 0);
timelib_update_ts(t, tzi);
ts = timelib_date_to_int(t, &error2);
@@ -1236,8 +1230,10 @@ static zend_object_value date_object_new_date(zend_class_entry *class_type TSRML
intern = emalloc(sizeof(php_date_obj));
memset(intern, 0, sizeof(php_date_obj));
intern->std.ce = class_type;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
ALLOC_HASHTABLE(intern->std.properties);
zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_date, NULL TSRMLS_CC);
@@ -1254,8 +1250,10 @@ static zend_object_value date_object_new_timezone(zend_class_entry *class_type T
intern = emalloc(sizeof(php_timezone_obj));
memset(intern, 0, sizeof(php_timezone_obj));
intern->std.ce = class_type;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
ALLOC_HASHTABLE(intern->std.properties);
zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_timezone, NULL TSRMLS_CC);
@@ -1275,7 +1273,12 @@ static void date_object_free_storage_date(void *object TSRMLS_DC)
timelib_time_dtor(intern->time);
}
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->std.properties) {
zend_hash_destroy(intern->std.properties);
efree(intern->std.properties);
intern->std.properties = NULL;
}
efree(object);
}
@@ -1283,7 +1286,12 @@ static void date_object_free_storage_timezone(void *object TSRMLS_DC)
{
php_timezone_obj *intern = (php_timezone_obj *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->std.properties) {
zend_hash_destroy(intern->std.properties);
efree(intern->std.properties);
intern->std.properties = NULL;
}
efree(object);
}
@@ -1305,6 +1313,7 @@ PHP_FUNCTION(date_create)
{
php_date_obj *dateobj;
zval *timezone_object = NULL;
int error;
timelib_time *now;
timelib_tzinfo *tzi;
char *time_str;
@@ -1316,7 +1325,7 @@ PHP_FUNCTION(date_create)
date_instanciate(date_ce_date, return_value TSRMLS_CC);
dateobj = (php_date_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, NULL, DATE_TIMEZONEDB);
dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &error, DATE_TIMEZONEDB);
if (timezone_object) {
php_timezone_obj *tzobj;
@@ -1348,101 +1357,6 @@ PHP_FUNCTION(date_create)
timelib_time_dtor(now);
}
PHP_FUNCTION(date_parse)
{
char *date;
int date_len, i;
struct timelib_error_container *error;
timelib_time *parsed_time;
zval *element;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &date, &date_len) == FAILURE) {
RETURN_FALSE;
}
parsed_time = timelib_strtotime(date, date_len, &error, DATE_TIMEZONEDB);
array_init(return_value);
#define PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(name, elem) \
if (parsed_time->elem == -1) { \
add_assoc_bool(return_value, #name, 0); \
} else { \
add_assoc_long(return_value, #name, parsed_time->elem); \
}
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(year, y);
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(month, m);
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(day, d);
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(hour, h);
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(minute, i);
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(second, s);
if (parsed_time->f == -1) {
add_assoc_bool(return_value, "fraction", 0);
} else {
add_assoc_double(return_value, "fraction", parsed_time->f);
}
add_assoc_long(return_value, "warning_count", error->warning_count);
MAKE_STD_ZVAL(element);
array_init(element);
for (i = 0; i < error->warning_count; i++) {
add_index_string(element, error->warning_messages[i].position, error->warning_messages[i].message, 1);
}
add_assoc_zval(return_value, "warnings", element);
add_assoc_long(return_value, "error_count", error->error_count);
MAKE_STD_ZVAL(element);
array_init(element);
for (i = 0; i < error->error_count; i++) {
add_index_string(element, error->error_messages[i].position, error->error_messages[i].message, 1);
}
add_assoc_zval(return_value, "errors", element);
timelib_error_container_dtor(error);
add_assoc_bool(return_value, "is_localtime", parsed_time->is_localtime);
if (parsed_time->is_localtime) {
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(zone_type, zone_type);
switch (parsed_time->zone_type) {
case TIMELIB_ZONETYPE_OFFSET:
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(zone, z);
add_assoc_bool(return_value, "is_dst", parsed_time->dst);
break;
case TIMELIB_ZONETYPE_ID:
if (parsed_time->tz_abbr) {
add_assoc_string(return_value, "tz_abbr", parsed_time->tz_abbr, 1);
}
if (parsed_time->tz_info) {
add_assoc_string(return_value, "tz_id", parsed_time->tz_info->name, 1);
}
break;
case TIMELIB_ZONETYPE_ABBR:
PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(zone, z);
add_assoc_bool(return_value, "is_dst", parsed_time->dst);
add_assoc_string(return_value, "tz_abbr", parsed_time->tz_abbr, 1);
break;
}
}
if (parsed_time->have_relative || parsed_time->have_weekday_relative) {
MAKE_STD_ZVAL(element);
array_init(element);
}
if (parsed_time->have_relative) {
add_assoc_long(element, "year", parsed_time->relative.y);
add_assoc_long(element, "month", parsed_time->relative.m);
add_assoc_long(element, "day", parsed_time->relative.d);
add_assoc_long(element, "hour", parsed_time->relative.h);
add_assoc_long(element, "minute", parsed_time->relative.i);
add_assoc_long(element, "second", parsed_time->relative.s);
}
if (parsed_time->have_weekday_relative) {
add_assoc_long(element, "weekday", parsed_time->relative.weekday);
}
if (parsed_time->have_relative || parsed_time->have_weekday_relative) {
add_assoc_zval(return_value, "relative", element);
}
timelib_time_dtor(parsed_time);
}
PHP_FUNCTION(date_format)
{
zval *object;
@@ -1463,6 +1377,7 @@ PHP_FUNCTION(date_modify)
php_date_obj *dateobj;
char *modify;
int modify_len;
int error;
timelib_time *tmp_time;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) {
@@ -1470,7 +1385,7 @@ PHP_FUNCTION(date_modify)
}
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
tmp_time = timelib_strtotime(modify, modify_len, NULL, DATE_TIMEZONEDB);
tmp_time = timelib_strtotime(modify, modify_len, &error, DATE_TIMEZONEDB);
dateobj->time->relative.y = tmp_time->relative.y;
dateobj->time->relative.m = tmp_time->relative.m;
dateobj->time->relative.d = tmp_time->relative.d;
@@ -1643,26 +1558,6 @@ PHP_FUNCTION(timezone_name_get)
RETURN_STRING(tzobj->tz->name, 1);
}
PHP_FUNCTION(timezone_name_from_abbr)
{
char *abbr;
char *tzname;
int abbr_len;
long gmtoffset = -1;
long isdst = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &abbr, &abbr_len, &gmtoffset, &isdst) == FAILURE) {
RETURN_FALSE;
}
tzname = timelib_timezone_id_from_abbr(abbr, gmtoffset, isdst);
if (tzname) {
RETURN_STRING(tzname, 1);
} else {
RETURN_FALSE;
}
}
PHP_FUNCTION(timezone_offset_get)
{
zval *object, *dateobject;
@@ -1851,8 +1746,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
timelib_unixtime2local(t, time);
rs = timelib_astro_rise_set_altitude(t, longitude, latitude, altitude, altitude > -1 ? 1 : 0, &h_rise, &h_set, &rise, &set, &transit);
timelib_time_dtor(t);
if (rs != 0) {
RETURN_FALSE;
}
@@ -1995,8 +1889,6 @@ PHP_FUNCTION(date_sun_info)
t2->sse = set;
add_assoc_long(return_value, "astronomical_twilight_end", timelib_date_to_int(t2, &dummy));
}
timelib_time_dtor(t);
timelib_time_dtor(t2);
}
/* }}} */
/*
-2
View File
@@ -49,7 +49,6 @@ PHP_FUNCTION(getdate);
#ifdef EXPERIMENTAL_DATE_SUPPORT
/* Advanced Interface */
PHP_FUNCTION(date_create);
PHP_FUNCTION(date_parse);
PHP_FUNCTION(date_format);
PHP_FUNCTION(date_modify);
PHP_FUNCTION(date_timezone_get);
@@ -62,7 +61,6 @@ PHP_FUNCTION(date_isodate_set);
PHP_FUNCTION(timezone_open);
PHP_FUNCTION(timezone_name_get);
PHP_FUNCTION(timezone_name_from_abbr);
PHP_FUNCTION(timezone_offset_get);
PHP_FUNCTION(timezone_transistions_get);
PHP_FUNCTION(timezone_identifiers_list);
+1 -1
View File
@@ -1,6 +1,6 @@
--TEST--
Bug #26317 (military timezone offset signedness)
--SKIPIF--
--SKIP--
if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') {
die("skip unable to change TZ enviroment variable\n");
}
+2 -2
View File
@@ -1,6 +1,6 @@
--TEST--
Bug #26320 (strtotime handling of XML Schema/ISO 8601 format)
--SKIPIF--
--SKIP--
if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') {
die("skip unable to change TZ enviroment variable\n");
}
@@ -12,4 +12,4 @@ if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') {
?>
--EXPECT--
2003-11-19 12:30:42
2003-11-19 12:30:42
2003-11-19 12:30:42
-12
View File
@@ -1,12 +0,0 @@
--TEST--
Bug #36988 (mktime freezes on long numbers)
--INI--
date.timezone=GMT
--FILE--
<?php
$start = microtime(true);
$a = mktime(1, 1, 1, 1, 1, 11111111111);
echo (microtime(true) - $start) < 1 ? "smaller than one second" : "more than a second";
?>
--EXPECT--
smaller than one second
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #37017 (strtotime fails before 13:00:00 with some time zones identifiers).
--INI--
date.timezone=GMT
--FILE--
<?php
echo strtotime("2006-05-12 13:00:01 America/New_York"), "\n";
echo strtotime("2006-05-12 13:00:00 America/New_York"), "\n";
echo strtotime("2006-05-12 12:59:59 America/New_York"), "\n";
echo strtotime("2006-05-12 12:59:59 GMT"), "\n";
?>
--EXPECT--
1147453201
1147453200
1147453199
1147438799
+1 -1
View File
@@ -77,7 +77,7 @@ PHP_METHOD(domattr, __construct)
}
if (intern != NULL) {
oldnode = dom_object_get_node(intern);
oldnode = (xmlNodePtr)intern->ptr;
if (oldnode != NULL) {
php_libxml_node_free_resource(oldnode TSRMLS_CC);
}
+1 -1
View File
@@ -128,7 +128,7 @@ PHP_METHOD(domelement, __construct)
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
oldnode = dom_object_get_node(intern);
oldnode = (xmlNodePtr)intern->ptr;
if (oldnode != NULL) {
php_libxml_node_free_resource(oldnode TSRMLS_CC);
}
+10 -6
View File
@@ -289,8 +289,6 @@ zval *dom_read_property(zval *object, zval *member, int type TSRMLS_DC)
if (obj->prop_handler != NULL) {
ret = zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);
} else if (instanceof_function(obj->std.ce, dom_node_class_entry TSRMLS_CC)) {
php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", obj->std.ce->name);
}
if (ret == SUCCESS) {
ret = hnd->read_func(obj, &retval TSRMLS_CC);
@@ -905,7 +903,8 @@ void dom_xpath_objects_free_storage(void *object TSRMLS_DC)
{
dom_object *intern = (dom_object *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
zend_hash_destroy(intern->std.properties);
FREE_HASHTABLE(intern->std.properties);
if (intern->ptr != NULL) {
xmlXPathFreeContext((xmlXPathContextPtr) intern->ptr);
@@ -924,7 +923,8 @@ void dom_objects_free_storage(void *object TSRMLS_DC)
dom_object *intern = (dom_object *)object;
int retcount;
zend_object_std_dtor(&intern->std TSRMLS_CC);
zend_hash_destroy(intern->std.properties);
FREE_HASHTABLE(intern->std.properties);
if (intern->ptr != NULL && ((php_libxml_node_ptr *)intern->ptr)->node != NULL) {
if (((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_DOCUMENT_NODE && ((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_HTML_DOCUMENT_NODE) {
@@ -970,6 +970,8 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool
dom_object *intern;
intern = emalloc(sizeof(dom_object));
intern->std.ce = class_type;
intern->std.guards = NULL;
intern->ptr = NULL;
intern->prop_handler = NULL;
intern->document = NULL;
@@ -981,7 +983,8 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool
zend_hash_find(&classes, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
ALLOC_HASHTABLE(intern->std.properties);
zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
if (hash_copy) {
zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
}
@@ -1086,7 +1089,8 @@ void dom_nnodemap_objects_free_storage(void *object TSRMLS_DC)
php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC);
zend_object_std_dtor(&intern->std TSRMLS_CC);
zend_hash_destroy(intern->std.properties);
FREE_HASHTABLE(intern->std.properties);
efree(object);
}
-35
View File
@@ -1,35 +0,0 @@
--TEST--
Bug #36756: (DOMDocument::removeChild corrupts node)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
/* Node is preserved from removeChild */
$dom = new DOMDocument();
$dom->loadXML('<root><child/></root>');
$xpath = new DOMXpath($dom);
$node = $xpath->query('/root')->item(0);
echo $node->nodeName . "\n";
$dom->removeChild($GLOBALS['dom']->firstChild);
echo "nodeType: " . $node->nodeType . "\n";
/* Node gets destroyed during removeChild */
$dom->loadXML('<root><child/></root>');
$xpath = new DOMXpath($dom);
$node = $xpath->query('//child')->item(0);
echo $node->nodeName . "\n";
$GLOBALS['dom']->removeChild($GLOBALS['dom']->firstChild);
echo "nodeType: " . $node->nodeType . "\n";
?>
--EXPECTF--
root
nodeType: 1
child
Warning: Couldn't fetch DOMElement. Node no longer exists in %sbug36756.php on line %d
Notice: Undefined property: DOMElement::$nodeType in %sbug36756.php on line %d
nodeType:
-25
View File
@@ -1,25 +0,0 @@
--TEST--
Bug # 37277 (cloning Dom Documents or Nodes does not work)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$dom1 = new DomDocument('1.0', 'UTF-8');
$xml = '<foo />';
$dom1->loadXml($xml);
$node = clone $dom1->documentElement;
$dom2 = new DomDocument('1.0', 'UTF-8');
$dom2->appendChild($dom2->importNode($node->cloneNode(true), TRUE));
print $dom2->saveXML();
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<foo/>
+1 -1
View File
@@ -1560,7 +1560,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
image_info_data *info_data;
image_info_data *list;
if (length < 0) {
if (length >= LONG_MAX) {
return;
}
+4 -4
View File
@@ -810,7 +810,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
if (resumepos > 0) {
if (resumepos > 2147483647) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483647 bytes.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater then 2147483647 bytes.");
goto bail;
}
sprintf(arg, "%u", resumepos);
@@ -907,7 +907,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, i
if (startpos > 0) {
if (startpos > 2147483647) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater then 2147483647 bytes.");
goto bail;
}
sprintf(arg, "%u", startpos);
@@ -1706,7 +1706,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ
* since php is 32 bit by design, we bail out with warning
*/
if (resumepos > 2147483647) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483648 bytes.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater then 2147483648 bytes.");
goto bail;
}
sprintf(arg, "%u", resumepos);
@@ -1824,7 +1824,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type
}
if (startpos > 0) {
if (startpos > 2147483647) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes.");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater then 2147483647 bytes.");
goto bail;
}
sprintf(arg, "%u", startpos);
-9
View File
@@ -1094,7 +1094,6 @@ PHP_FUNCTION(imagesavealpha)
RETURN_TRUE;
}
/* }}} */
#endif
#if HAVE_GD_BUNDLED
@@ -1636,11 +1635,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
#ifdef HAVE_GD_JPG
case PHP_GDIMG_TYPE_JPG:
ignore_warning = INI_INT("gd.jpeg_ignore_warning");
#ifdef HAVE_GD_BUNDLED
im = gdImageCreateFromJpeg(fp, ignore_warning);
#else
im = gdImageCreateFromJpeg(fp);
#endif
break;
#endif
@@ -3923,11 +3918,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
#ifdef HAVE_GD_JPG
case PHP_GDIMG_TYPE_JPG:
ignore_warning = INI_INT("gd.jpeg_ignore_warning");
#ifdef HAVE_GD_BUNDLED
im_org = gdImageCreateFromJpeg(org, ignore_warning);
#else
im_org = gdImageCreateFromJpeg(org);
#endif
if (im_org == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid JPEG file", fn_dest);
RETURN_FALSE;
+1 -1
View File
@@ -133,7 +133,7 @@ void gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
BitsPerPixel = colorstobpp(tim->colorsTotal);
/* All set, let's do it. */
GIFEncode(
out, tim->sx, tim->sy, tim->interlace, 0, tim->transparent, BitsPerPixel,
out, tim->sx, tim->sy, interlace, 0, transparent, BitsPerPixel,
tim->red, tim->green, tim->blue, tim);
if (pim) {
/* Destroy palette based temporary image. */
-31
View File
@@ -1,31 +0,0 @@
--TEST--
Bug #36697 (TrueColor transparency with GIF palette output).
--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
$dest = dirname(__FILE__) . "/36697.gif";
$im = imagecreatetruecolor(192, 36);
$trans_color = imagecolorallocate($im, 255, 0, 0);
$color = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $trans_color);
imagefilledrectangle($im, 0,0, 192,36, $trans_color);
$c = imagecolorat($im, 191,35);
imagegif($im, $dest);
imagedestroy($im);
$im = imagecreatefromgif($dest);
$c = imagecolorat($im, 191, 35);
$colors = imagecolorsforindex($im, $c);
echo $colors['red'] . ' ' . $colors['green'] . ' ' . $colors['blue'];
@unlink($dest);
?>
--EXPECT--
255 0 0
+1 -1
View File
@@ -5,7 +5,7 @@ ARG_WITH("gettext", "gettext support", "no");
if (PHP_GETTEXT != "no") {
if (CHECK_LIB("libintl.lib", "gettext", PHP_GETTEXT) && CHECK_HEADER_ADD_INCLUDE("libintl.h", "CFLAGS_GETTEXT")) {
EXTENSION("gettext", "gettext.c", PHP_GETTEXT_SHARED, "-DHAVE_BIND_TEXTDOMAIN_CODESET=1 -DHAVE_DNGETTEXT=1 -DHAVE_NGETTEXT=1 -DHAVE_LIBINTL=1 -DHAVE_DCNGETTEXT=1");
EXTENSION("gettext", "gettext.c", PHP_GETTEXT_SHARED, "-DHAVE_BIND_TEXTDOMAIN_CODESET=1 -DHAVE_DNGETTEXT=1 -DHAVE_NGETTEXT=1 -DHAVE_LIBINTL=1");
} else {
WARNING("gettext not enabled; libraries and headers not found");
}
+1 -3
View File
@@ -29,10 +29,8 @@ PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context)
PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
{
php_hash_uint32 i, s[2];
php_hash_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff };
s[0] = context->state & 0xffff;
s[1] = (context->state >> 16) & 0xffff;
for (i = 0; i < len; ++i) {
s[0] = (s[0] + input[i]) % 65521;
s[1] = (s[1] + s[0]) % 65521;
+18 -14
View File
@@ -822,16 +822,18 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
j += GENERIC_SUPERSET_NBYTES;
}
if (_php_iconv_memequal(buf, &ndl_buf[i], sizeof(buf))) {
if (!_php_iconv_memequal(buf, &ndl_buf[i], sizeof(buf))) {
i = 0;
}
if (i == 0) {
match_ofs = (unsigned int)-1;
} else {
match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES;
i += GENERIC_SUPERSET_NBYTES;
ndl_buf_p = &ndl_buf[i];
ndl_buf_left = ndl_buf_len - i;
} else {
match_ofs = (unsigned int)-1;
ndl_buf_p = ndl_buf;
ndl_buf_left = ndl_buf_len;
}
ndl_buf_p = &ndl_buf[i];
ndl_buf_left = ndl_buf_len - i;
}
}
} else {
@@ -865,16 +867,18 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
j += GENERIC_SUPERSET_NBYTES;
}
if (_php_iconv_memequal(buf, &ndl_buf[i], sizeof(buf))) {
if (!_php_iconv_memequal(buf, &ndl_buf[i], sizeof(buf))) {
i = 0;
}
if (i == 0) {
match_ofs = (unsigned int)-1;
} else {
match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES;
i += GENERIC_SUPERSET_NBYTES;
ndl_buf_p = &ndl_buf[i];
ndl_buf_left = ndl_buf_len - i;
} else {
match_ofs = (unsigned int)-1;
ndl_buf_p = ndl_buf;
ndl_buf_left = ndl_buf_len;
}
ndl_buf_p = &ndl_buf[i];
ndl_buf_left = ndl_buf_len - i;
}
}
}
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #37176 (iconv_strpos() fails to find a string)
--FILE--
<?php
var_dump(iconv_strpos('11--','1-',0,'UTF-8'));
var_dump(iconv_strpos('-11--','1-',0,'UTF-8'));
?>
--EXPECT--
int(1)
int(2)
+1 -1
View File
@@ -293,7 +293,7 @@ if test "$PHP_MBSTRING" != "no"; then
dnl libmbfl is required
PHP_MBSTRING_SETUP_LIBMBFL
PHP_MBSTRING_EXTENSION
PHP_INSTALL_HEADERS([ext/mbstring], [libmbfl/ libmbfl/mbfl])
PHP_INSTALL_HEADERS([ext/mbstring], [libmbfl libmbfl/mbfl])
fi
# vim600: sts=2 sw=2 et
-18
View File
@@ -331,24 +331,6 @@ mbfl_buffer_converter_feed_result(mbfl_buffer_converter *convd, mbfl_string *str
return mbfl_memory_device_result(&convd->device, result);
}
int mbfl_buffer_illegalchars(mbfl_buffer_converter *convd)
{
int num_illegalchars = 0;
if (convd == NULL) {
return 0;
}
if (convd->filter1 != NULL) {
num_illegalchars += convd->filter1->num_illegalchar;
}
if (convd->filter2 != NULL) {
num_illegalchars += convd->filter2->num_illegalchar;
}
return (num_illegalchars);
}
/*
* encoding detector
-1
View File
@@ -129,7 +129,6 @@ MBFLAPI extern int mbfl_buffer_converter_flush(mbfl_buffer_converter *convd);
MBFLAPI extern mbfl_string * mbfl_buffer_converter_getbuffer(mbfl_buffer_converter *convd, mbfl_string *result);
MBFLAPI extern mbfl_string * mbfl_buffer_converter_result(mbfl_buffer_converter *convd, mbfl_string *result);
MBFLAPI extern mbfl_string * mbfl_buffer_converter_feed_result(mbfl_buffer_converter *convd, mbfl_string *string, mbfl_string *result);
MBFLAPI extern int mbfl_buffer_illegalchars(mbfl_buffer_converter *convd);
/*
* encoding detector
+1 -3
View File
@@ -250,7 +250,6 @@ mbfl_convert_filter_new(
filter->data = data;
filter->illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
filter->illegal_substchar = 0x3f; /* '?' */
filter->num_illegalchar = 0;
/* setup the function table */
mbfl_convert_filter_reset_vtbl(filter);
@@ -318,7 +317,6 @@ mbfl_convert_filter_copy(
dist->to = src->to;
dist->illegal_mode = src->illegal_mode;
dist->illegal_substchar = src->illegal_substchar;
dist->num_illegalchar = src->num_illegalchar;
}
int mbfl_convert_filter_devcat(mbfl_convert_filter *filter, mbfl_memory_device *src)
@@ -434,7 +432,7 @@ mbfl_filt_conv_illegal_output(int c, mbfl_convert_filter *filter)
break;
}
filter->illegal_mode = mode_backup;
filter->num_illegalchar++;
return ret;
}
-1
View File
@@ -51,7 +51,6 @@ struct _mbfl_convert_filter {
const mbfl_encoding *to;
int illegal_mode;
int illegal_substchar;
int num_illegalchar;
void *opaque;
};
+13 -129
View File
@@ -220,7 +220,6 @@ zend_function_entry mbstring_functions[] = {
PHP_FE(mb_decode_numericentity, NULL)
PHP_FE(mb_send_mail, NULL)
PHP_FE(mb_get_info, NULL)
PHP_FE(mb_check_encoding, NULL)
#if HAVE_MBREGEX
PHP_MBREGEX_FUNCTION_ENTRIES
#endif
@@ -688,9 +687,6 @@ static PHP_INI_MH(OnUpdate_mbstring_script_encoding)
/* {{{ static PHP_INI_MH(OnUpdate_mbstring_substitute_character) */
static PHP_INI_MH(OnUpdate_mbstring_substitute_character)
{
int c;
char *endptr = NULL;
if (new_value != NULL) {
if (strcasecmp("none", new_value) == 0) {
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE;
@@ -698,12 +694,7 @@ static PHP_INI_MH(OnUpdate_mbstring_substitute_character)
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG;
} else {
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
if (new_value_length >0) {
c = strtol(new_value, &endptr, 0);
if (*endptr == '\0') {
MBSTRG(filter_illegal_substchar) = c;
}
}
MBSTRG(filter_illegal_substchar) = zend_atoi(new_value, new_value_length);
}
}
@@ -786,7 +777,6 @@ static void _php_mb_globals_ctor(zend_mbstring_globals *pglobals TSRMLS_DC)
MBSTRG(filter_illegal_substchar) = 0x3f; /* '?' */
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = 0x3f; /* '?' */
MBSTRG(illegalchars) = 0;
MBSTRG(func_overload) = 0;
MBSTRG(encoding_translation) = 0;
MBSTRG(strict_detection) = 0;
@@ -929,7 +919,6 @@ PHP_RINIT_FUNCTION(mbstring)
MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding);
MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode);
MBSTRG(current_filter_illegal_substchar) = MBSTRG(filter_illegal_substchar);
MBSTRG(illegalchars) = 0;
n = 0;
if (MBSTRG(detect_order_list)) {
@@ -998,7 +987,6 @@ PHP_RSHUTDOWN_FUNCTION(mbstring)
MBSTRG(current_detect_order_list_size) = 0;
}
if (MBSTRG(outconv) != NULL) {
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(MBSTRG(outconv));
MBSTRG(outconv) = NULL;
}
@@ -1455,7 +1443,6 @@ PHP_FUNCTION(mb_output_handler)
if ((arg_status & PHP_OUTPUT_HANDLER_START) != 0) {
/* delete the converter just in case. */
if (MBSTRG(outconv)) {
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(MBSTRG(outconv));
MBSTRG(outconv) = NULL;
}
@@ -1520,7 +1507,6 @@ PHP_FUNCTION(mb_output_handler)
/* delete the converter if it is the last feed. */
if (last_feed) {
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(MBSTRG(outconv));
MBSTRG(outconv) = NULL;
}
@@ -2085,7 +2071,6 @@ MBSTRING_API char * php_mb_convert_encoding(char *input, size_t length, char *_t
output = (char *)ret->val;
}
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
return output;
}
@@ -2732,7 +2717,6 @@ detect_end:
}
efree(stack);
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
@@ -3342,22 +3326,20 @@ PHP_FUNCTION(mb_send_mail)
/* }}} */
/* {{{ proto mixed mb_get_info([string type])
/* {{{ proto string mb_get_info([string type])
Returns the current settings of mbstring */
PHP_FUNCTION(mb_get_info)
{
char *typ = NULL;
int typ_len;
char *name;
const struct mb_overload_def *over_func;
zval *row;
const mbfl_language *lang = mbfl_no2language(MBSTRG(current_language));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &typ, &typ_len) == FAILURE) {
RETURN_FALSE;
}
if (!typ || !strcasecmp("all", typ)) {
const mbfl_language *lang = mbfl_no2language(MBSTRG(current_language));
array_init(return_value);
if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_internal_encoding))) != NULL) {
add_assoc_string(return_value, "internal_encoding", name, 1);
@@ -3368,30 +3350,16 @@ PHP_FUNCTION(mb_get_info)
if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_http_output_encoding))) != NULL) {
add_assoc_string(return_value, "http_output", name, 1);
}
if (MBSTRG(func_overload)){
over_func = &(mb_ovld[0]);
MAKE_STD_ZVAL(row);
array_init(row);
while (over_func->type > 0) {
if ((MBSTRG(func_overload) & over_func->type) == over_func->type ) {
add_assoc_string(row, over_func->orig_func, over_func->ovld_func, 1);
}
over_func++;
}
add_assoc_zval(return_value, "func_overload", row);
} else {
add_assoc_string(return_value, "func_overload", "no overload", 1);
}
if ((name = (char *)mbfl_no_encoding2name(MBSTRG(func_overload))) != NULL) {
add_assoc_string(return_value, "func_overload", name, 1);
}
if (lang != NULL) {
if ((name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) {
add_assoc_string(return_value, "mail_charset", name, 1);
}
if ((name = (char *)mbfl_no_encoding2name(lang->mail_header_encoding)) != NULL) {
add_assoc_string(return_value, "mail_header_encoding", name, 1);
}
if ((name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding)) != NULL) {
add_assoc_string(return_value, "mail_body_encoding", name, 1);
}
add_assoc_string(return_value, "mail_charset",
mbfl_no_encoding2name(lang->mail_charset), 1);
add_assoc_string(return_value, "mail_header_encoding",
mbfl_no_encoding2name(lang->mail_header_encoding), 1);
add_assoc_string(return_value, "mail_body_encoding",
mbfl_no_encoding2name(lang->mail_body_encoding), 1);
}
} else if (!strcasecmp("internal_encoding", typ)) {
if ((name = (char *)mbfl_no_encoding2name(MBSTRG(current_internal_encoding))) != NULL) {
@@ -3406,91 +3374,9 @@ PHP_FUNCTION(mb_get_info)
RETVAL_STRING(name, 1);
}
} else if (!strcasecmp("func_overload", typ)) {
if (MBSTRG(func_overload)){
over_func = &(mb_ovld[0]);
array_init(return_value);
while (over_func->type > 0) {
if ((MBSTRG(func_overload) & over_func->type) == over_func->type ) {
add_assoc_string(return_value, over_func->orig_func, over_func->ovld_func, 1);
}
over_func++;
}
} else {
RETVAL_STRING("no overload", 1);
}
} else if (!strcasecmp("mail_charset", typ)) {
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_charset)) != NULL) {
if ((name = (char *)mbfl_no_encoding2name(MBSTRG(func_overload))) != NULL) {
RETVAL_STRING(name, 1);
}
} else if (!strcasecmp("mail_header_encoding", typ)) {
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_header_encoding)) != NULL) {
RETVAL_STRING(name, 1);
}
} else if (!strcasecmp("mail_body_encoding", typ)) {
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding)) != NULL) {
RETVAL_STRING(name, 1);
}
} else if (!strcasecmp("illegal_chars", typ)) {
RETVAL_LONG(MBSTRG(illegalchars));
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto bool mb_check_encoding([string var[, string encoding]])
Check if the string is valid for the specified encoding */
PHP_FUNCTION(mb_check_encoding)
{
char *var = NULL;
int var_len;
char *enc = NULL;
int enc_len;
mbfl_buffer_converter *convd;
enum mbfl_no_encoding no_encoding = MBSTRG(current_internal_encoding);
mbfl_string string, result, *ret = NULL;
long illegalchars = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &var, &var_len, &enc, &enc_len) == FAILURE) {
RETURN_FALSE;
}
if (var == NULL) {
RETURN_BOOL(MBSTRG(illegalchars) == 0);
}
if (enc != NULL) {
no_encoding = mbfl_name2no_encoding(enc);
if (no_encoding == mbfl_no_encoding_invalid || no_encoding == mbfl_no_encoding_pass) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid encoding \"%s\"", enc);
RETURN_FALSE;
}
}
convd = mbfl_buffer_converter_new(no_encoding, no_encoding, 0);
if (convd == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create converter");
RETURN_FALSE;
}
mbfl_buffer_converter_illegal_mode(convd, MBSTRG(current_filter_illegal_mode));
mbfl_buffer_converter_illegal_substchar(convd, MBSTRG(current_filter_illegal_substchar));
/* initialize string */
mbfl_string_init(&string);
mbfl_string_init(&result);
string.no_encoding = no_encoding;
string.no_language = MBSTRG(current_language);
string.val = (unsigned char *)var;
string.len = var_len;
ret = mbfl_buffer_converter_feed_result(convd, &string, &result);
illegalchars = mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
if (ret != NULL) {
MBSTRG(illegalchars) += illegalchars;
efree(ret->val);
RETURN_BOOL(illegalchars == 0);
} else {
RETURN_FALSE;
}
@@ -3657,7 +3543,6 @@ MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, int num, co
str[i] = ret->val;
len[i] = ret->len;
}
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
@@ -3874,7 +3759,6 @@ int php_mb_encoding_converter(char **to, int *to_length, const char *from,
*to = ret->val;
*to_length = ret->len;
}
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
return ret ? 0 : -1;
-2
View File
@@ -120,7 +120,6 @@ PHP_FUNCTION(mb_encode_numericentity);
PHP_FUNCTION(mb_decode_numericentity);
PHP_FUNCTION(mb_send_mail);
PHP_FUNCTION(mb_get_info);
PHP_FUNCTION(mb_check_encoding);
MBSTRING_API int php_mb_encoding_translation(TSRMLS_D);
@@ -182,7 +181,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
long func_overload;
zend_bool encoding_translation;
long strict_detection;
long illegalchars;
mbfl_buffer_converter *outconv;
#if HAVE_MBREGEX && defined(PHP_MBREGEX_GLOBALS)
PHP_MBREGEX_GLOBALS
+1 -1
View File
@@ -205,7 +205,7 @@ PHP_FUNCTION(mhash_keygen_s2k)
WRONG_PARAM_COUNT;
}
if (bytes <= 0){
php_error_docref(NULL TSRMLS_CC, E_WARNING, "the byte parameter must be greater than 0");
php_error_docref(NULL TSRMLS_CC, E_WARNING, "the byte parameter must be greater then 0");
RETURN_FALSE;
}
-5
View File
@@ -229,7 +229,6 @@ static void _free_mssql_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
mssql_result *result = (mssql_result *)rsrc->ptr;
_free_result(result, 1);
dbcancel(result->mssql_ptr->link);
efree(result);
}
@@ -1234,7 +1233,6 @@ PHP_FUNCTION(mssql_query)
}
if (dbsqlexec(mssql_ptr->link)==FAIL || (retvalue = dbresults(mssql_ptr->link))==FAIL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed");
dbcancel(mssql_ptr->link);
RETURN_FALSE;
}
@@ -1249,7 +1247,6 @@ PHP_FUNCTION(mssql_query)
retvalue=dbnextrow(mssql_ptr->link);
if (retvalue==FAIL) {
dbcancel(mssql_ptr->link);
RETURN_FALSE;
}
@@ -2175,7 +2172,6 @@ PHP_FUNCTION(mssql_execute)
if (dbrpcexec(mssql_ptr->link)==FAIL || dbsqlok(mssql_ptr->link)==FAIL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "stored procedure execution failed");
dbcancel(mssql_ptr->link);
RETURN_FALSE;
}
@@ -2183,7 +2179,6 @@ PHP_FUNCTION(mssql_execute)
if (retval_results==FAIL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not retrieve results");
dbcancel(mssql_ptr->link);
RETURN_FALSE;
}
+32 -21
View File
@@ -123,9 +123,8 @@ void php_clear_mysql(MY_MYSQL *mysql) {
static void mysqli_objects_free_storage(zend_object *object TSRMLS_DC)
{
mysqli_object *intern = (mysqli_object *)object;
zend_object_std_dtor(&intern->zo TSRMLS_CC);
efree(intern);
zend_objects_free_object_storage(&(intern->zo) TSRMLS_CC);
}
/* }}} */
@@ -212,11 +211,22 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)
}
if (ret == SUCCESS) {
if (strcmp(obj->zo.ce->name, "mysqli_driver") &&
(!obj->ptr || ((MYSQLI_RESOURCE *)(obj->ptr))->status < MYSQLI_STATUS_INITIALIZED)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name );
retval = EG(uninitialized_zval_ptr);
return(retval);
/* check if mysqli object is still valid */
if (!strcmp(obj->zo.ce->name, "mysqli")) {
if (!obj->ptr ||
!((MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql)->thread_id) {
retval = EG(uninitialized_zval_ptr);
return(retval);
}
} else
/* check if stmt object is still valid */
if (!strcmp(obj->zo.ce->name, "mysqli_stmt")) {
if (!obj->ptr ||
!((MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt)->mysql) {
retval = EG(uninitialized_zval_ptr);
return(retval);
}
}
ret = hnd->read_func(obj, &retval TSRMLS_CC);
@@ -333,7 +343,10 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
intern = emalloc(sizeof(mysqli_object));
memset(intern, 0, sizeof(mysqli_object));
intern->zo.ce = class_type;
intern->zo.guards = NULL;
intern->ptr = NULL;
intern->valid = 0;
intern->prop_handler = NULL;
mysqli_base_class = class_type;
@@ -344,7 +357,8 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
zend_hash_find(&classes, mysqli_base_class->name, mysqli_base_class->name_length + 1,
(void **) &intern->prop_handler);
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
ALLOC_HASHTABLE(intern->zo.properties);
zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,
(void *) &tmp, sizeof(zval *));
@@ -574,7 +588,6 @@ PHP_MINIT_FUNCTION(mysqli)
/* reporting */
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_INDEX", MYSQLI_REPORT_INDEX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ERROR", MYSQLI_REPORT_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_STRICT", MYSQLI_REPORT_STRICT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ALL", MYSQLI_REPORT_ALL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_OFF", 0, CONST_CS | CONST_PERSISTENT);
@@ -626,8 +639,7 @@ PHP_MINFO_FUNCTION(mysqli)
{
php_info_print_table_start();
php_info_print_table_header(2, "MysqlI Support", "enabled");
php_info_print_table_row(2, "Client API library version", mysql_get_client_info());
php_info_print_table_row(2, "Client API header version", MYSQL_SERVER_VERSION);
php_info_print_table_row(2, "Client API version", mysql_get_client_info());
php_info_print_table_row(2, "MYSQLI_SOCKET", MYSQL_UNIX_ADDR);
@@ -640,7 +652,7 @@ PHP_MINFO_FUNCTION(mysqli)
/* {{{ mixed mysqli_stmt_construct()
constructor for statement object.
Parameters:
object -> mysqli_stmt_init
object -> mysqli_init
object, query -> mysqli_prepare
*/
ZEND_FUNCTION(mysqli_stmt_construct)
@@ -658,7 +670,7 @@ ZEND_FUNCTION(mysqli_stmt_construct)
if (zend_parse_parameters(1 TSRMLS_CC, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
@@ -668,7 +680,7 @@ ZEND_FUNCTION(mysqli_stmt_construct)
if (zend_parse_parameters(2 TSRMLS_CC, "Os", &mysql_link, mysqli_link_class_entry, &statement, &stmt_len)==FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
@@ -688,9 +700,9 @@ ZEND_FUNCTION(mysqli_stmt_construct)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)stmt;
mysqli_resource->status = (ZEND_NUM_ARGS() == 1) ? MYSQLI_STATUS_INITIALIZED : MYSQLI_STATUS_VALID;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
/* }}} */
@@ -722,7 +734,7 @@ ZEND_FUNCTION(mysqli_result_construct)
WRONG_PARAM_COUNT;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
result = (resmode == MYSQLI_STORE_RESULT) ? mysql_store_result(mysql->mysql) :
mysql_use_result(mysql->mysql);
@@ -733,9 +745,9 @@ ZEND_FUNCTION(mysqli_result_construct)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)result;
mysqli_resource->status = MYSQLI_STATUS_VALID;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
/* }}} */
@@ -784,7 +796,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
}
}
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if ((fetchtype & MYSQLI_BOTH) == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
@@ -976,7 +988,6 @@ int php_local_infile_init(void **ptr, const char *filename, void *userdata)
mysql->li_stream = php_stream_open_wrapper_ex((char *)filename, "r", 0, NULL, context);
if (mysql->li_stream == NULL) {
sprintf((char *)data->error_msg, "Can't find file '%-.64s'.", filename);
return 1;
}
+89 -106
View File
@@ -41,7 +41,7 @@ PHP_FUNCTION(mysqli_affected_rows)
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
rc = mysql_affected_rows(mysql->mysql);
if (rc == (my_ulonglong) -1) {
@@ -62,7 +62,7 @@ PHP_FUNCTION(mysqli_autocommit)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ob", &mysql_link, mysqli_link_class_entry, &automode) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql_autocommit(mysql->mysql, automode)) {
RETURN_FALSE;
@@ -103,7 +103,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param)
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if (getThis()) {
start = 1;
@@ -229,7 +229,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if (argc < (getThis() ? 1 : 2)) {
WRONG_PARAM_COUNT;
@@ -295,7 +295,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
convert_to_long_ex(args[i]);
stmt->result.buf[ofs].type = IS_LONG;
stmt->result.buf[ofs].buflen = 0;
stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int));
stmt->result.buf[ofs].val = (char *)emalloc(sizeof(long));
bind[ofs].buffer_type = MYSQL_TYPE_LONG;
bind[ofs].buffer = stmt->result.buf[ofs].val;
bind[ofs].is_null = &stmt->result.is_null[ofs];
@@ -326,12 +326,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
case MYSQL_TYPE_NEWDECIMAL:
#endif
{
#if MYSQL_VERSION_ID > 50099
/* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */
my_bool tmp;
#else
ulong tmp = 0;
#endif
ulong tmp;
stmt->result.buf[ofs].type = IS_STRING;
/*
If the user has called $stmt->store_result() then we have asked
@@ -409,7 +404,7 @@ PHP_FUNCTION(mysqli_change_user)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osss", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
rc = mysql_change_user(mysql->mysql, user, password, dbname);
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
@@ -433,7 +428,7 @@ PHP_FUNCTION(mysqli_character_set_name)
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_STRING((char *) mysql_character_set_name(mysql->mysql), 1);
}
@@ -450,7 +445,7 @@ PHP_FUNCTION(mysqli_close)
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
mysql_close(mysql->mysql);
php_clear_mysql(mysql);
@@ -470,7 +465,7 @@ PHP_FUNCTION(mysqli_commit)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql_commit(mysql->mysql)) {
RETURN_FALSE;
}
@@ -490,7 +485,7 @@ PHP_FUNCTION(mysqli_data_seek)
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if (result->handle && result->handle->status == MYSQL_STATUS_USE_RESULT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT");
@@ -533,7 +528,7 @@ PHP_FUNCTION(mysqli_dump_debug_info)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
rc = mysql_dump_debug_info(mysql->mysql);
@@ -554,7 +549,7 @@ PHP_FUNCTION(mysqli_errno)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_errno(mysql->mysql));
}
/* }}} */
@@ -569,7 +564,7 @@ PHP_FUNCTION(mysqli_error)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_STRING((char *)mysql_error(mysql->mysql),1);
}
/* }}} */
@@ -585,7 +580,7 @@ PHP_FUNCTION(mysqli_stmt_execute)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
for (i = 0; i < stmt->param.var_cnt; i++) {
if (stmt->param.vars[i]) {
@@ -632,13 +627,14 @@ PHP_FUNCTION(mysqli_stmt_fetch)
unsigned int i;
ulong ret;
unsigned int uval;
double dval;
my_ulonglong llval;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
/* reset buffers */
@@ -662,7 +658,7 @@ PHP_FUNCTION(mysqli_stmt_fetch)
if (!stmt->result.is_null[i]) {
switch (stmt->result.buf[i].type) {
case IS_LONG:
if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
if ((sizeof(long) ==4) && (stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
&& (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
{
/* unsigned int (11) */
@@ -683,14 +679,11 @@ PHP_FUNCTION(mysqli_stmt_fetch)
break;
}
}
if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) {
ZVAL_LONG(stmt->result.vars[i], *(unsigned int *)stmt->result.buf[i].val);
} else {
ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val);
};
ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val);
break;
case IS_DOUBLE:
ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val);
memcpy(&dval, stmt->result.buf[i].val, sizeof(dval));
ZVAL_DOUBLE(stmt->result.vars[i], dval);
break;
case IS_STRING:
if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG) {
@@ -705,10 +698,10 @@ PHP_FUNCTION(mysqli_stmt_fetch)
#endif
char tmp[22];
/* even though lval is declared as unsigned, the value
* may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must
* use MYSQLI_LL_SPEC.
* may be negative. Therefor we cannot use %llu and must
* use %lld.
*/
sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? "%llu":"%lld", llval);
ZVAL_STRING(stmt->result.vars[i], tmp, 1);
} else {
ZVAL_LONG(stmt->result.vars[i], llval);
@@ -761,7 +754,7 @@ PHP_FUNCTION(mysqli_fetch_field)
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if (!(field = mysql_fetch_field(result))) {
RETURN_FALSE;
@@ -798,7 +791,7 @@ PHP_FUNCTION(mysqli_fetch_fields)
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
array_init(return_value);
@@ -839,7 +832,7 @@ PHP_FUNCTION(mysqli_fetch_field_direct)
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if (offset < 0 || offset >= mysql_num_fields(result)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field offset is invalid for resultset");
@@ -879,7 +872,7 @@ PHP_FUNCTION(mysqli_fetch_lengths)
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if (!(ret = mysql_fetch_lengths(result))) {
RETURN_FALSE;
@@ -912,7 +905,7 @@ PHP_FUNCTION(mysqli_field_count)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_field_count(mysql->mysql));
}
@@ -930,7 +923,7 @@ PHP_FUNCTION(mysqli_field_seek)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &fieldnr) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if (fieldnr < 0 || fieldnr >= mysql_num_fields(result)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT");
@@ -952,7 +945,7 @@ PHP_FUNCTION(mysqli_field_tell)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
RETURN_LONG(mysql_field_tell(result));
}
@@ -968,7 +961,7 @@ PHP_FUNCTION(mysqli_free_result)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
mysql_free_result(result);
MYSQLI_CLEAR_RESOURCE(&mysql_result);
@@ -1003,7 +996,7 @@ PHP_FUNCTION(mysqli_get_host_info)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_STRING((mysql->mysql->host_info) ? mysql->mysql->host_info : "", 1);
}
@@ -1019,7 +1012,7 @@ PHP_FUNCTION(mysqli_get_proto_info)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_get_proto_info(mysql->mysql));
}
@@ -1035,7 +1028,7 @@ PHP_FUNCTION(mysqli_get_server_info)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_STRING((char *)mysql_get_server_info(mysql->mysql), 1);
}
@@ -1052,7 +1045,7 @@ PHP_FUNCTION(mysqli_get_server_version)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_get_server_version(mysql->mysql));
}
@@ -1068,7 +1061,7 @@ PHP_FUNCTION(mysqli_info)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_STRING((mysql->mysql->info) ? mysql->mysql->info : "", 1);
}
@@ -1088,12 +1081,12 @@ PHP_FUNCTION(mysqli_init)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)mysql;
mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_link_class_entry TSRMLS_CC)) {
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
} else {
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
}
/* }}} */
@@ -1109,7 +1102,7 @@ PHP_FUNCTION(mysqli_insert_id)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
rc = mysql_insert_id(mysql->mysql);
MYSQLI_RETURN_LONG_LONG(rc)
}
@@ -1126,7 +1119,7 @@ PHP_FUNCTION(mysqli_kill)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &processid) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql_kill(mysql->mysql, processid)) {
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
@@ -1147,7 +1140,7 @@ PHP_FUNCTION(mysqli_set_local_infile_default)
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql->li_read) {
efree(Z_STRVAL_P(mysql->li_read));
@@ -1171,7 +1164,7 @@ PHP_FUNCTION(mysqli_set_local_infile_handler)
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
/* check callback function */
if (!zend_is_callable(callback_func, 0, &callback_name)) {
@@ -1197,7 +1190,7 @@ PHP_FUNCTION(mysqli_more_results)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (!mysql_more_results(mysql->mysql)) {
RETURN_FALSE;
@@ -1215,7 +1208,7 @@ PHP_FUNCTION(mysqli_next_result) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql_next_result(mysql->mysql)) {
RETURN_FALSE;
@@ -1234,7 +1227,7 @@ PHP_FUNCTION(mysqli_num_fields)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
RETURN_LONG(mysql_num_fields(result));
}
@@ -1250,7 +1243,7 @@ PHP_FUNCTION(mysqli_num_rows)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
if (result->handle && result->handle->status == MYSQL_STATUS_USE_RESULT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT");
@@ -1275,7 +1268,7 @@ PHP_FUNCTION(mysqli_options)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olz", &mysql_link, mysqli_link_class_entry, &mysql_option, &mysql_value) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
switch (Z_TYPE_PP(&mysql_value)) {
case IS_STRING:
@@ -1308,7 +1301,7 @@ PHP_FUNCTION(mysqli_ping)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
rc = mysql_ping(mysql->mysql);
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
if (rc) {
@@ -1332,7 +1325,7 @@ PHP_FUNCTION(mysqli_prepare)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",&mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql->mysql->status == MYSQL_STATUS_GET_RESULT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "All data must be fetched before a new statement prepare takes place");
RETURN_FALSE;
@@ -1367,14 +1360,10 @@ PHP_FUNCTION(mysqli_prepare)
RETURN_FALSE;
}
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)stmt;
stmt->query = (query_len) ? (char *)emalloc(query_len + 1) : NULL;
strcpy(stmt->query, query);
/* change status */
mysqli_resource->status = MYSQLI_STATUS_VALID;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_stmt_class_entry);
}
/* }}} */
@@ -1388,6 +1377,7 @@ PHP_FUNCTION(mysqli_real_connect)
unsigned int hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
unsigned long port=0, flags=0;
zval *mysql_link;
zval *object = getThis();
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sssslsl", &mysql_link, mysqli_link_class_entry,
&hostname, &hostname_len, &username, &username_len, &passwd, &passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len,
@@ -1413,7 +1403,7 @@ PHP_FUNCTION(mysqli_real_connect)
}
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
/* remove some insecure options */
flags ^= CLIENT_MULTI_STATEMENTS; /* don't allow multi_queries via connect parameter */
@@ -1426,24 +1416,23 @@ PHP_FUNCTION(mysqli_real_connect)
}
if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,flags) == NULL) {
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC);
php_mysqli_throw_sql_exception( mysql->mysql->net.sqlstate, mysql->mysql->net.last_errno TSRMLS_CC,
"%s", mysql->mysql->net.last_error);
/* change status */
MYSQLI_SET_STATUS(&mysql_link, MYSQLI_STATUS_INITIALIZED);
RETURN_FALSE;
}
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *)mysql_error(mysql->mysql) TSRMLS_CC);
mysql->mysql->reconnect = MyG(reconnect);
/* set our own local_infile handler */
php_set_local_infile_handler_default(mysql);
/* change status */
MYSQLI_SET_STATUS(&mysql_link, MYSQLI_STATUS_VALID);
if (object) {
((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->valid = 1;
}
RETURN_TRUE;
}
@@ -1461,7 +1450,7 @@ PHP_FUNCTION(mysqli_real_query)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
MYSQLI_DISABLE_MQ; /* disable multi statements/queries */
@@ -1491,7 +1480,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &escapestr, &escapestr_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
newstr = safe_emalloc(2, escapestr_len, 1);
newstr_len = mysql_real_escape_string(mysql->mysql, newstr, escapestr, escapestr_len);
@@ -1511,7 +1500,7 @@ PHP_FUNCTION(mysqli_rollback)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (mysql_rollback(mysql->mysql)) {
RETURN_FALSE;
@@ -1534,7 +1523,7 @@ PHP_FUNCTION(mysqli_stmt_send_long_data)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ols", &mysql_stmt, mysqli_stmt_class_entry, &param_nr, &data, &data_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if (param_nr < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter number");
@@ -1559,7 +1548,7 @@ PHP_FUNCTION(mysqli_stmt_affected_rows)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
rc = mysql_stmt_affected_rows(stmt->stmt);
if (rc == (my_ulonglong) -1) {
@@ -1579,13 +1568,13 @@ PHP_FUNCTION(mysqli_stmt_close)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
mysql_stmt_close(stmt->stmt);
stmt->stmt = NULL;
php_clear_stmt_bind(stmt);
MYSQLI_CLEAR_RESOURCE(&mysql_stmt);
RETURN_TRUE;
}
/* }}} */
@@ -1605,7 +1594,7 @@ PHP_FUNCTION(mysqli_stmt_data_seek)
RETURN_FALSE;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
mysql_stmt_data_seek(stmt->stmt, offset);
return;
@@ -1622,7 +1611,7 @@ PHP_FUNCTION(mysqli_stmt_field_count)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
}
@@ -1639,7 +1628,7 @@ PHP_FUNCTION(mysqli_stmt_free_result)
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
mysql_stmt_free_result(stmt->stmt);
@@ -1658,7 +1647,7 @@ PHP_FUNCTION(mysqli_stmt_insert_id)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
rc = mysql_stmt_insert_id(stmt->stmt);
MYSQLI_RETURN_LONG_LONG(rc)
}
@@ -1674,7 +1663,7 @@ PHP_FUNCTION(mysqli_stmt_param_count)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
}
@@ -1691,7 +1680,7 @@ PHP_FUNCTION(mysqli_stmt_reset)
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if (mysql_stmt_reset(stmt->stmt)) {
RETURN_FALSE;
@@ -1712,7 +1701,7 @@ PHP_FUNCTION(mysqli_stmt_num_rows)
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
rc = mysql_stmt_num_rows(stmt->stmt);
MYSQLI_RETURN_LONG_LONG(rc)
@@ -1732,7 +1721,7 @@ PHP_FUNCTION(mysqli_select_db)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &dbname, &dbname_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (!mysql_select_db(mysql->mysql, dbname)) {
RETURN_TRUE;
@@ -1753,7 +1742,7 @@ PHP_FUNCTION(mysqli_sqlstate)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_STRING((char *)mysql_sqlstate(mysql->mysql),1);
}
/* }}} */
@@ -1770,7 +1759,7 @@ PHP_FUNCTION(mysqli_ssl_set)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osssss", &mysql_link, mysqli_link_class_entry, &ssl_parm[0], &ssl_parm_len[0], &ssl_parm[1], &ssl_parm_len[1], &ssl_parm[2], &ssl_parm_len[2], &ssl_parm[3], &ssl_parm_len[3], &ssl_parm[4], &ssl_parm_len[4]) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
for (i=0; i < 5; i++) {
if (!ssl_parm_len[i]) {
@@ -1795,7 +1784,7 @@ PHP_FUNCTION(mysqli_stat)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if ((stat = (char *)mysql_stat(mysql->mysql))) {
RETURN_STRING(stat, 1);
@@ -1818,7 +1807,7 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if ((rc = mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode))) {
RETURN_FALSE;
@@ -1833,14 +1822,14 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
{
MY_STMT *stmt;
zval *mysql_stmt;
ulong value = 0;
ulong value;
ulong attr;
int rc;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &attr) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
RETURN_FALSE;
@@ -1859,7 +1848,7 @@ PHP_FUNCTION(mysqli_stmt_errno)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
RETURN_LONG(mysql_stmt_errno(stmt->stmt));
}
@@ -1875,7 +1864,7 @@ PHP_FUNCTION(mysqli_stmt_error)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1);
}
@@ -1894,7 +1883,7 @@ PHP_FUNCTION(mysqli_stmt_init)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",&mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
@@ -1904,7 +1893,6 @@ PHP_FUNCTION(mysqli_stmt_init)
}
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
mysqli_resource->ptr = (void *)stmt;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_stmt_class_entry);
}
@@ -1923,14 +1911,12 @@ PHP_FUNCTION(mysqli_stmt_prepare)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_stmt, mysqli_stmt_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
RETURN_FALSE;
}
/* change status */
MYSQLI_SET_STATUS(&mysql_stmt, MYSQLI_STATUS_VALID);
RETURN_TRUE;
}
/* }}} */
@@ -1947,7 +1933,7 @@ PHP_FUNCTION(mysqli_stmt_result_metadata)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
@@ -1956,7 +1942,6 @@ PHP_FUNCTION(mysqli_stmt_result_metadata)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)result;
mysqli_resource->status = MYSQLI_STATUS_VALID;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);
}
/* }}} */
@@ -1972,7 +1957,7 @@ PHP_FUNCTION(mysqli_stmt_store_result)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
/*
If the user wants to store the data and we have BLOBs/TEXTs we try to allocate
@@ -2007,7 +1992,7 @@ PHP_FUNCTION(mysqli_stmt_sqlstate)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
RETURN_STRING((char *)mysql_stmt_sqlstate(stmt->stmt),1);
}
@@ -2025,7 +2010,7 @@ PHP_FUNCTION(mysqli_store_result)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (!(result = mysql_store_result(mysql->mysql))) {
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
@@ -2034,10 +2019,8 @@ PHP_FUNCTION(mysqli_store_result)
if (MyG(report_mode) & MYSQLI_REPORT_INDEX) {
php_mysqli_report_index("from previous query", mysql->mysql->server_status TSRMLS_CC);
}
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)result;
mysqli_resource->status = MYSQLI_STATUS_VALID;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);
}
/* }}} */
@@ -2052,7 +2035,7 @@ PHP_FUNCTION(mysqli_thread_id)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_thread_id(mysql->mysql));
}
@@ -2079,7 +2062,7 @@ PHP_FUNCTION(mysqli_use_result)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
if (!(result = mysql_use_result(mysql->mysql))) {
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
@@ -2089,9 +2072,9 @@ PHP_FUNCTION(mysqli_use_result)
if (MyG(report_mode) & MYSQLI_REPORT_INDEX) {
php_mysqli_report_index("from previous query", mysql->mysql->server_status TSRMLS_CC);
}
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)result;
mysqli_resource->status = MYSQLI_STATUS_VALID;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);
}
/* }}} */
@@ -2106,7 +2089,7 @@ PHP_FUNCTION(mysqli_warning_count)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_warning_count(mysql->mysql));
}
+1
View File
@@ -130,6 +130,7 @@ MAP_PROPERTY_MYG_LONG_READ(driver_report_read, report_mode);
ZEND_FUNCTION(mysqli_driver_construct)
{
}
mysqli_property_entry mysqli_driver_property_entries[] = {
+8 -10
View File
@@ -75,11 +75,10 @@ PHP_FUNCTION(mysqli_connect)
}
#ifdef HAVE_EMBEDDED_MYSQLI
if (strcmp(hostname, ":embedded")) {
if (hostname_len && hostname) {
unsigned int external=1;
mysql_options(mysql->mysql, MYSQL_OPT_USE_REMOTE_CONNECTION, (char *)&external);
} else {
hostname[0] = '\0';
mysql_options(mysql->mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, 0);
}
#endif
@@ -112,12 +111,12 @@ PHP_FUNCTION(mysqli_connect)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)mysql;
mysqli_resource->status = MYSQLI_STATUS_VALID;
if (!object || !instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry TSRMLS_CC)) {
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
} else {
((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->ptr = mysqli_resource;
((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->valid = 1;
}
}
/* }}} */
@@ -178,7 +177,7 @@ PHP_FUNCTION(mysqli_multi_query)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
MYSQLI_ENABLE_MQ;
if (mysql_real_query(mysql->mysql, query, query_len)) {
@@ -229,7 +228,7 @@ PHP_FUNCTION(mysqli_query)
RETURN_FALSE;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link");
MYSQLI_DISABLE_MQ;
@@ -260,7 +259,6 @@ PHP_FUNCTION(mysqli_query)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)result;
mysqli_resource->status = MYSQLI_STATUS_VALID;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);
}
/* }}} */
@@ -276,7 +274,7 @@ PHP_FUNCTION(mysqli_get_warnings)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link");
if (mysql_warning_count(mysql->mysql)) {
w = php_get_warnings(mysql->mysql);
@@ -300,7 +298,7 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &stmt_link, mysqli_stmt_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT*, &stmt_link, "mysqli_stmt", 1);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT*, &stmt_link, "mysqli_stmt");
if (mysql_warning_count(stmt->stmt->mysql)) {
w = php_get_warnings(stmt->stmt->mysql);
@@ -326,7 +324,7 @@ PHP_FUNCTION(mysqli_set_charset)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link");
if (mysql_set_character_set(mysql->mysql, cs_name)) {
RETURN_FALSE;
@@ -348,7 +346,7 @@ PHP_FUNCTION(mysqli_get_charset)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link");
object_init(return_value);
+75 -85
View File
@@ -29,49 +29,51 @@
#include "ext/standard/info.h"
#include "php_mysqli.h"
#define CHECK_STATUS(value) \
if (((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property access is not allowed yet"); \
#define CHECK_OBJECT() \
if (!obj->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property access is not allowed yet. Call the default constructor of the object first"); \
ZVAL_NULL(*retval); \
return SUCCESS; \
} \
#define MYSQLI_GET_MYSQL(statusval) \
#define MYSQLI_GET_MYSQL() \
MYSQL *p; \
ALLOC_ZVAL(*retval);\
CHECK_OBJECT();\
if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
return SUCCESS; \
} else if (!obj->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid resource %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
return SUCCESS; \
} else { \
CHECK_STATUS(statusval);\
p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql;\
p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql; \
}
#define MYSQLI_GET_RESULT(statusval) \
#define MYSQLI_GET_RESULT() \
MYSQL_RES *p; \
ALLOC_ZVAL(*retval);\
CHECK_OBJECT();\
if (!obj->ptr) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
return SUCCESS; \
} else if (!obj->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid resource %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
return SUCCESS; \
} else { \
CHECK_STATUS(statusval);\
p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; \
}
#define MYSQLI_GET_STMT(statusval) \
#define MYSQLI_GET_STMT() \
MYSQL_STMT *p; \
ALLOC_ZVAL(*retval);\
if (!obj->ptr) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
return SUCCESS; \
} else { \
CHECK_STATUS(statusval);\
p = (MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt;\
}
CHECK_OBJECT();\
p = (MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt
#define MYSQLI_MAP_PROPERTY_FUNC_LONG( __func, __int_func, __get_type, __ret_type)\
static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \
@@ -86,7 +88,7 @@ static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \
ZVAL_LONG(*retval, l);\
} else { \
char ret[40]; \
sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong)l); \
sprintf(ret, "%llu", (my_ulonglong)l); \
ZVAL_STRING(*retval, ret, 1); \
} \
}\
@@ -124,7 +126,6 @@ static int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
ALLOC_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
ZVAL_STRING(*retval, MYSQL_SERVER_VERSION, 1);
return SUCCESS;
}
@@ -134,7 +135,6 @@ static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
ALLOC_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
ZVAL_LONG(*retval, (long)MyG(error_no));
return SUCCESS;
}
@@ -144,7 +144,6 @@ static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_connect_error_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
ALLOC_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
ZVAL_STRING(*retval, MyG(error_msg), 1);
return SUCCESS;
}
@@ -157,46 +156,41 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
my_ulonglong rc;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (!mysql) {
ZVAL_NULL(*retval);
rc = mysql_affected_rows(mysql->mysql);
if (rc == (my_ulonglong)-1) {
ZVAL_LONG(*retval, -1);
return SUCCESS;
}
if (rc < LONG_MAX) {
ZVAL_LONG(*retval, rc);
} else {
CHECK_STATUS(MYSQLI_STATUS_VALID);
rc = mysql_affected_rows(mysql->mysql);
if (rc == (my_ulonglong)-1) {
ZVAL_LONG(*retval, -1);
return SUCCESS;
}
if (rc < LONG_MAX) {
ZVAL_LONG(*retval, rc);
} else {
char ret[40];
sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc);
ZVAL_STRING(*retval, ret, 1);
}
char ret[40];
sprintf(ret, "%llu", (my_ulonglong) rc);
ZVAL_STRING(*retval, ret, 1);
}
return SUCCESS;
}
/* }}} */
/* link properties */
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read, mysql_errno, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_error_read, mysql_error, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED));
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_host_info_read, mysql_get_host_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID));
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_info_read, mysql_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID));
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_insert_id_read, mysql_insert_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_server_info_read, mysql_get_server_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID));
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID));
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read, mysql_errno, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_error_read, mysql_error, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_host_info_read, mysql_get_host_info, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_info_read, mysql_info, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_insert_id_read, mysql_insert_id, MYSQLI_GET_MYSQL(), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_server_info_read, mysql_get_server_info, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(), ulong);
/* result properties */
/* {{{ property result_type_read */
@@ -205,7 +199,7 @@ static int result_type_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MYSQL_RES *p;
ALLOC_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
CHECK_OBJECT();
p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (!p) {
@@ -223,15 +217,15 @@ static int result_lengths_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MYSQL_RES *p;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (!p || !p->field_count) {
ZVAL_NULL(*retval);
} else {
ulong i;
zval *l;
array_init(*retval);
for (i=0; i < p->field_count; i++) {
@@ -245,9 +239,9 @@ static int result_lengths_read(mysqli_object *obj, zval **retval TSRMLS_DC)
/* }}} */
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(), my_ulonglong);
/* statement properties */
@@ -257,7 +251,7 @@ static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MY_STMT *p;
ALLOC_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
CHECK_OBJECT();
p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@@ -273,43 +267,39 @@ static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC)
/* {{{ property stmt_affected_rows_read */
static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
MY_STMT *p;
MY_STMT *stmt;
my_ulonglong rc;
ALLOC_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
CHECK_OBJECT();
p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
stmt = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
rc = mysql_stmt_affected_rows(stmt->stmt);
if (!p) {
ZVAL_NULL(*retval);
if (rc == (my_ulonglong)-1) {
ZVAL_LONG(*retval, -1);
return SUCCESS;
}
if (rc < LONG_MAX) {
ZVAL_LONG(*retval, rc);
} else {
rc = mysql_stmt_affected_rows(p->stmt);
if (rc == (my_ulonglong)-1) {
ZVAL_LONG(*retval, -1);
return SUCCESS;
}
if (rc < LONG_MAX) {
ZVAL_LONG(*retval, rc);
} else {
char ret[40];
sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc);
ZVAL_STRING(*retval, ret, 1);
}
char ret[40];
sprintf(ret, "%llu", (my_ulonglong) rc);
ZVAL_STRING(*retval, ret, 1);
}
return SUCCESS;
}
/* }}} */
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_insert_id_read, mysql_stmt_insert_id, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_num_rows_read, mysql_stmt_num_rows, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_error_read, mysql_stmt_error, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED));
MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED));
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_insert_id_read, mysql_stmt_insert_id, MYSQLI_GET_STMT(), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_num_rows_read, mysql_stmt_num_rows, MYSQLI_GET_STMT(), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_error_read, mysql_stmt_error, MYSQLI_GET_STMT());
MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_GET_STMT());
/* }}} */
mysqli_property_entry mysqli_link_property_entries[] = {
+10 -10
View File
@@ -39,7 +39,7 @@ PHP_FUNCTION(mysqli_disable_reads_from_master)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
mysql_disable_reads_from_master(mysql);
RETURN_TRUE;
}
@@ -55,7 +55,7 @@ PHP_FUNCTION(mysqli_disable_rpl_parse)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
mysql_disable_rpl_parse(mysql);
RETURN_TRUE;
}
@@ -71,7 +71,7 @@ PHP_FUNCTION(mysqli_enable_reads_from_master)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
mysql_enable_reads_from_master(mysql);
RETURN_TRUE;
@@ -88,7 +88,7 @@ PHP_FUNCTION(mysqli_enable_rpl_parse)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
mysql_enable_rpl_parse(mysql);
RETURN_TRUE;
@@ -106,7 +106,7 @@ PHP_FUNCTION(mysqli_master_query) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
if (mysql_master_query(mysql, query, query_len)) {
RETURN_FALSE;
@@ -125,7 +125,7 @@ PHP_FUNCTION(mysqli_rpl_parse_enabled)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_rpl_parse_enabled(mysql));
}
@@ -141,7 +141,7 @@ PHP_FUNCTION(mysqli_rpl_probe)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
if (mysql_rpl_probe(mysql)) {
@@ -163,7 +163,7 @@ PHP_FUNCTION(mysqli_rpl_query_type)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
RETURN_LONG(mysql_rpl_query_type(query, query_len));
}
@@ -181,7 +181,7 @@ PHP_FUNCTION(mysqli_send_query)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
if (mysql_send_query(mysql, query, query_len)) {
RETURN_FALSE;
@@ -202,7 +202,7 @@ PHP_FUNCTION(mysqli_slave_query)
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
if (mysql_slave_query(mysql, query, query_len)) {
RETURN_FALSE;
+4 -4
View File
@@ -100,7 +100,7 @@ PHP_METHOD(mysqli_warning, next)
return;
}
MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysqli_warning, "mysqli_warning", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysqli_warning, "mysqli_warning");
if (w->next) {
w = w->next;
@@ -182,11 +182,11 @@ PHP_METHOD(mysqli_warning, __construct)
if (obj->zo.ce == mysqli_link_class_entry) {
MY_MYSQL *mysql;
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &z, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &z, "mysqli_link");
hdl = mysql->mysql;
} else if (obj->zo.ce == mysqli_stmt_class_entry) {
MY_STMT *stmt;
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &z, "mysqli_stmt", MYSQLI_STATUS_VALID);
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &z, "mysqli_stmt");
hdl = stmt->stmt->mysql;
} else {
RETURN_FALSE;
@@ -199,13 +199,13 @@ PHP_METHOD(mysqli_warning, __construct)
}
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->status = MYSQLI_STATUS_VALID;
mysqli_resource->ptr = mysqli_resource->info = (void *)w;
if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_warning_class_entry TSRMLS_CC)) {
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
} else {
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
}
+26 -37
View File
@@ -36,20 +36,12 @@
#define HAVE_MYSQLI_SET_CHARSET
#endif
#include <errmsg.h>
#ifndef PHP_MYSQLI_H
#define PHP_MYSQLI_H
#define MYSQLI_VERSION_ID 101009
enum mysqli_status {
MYSQLI_STATUS_UNKNOWN=0,
MYSQLI_STATUS_CLEARED,
MYSQLI_STATUS_INITIALIZED,
MYSQLI_STATUS_VALID
};
#define MYSQLI_VERSION_ID 101008
typedef struct {
ulong buflen;
@@ -65,17 +57,17 @@ typedef struct {
} BIND_BUFFER;
typedef struct {
MYSQL_STMT *stmt;
BIND_BUFFER param;
BIND_BUFFER result;
char *query;
MYSQL_STMT *stmt;
BIND_BUFFER param;
BIND_BUFFER result;
char *query;
} MY_STMT;
typedef struct {
MYSQL *mysql;
zval *li_read;
php_stream *li_stream;
unsigned int multi_query;
MYSQL *mysql;
zval *li_read;
php_stream *li_stream;
unsigned int multi_query;
} MY_MYSQL;
typedef struct {
@@ -85,15 +77,15 @@ typedef struct {
} PROFILER;
typedef struct {
void *ptr; /* resource: (mysql, result, stmt) */
void *info; /* additional buffer */
enum mysqli_status status;
void *ptr; /* resource: (mysql, result, stmt) */
void *info; /* additional buffer */
} MYSQLI_RESOURCE;
typedef struct _mysqli_object {
zend_object zo;
void *ptr;
HashTable *prop_handler;
zend_object zo;
void *ptr;
char valid;
HashTable *prop_handler;
} mysqli_object; /* extends zend_object */
typedef struct {
@@ -118,12 +110,8 @@ typedef struct {
#ifdef PHP_WIN32
#define PHP_MYSQLI_API __declspec(dllexport)
#define MYSQLI_LLU_SPEC "%I64u"
#define MYSQLI_LL_SPEC "%I64d"
#else
#define PHP_MYSQLI_API
#define MYSQLI_LLU_SPEC "%llu"
#define MYSQLI_LL_SPEC "%lld"
#endif
#ifdef ZTS
@@ -193,6 +181,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
#define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval, __ce) \
((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->ptr = __ptr; \
((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->valid = 1;
#define MYSQLI_RETURN_RESOURCE(__ptr, __ce) \
Z_TYPE_P(return_value) = IS_OBJECT; \
@@ -210,7 +199,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
MYSQLI_REGISTER_RESOURCE_EX(__ptr, object, __ce)\
}
#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name, __check) \
#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name) \
{ \
MYSQLI_RESOURCE *my_res; \
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
@@ -218,19 +207,19 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);\
RETURN_NULL();\
}\
if (!intern->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid resource %s", intern->zo.ce->name); \
RETURN_NULL(); \
} \
__ptr = (__type)my_res->ptr; \
if (__check && my_res->status < __check) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name); \
RETURN_NULL();\
if (!strcmp((char *)__name, "mysqli_stmt")) {\
if (!((MY_STMT *)__ptr)->stmt->mysql) {\
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Statement isn't valid anymore");\
RETURN_NULL();\
}\
}\
}
#define MYSQLI_SET_STATUS(__id, __value) \
{ \
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
((MYSQLI_RESOURCE *)intern->ptr)->status = __value; \
} \
#define MYSQLI_CLEAR_RESOURCE(__id) \
{ \
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
-1
View File
@@ -8,7 +8,6 @@ mysqli bind_result 1
/*** test mysqli_connect 127.0.0.1 ***/
$link = mysqli_connect($host, $user, $passwd);
$link->query("CREATE SCHEMA test");
mysqli_select_db($link, "test");
$rc = mysqli_query($link,"DROP TABLE IF EXISTS test_fetch_null");
+3 -2
View File
@@ -2,18 +2,19 @@
mysqli autocommit/commit/rollback
--SKIPIF--
<?php
require_once('skipif.inc');
include "connect.inc";
$link = mysqli_connect($host, $user, $passwd);
$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
mysqli_close($link);
if ($row[1] == "DISABLED" || $row[1] == "NO") {
printf ("skip innodb support is not installed or enabled.");
exit;
}
?>
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include "connect.inc";
+2 -1
View File
@@ -2,7 +2,6 @@
mysqli autocommit/commit/rollback with myisam
--SKIPIF--
<?php
require_once('skipif.inc');
include "connect.inc";
$link = mysqli_connect($host, $user, $passwd);
$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
@@ -14,6 +13,8 @@ mysqli autocommit/commit/rollback with myisam
printf ("skip innodb support not installed.");
}
?>
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include "connect.inc";
+4 -2
View File
@@ -12,13 +12,15 @@ mysqli fetch functions
mysqli_select_db($link, "test");
$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'");
$stmt = mysqli_prepare($link, "SELECT current_user(), database(), 'foo'");
mysqli_bind_result($stmt, $c0, $c1, $c2);
mysqli_execute($stmt);
mysqli_fetch($stmt);
mysqli_stmt_close($stmt);
$c0 = ($c0 == $user . "@" . $host) ? 1 : 0;
$test = array($c0, $c1, $c2);
var_dump($test);
@@ -27,7 +29,7 @@ mysqli fetch functions
--EXPECT--
array(3) {
[0]=>
string(32) "37b51d194a7513e45b56f6524f2d51f2"
int(1)
[1]=>
string(4) "test"
[2]=>
+3 -3
View File
@@ -2,9 +2,6 @@
mysqli_bind_result (SHOW)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
include "connect.inc";
$link = mysqli_connect($host, $user, $passwd);
@@ -18,6 +15,9 @@ mysqli_bind_result (SHOW)
$stmt->close();
mysqli_close($link);
?>
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include "connect.inc";
+4 -6
View File
@@ -11,16 +11,14 @@ mysql_fetch_row (OO-Style)
$mysql = mysqli_connect($host, $user, $passwd);
$mysql->select_db("test");
$result = $mysql->query("SELECT DATABASE()");
$result = $mysql->query("SELECT CURRENT_USER()");
$row = $result->fetch_row();
$result->close();
var_dump($row);
$ok = ($row[0] == $user . "@" . $host);
var_dump($ok);
$mysql->close();
?>
--EXPECT--
array(1) {
[0]=>
string(4) "test"
}
bool(true)
+2 -3
View File
@@ -9,16 +9,15 @@ class DbConnection {
public function connect() {
include "connect.inc";
$link = mysqli_connect($host, $user, $passwd);
$link = mysqli::connect($host, $user, $passwd);
var_dump($link);
$link = mysqli_init();
$link = mysqli::init();
var_dump($link);
$mysql = new mysqli($host, $user, $passwd, "test");
$mysql->query("DROP TABLE IF EXISTS test_warnings");
$mysql->query("CREATE TABLE test_warnings (a int not null)");
$mysql->query("SET sql_mode=''");
$mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)");
var_dump(mysqli_warning::__construct($mysql));
}
-23
View File
@@ -1,23 +0,0 @@
--TEST--
bug #36745 : LOAD DATA LOCAL INFILE doesn't return correct error message
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include ("connect.inc");
/*** test mysqli_connect 127.0.0.1 ***/
$mysql = mysqli_connect($host, $user, $passwd, "test");
$mysql->query("DROP TABLE IF EXISTS litest");
$mysql->query("CREATE TABLE litest (a VARCHAR(20))");
$mysql->query("LOAD DATA LOCAL INFILE 'filenotfound' INTO TABLE litest");
var_dump($mysql->error);
$mysql->close();
printf("Done");
?>
--EXPECT--
string(31) "Can't find file 'filenotfound'."
Done
-42
View File
@@ -1,42 +0,0 @@
--TEST--
bug #36802 : crashes with mysql_init
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
class my_mysqli extends mysqli {
function __construct()
{
}
}
include "connect.inc";
$mysql = mysqli_init();
/* following operations should not work */
$x[0] = @$mysql->set_charset('utf8');
$x[1] = @$mysql->query("SELECT 'foo' FROM DUAL");
/* following operations should work */
$x[2] = ($mysql->client_version > 0);
$x[3] = $mysql->errno;
$mysql->close();
var_dump($x);
?>
--EXPECT--
array(4) {
[0]=>
NULL
[1]=>
NULL
[2]=>
bool(true)
[3]=>
int(0)
}
+2 -4
View File
@@ -10,16 +10,14 @@
$passwd = "";
} else {
$path = dirname(__FILE__);
$host = ":embedded";
$user = $passwd = NULL;
$host = $user = $passwd = NULL;
$args = array(
"--datadir=$path",
"--innodb_data_home_dir=$path",
"--innodb_data_file_path=ibdata1:10M:autoextend",
"--log-error=$path/testrun.log"
);
$x = $driver->embedded_server_start(TRUE, $args, NULL);
var_dump($x);
$driver->embedded_server_start(TRUE, $args, NULL);
}
?>
-9
View File
@@ -232,13 +232,6 @@ if test "$PHP_OCI8" != "no" && test "$PHP_OCI8_INSTANT_CLIENT" = "no"; then
], [], [
-L$OCI8_DIR/$OCI8_LIB_DIR $OCI8_SHARED_LIBADD
])
PHP_CHECK_LIBRARY(clntsh, OCILobRead2,
[
AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ])
], [], [
-L$OCI8_DIR/$OCI8_LIB_DIR $OCI8_SHARED_LIBADD
])
;;
@@ -249,7 +242,6 @@ if test "$PHP_OCI8" != "no" && test "$PHP_OCI8_INSTANT_CLIENT" = "no"; then
AC_DEFINE(HAVE_OCI_ENV_NLS_CREATE,1,[ ])
AC_DEFINE(HAVE_OCI_ENV_CREATE,1,[ ])
AC_DEFINE(HAVE_OCI_STMT_PREPARE2,1,[ ])
AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ])
AC_DEFINE(HAVE_OCI8_TEMP_LOB,1,[ ])
AC_DEFINE(PHP_OCI8_HAVE_COLLECTIONS,1,[ ])
;;
@@ -362,7 +354,6 @@ dnl Header directory for manual installation
AC_DEFINE(HAVE_OCI_ENV_NLS_CREATE,1,[ ])
AC_DEFINE(HAVE_OCI_ENV_CREATE,1,[ ])
AC_DEFINE(HAVE_OCI_STMT_PREPARE2,1,[ ])
AC_DEFINE(HAVE_OCI_LOB_READ2,1,[ ])
AC_DEFINE(HAVE_OCI8_TEMP_LOB,1,[ ])
AC_DEFINE(PHP_OCI8_HAVE_COLLECTIONS,1,[ ])
+2 -7
View File
@@ -11,14 +11,9 @@ if (PHP_OCI8 != "no") {
) {
EXTENSION('oci8', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c');
AC_DEFINE('HAVE_OCI8', 1);
AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1);
AC_DEFINE('HAVE_OCI8_ATTR_STATEMENT', 1);
AC_DEFINE('HAVE_OCI_ENV_NLS_CREATE', 1);
AC_DEFINE('HAVE_OCI_ENV_CREATE', 1);
AC_DEFINE('HAVE_OCI_STMT_PREPARE2', 1);
AC_DEFINE('HAVE_OCI_LOB_READ2', 1);
AC_DEFINE('HAVE_OCI8_TEMP_LOB', 1);
AC_DEFINE('HAVE_OCI8', 1);
AC_DEFINE('HAVE_OCI8_ATTR_STATEMENT', 1);
AC_DEFINE('PHP_OCI8_HAVE_COLLECTIONS', 1);
} else {
+2 -10
View File
@@ -541,8 +541,6 @@ PHP_MINIT_FUNCTION(oci)
REGISTER_LONG_CONSTANT("SQLT_FLT",SQLT_FLT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_UIN",SQLT_UIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_LNG",SQLT_LNG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_LBI",SQLT_LBI, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_BIN",SQLT_BIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_ODT",SQLT_ODT, CONST_CS | CONST_PERSISTENT);
#if defined(HAVE_OCI_INSTANT_CLIENT) || (defined(OCI_MAJOR_VERSION) && OCI_MAJOR_VERSION > 10)
REGISTER_LONG_CONSTANT("SQLT_BDOUBLE",SQLT_BDOUBLE, CONST_CS | CONST_PERSISTENT);
@@ -1058,9 +1056,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
/* okay, the connection is open and the server is still alive */
connection->used_this_request = 1;
smart_str_free_ex(&hashed_details, 0);
if (zend_list_addref(connection->rsrc_id) == FAILURE) {
connection->rsrc_id = zend_list_insert(connection, le_pconnection);
}
connection->rsrc_id = zend_list_insert(connection, le_pconnection);
return connection;
}
}
@@ -1290,11 +1286,7 @@ open:
case OCI_SYSDBA:
case OCI_SYSOPER:
default:
if (username_len == 1 && username[0] == '/' && password_len == 0) {
OCI_G(errcode) = PHP_OCI_CALL(OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) OCI_CRED_EXT, (ub4) session_mode));
} else {
OCI_G(errcode) = PHP_OCI_CALL(OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) OCI_CRED_RDBMS, (ub4) session_mode));
}
OCI_G(errcode) = PHP_OCI_CALL(OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) OCI_CRED_EXT, (ub4) session_mode));
break;
}
+7 -7
View File
@@ -1191,7 +1191,7 @@ PHP_FUNCTION(oci_field_type)
RETVAL_STRING("LONG RAW",1);
break;
case SQLT_CHR:
RETVAL_STRING("VARCHAR2",1);
RETVAL_STRING("VARCHAR",1);
break;
case SQLT_RSET:
RETVAL_STRING("REFCURSOR",1);
@@ -1439,7 +1439,7 @@ PHP_FUNCTION(oci_fetch_all)
Fetch a result row as an object */
PHP_FUNCTION(oci_fetch_object)
{
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_ASSOC | PHP_OCI_RETURN_NULLS, 2);
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_ASSOC, 2);
if (Z_TYPE_P(return_value) == IS_ARRAY) {
object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value));
@@ -1451,7 +1451,7 @@ PHP_FUNCTION(oci_fetch_object)
Fetch a result row as an enumerated array */
PHP_FUNCTION(oci_fetch_row)
{
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_NUM | PHP_OCI_RETURN_NULLS, 1);
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_NUM, 1);
}
/* }}} */
@@ -1459,7 +1459,7 @@ PHP_FUNCTION(oci_fetch_row)
Fetch a result row as an associative array */
PHP_FUNCTION(oci_fetch_assoc)
{
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_ASSOC | PHP_OCI_RETURN_NULLS, 1);
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_ASSOC, 1);
}
/* }}} */
@@ -1467,7 +1467,7 @@ PHP_FUNCTION(oci_fetch_assoc)
Fetch a result row as an array */
PHP_FUNCTION(oci_fetch_array)
{
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_BOTH | PHP_OCI_RETURN_NULLS, 2);
php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_BOTH, 2);
}
/* }}} */
@@ -1521,7 +1521,7 @@ PHP_FUNCTION(oci_new_connect)
}
/* }}} */
/* {{{ proto resource oci_connect(string user, string pass [, string db [, string charset [, int session_mode ]])
/* {{{ proto resource oci_connect(string user, string pass [, string db])
Connect to an Oracle database and log on. Returns a new session. */
PHP_FUNCTION(oci_connect)
{
@@ -1529,7 +1529,7 @@ PHP_FUNCTION(oci_connect)
}
/* }}} */
/* {{{ proto resource oci_pconnect(string user, string pass [, string db [, string charset ]])
/* {{{ proto resource oci_pconnect(string user, string pass [, string db])
Connect to an Oracle database using a persistent connection and log on. Returns a new session. */
PHP_FUNCTION(oci_pconnect)
{
+17 -72
View File
@@ -150,11 +150,9 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
{
php_oci_connection *connection = descriptor->connection;
ub4 length = 0;
int bytes_read, bytes_total = 0, offset = 0;
ub4 block_length = PHP_OCI_LOB_BUFFER_SIZE;
int bytes_read, bytes_total = 0, offset = 0, data_len_chars = 0;
int requested_len = read_length; /* this is by default */
#if defined(HAVE_OCI_LOB_READ2)
int chars_read = 0, is_clob = 0;
#endif
*data_len = 0;
*data = NULL;
@@ -180,10 +178,14 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
requested_len = length - initial_offset;
}
if (requested_len <= 0) {
if (requested_len == 0) {
return 0;
}
if (requested_len < block_length) {
block_length = requested_len;
}
if (descriptor->type == OCI_DTYPE_FILE) {
connection->errcode = PHP_OCI_CALL(OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY));
@@ -193,71 +195,11 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
return 1;
}
}
#ifdef HAVE_OCI_LOB_READ2
else {
ub2 charset_id = 0;
connection->errcode = PHP_OCI_CALL(OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id));
if (connection->errcode != OCI_SUCCESS) {
php_oci_error(connection->err, connection->errcode TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
return 1;
}
if (charset_id > 0) { /* charset_id is always > 0 for [N]CLOBs */
is_clob = 1;
}
}
#endif
*data = (char *)emalloc(requested_len + 1);
bytes_read = requested_len;
*data = (char *)emalloc(block_length + 1);
bytes_read = block_length;
offset = initial_offset;
/* TODO
* We need to make sure this function works with Unicode LOBs
* */
#if defined(HAVE_OCI_LOB_READ2)
do {
chars_read = 0;
connection->errcode = PHP_OCI_CALL(OCILobRead2,
(
connection->svc,
connection->err,
descriptor->descriptor,
(oraub8 *)&bytes_read, /* IN/OUT bytes toread/read */
(oraub8 *)&chars_read,
(oraub8) offset + 1, /* offset (starts with 1) */
(dvoid *) ((char *) *data + *data_len),
(oraub8) requested_len, /* size of buffer */
0,
NULL,
(OCICallbackLobRead2) 0, /* callback... */
(ub2) connection->charset, /* The character set ID of the buffer data. */
(ub1) SQLCS_IMPLICIT /* The character set form of the buffer data. */
)
);
bytes_total += bytes_read;
if (is_clob) {
offset += chars_read;
} else {
offset += bytes_read;
}
*data_len += bytes_read;
if (connection->errcode != OCI_NEED_DATA) {
break;
}
*data = erealloc(*data, *data_len + PHP_OCI_LOB_BUFFER_SIZE + 1);
} while (connection->errcode == OCI_NEED_DATA);
#else
do {
connection->errcode = PHP_OCI_CALL(OCILobRead,
(
@@ -267,7 +209,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
&bytes_read, /* IN/OUT bytes toread/read */
offset + 1, /* offset (starts with 1) */
(dvoid *) ((char *) *data + *data_len),
requested_len, /* size of buffer */
block_length, /* size of buffer */
(dvoid *)0,
(OCICallbackLobRead) 0, /* callback... */
(ub2) connection->charset, /* The character set ID of the buffer data. */
@@ -276,9 +218,14 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
);
bytes_total += bytes_read;
offset += bytes_read;
/*
* Oracle doesn't tell use how many CHARS were read,
* so we have to count them to get the correct offset for CLOBS */
data_len_chars = OCIMultiByteStrnDisplayLength(connection->env, *data, bytes_total);
offset = initial_offset + data_len_chars;
*data_len += bytes_read;
block_length = PHP_OCI_LOB_BUFFER_SIZE;
if (connection->errcode != OCI_NEED_DATA) {
break;
@@ -286,8 +233,6 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
*data = erealloc(*data, *data_len + PHP_OCI_LOB_BUFFER_SIZE + 1);
} while (connection->errcode == OCI_NEED_DATA);
#endif
if (connection->errcode != OCI_SUCCESS) {
php_oci_error(connection->err, connection->errcode TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
@@ -296,7 +241,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
return 1;
}
descriptor->lob_current_position = offset;
descriptor->lob_current_position += data_len_chars;
if (descriptor->type == OCI_DTYPE_FILE) {
connection->errcode = PHP_OCI_CALL(OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor));
Loaded 100 of 354 files, more files were not shown because too many files have changed in this diff. Show more