Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29834 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32899 invoked by uid 1010); 28 May 2007 05:53:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 32884 invoked from network); 28 May 2007 05:53:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 May 2007 05:53:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 66.79.163.178 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 66.79.163.178 bluga.net Linux 2.5 (sometimes 2.4) (4) Received: from [66.79.163.178] ([66.79.163.178:50267] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/81-10756-86E6A564 for ; Mon, 28 May 2007 01:53:47 -0400 Received: from mail.bluga.net (mail.bluga.net [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id CC3198744F for ; Sun, 27 May 2007 22:56:12 -0700 (PDT) Received: from [192.168.0.106] (CPE-72-133-60-138.neb.res.rr.com [72.133.60.138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 63300873F2 for ; Sun, 27 May 2007 22:56:11 -0700 (PDT) Message-ID: <465A6EBB.7040000@chiaraquartet.net> Date: Mon, 28 May 2007 00:55:07 -0500 User-Agent: Thunderbird 1.5.0.10 (X11/20070306) MIME-Version: 1.0 To: internals Mailing List X-Enigmail-Version: 0.94.0.0 Content-Type: multipart/mixed; boundary="------------020201050005030802070507" X-Virus-Scanned: ClamAV using ClamSMTP Subject: __HALT_COMPILER(); patch to be MFB From: greg@chiaraquartet.net (Gregory Beaver) --------------020201050005030802070507 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, The fix recently incorporated in PHP 5.2.2 for __HALT_COMPILER(); needs to be MFB. Until today, I didn't have the time to get it working, but attached is the patch. It is also available at http://chiaraquartet.net/halt_compiler_php6.patch.txt Greg P.S. don't prepend www. or you'll get redirected to the chiara quartet website, which although pretty cool looking, has no patches to HEAD anywhere to be found. --------------020201050005030802070507 Content-Type: text/plain; name="halt_compiler_php6.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="halt_compiler_php6.patch.txt" ? halt_compiler_php6.patch.txt Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.744 diff -u -r1.744 zend_compile.c --- Zend/zend_compile.c 3 Apr 2007 06:32:59 -0000 1.744 +++ Zend/zend_compile.c 28 May 2007 05:47:16 -0000 @@ -3329,6 +3329,18 @@ zend_llist_add_element(fetch_list_ptr, &opline); } +void zend_do_halt_compiler_register(TSRMLS_D) +{ + char *name, *cfilename; + char haltoff[] = "__COMPILER_HALT_OFFSET__"; + int len, clen; + cfilename = zend_get_compiled_filename(TSRMLS_C); + clen = strlen(cfilename); + zend_mangle_property_name(&name, &len, haltoff, + sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0); + zend_register_long_constant(name, len+1, zend_get_scanned_file_offset(TSRMLS_C), CONST_CS, 0 TSRMLS_CC); + pefree(name, 0); +} void zend_do_declare_implicit_property(TSRMLS_D) Index: Zend/zend_compile.h =================================================================== RCS file: /repository/ZendEngine2/zend_compile.h,v retrieving revision 1.356 diff -u -r1.356 zend_compile.h --- Zend/zend_compile.h 8 Mar 2007 17:30:28 -0000 1.356 +++ Zend/zend_compile.h 28 May 2007 05:47:17 -0000 @@ -457,6 +457,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znode *parent_class_name TSRMLS_DC); void zend_do_end_class_declaration(znode *class_token, znode *parent_token TSRMLS_DC); void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_type TSRMLS_DC); +void zend_do_halt_compiler_register(TSRMLS_D); void zend_do_declare_implicit_property(TSRMLS_D); void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC); Index: Zend/zend_constants.c =================================================================== RCS file: /repository/ZendEngine2/zend_constants.c,v retrieving revision 1.90 diff -u -r1.90 zend_constants.c --- Zend/zend_constants.c 1 Jan 2007 09:29:20 -0000 1.90 +++ Zend/zend_constants.c 28 May 2007 05:47:17 -0000 @@ -347,7 +347,27 @@ retval=0; } } else { - retval=0; + char haltoff[] = "__COMPILER_HALT_OFFSET__"; + if (!EG(in_execution)) { + retval = 0; + } else if (name_len == sizeof("__COMPILER_HALT_OFFSET__") - 1 && memcmp(haltoff, name.s, name_len) == 0) { + char *cfilename; + zstr haltname; + int len, clen; + cfilename = zend_get_executed_filename(TSRMLS_C); + clen = strlen(cfilename); + /* check for __COMPILER_HALT_OFFSET__ */ + zend_mangle_property_name(&haltname.s, &len, haltoff, + sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0); + if (zend_u_hash_find(EG(zend_constants), IS_STRING, haltname, len+1, (void **) &c) == SUCCESS) { + retval=1; + } else { + retval=0; + } + pefree(haltname.s, 0); + } else { + retval=0; + } } efree(lookup_name.v); } @@ -373,6 +393,7 @@ zstr lookup_name; zstr name; int ret = SUCCESS; + static char haltoff[] = "__COMPILER_HALT_OFFSET__"; #if 0 printf("Registering constant for module %d\n", c->module_number); @@ -388,6 +409,13 @@ lookup_name = NULL_ZSTR; } + if (EG(in_execution) && lookup_name_len == sizeof("__COMPILER_HALT_OFFSET__") && memcmp(haltoff, name.s, lookup_name_len) == 0) { + zend_error(E_NOTICE,"Constant %R already defined", type, name); + if (lookup_name.v) { + efree(lookup_name.v); + } + ret = FAILURE; + } if (zend_u_hash_add(EG(zend_constants), type, name, lookup_name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { zend_error(E_NOTICE,"Constant %R already defined", type, name); free(c->name.v); Index: Zend/zend_language_parser.y =================================================================== RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.180 diff -u -r1.180 zend_language_parser.y --- Zend/zend_language_parser.y 8 Mar 2007 17:30:28 -0000 1.180 +++ Zend/zend_language_parser.y 28 May 2007 05:47:18 -0000 @@ -165,7 +165,7 @@ statement | function_declaration_statement { zend_do_early_binding(TSRMLS_C); } | class_declaration_statement { zend_do_early_binding(TSRMLS_C); } - | T_HALT_COMPILER '(' ')' ';' { zval c; if (zend_get_constant("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1, &c TSRMLS_CC)) { zval_dtor(&c); zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used once per request"); } else { REGISTER_MAIN_LONG_CONSTANT("__COMPILER_HALT_OFFSET__", zend_get_scanned_file_offset(TSRMLS_C), CONST_CS); } YYACCEPT; } + | T_HALT_COMPILER '(' ')' ';' { zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; } ; Index: tests/lang/halt_compiler1.phpt =================================================================== RCS file: tests/lang/halt_compiler1.phpt diff -N tests/lang/halt_compiler1.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/lang/halt_compiler1.phpt 28 May 2007 05:47:26 -0000 @@ -0,0 +1,8 @@ +--TEST-- +__HALT_COMPILER(); +--FILE-- + +===DONE=== +--EXPECT-- +testint(73) \ No newline at end of file Index: tests/lang/halt_compiler2.phpt =================================================================== RCS file: tests/lang/halt_compiler2.phpt diff -N tests/lang/halt_compiler2.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/lang/halt_compiler2.phpt 28 May 2007 05:47:26 -0000 @@ -0,0 +1,23 @@ +--TEST-- +__HALT_COMPILER(); 2 files +--FILE-- + +hi there"; +file_put_contents(dirname(__FILE__) . '/test1.php', $text); +$text = " +hi there 2"; +file_put_contents(dirname(__FILE__) . '/test2.php', $text); +include dirname(__FILE__) . '/test1.php'; +include dirname(__FILE__) . '/test2.php'; +?> +==DONE== +--CLEAN-- + +--EXPECT-- +testint(73) +test2int(74) +==DONE== \ No newline at end of file Index: tests/lang/halt_compiler3.phpt =================================================================== RCS file: tests/lang/halt_compiler3.phpt diff -N tests/lang/halt_compiler3.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/lang/halt_compiler3.phpt 28 May 2007 05:47:26 -0000 @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER(); bad define() of __COMPILER_HALT_OFFSET__ 1 +--FILE-- + +==DONE== +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d +==DONE== \ No newline at end of file Index: tests/lang/halt_compiler4.phpt =================================================================== RCS file: tests/lang/halt_compiler4.phpt diff -N tests/lang/halt_compiler4.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/lang/halt_compiler4.phpt 28 May 2007 05:47:26 -0000 @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER(); bad define() of __COMPILER_HALT_OFFSET__ 2 +--FILE-- + +==DONE== +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d \ No newline at end of file --------------020201050005030802070507--