Commit:    afb43f5650da2d24f03ce893bcd5123c12aba3fd
Author:    Dmitry Stogov <dmi...@zend.com>         Thu, 14 Feb 2013 11:59:23 
+0400
Parents:   4bc28ae783eb5c8205b53df4edf581d05a8662ae
Branches:  PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=afb43f5650da2d24f03ce893bcd5123c12aba3fd

Log:
- Added zend_optimizerplus.load_comments configuration durective, so "Doc 
comments" may be always stored in SHM, but
restored only by applicaions that really need them.
- Added note, that zend_optimizerplus.save_comments is dangerous and may break 
applications and frameworks.

Changed paths:
  M  README
  M  ZendAccelerator.h
  M  zend_accelerator_module.c
  M  zend_accelerator_util_funcs.c


Diff:
diff --git a/README b/README
index 05c4c60..5b25a7a 100644
--- a/README
+++ b/README
@@ -44,11 +44,16 @@ zend_optimizerplus.memory_consumption=128
 zend_optimizerplus.interned_strings_buffer=8
 zend_optimizerplus.max_accelerated_files=4000
 zend_optimizerplus.revalidate_freq=60
-zend_optimizerplus.save_comments=0
 zend_optimizerplus.fast_shutdown=1
-zend_optimizerplus.enable_file_override=1
 zend_optimizerplus.enable_cli=1
 
+You also may add the following, but it may break some applications and
+frameworks. Please, read description of these directives and add them on your
+own risk.
+
+zend_optimizerplus.save_comments=0
+zend_optimizerplus.enable_file_override=1
+
 In some cases you may like to prefer enabling/disabling some features
 to avoid incompatibilities at the cost of some performance degradation.
 
@@ -102,7 +107,13 @@ zend_optimizerplus.revalidate_path (default "0")
 
 zend_optimizerplus.save_comments (default "1")
        If disabled, all PHPDoc comments are dropped from the code to reduce the
-       size of the optimized code.
+       size of the optimized code. Disabling "Doc Comments" may break some
+       existing applications and frameworks (e.g. Doctrine, ZF2, PHPUnit)
+
+zend_optimizerplus.load_comments (default "1")
+       If disabled, PHPDoc comments are not loaded from SHM, so "Doc Comments"
+       may be always stored (save_comments=1), but not loaded by applications
+       that don't need them anyway.
 
 zend_optimizerplus.fast_shutdown (default "0")
        If enabled, a fast shutdown sequence is used for the accelerated code
diff --git a/ZendAccelerator.h b/ZendAccelerator.h
index 2aa2248..d7ac0ed 100644
--- a/ZendAccelerator.h
+++ b/ZendAccelerator.h
@@ -204,6 +204,7 @@ typedef struct _zend_accel_directives {
        zend_bool      validate_timestamps;
        zend_bool      revalidate_path;
        zend_bool      save_comments;
+       zend_bool      load_comments;
        zend_bool      fast_shutdown;
        zend_bool      protect_memory;
        zend_bool      file_override_enabled;
diff --git a/zend_accelerator_module.c b/zend_accelerator_module.c
index be0655a..e64ad19 100644
--- a/zend_accelerator_module.c
+++ b/zend_accelerator_module.c
@@ -221,6 +221,7 @@ ZEND_INI_BEGIN()
 
        STD_PHP_INI_ENTRY("zend_optimizerplus.protect_memory"        , "0"  , 
PHP_INI_SYSTEM, OnUpdateBool,                  accel_directives.protect_memory, 
           zend_accel_globals, accel_globals)
        STD_PHP_INI_ENTRY("zend_optimizerplus.save_comments"         , "1"  , 
PHP_INI_SYSTEM, OnUpdateBool,                  accel_directives.save_comments,  
           zend_accel_globals, accel_globals)
+       STD_PHP_INI_ENTRY("zend_optimizerplus.load_comments"         , "1"  , 
PHP_INI_ALL,    OnUpdateBool,                  accel_directives.load_comments,  
           zend_accel_globals, accel_globals)
        STD_PHP_INI_ENTRY("zend_optimizerplus.fast_shutdown"         , "0"  , 
PHP_INI_SYSTEM, OnUpdateBool,                  accel_directives.fast_shutdown,  
           zend_accel_globals, accel_globals)
 
        STD_PHP_INI_ENTRY("zend_optimizerplus.optimization_level"    , 
DEFAULT_OPTIMIZATION_LEVEL , PHP_INI_SYSTEM, OnUpdateLong, 
accel_directives.optimization_level,   zend_accel_globals, accel_globals)
diff --git a/zend_accelerator_util_funcs.c b/zend_accelerator_util_funcs.c
index 275642b..c41080f 100644
--- a/zend_accelerator_util_funcs.c
+++ b/zend_accelerator_util_funcs.c
@@ -520,7 +520,11 @@ static void zend_hash_clone_prop_info(HashTable *ht, 
HashTable *source, zend_cla
                /* Copy constructor */
                prop_info->name = interned_estrndup(prop_info->name, 
prop_info->name_length);
                if(prop_info->doc_comment) {
-                       prop_info->doc_comment = 
estrndup(prop_info->doc_comment, prop_info->doc_comment_len);
+                       if (ZCG(accel_directives).load_comments) {
+                               prop_info->doc_comment = 
estrndup(prop_info->doc_comment, prop_info->doc_comment_len);
+                       } else {
+                               prop_info->doc_comment = NULL;
+                       }
                }
                if(prop_info->ce == old_ce) {
                        prop_info->ce = ce;
@@ -637,7 +641,11 @@ static void zend_class_copy_ctor(zend_class_entry **pce)
                ce->interfaces = NULL;
        }
        if (ZEND_CE_DOC_COMMENT(ce)) {
-               ZEND_CE_DOC_COMMENT(ce) = estrndup(ZEND_CE_DOC_COMMENT(ce), 
ZEND_CE_DOC_COMMENT_LEN(ce));
+               if (ZCG(accel_directives).load_comments) {
+                       ZEND_CE_DOC_COMMENT(ce) = 
estrndup(ZEND_CE_DOC_COMMENT(ce), ZEND_CE_DOC_COMMENT_LEN(ce));
+               } else {
+                       ZEND_CE_DOC_COMMENT(ce) =  NULL;
+               }
        }
 
        if(ce->parent) {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to