php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59793 Check for already declared functions issue
Submitted: 2011-05-30 07:48 UTC Modified: 2016-11-18 21:41 UTC
Votes:6
Avg. Score:3.7 ± 1.2
Reproduced:5 of 6 (83.3%)
Same Version:1 (20.0%)
Same OS:3 (60.0%)
From: vnsavage at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2011-05-30 07:48 UTC] vnsavage at gmail dot com
Description:
------------
When compiling cached opcode, APC does not check if functions 
are already declared.

This seems to be happening because the return value of 
install_function() in cached_compile() is not checked.

If you need more testing or patches, please let me know. I'd 
be glad to help.

Reproduce code:
---------------
Step one:

~# cat index.php

<?php
require('file2.php');
test();

~# cat file2.php

<?php 
function test() { echo 'test() called from file2.php'; }

Load index.php in a browser.

Step two:

~# cat index.php

<?php
require('file1.php');
require('file2.php');
test();

~# cat file1.php

<?php 
function test() { echo 'test() called from file1.php'; }

~# cat file2.php

<?php 
function test() { echo 'test() called from file2.php'; }

Reload index.php in a browser.

Expected result:
----------------
Fatal error: Cannot redeclare test() (previously declared in 
~/file1.php:2) in ~/file2.php on line 2

Actual result:
--------------
test() called from file1.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-18 21:41 UTC] kalle@php.net
-Status: Open +Status: Wont fix
 [2016-11-18 21:41 UTC] kalle@php.net
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 09:01:27 2024 UTC