Re: [PHP-DEV] A patch for APC harklinks problem

2011-04-28 Thread Christopher Jones

On 04/27/2011 08:18 PM, 陈磊 wrote:
 The bug url:
 http://pecl.php.net/bugs/bug.php?id=22673

I would also suggest mailing apc-dev @ lists.php.net (even though there
is likely to be a big overlap in readership with internals@).

Chris


 
 BRs,
 Chen Lei
 
 于 2011-4-27 18:34, Pierre Joye 写道:
 hi,

 Please report bug and patches to the pecl.php.net/apc bug tracker.

 Thanks for your work,

 Cheers,

 2011/4/27 陈磊simpcl2...@gmail.com:
 Hi,

 I come from sae team of sina. We meet with a problem of APC harklinks
 mentioned in the buglist of PHP and APC long time ago.

 The key word __FILE__ is a magic constants, and it is generated after the
 php source code is compiled.
 When the APC is used as a php extension for performence reason, the
 compiling and executing are independent.
 So, there are some problems. Please refer to the bug links:
 http://bugs.php.net/bug.php?id=45421
 http://pecl.php.net/bugs/bug.php?id=14055thanks=3

 I thinks there shoule be a feature in PHP Runtime to get the current
 executed file name at execute-time(not compile-time).
 apc_auto_hardlinks_for_php_5.3.5.diff is a patch for PHP 5.3.5, and the
 patch is to add a new key word executed_filename.

 When the following code is running:
   ?php
   echo executed_filename;
   ?

 In PHP Runtime, zend_get_executed_filename() is called to returne the
 current executed file name and being displayed.

 To fixed the APC hardlinks problem, the other patch
 auto_hardlinks_for_apc_3.1.6.diff must be used. The filename of
 opcode array should be updated when both setting and getting get opcode
 array to caches in APC.

 Hope the php patch should be reviewed and php runime will provide the way to
 get current executed file name at
 execute-time in the future.

 Thanks so much.

 BRs,
 Chen Lei
 simpcl2...@gmail.com

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php



 

-- 
Email: christopher.jo...@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] A patch for APC harklinks problem

2011-04-27 Thread 陈磊
Hi,

I come from sae team of sina. We meet with a problem of APC harklinks
mentioned in the buglist of PHP and APC long time ago.

The key word __FILE__ is a magic constants, and it is generated after
the php source code is compiled.
When the APC is used as a php extension for performence reason, the
compiling and executing are independent.
So, there are some problems. Please refer to the bug links:
http://bugs.php.net/bug.php?id=45421
http://pecl.php.net/bugs/bug.php?id=14055thanks=3
http://pecl.php.net/bugs/bug.php?id=14055thanks=3

I thinks there shoule be a feature in PHP Runtime to get the current
executed file name at execute-time(not compile-time).
apc_auto_hardlinks_for_php_5.3.5.diff is a patch for PHP 5.3.5, and the
patch is to add a new key word executed_filename.

When the following code is running:
?php
echo executed_filename;
?

In PHP Runtime, zend_get_executed_filename() is called to returne the
current executed file name and being displayed.

To fixed the APC hardlinks problem, the other patch
auto_hardlinks_for_apc_3.1.6.diff must be used. The filename of
opcodearray should be updated when both setting and getting get opcode
array to caches in APC.

Hope the php patch should be reviewed and php runime will provide the
way to get current executed file name at
execute-time in the future.

Thanks so much.

BRs,
Chen Lei
simpcl2...@gmail.com
diff -uprN php-5.3.5/Zend/zend_compile.c php-5.3.5-sae/Zend/zend_compile.c
--- php-5.3.5/Zend/zend_compile.c   2010-11-03 23:40:24.0 +0800
+++ php-5.3.5-sae/Zend/zend_compile.c   2011-04-27 14:10:30.0 +0800
@@ -5404,6 +5404,20 @@ ZEND_API size_t zend_dirname(char *path,
 }
 /* }}} */
 
+void zend_do_executed_filename(znode *result TSRMLS_DC) /* {{{ */
+{
+zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
+
+opline-result.op_type = IS_TMP_VAR;
+opline-result.u.var = get_temporary_variable(CG(active_op_array));
+opline-opcode = ZEND_EXECUTED_FILENAME;
+SET_UNUSED(opline-op1);
+SET_UNUSED(opline-op2);
+*result = opline-result;
+}
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4
diff -uprN php-5.3.5/Zend/zend_compile.h php-5.3.5-sae/Zend/zend_compile.h
--- php-5.3.5/Zend/zend_compile.h   2010-06-10 17:13:22.0 +0800
+++ php-5.3.5-sae/Zend/zend_compile.h   2011-04-27 14:10:20.0 +0800
@@ -548,6 +548,8 @@ void zend_do_goto(const znode *label TSR
 void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline, int 
pass2 TSRMLS_DC);
 void zend_release_labels(TSRMLS_D);
 
+void zend_do_executed_filename(znode *result TSRMLS_DC);
+
 ZEND_API void function_add_ref(zend_function *function);
 
 #define INITIAL_OP_ARRAY_SIZE 64
diff -uprN php-5.3.5/Zend/zend_language_parser.y 
php-5.3.5-sae/Zend/zend_language_parser.y
--- php-5.3.5/Zend/zend_language_parser.y   2010-01-06 04:40:23.0 
+0800
+++ php-5.3.5-sae/Zend/zend_language_parser.y   2011-04-27 13:53:17.0 
+0800
@@ -132,7 +132,7 @@
 %token T_METHOD_C
 %token T_FUNC_C
 %token T_LINE
-%token T_FILE
+%token T_FILE T_EXECUTED_FILENAME
 %token T_COMMENT
 %token T_DOC_COMMENT
 %token T_OPEN_TAG
@@ -765,6 +765,7 @@ common_scalar:
|   T_NS_C  { $$ = $1; }
|   T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = 
$2; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = 
Z_STRLEN($1.u.constant); }
|   T_START_HEREDOC T_END_HEREDOC { 
ZVAL_EMPTY_STRING($$.u.constant); INIT_PZVAL($$.u.constant); $$.op_type = 
IS_CONST; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = 
Z_STRLEN($1.u.constant); }
+|   T_EXECUTED_FILENAME { zend_do_executed_filename($$ 
TSRMLS_CC); }
 ;
 
 
diff -uprN php-5.3.5/Zend/zend_language_scanner.l 
php-5.3.5-sae/Zend/zend_language_scanner.l
--- php-5.3.5/Zend/zend_language_scanner.l  2010-11-18 00:46:19.0 
+0800
+++ php-5.3.5-sae/Zend/zend_language_scanner.l  2011-04-27 13:50:39.0 
+0800
@@ -1459,6 +1459,10 @@ NEWLINE (\r|\n|\r\n)
return T_FILE;
 }
 
+ST_IN_SCRIPTINGexecuted_filename {
+return T_EXECUTED_FILENAME;
+}
+
 ST_IN_SCRIPTING__DIR__ {
char *filename = zend_get_compiled_filename(TSRMLS_C);
const size_t filename_len = strlen(filename);
diff -uprN php-5.3.5/Zend/zend_vm_def.h php-5.3.5-sae/Zend/zend_vm_def.h
--- php-5.3.5/Zend/zend_vm_def.h2010-07-05 17:08:35.0 +0800
+++ php-5.3.5-sae/Zend/zend_vm_def.h2011-04-27 14:11:14.0 +0800
@@ -4432,4 +4432,14 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA
ZEND_VM_NEXT_OPCODE();
 }
 
+ZEND_VM_HANDLER(154, ZEND_EXECUTED_FILENAME, ANY, ANY)
+{
+zend_op *opline = EX(opline);
+
+char* s = zend_get_executed_filename(TSRMLS_C);
+ZVAL_STRING((EX_T(opline-result.u.var).tmp_var), s, 1);
+
+ZEND_VM_NEXT_OPCODE();
+}
+
 ZEND_VM_EXPORT_HELPER(zend_do_fcall, zend_do_fcall_common_helper)
--- APC-3.1.6/apc_main.c2010-11-30 18:18:31.0 

Re: [PHP-DEV] A patch for APC harklinks problem

2011-04-27 Thread Pierre Joye
hi,

Please report bug and patches to the pecl.php.net/apc bug tracker.

Thanks for your work,

Cheers,

2011/4/27 陈磊 simpcl2...@gmail.com:
 Hi,

 I come from sae team of sina. We meet with a problem of APC harklinks
 mentioned in the buglist of PHP and APC long time ago.

 The key word __FILE__ is a magic constants, and it is generated after the
 php source code is compiled.
 When the APC is used as a php extension for performence reason, the
 compiling and executing are independent.
 So, there are some problems. Please refer to the bug links:
 http://bugs.php.net/bug.php?id=45421
 http://pecl.php.net/bugs/bug.php?id=14055thanks=3

 I thinks there shoule be a feature in PHP Runtime to get the current
 executed file name at execute-time(not compile-time).
 apc_auto_hardlinks_for_php_5.3.5.diff is a patch for PHP 5.3.5, and the
 patch is to add a new key word executed_filename.

 When the following code is running:
  ?php
  echo executed_filename;
  ?

 In PHP Runtime, zend_get_executed_filename() is called to returne the
 current executed file name and being displayed.

 To fixed the APC hardlinks problem, the other patch
 auto_hardlinks_for_apc_3.1.6.diff must be used. The filename of
 opcode array should be updated when both setting and getting get opcode
 array to caches in APC.

 Hope the php patch should be reviewed and php runime will provide the way to
 get current executed file name at
 execute-time in the future.

 Thanks so much.

 BRs,
 Chen Lei
 simpcl2...@gmail.com

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] A patch for APC harklinks problem

2011-04-27 Thread 陈磊
The bug url:
http://pecl.php.net/bugs/bug.php?id=22673

BRs,
Chen Lei

于 2011-4-27 18:34, Pierre Joye 写道:
 hi,

 Please report bug and patches to the pecl.php.net/apc bug tracker.

 Thanks for your work,

 Cheers,

 2011/4/27 陈磊 simpcl2...@gmail.com:
 Hi,

 I come from sae team of sina. We meet with a problem of APC harklinks
 mentioned in the buglist of PHP and APC long time ago.

 The key word __FILE__ is a magic constants, and it is generated after the
 php source code is compiled.
 When the APC is used as a php extension for performence reason, the
 compiling and executing are independent.
 So, there are some problems. Please refer to the bug links:
 http://bugs.php.net/bug.php?id=45421
 http://pecl.php.net/bugs/bug.php?id=14055thanks=3

 I thinks there shoule be a feature in PHP Runtime to get the current
 executed file name at execute-time(not compile-time).
 apc_auto_hardlinks_for_php_5.3.5.diff is a patch for PHP 5.3.5, and the
 patch is to add a new key word executed_filename.

 When the following code is running:
  ?php
  echo executed_filename;
  ?

 In PHP Runtime, zend_get_executed_filename() is called to returne the
 current executed file name and being displayed.

 To fixed the APC hardlinks problem, the other patch
 auto_hardlinks_for_apc_3.1.6.diff must be used. The filename of
 opcode array should be updated when both setting and getting get opcode
 array to caches in APC.

 Hope the php patch should be reviewed and php runime will provide the way to
 get current executed file name at
 execute-time in the future.

 Thanks so much.

 BRs,
 Chen Lei
 simpcl2...@gmail.com

 --
 PHP Internals - PHP Runtime Development Mailing List
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php