[TYPO3-core] RFC: #15822: t3lib_beFunc use $this in static methods

Dmitry Dulepov dmitry at typo3.org
Mon Sep 27 12:08:48 CEST 2010


Hi!

Steffen Kamper wrote:
> One time some methods inside t3lib_beFunc were changed to static
> functions. But they call other functions using $this which is not
> available in static context.
> Use NULL for the reference.

There can be side effects. In case if the function is not defined as static
but called statically, $this exists and points to a first object instance
on the stack. The hook can use that to get the instance of the calling
class (TCEforms or List instance, for example). Setting it to null may
break that. Such assumptions of having $this are hacky, of course, but we
may provide better compatibility by adding an optional parameter to such
functions that is null by default. We could pass that as $this to hooks.
That would ensure the same behavior. Also other core functions should be
modified to provide their $this to t3lib_BEfunc static functions.

I do not know if anybody uses $this in such hooks, so I am not sure if we
should provide such compatibility layer.

-- 
Dmitry Dulepov
TYPO3 core&security team member
Twitter: http://twitter.com/dmitryd
Read more @ http://dmitry-dulepov.com/


More information about the TYPO3-team-core mailing list