php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55369 Files with classes are included, but classes are not defined correctly
Submitted: 2011-08-05 10:12 UTC Modified: 2012-02-21 07:28 UTC
Votes:5
Avg. Score:3.8 ± 1.0
Reproduced:3 of 5 (60.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: md dot xytop at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.6 OS: Debian/Ubuntu/MacOS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: md dot xytop at gmail dot com
New email:
PHP Version: OS:

 

 [2011-08-05 10:12 UTC] md dot xytop at gmail dot com
Description:
------------
After updating our php code (added some classes, have rewritten some functionality) one of our utilites stopped to work. After deep digging we found that php doesn't define a class in some circumstances. In attachment is our handmade example.
Try to run file0.php

On 5.2.17 and 5.3.2 we have output:

/home/vitaly/.../public_html/file3.php
/home/vitaly/.../public_html/file4.php
/home/vitaly/.../public_html/file2.php
/home/vitaly/.../public_html/file1.php
/home/vitaly/.../public_html/file0.php

On 5.3.5:

Fatal error: Class 'Class1' not found in /.../file3.php on line 6

On our real project (which uses 5.2.17) ^^ we have the same fatal error. Project is very big and has many includes, so we can't provide simple example for it, but probably changing example from attachment to one or another side will do the trick..

We don't have 5.3.6 version, yes, we out of date, but I think this is something that's will reoccur from one version to another.

Expected result:
----------------
Run file0.php

I expect to have loading sequence



Actual result:
--------------
On some php version I have fatal error that class is undefined.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-05 10:15 UTC] md dot xytop at gmail dot com
file0.php:

<?php

require_once(dirname(__FILE__) . '/file1.php');

class Class0
{
}

echo __FILE__ . '<br/>' . "\r\n";

?>


file1.php:

<?php

require_once(dirname(__FILE__) . '/file2.php');
require_once(dirname(__FILE__) . '/file4.php');

class Class1 extends Class0
{
}

echo __FILE__ . '<br/>' . "\r\n";

?>


file2.php:

<?php

require_once(dirname(__FILE__) . '/file1.php');
require_once(dirname(__FILE__) . '/file3.php');
require_once(dirname(__FILE__) . '/file4.php');

class Class2 extends Class0
{
}

echo __FILE__ . '<br/>' . "\r\n";

?>


file3.php:


<?php

require_once(dirname(__FILE__) . '/file1.php');

class Class3 extends Class1
{
}

echo __FILE__ . '<br/>' . "\r\n";

?>



file4.php:


<?php

class Class4 extends Class0
{
}

echo __FILE__ . '<br/>' . "\r\n";

?>
 [2011-08-05 10:18 UTC] md dot xytop at gmail dot com
See first comment to look at example
 [2012-02-21 07:28 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2012-02-21 07:28 UTC] rasmus@php.net
No idea what might have been wrong with your 5.3.5, but it works fine on 5.3.10 
and 5.4.0. I get the same output from both:

/home/rasmus/file3.php<br/>
/home/rasmus/file4.php<br/>
/home/rasmus/file2.php<br/>
/home/rasmus/file1.php<br/>
/home/rasmus/file0.php<br/>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC