[TYPO3-core] #53682, PHP 5.5.6, call-time pass-by-reference, PHP 5.6

Markus Klein klein.t3 at mfc-linz.at
Fri Dec 13 09:28:51 CET 2013


Sorry but I've to clear things up a bit here.

It is WRONG that passing variables by reference is deprecated. It is of course not!!!

What has been deprecated long ago is the & operator used on variables in a function call. So called "call-time pass-by-reference". (function foo($x) {}    $a = ''; foo(&$a);)

We have to strongly distinguish between variables being an object-reference and variables passed by reference. It is perfectly valid to pass an object-reference by reference.

This example works and is not deprecated:
class classA{};
class classB{};

function changeIt (object &$a) { $a = new classB(); ]

$x = new classA();
echo gettype($x); // classA
echo gettype($x); // classB

So our current solution in Core is not against any rule!
It is indeed a breaking change in PHP 5.6+ that the support of passing variables by reference to a constructor is not possible anymore.

Kind regards

Markus Klein
TYPO3 CMS Active Contributors Team Member

> -----Original Message-----
> From: typo3-team-core-bounces at lists.typo3.org [mailto:typo3-team-core-
> bounces at lists.typo3.org] On Behalf Of Philipp Gampe
> Sent: Thursday, December 12, 2013 11:18 PM
> To: typo3-team-core at lists.typo3.org
> Subject: [TYPO3-core] #53682, PHP 5.5.6, call-time pass-by-reference, PHP
> 5.6
> Hi all,
> Some distributions (like Fedora) already ship PHP 5.5.6. The version includes
> a performance improvement for func_get_args() that breaks the TYPO3
> backend (all versions).
> > Improved performance of array_merge() and func_get_args() by
> eliminating
> >     useless copying. (Dmitry)
> > Exception '$toolbarItem "shortcuts" must implement interface ...
> ToolbarItemHookInterface'
> http://forge.typo3.org/issues/53682
> The problem here is that the deprecated usage of the reference operator is
> used in the interface of ToolBarItemHook (top bar items).
> Removing the reference operator changes the method signature and PHP
> throws a fatal error for each implementing class.
> This will break any backend where extensions with custom toolbar items
> (e.g.
> extdevel) are used - even if we fix all usages in the core itself.
> The change in PHP 5.5.6 has been reverted for PHP 5.5.7:
> https://bugs.php.net/bug.php?id=66107
> However PHP 5.6 (expected in June) will ship the change. Therefore we need
> to react.
> https://wiki.php.net/todo/php56#timetable
> There is a change suggested to change makeInstance() to check for such a
> reference operator (via reflection) and pass the parameter by reference.
> Although the change did not have a big impact for me, it still create yet
> another performance drawback.
> I suggest to change the the problematic lines in the core for 6.2 as we will get
> a breaking backend without it and extensions are expected to likely break.
> Will still need to find a solution for <=6.1. Either by introducing an upper the
> PHP version limit for the older branches as PHP 5.5.x excluding 5.5.6; or by
> changing the code (likely breaks many backends) or by introducing the
> workaround from above.
> I would like to hear your options regarding this topic.
> Best regards
> --
> Philipp Gampe – PGP-Key 0AD96065 – TYPO3 UG Bonn/Köln Documentation
> – Active contributor TYPO3 CMS
> TYPO3 .... inspiring people to share!
> _______________________________________________
> Before posting to this list, please have a look to the posting rules on the
> following websites:
> http://typo3.org/teams/core/core-mailinglist-rules/
> http://typo3.org/development/bug-fixing/diff-and-patch/
> _______________________________________________
> TYPO3-team-core mailing list
> TYPO3-team-core at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-team-core

More information about the TYPO3-team-core mailing list