Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5

This commit is contained in:
Pierre Joye 2013-04-10 20:15:03 +02:00
commit 6ea7e6da8b
6 changed files with 68 additions and 4 deletions

View File

@ -613,6 +613,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
COPY_NODE(opline->op2, src->op1);
MAKE_NOP(src);
#if ZEND_EXTENSION_API_NO >= PHP_5_4_X_API_NO
/* numeric string constants used as array indeces have to be
converted to long at compile time */
if (opline->opcode == ZEND_ADD_ARRAY_ELEMENT ||
@ -652,6 +653,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
}
}
}
#endif
}
/* T = PRINT(X), F(T) => ECHO(X), F(1) */

View File

@ -151,13 +151,13 @@ opcache.dups_fix (default "0")
Enable this hack as a workaround for "Cannot redeclare class" errors.
opcache.blacklist_filename
The location of the OPcache blacklist file.
The OPcache blacklist file is a text file that holds the names of files
The location of the OPcache blacklist file (wildcards allowed).
Each OPcache blacklist file is a text file that holds the names of files
that should not be accelerated. The file format is to add each filename
to a new line. The filename may be a full path or just a file prefix
(i.e., /var/www/x blacklists all the files and directories in /var/www
that start with 'x'). Files are usually triggered by one of the following
three reasons:
that start with 'x'). Line starting with a ; are ignored (comments).
Files are usually triggered by one of the following three reasons:
1) Directories that contain auto generated code, like Smarty or ZFW cache.
2) Code that does not work well when accelerated, due to some delayed
compile time evaluation.

View File

@ -0,0 +1,20 @@
--TEST--
Blacklist (with glob, quote and comments)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.blacklist_filename={PWD}/opcache-*.blacklist
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$conf = opcache_get_configuration();
print_r($conf['blacklist']);
?>
--EXPECT--
Array
(
[0] => /path/to/foo
[1] => /path/to/foo2
[2] => /path/to/bar
)

View File

@ -0,0 +1,5 @@
; comments are allowed in blacklist file
; and empty line are ignored
/path/to/foo
"/path/to/foo2"

View File

@ -0,0 +1 @@
/path/to/bar

View File

@ -36,6 +36,14 @@
# define REGEX_MODE (REG_EXTENDED|REG_NOSUB)
#endif
#ifdef HAVE_GLOB
#ifdef PHP_WIN32
#include "win32/glob.h"
#else
#include <glob.h>
#endif
#endif
#define ZEND_BLACKLIST_BLOCK_SIZE 32
struct _zend_regexp_list {
@ -168,7 +176,11 @@ static inline void zend_accel_blacklist_allocate(zend_blacklist *blacklist)
}
}
#ifdef HAVE_GLOB
static void zend_accel_blacklist_loadone(zend_blacklist *blacklist, char *filename)
#else
void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
#endif
{
char buf[MAXPATHLEN + 1], real_path[MAXPATHLEN + 1];
FILE *fp;
@ -238,6 +250,30 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
zend_accel_blacklist_update_regexp(blacklist);
}
#ifdef HAVE_GLOB
void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
{
glob_t globbuf;
int ret, i;
memset(&globbuf, 0, sizeof(glob_t));
ret = glob(filename, 0, NULL, &globbuf);
#ifdef GLOB_NOMATCH
if (ret == GLOB_NOMATCH || !globbuf.gl_pathc) {
#else
if (!globbuf.gl_pathc) {
#endif
zend_accel_error(ACCEL_LOG_WARNING, "No blacklist file found matching: %s\n", filename);
} else {
for(i=0 ; i<globbuf.gl_pathc; i++) {
zend_accel_blacklist_loadone(blacklist, globbuf.gl_pathv[i]);
}
globfree(&globbuf);
}
}
#endif
zend_bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path)
{
int ret = 0;