[TYPO3-dev] Antw: Re: Compat Layer in LTS 6.2 ?

Helmut Hummel helmut.hummel at typo3.org
Mon Sep 9 11:23:32 CEST 2013


Hi Britta,

On 09.09.13 10:59, Britta Kohorst wrote:

> thank you for your answers. That is very reassuring for us, it means we don't have to spend days mending extensions that are in the process of being re-coded all over anyhow.
> So, we will remove all include_once statements and let the autoloader do the job.

Great.

> But what about code parts like the following:
>
> reset($SOBE->include_once);
> while(list(,$INC_FILE)=each($SOBE->include_once))	{include_once($INC_FILE);}

This includes files that must be loaded for the backend module to work. 
Since this is a loop over a property of the module object, it might be 
that core classes are included in this place, but it also might be that 
only extension classes are included, which would be no problem.

So in this case you have to check the code where values are assigned to 
the include_once propety and remove core files from there.

But since this is an include statement and not a require statement, it 
does not harm to not change anything because PHP just proceeds if the 
file is not found (in contrast to the require statements where you get a 
PHP fatal error).

> And one more question: I assume the 'require_once' statements in backend modules must also be deleted for the extension to be runnable with TYPO3 6.2?

Just to explain why it is needed to remove the require_once.

Prior to the autoloading mechanism for classes, you had to maually 
needed to require the files where a class is defined before being able 
to use this class in your code.
With autoloading you do not have to do a manual require any more, 
because the autoloader is triggered if PHP does not find a class and the 
autoloader then does require the requested class for you.

But it does not harm, if you use a require_once on the class file, 
because then the autoloader is not triggered any more by PHP as the 
class is already defined.

In TYPO3 many class files used to reside in the t3lib/ folder.
For the namespace change all classes have been renamed and moved to
new locations.

For backwards compatibility we kept dummy files in the old location 
which did nothing else than requiring the file in the new location.
By that, extensions that still did a manual require on the old class 
files in t3lib/ still worked because a file still existed in the old 
location. As of TYPO3 6.2 the old location does not exist any more and 
all extensions using require on files in the old location will cause a 
fatal error. So extension authors either have to adapt the require to 
include the new file, or (as sugessted) remove the require as the 
autoloader does the job anyway.


For your own extensions I would recommend to use the autoloader 
mechanism as it makes the life easier. But it does not harm if you keep 
the require calls in your own code, as long as you do not move files 
around ;)

HTH

Kind regards,
Helmut

-- 
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 Core Developer, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org



More information about the TYPO3-dev mailing list