mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'master' into sccp
* master:
Fixed memory leak introduced by 7cb5bdf64a
eliminate casts
remove checks for eol dependencies
improve test
Small fix in ext/ldap, Moved vars definitions to the beginning of the block using them
ZipArchive implements countable, added ZipArchive::count() method
This commit is contained in:
3
NEWS
3
NEWS
@@ -49,6 +49,9 @@ PHP NEWS
|
||||
. Fixed bug #74883 (SQLite3::__construct() produces "out of memory" exception
|
||||
with invalid flags). (Anatol)
|
||||
|
||||
- ZIP:
|
||||
. ZipArchive implements countable, added ZipArchive::count() method. (Remi)
|
||||
|
||||
06 Jul 2017, PHP 7.2.0alpha3
|
||||
|
||||
- Core:
|
||||
|
||||
@@ -143,6 +143,8 @@ PHP 7.2 UPGRADE NOTES
|
||||
ZipArchive::EM_AES_192
|
||||
ZipArchive::EM_AES_256
|
||||
. accept 'password' from zip stream context
|
||||
. ZipArchive implements countable, added ZipArchive::count() method.
|
||||
|
||||
|
||||
========================================
|
||||
3. Changes in SAPI modules
|
||||
|
||||
@@ -2199,8 +2199,6 @@ PHP_FUNCTION(ldap_sort)
|
||||
PHP_FUNCTION(ldap_get_option)
|
||||
{
|
||||
zval *link, *retval;
|
||||
zval tmp1;
|
||||
int num_entries;
|
||||
ldap_linkdata *ld;
|
||||
zend_long option;
|
||||
|
||||
@@ -2348,6 +2346,8 @@ PHP_FUNCTION(ldap_get_option)
|
||||
case LDAP_OPT_SERVER_CONTROLS:
|
||||
case LDAP_OPT_CLIENT_CONTROLS:
|
||||
{
|
||||
zval tmp1;
|
||||
int num_entries;
|
||||
LDAPControl **ctrls = NULL, **ctrlp;
|
||||
|
||||
if (ldap_get_option(ld->link, option, &ctrls) || ctrls == NULL) {
|
||||
|
||||
@@ -22,16 +22,6 @@ if (PHP_PDO_DBLIB != "no") {
|
||||
ARG_WITH("pdo-mssql", "Native MS-SQL support for PDO", "no");
|
||||
|
||||
if (PHP_PDO_MSSQL != "no") {
|
||||
/* if they pointed us to a freetds dir, pick that up,
|
||||
* otherwise we'll poke around and look for MSSQL libs */
|
||||
|
||||
pdo_mssql_locations = new Array(
|
||||
PHP_PDO_MSSQL,
|
||||
"\\Program Files\\Microsoft SQL Server\\80",
|
||||
"\\MSSQL8",
|
||||
"\\MSSQL7",
|
||||
PHP_PHP_BUILD + "\\MSSQL80"
|
||||
);
|
||||
PDO_DBLIB_FLAVOUR = 0;
|
||||
|
||||
if (CHECK_LIB("sybdb.lib", "pdo_mssql", PHP_PDO_MSSQL) &&
|
||||
@@ -39,35 +29,14 @@ if (PHP_PDO_MSSQL != "no") {
|
||||
PHP_PDO_MSSQL, null, null, true)) {
|
||||
/* smells like FreeTDS (or maybe native sybase dblib) */
|
||||
PDO_DBLIB_FLAVOUR = "freetds";
|
||||
} else {
|
||||
|
||||
for (i = 0; i < pdo_mssql_locations.length; i++) {
|
||||
if (CHECK_LIB("ntwdblib.lib", "pdo_mssql",
|
||||
pdo_mssql_locations[i] + "\\DevTools\\Lib") &&
|
||||
CHECK_HEADER_ADD_INCLUDE("sqlfront.h", "CFLAGS_PDO_MSSQL",
|
||||
pdo_mssql_locations[i] + "\\DevTools\\Include",
|
||||
null, null, true)) {
|
||||
if (pdo_mssql_locations[i] == 'yes') {
|
||||
PDO_DBLIB_FLAVOUR = 70;
|
||||
} else {
|
||||
pdo_mssql_locations[i].match(new RegExp("(\\d)"));
|
||||
PDO_DBLIB_FLAVOUR = RegExp.$1 + 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PDO_DBLIB_FLAVOUR != 0) {
|
||||
EXTENSION("pdo_mssql", "pdo_dblib.c dblib_driver.c dblib_stmt.c", null, null, null, "ext\\pdo_mssql");
|
||||
if (PDO_DBLIB_FLAVOUR != "freetds") {
|
||||
ADD_FLAG("CFLAGS_PDO_MSSQL", "/DPHP_DBLIB_IS_MSSQL=1 /DDBNTWIN32=1 /DMSSQL" + PDO_DBLIB_FLAVOUR + "0=1 /DMSSQL_VERSION=\\\"" + PDO_DBLIB_FLAVOUR + ".0\\\"");
|
||||
ADD_FLAG("CFLAGS_PDO_MSSQL", "/DPDO_DBLIB_IS_MSSQL=" + PDO_DBLIB_FLAVOUR);
|
||||
PDO_DBLIB_FLAVOUR = "MSSQL_" + PDO_DBLIB_FLAVOUR;
|
||||
}
|
||||
ADD_FLAG('CFLAGS_PDO_MSSQL', "/D PDO_DBLIB_FLAVOUR=\\\"" + PDO_DBLIB_FLAVOUR + "\\\"");
|
||||
ADD_EXTENSION_DEP('pdo_mssql', 'pdo');
|
||||
} else {
|
||||
WARNING("pdo_mssql not enabled, libraries or headers not found")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,16 @@ $p = proc_open(
|
||||
array("bypass_shell" => true)
|
||||
);
|
||||
|
||||
echo fread($pipes[1], 1024);
|
||||
$out = "";
|
||||
|
||||
while (!feof($pipes[1])) {
|
||||
$out .= fread($pipes[1], 1024);
|
||||
}
|
||||
|
||||
proc_close($p);
|
||||
|
||||
echo $out;
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
|
||||
@@ -26,10 +26,16 @@ $p = proc_open(
|
||||
$pipes
|
||||
);
|
||||
|
||||
echo fread($pipes[1], 1024);
|
||||
$out = "";
|
||||
|
||||
while (!feof($pipes[1])) {
|
||||
$out .= fread($pipes[1], 1024);
|
||||
}
|
||||
|
||||
proc_close($p);
|
||||
|
||||
echo $out;
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECTF--
|
||||
|
||||
@@ -391,7 +391,7 @@ static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTab
|
||||
ZVAL_UNDEF(&key);
|
||||
|
||||
if (!php_var_unserialize_internal(&key, p, max, NULL)) {
|
||||
zval_dtor(&key);
|
||||
zval_ptr_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ numeric_key:
|
||||
data = zend_hash_add_new(ht, Z_STR(key), &d);
|
||||
}
|
||||
} else {
|
||||
zval_dtor(&key);
|
||||
zval_ptr_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -435,7 +435,7 @@ string_key:
|
||||
size_t unmangled_prop_len;
|
||||
|
||||
if (UNEXPECTED(zend_unmangle_property_name_ex(Z_STR(key), &unmangled_class, &unmangled_prop, &unmangled_prop_len) == FAILURE)) {
|
||||
zval_dtor(&key);
|
||||
zval_ptr_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ string_key:
|
||||
new_key = unmangled;
|
||||
}
|
||||
zend_string_release(Z_STR(key));
|
||||
Z_STR(key) = new_key;
|
||||
ZVAL_STR(&key, new_key);
|
||||
} else {
|
||||
zend_string_release(unmangled);
|
||||
}
|
||||
@@ -485,13 +485,13 @@ string_key:
|
||||
convert_to_string(&key);
|
||||
goto string_key;
|
||||
} else {
|
||||
zval_dtor(&key);
|
||||
zval_ptr_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!php_var_unserialize_internal(data, p, max, var_hash)) {
|
||||
zval_dtor(&key);
|
||||
zval_ptr_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ string_key:
|
||||
var_push_dtor(var_hash, data);
|
||||
}
|
||||
|
||||
zval_dtor(&key);
|
||||
zval_ptr_dtor(&key);
|
||||
|
||||
if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
|
||||
(*p)--;
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
#include "ext/standard/php_string.h"
|
||||
#include "ext/pcre/php_pcre.h"
|
||||
#include "ext/standard/php_filestat.h"
|
||||
#if PHP_VERSION_ID >= 70200
|
||||
#include "zend_interfaces.h"
|
||||
#elif defined(HAVE_SPL)
|
||||
#include "ext/spl/spl_iterators.h"
|
||||
#endif
|
||||
#include "php_zip.h"
|
||||
|
||||
/* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */
|
||||
@@ -1548,6 +1553,23 @@ static ZIPARCHIVE_METHOD(close)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool ZipArchive::count()
|
||||
close the zip archive */
|
||||
static ZIPARCHIVE_METHOD(count)
|
||||
{
|
||||
struct zip *intern;
|
||||
zval *self = getThis();
|
||||
|
||||
if (!self) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZIP_FROM_OBJECT(intern, self);
|
||||
|
||||
RETVAL_LONG(zip_get_num_files(intern));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ZipArchive::getStatusString()
|
||||
* Returns the status error message, system and/or zip messages */
|
||||
static ZIPARCHIVE_METHOD(getStatusString)
|
||||
@@ -3069,6 +3091,7 @@ static const zend_function_entry zip_class_functions[] = {
|
||||
ZIPARCHIVE_ME(open, arginfo_ziparchive_open, ZEND_ACC_PUBLIC)
|
||||
ZIPARCHIVE_ME(setPassword, arginfo_ziparchive_setpassword, ZEND_ACC_PUBLIC)
|
||||
ZIPARCHIVE_ME(close, arginfo_ziparchive__void, ZEND_ACC_PUBLIC)
|
||||
ZIPARCHIVE_ME(count, arginfo_ziparchive__void, ZEND_ACC_PUBLIC)
|
||||
ZIPARCHIVE_ME(getStatusString, arginfo_ziparchive__void, ZEND_ACC_PUBLIC)
|
||||
ZIPARCHIVE_ME(addEmptyDir, arginfo_ziparchive_addemptydir, ZEND_ACC_PUBLIC)
|
||||
ZIPARCHIVE_ME(addFromString, arginfo_ziparchive_addfromstring, ZEND_ACC_PUBLIC)
|
||||
@@ -3141,6 +3164,11 @@ static PHP_MINIT_FUNCTION(zip)
|
||||
php_zip_register_prop_handler(&zip_prop_handlers, "numFiles", php_zip_get_num_files, NULL, NULL, IS_LONG);
|
||||
php_zip_register_prop_handler(&zip_prop_handlers, "filename", NULL, NULL, php_zipobj_get_filename, IS_STRING);
|
||||
php_zip_register_prop_handler(&zip_prop_handlers, "comment", NULL, php_zipobj_get_zip_comment, NULL, IS_STRING);
|
||||
#if PHP_VERSION_ID >= 70200
|
||||
zend_class_implements(zip_class_entry, 1, zend_ce_countable);
|
||||
#elif defined(HAVE_SPL)
|
||||
zend_class_implements(zip_class_entry, 1, spl_ce_Countable);
|
||||
#endif
|
||||
|
||||
REGISTER_ZIP_CLASS_CONST_LONG("CREATE", ZIP_CREATE);
|
||||
REGISTER_ZIP_CLASS_CONST_LONG("EXCL", ZIP_EXCL);
|
||||
|
||||
@@ -37,7 +37,7 @@ extern zend_module_entry zip_module_entry;
|
||||
#define ZIP_OVERWRITE ZIP_TRUNCATE
|
||||
#endif
|
||||
|
||||
#define PHP_ZIP_VERSION "1.14.0"
|
||||
#define PHP_ZIP_VERSION "1.15.0"
|
||||
|
||||
#define ZIP_OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename)
|
||||
|
||||
|
||||
26
ext/zip/tests/oo_count.phpt
Normal file
26
ext/zip/tests/oo_count.phpt
Normal file
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
ziparchive::count()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
/* $Id$ */
|
||||
if(!extension_loaded('zip')) die('skip');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$dirname = dirname(__FILE__) . '/';
|
||||
$file = $dirname . 'test.zip';
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if (!$zip->open($file)) {
|
||||
exit('failed');
|
||||
}
|
||||
|
||||
var_dump($zip->numFiles, count($zip), $zip->numFiles == count($zip));
|
||||
?>
|
||||
Done
|
||||
--EXPECTF--
|
||||
int(4)
|
||||
int(4)
|
||||
bool(true)
|
||||
Done
|
||||
@@ -1229,8 +1229,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
|
||||
/* we look for directory separator from the end of string, thus hopefuly reducing our work load */
|
||||
char *e;
|
||||
zend_stat_t sb;
|
||||
int dir_len = (int)strlen(dir);
|
||||
int offset = 0;
|
||||
size_t dir_len = strlen(dir), offset = 0;
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
if (!expand_filepath_with_mode(dir, buf, NULL, 0, CWD_EXPAND )) {
|
||||
@@ -1438,7 +1437,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(const char *filename, const char
|
||||
const char *ptr;
|
||||
char trypath[MAXPATHLEN];
|
||||
php_stream *stream;
|
||||
int filename_length;
|
||||
size_t filename_length;
|
||||
zend_string *exec_filename;
|
||||
|
||||
if (opened_path) {
|
||||
@@ -1449,7 +1448,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(const char *filename, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
filename_length = (int)strlen(filename);
|
||||
filename_length = strlen(filename);
|
||||
#ifndef PHP_WIN32
|
||||
(void) filename_length;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user