diff options
-rw-r--r-- | opcache-blacklist.patch | 178 | ||||
-rw-r--r-- | opcache-default.blacklist | 11 | ||||
-rw-r--r-- | opcache.ini | 11 | ||||
-rw-r--r-- | php-pecl-zendopcache-dev.spec | 21 | ||||
-rw-r--r-- | php-pecl-zendopcache.spec | 21 |
5 files changed, 231 insertions, 11 deletions
diff --git a/opcache-blacklist.patch b/opcache-blacklist.patch new file mode 100644 index 0000000..2bfda57 --- /dev/null +++ b/opcache-blacklist.patch @@ -0,0 +1,178 @@ +From dc416b995f4560f73558d2567c7c45b665b58685 Mon Sep 17 00:00:00 2001 +From: Dmitry Stogov <dmitry@zend.com> +Date: Tue, 9 Apr 2013 10:51:19 +0400 +Subject: [PATCH] Fixed issue #82 (allow comments in blacklist file, lines + started with ";") + +--- + zend_accelerator_blacklist.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/zend_accelerator_blacklist.c b/zend_accelerator_blacklist.c +index 0ccd62e..764c950 100644 +--- a/zend_accelerator_blacklist.c ++++ b/zend_accelerator_blacklist.c +@@ -212,6 +212,11 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) + continue; + } + ++ /* skip comments */ ++ if (pbuf[0]==';') { ++ continue; ++ } ++ + path_dup = zend_strndup(pbuf, path_length); + expand_filepath(path_dup, real_path TSRMLS_CC); + path_length = strlen(real_path); +-- +1.8.1.5 + +From f80a5538063f470d7c42b386a357d47794108a74 Mon Sep 17 00:00:00 2001 +From: Dmitry Stogov <dmitry@zend.com> +Date: Wed, 10 Apr 2013 21:41:30 +0400 +Subject: [PATCH] Allow wilcards in opcache.blacklist_filename + +--- + README | 8 ++++---- + tests/blacklist.phpt | 20 ++++++++++++++++++++ + tests/opcache-1.blacklist | 5 +++++ + tests/opcache-2.blacklist | 1 + + zend_accelerator_blacklist.c | 36 ++++++++++++++++++++++++++++++++++++ + 5 files changed, 66 insertions(+), 4 deletions(-) + create mode 100644 tests/blacklist.phpt + create mode 100644 tests/opcache-1.blacklist + create mode 100644 tests/opcache-2.blacklist + +diff --git a/README b/README +index 03386a0..3110012 100644 +--- a/README ++++ b/README +@@ -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. +diff --git a/tests/blacklist.phpt b/tests/blacklist.phpt +new file mode 100644 +index 0000000..f4a3472 +--- /dev/null ++++ b/tests/blacklist.phpt +@@ -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 ++) +\ No newline at end of file +diff --git a/tests/opcache-1.blacklist b/tests/opcache-1.blacklist +new file mode 100644 +index 0000000..5f498d6 +--- /dev/null ++++ b/tests/opcache-1.blacklist +@@ -0,0 +1,5 @@ ++; comments are allowed in blacklist file ++; and empty line are ignored ++ ++/path/to/foo ++"/path/to/foo2" +\ No newline at end of file +diff --git a/tests/opcache-2.blacklist b/tests/opcache-2.blacklist +new file mode 100644 +index 0000000..4f6580a +--- /dev/null ++++ b/tests/opcache-2.blacklist +@@ -0,0 +1 @@ ++/path/to/bar +diff --git a/zend_accelerator_blacklist.c b/zend_accelerator_blacklist.c +index 764c950..b09d0e5 100644 +--- a/zend_accelerator_blacklist.c ++++ b/zend_accelerator_blacklist.c +@@ -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; +-- +1.8.1.5 + diff --git a/opcache-default.blacklist b/opcache-default.blacklist new file mode 100644 index 0000000..0cc2e18 --- /dev/null +++ b/opcache-default.blacklist @@ -0,0 +1,11 @@ +; The 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'). 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. +; 3) Code that triggers an OPcache bug. + diff --git a/opcache.ini b/opcache.ini index 4498e68..ef6e0e0 100644 --- a/opcache.ini +++ b/opcache.ini @@ -60,13 +60,10 @@ opcache.fast_shutdown=1 ;opcache.inherited_hack=1 ;opcache.dups_fix=0 -; The location of the OPcache blacklist file. -; The 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'). -;opcache.blacklist_filename= +; 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. +opcache.blacklist_filename=/etc/php.d/opcache*.blacklist ; Allows exclusion of large files from being cached. By default all files ; are cached. diff --git a/php-pecl-zendopcache-dev.spec b/php-pecl-zendopcache-dev.spec index 64fc764..4812c91 100644 --- a/php-pecl-zendopcache-dev.spec +++ b/php-pecl-zendopcache-dev.spec @@ -9,7 +9,7 @@ Name: php-pecl-%{pecl_name} Version: 7.0.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: The Zend OPcache Group: Development/Libraries @@ -23,6 +23,11 @@ Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz # this extension must be loaded before XDebug # So "opcache" if before "xdebug" Source1: %{plug_name}.ini +Source2: %{plug_name}-default.blacklist + +# Allow comments in blacklist content +# Allow wildcard in blacklist filename +Patch0: %{plug_name}-blacklist.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: php-devel >= 5.2.0 @@ -69,12 +74,16 @@ sed -e '/release/s/7.0.0/%{version}%{prever}/' \ mv %{pecl_name}-%{version} NTS %endif +cd NTS +%patch0 -p1 -b .blacklist + # Sanity check, really often broken -extver=$(sed -n '/#define ACCELERATOR_VERSION/{s/.* "//;s/".*$//;p}' NTS/ZendAccelerator.h) +extver=$(sed -n '/#define ACCELERATOR_VERSION/{s/.* "//;s/".*$//;p}' ZendAccelerator.h) if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then : Error: Upstream extension version is ${extver}, expecting %{version}%{?prever:-%{prever}}. exit 1 fi +cd .. # Duplicate source tree for NTS / ZTS build cp -pr NTS ZTS @@ -111,6 +120,9 @@ sed -e 's:@EXTPATH@:%{php_ztsextdir}:' \ make -C ZTS install INSTALL_ROOT=%{buildroot} +# The default Zend OPcache blacklist file +install -D -p -m 644 %{SOURCE2} %{buildroot}%{php_inidir}/%{plug_name}-default.blacklist + # Install XML package description install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml @@ -156,6 +168,7 @@ fi %files %defattr(-,root,root,-) %doc NTS/{LICENSE,README} +%config(noreplace) %{php_inidir}/%{plug_name}-default.blacklist %config(noreplace) %{php_inidir}/%{plug_name}.ini %{php_extdir}/%{plug_name}.so @@ -166,6 +179,10 @@ fi %changelog +* Thu Apr 11 2013 Remi Collet <rcollet@redhat.com> - 7.0.1-2 +- allow wildcard in opcache.blacklist_filename and provide + default /etc/php.d/opcache-default.blacklist + * Mon Mar 25 2013 Remi Collet <remi@fedoraproject.org> - 7.0.1-1 - official PECL release, version 7.0.1 (beta) - rename to php-pecl-zendopcache diff --git a/php-pecl-zendopcache.spec b/php-pecl-zendopcache.spec index a26ed21..c09c252 100644 --- a/php-pecl-zendopcache.spec +++ b/php-pecl-zendopcache.spec @@ -8,7 +8,7 @@ Name: php-pecl-%{pecl_name} Version: 7.0.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: The Zend OPcache Group: Development/Libraries @@ -18,6 +18,11 @@ Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz # this extension must be loaded before XDebug # So "opcache" if before "xdebug" Source1: %{plug_name}.ini +Source2: %{plug_name}-default.blacklist + +# Allow comments in blacklist content +# Allow wildcard in blacklist filename +Patch0: %{plug_name}-blacklist.patch BuildRequires: php-devel >= 5.2.0 BuildRequires: php-pear @@ -54,12 +59,16 @@ bytecode optimization patterns that make code execution faster. %setup -q -c mv %{pecl_name}-%{version} NTS +cd NTS +%patch0 -p1 -b .blacklist + # Sanity check, really often broken -extver=$(sed -n '/#define ACCELERATOR_VERSION/{s/.* "//;s/".*$//;p}' NTS/ZendAccelerator.h) +extver=$(sed -n '/#define ACCELERATOR_VERSION/{s/.* "//;s/".*$//;p}' ZendAccelerator.h) if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then : Error: Upstream extension version is ${extver}, expecting %{version}%{?prever:-%{prever}}. exit 1 fi +cd .. %if %{with_zts} # Duplicate source tree for NTS / ZTS build @@ -100,6 +109,9 @@ sed -e 's:@EXTPATH@:%{php_ztsextdir}:' \ make -C ZTS install INSTALL_ROOT=%{buildroot} %endif +# The default Zend OPcache blacklist file +install -D -p -m 644 %{SOURCE2} %{buildroot}%{php_inidir}/%{plug_name}-default.blacklist + # Install XML package description install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml @@ -142,6 +154,7 @@ fi %files %doc NTS/{LICENSE,README} +%config(noreplace) %{php_inidir}/%{plug_name}-default.blacklist %config(noreplace) %{php_inidir}/%{plug_name}.ini %{php_extdir}/%{plug_name}.so @@ -154,6 +167,10 @@ fi %changelog +* Thu Apr 11 2013 Remi Collet <rcollet@redhat.com> - 7.0.1-2 +- allow wildcard in opcache.blacklist_filename and provide + default /etc/php.d/opcache-default.blacklist + * Mon Mar 25 2013 Remi Collet <remi@fedoraproject.org> - 7.0.1-1 - official PECL release, version 7.0.1 (beta) - rename to php-pecl-zendopcache |