ID: 23785
Updated by: [EMAIL PROTECTED]
Reported By: zyxwvu at me2 dot pl
-Status: Open
+Status: Closed
Bug Type: Zend Engine 2 problem
Operating System: Mandrake Linux 9
PHP Version: 5CVS-2003-05-23 (dev)
New Comment:
actually close.
Previous Comments:
------------------------------------------------------------------------
[2003-06-04 22:27:32] [EMAIL PROTECTED]
there are no namespaces in php.
------------------------------------------------------------------------
[2003-05-23 14:39:37] zyxwvu at me2 dot pl
When I ran this PHP script:
<?php
namespace ns{
function zend_version(){
echo zend_version();
}
function make_php_happy(){
echo "I'm happy!!!";
}
}
ns::make_php_happy();
ns::zend_version();
?>
I noticed that my system works veeery slow. I tried to kill the server
process, but i had to pick "Reset". After this history I started to
analyze whole problem and I found interesing thing. In my opinion, if
we make in the namespace's function (which has got the same name, like
build-in PHP function, or also global function created by user)
<?php
function foo(){
echo 'foo';
}
namespace x{
function foo(){
foo();
}
}
x::foo();
?>
The namespace's function foo() shouldn't call itself, but global
function foo(), should it? The same way is with the build-in-functions.
If we want to make a recursive (function calls itself), we should use
"x::foo();" to do it.
I tried to fix this bug myself, but I only found the place, where the
error is: php-5/Zend/zend_compile.h, on line 1184, function
"zend_do_begin_function_call()". Oryginally we had these lines in this
place:
-----------------------------------
switch (function->type) {
case ZEND_USER_FUNCTION: {
zend_op_array *op_array = (zend_op_array *) function;
zend_stack_push(&CG(function_call_stack), (void *) &op_array,
sizeof(zend_function *));
break;
------------------------------------
I replaced it by this code:
------------------------------------
switch (function->type) {
case ZEND_USER_FUNCTION: {
if(function -> common.ns != CG(active_namespace)){
zend_op_array *op_array = (zend_op_array *)
function;
zend_stack_push(&CG(function_call_stack),
(void *) &op_array,
sizeof(zend_function *));
break;
}else{
zend_error(E_COMPILE_ERROR, "Namespace error -
try to use global
function!");
}
}
------------------------------------
And then, when I try to run these PHP scripts, PHP generates:
"Fatal error: Namespace error - try to use global function! in file.php
on line 6"
or something like that :)
System params:
Mandrake Linux 9
Apache 2.0.45
PHP 5.0.0-dev
PHP configuration:
-- with-apxs2 --with-mysql --with-pgsql --with-zlib --with-gd
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23785&edit=1