Bug #14655
closedrequire_once() instead of require() should be used in entry scripts
0%
Description
In showpic.php, index_ts.php, typo3/init.php TYPO3 uses the PHP function require() to include classes like t3lib_div.
Later on in the process, there are some other files included having a line like this:
require_once(PATH_t3lib.'class.t3lib_div.php');
Normally the fact that t3lib_div was already included earlier should not cause any problems because require_once() should only include if the class wasn't already included, but it seems like the behaviour of that function changed in a recent PHP version, so that require_once() now DOES include files which have already been included with require(). The solution would be to change also the FIRST inclusions from require() to require_once().
According to Rupert Germann, this bug only occurs when a PHP accelerator is enabled.
A typical PHP error message resulting from this problem is this:
PHP Fatal error: Cannot redeclare class t3lib_div in /www/htdocs/_data/typo3.com/typo3_src-3.8.0-dev-cvs/t3lib/class.t3lib_div.php on line 209
(issue imported from #M958)
Files
Updated by Rupert Germann over 19 years ago
hey, seems that my search for the mysterious "Cannot redeclare class t3lib_div..." error when e-accelerator is enabled has an end. Could this have the same reason ? I'll try.
Updated by Rupert Germann over 19 years ago
it was the reason !
I replaced all (4) occurances of require with require_once in index_ts.php and my sites are accelerated again.
thx ingo ;-)
Updated by Ingmar Schlecht over 19 years ago
I checked the following files:
- index_ts.php
- showpic.php
- typo3/thumbs.php
- typo3/init.php
- ext/direct_mail/mod/dmailerd.phpcron
And it turned out that only tumbs.php, index_ts.php and dmailerd.phpcron needed a fix (see attached patches).
Since these fixes don't cause any harm, I see no problem in making the change.
Updated by Karsten Dambekalns over 19 years ago
I now have a similar problem - when using require_once it seems as if PHP checks for identical files by using the filename. Now when I includes e.g. t3lib_div with an absolute path and with a relative path, I get a fatal error about redeclaring class t3lib_div.
This seems to be a bug/design flaw in PHP, though. It might explain some strange results...
Updated by Karsten Dambekalns over 19 years ago
The changes are indeed risk-less, I applied the patches to the core files. I have no access to the direct mail CVS, though. Who could apply the changes there?
@Ingmar: Any specific reason why you didn't look a returnmail.phpsh in direct mail as well?
Updated by Ingmar Schlecht over 19 years ago
Assigned to Jan-Erik Revsbech so he can commit dmailerd.phpcron.patch and returnmail.phpsh.patch.
Updated by Michael Stucki over 19 years ago
Ingmar, did you look at your change?
-require_once (PATH_t3lib."class.t3lib_readmail.php");
+require_once_once (PATH_t3lib."class.t3lib_readmail.php");
I don't believe that this was intended.
PS: Whenever changing such files we should get used to replace the double with single quotes.
Updated by Jan-Erik Revsbech over 19 years ago
Fixed it in dmailerd.phpcron and returnmail.phpsh. Still does not have TER password, so only fixed in CVS.
Updated by Michael Stucki over 19 years ago
This can be closed, right? Ingmar, can you please check?
Updated by Ingmar Schlecht over 19 years ago
Yes, this bug can be closed/marked as resolved. (I hope the CVS version of direct_mail is included in 3.8.0b2)