Project

General

Profile

Actions

Bug #14655

closed

require_once() instead of require() should be used in entry scripts

Added by Ingmar Schlecht over 19 years ago. Updated over 18 years ago.

Status:
Closed
Priority:
Should have
Category:
Frontend
Target version:
-
Start date:
2005-04-09
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
3.8.0beta2
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

index_ts.php.patch (1.32 KB) index_ts.php.patch Administrator Admin, 2005-04-10 18:51
thumbs.php.patch (530 Bytes) thumbs.php.patch Administrator Admin, 2005-04-10 18:51
dmailerd.phpcron.patch (1.03 KB) dmailerd.phpcron.patch Administrator Admin, 2005-04-10 18:57
returnmail.phpsh.patch (1.29 KB) returnmail.phpsh.patch Administrator Admin, 2005-04-13 14:06
Actions #1

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.

Actions #2

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 ;-)

Actions #3

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.

Actions #4

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...

Actions #5

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?

Actions #6

Updated by Ingmar Schlecht over 19 years ago

Assigned to Jan-Erik Revsbech so he can commit dmailerd.phpcron.patch and returnmail.phpsh.patch.

Actions #7

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.

Actions #8

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.

Actions #9

Updated by Michael Stucki over 19 years ago

This can be closed, right? Ingmar, can you please check?

Actions #10

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)

Actions #11

Updated by Michael Stucki over 19 years ago

Yes it is.

Actions

Also available in: Atom PDF