|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2005-09-14 10:45 UTC] nick dot locking at gmail dot com
 Description:
------------
When APC is turned on, QuickForm breaks and produces an error:
Fatal error: Call to undefined method HTML_QuickForm_hidden::HTML_QuickForm_element() in /usr/lib/php/HTML/QuickForm/input.php on line 50
Obviously this method is not undefined. When APC is turned off, it works perfectly. Strangely, manually including "HTML/QuickForm/element.php" before the code fixes the problem.
PHP Version: 5.0.4
QuickForm Version: 3.2.5
APC Version: 3.0.8
Operating System: Trustix 2.2
Reproduce code:
---------------
HTAccess:
php_flag apc.enabled on
Whatever.php:
// Include QuickForm
require_once("HTML/QuickForm.php");
// This line, uncommented, fixes the problem
// require_once "HTML/QuickForm/element.php";
// Create a form
$form = new HTML_QuickForm('frmUser', 'post');
// This line produces the error
$form->addElement('hidden', 'id');
Expected result:
----------------
I expect a form to be created with a hidden element.
Actual result:
--------------
Fatal error: Call to undefined method HTML_QuickForm_hidden::HTML_QuickForm_element() in /usr/lib/php/HTML/QuickForm/input.php on line 50
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 11:00:01 2025 UTC | 
This is not a QuickForm-specific issue. It's a general problem with APC when using certain types of complex class hierarchies and particular include orders. QuickForm simply triggers this bug. I've crafted a replication scenario that doesn't involve QuickForm. The scenario is complex, so bear with me. You'll need to create 5 files: A.php ----- <? class A { function say_something() { print "Hello, World.<br />"; } } ?> B.php ----- <? require_once "A.php"; class B extends A { } ?> Z.php ----- <? require_once "A.php"; class Z extends A { } ?> first.php --------- <? require_once "Z.php"; require_once "B.php"; ?> second.php ---------- <? require_once "B.php"; $obj = new B(); $obj->say_something() ?> SCENARIO ONE ------------ 1) Restart your apache (or apc_clear_cache()) 2) Load first.php in your browser 3) Load second.php in your browser EXPECTED: "Hello, World." ACTUAL: "Call to undefined method B::say_something()" SCENARIO TWO ------------ 1) Restart your apache (or apc_clear_cache()) 2) Load second.php in your browser (no first.php) EXPECTED: "Hello, World." ACTUAL: "Hello, World." 3) Load first.php in your browser 4) Load second.php in your browser (no first.php) EXPECTED: "Hello, World." ACTUAL: "Hello, World." There is something about calling first.php BEFORE second.php that causes the APC cache to get into a bad state. As long as first.php is the first script loaded, ALL calls to second.php will fail until Apache is restarted or apc_clear_cache is called. If second.php is loaded BEFORE first.php ever is, then both scripts work fine going forward. VERSIONS -------- PHP: 5.0.2 Apache: 1.3.29 APC: 3.0.8 OS: Linux 2.6.9