|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61151 Incorrectly reports function as being redeclared
Submitted: 2012-02-21 06:48 UTC Modified: 2012-02-21 07:45 UTC
From: mark-kreine at yandex dot ru Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.3.10 OS: Ubuntu 11.10
Private report: No CVE-ID: None
 [2012-02-21 06:48 UTC] mark-kreine at yandex dot ru
I have created a web page which includes files config.php and functions.php. I define basic constants in config.php while the file "functions.php" is used to define functions. 
You can reproduce a problem if you create a page, include first "config.php" then "functions.php" and just invoke this page from a web browser.

My configure line is as follows:

'./configure' '--prefix=/soft/programs/php' '--with-apxs2=/soft/programs/apache/bin/apxs' '--with-config-file-path=/soft/programs/php/ini' '--with-config-file-scan-dir=/soft/programs/php/additional' '--with-zlib=shared,/soft/programs/zlib' '--with-bz2=shared,/soft/programs/bzip' '--with-curl=shared,/soft/programs/curl' '--with-gd=shared,/soft/programs/gd' '--with-jpeg-dir=/soft/programs/jpeg' '--with-png-dir=/soft/programs/libpng' '--with-freetype-dir=/soft/programs/freetype' '--with-gettext=shared,/soft/programs/gettext' '--with-mysql=shared,/soft/programs/mysql' '--with-mcrypt=shared,/soft/programs/libmcrypt' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-calendar' '--enable-mbstring' '--with-libexpat-dir=/soft/programs/expat' '--with-libxml-dir=/soft/programs/libxml' '--with-xsl=shared,/soft/programs/libxslt' '--enable-zip' 

Test script:
You'll find test script here:

Expected result:
Normal script execution without any fatal error.

Actual result:
Fatal error: Cannot redeclare get_tree() (previously declared in ...) in /test/functions.php on line 16


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-21 06:59 UTC]
But you haven't given us any way to reproduce this as we can't see your code.

What is on lines 3 and 16 of your functions.php script?

The error message very clearly states that you are declaring get_tree() on line 3 
and then again on line 16 of that file.
 [2012-02-21 06:59 UTC]
-Status: Open +Status: Feedback
 [2012-02-21 07:05 UTC] mark-kreine at yandex dot ru
-Status: Feedback +Status: Open
 [2012-02-21 07:05 UTC] mark-kreine at yandex dot ru
Thanks for the answer, but the message you see is not true, that is the reason for me to write here. 

Following are the lines from 3 till 16 of my code in functions.php:

function get_tree($tree, $pid, $result = array())
    foreach ($tree as $row)
        if ($row['parent_cat_id'] == $pid)
	    $result[] = $row;
            $result = get_tree($tree, $row['cat_id'], $result);
    return $result;
 [2012-02-21 07:11 UTC]
-Status: Open +Status: Feedback
 [2012-02-21 07:11 UTC]
We'll still need a reproducible test case to do anything here. There is obviously 
something you are not telling. A standalone file or tarball of files is needed 
since putting just the code you pasted into a file and including it will 
obviously not trigger that error.
 [2012-02-21 07:17 UTC] mark-kreine at yandex dot ru
-Status: Feedback +Status: Open
 [2012-02-21 07:17 UTC] mark-kreine at yandex dot ru
Well, there are many lines of code. If you permit I can send you a tarball of files or attach it somewhere to this bug report.

Please advise me on how to send you these files.
 [2012-02-21 07:33 UTC] mark-kreine at yandex dot ru
Problem solved.
 [2012-02-21 07:33 UTC] mark-kreine at yandex dot ru
-Status: Open +Status: Closed
 [2012-02-21 07:45 UTC]
-Status: Closed +Status: Not a bug
 [2012-02-21 07:45 UTC]
Ok, so it wasn't a bug. Different bug status on our end.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 08:01:31 2024 UTC