Bug #53682
closedException '$toolbarItem "shortcuts" must implement interface ...\ToolbarItemHookInterface'
Added by Jost Baron almost 11 years ago. Updated almost 6 years ago.
100%
Description
The backend does not work with PHP 5.5.6 anymore. The exception thrown is this one:
$toolbarItem "shortcuts" must implement interface TYPO3\CMS\Backend\Toolbar\ToolbarItemHookInterface
To reproduce, create a new 6.2 installation using the wizard in the install tool, and run it on PHP 5.5.6.
This does not happen on PHP 5.5.5 or 5.4.22, I have not tested other versions. Ernesto Baschny pointed out that this problem occurred with PHP 5.3.3 too, maybe that info helps?
Link to the PHP bug tracker: https://bugs.php.net/bug.php?id=66107
The following classes are affected:
- typo3/sysext/backend/Classes/Toolbar/ToolbarItemHookInterface
- typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem
- typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem
- typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem
- typo3/sysext/backend/Classes/Form/Element/TreeElement.php
- typo3/sysext/workspaces/Classes/ExtDirect/WorkspaceSelectorToolbarItem.php
- typo3/sysext/opendocs/Classes/Controller/OpendocsController.php
- typo3/sysext/sys_action/Classes/ActionToolbarMenu.php
To solve the issue temporarily you need to modify the constructor of those classes by removing the reference operator (&) of all referenced class parameters.
public function __construct(SomeClassNameHere &$backendReference = NULL)
public function __construct(SomeClassNameHere $backendReference = NULL)
Files
test.php (704 Bytes) test.php | Chris Zepernick, 2013-11-27 00:09 | ||
php-5.5.6.patch (7.06 KB) php-5.5.6.patch | Philipp Gampe, 2013-12-07 13:01 |
Updated by Markus Klein over 10 years ago
- Category set to Backend API
- Target version set to next-patchlevel
- PHP Version set to 5.5
Where does it occur exactly? This can happen in Core at two places?
The exception codes are:- 1195126772, BackendController:152
- 1195125501, BackendController:679
Updated by Jeff Segars over 10 years ago
I noticed the same error yesterday, thrown inside \TYPO3\CMS\Backend\Controller\BackendController->initializeCoreToolbarItems(). I've seen it on 4.7, 6.0, and 6.2 (haven't tested 4.5 or 6.1 yet). When I downgrade to PHP 5.5.5 the issue goes away.
From my initial investigation, the problem is in some way connected to using reflection and constructor arguments when creating the instance of the toolbar item. Inside initializeCoreToolbarItems, we have a call to makeInstance(), passing along $this as a constructor argument. Inside makeInstance(), reflection is used when handling arguments. At line 4179 of \TYPO3\CMS\Core\Utility\GeneralUtility we have "$instance = $reflectedClass->newInstanceArgs($constructorArguments)" which returns null. If I switch it to newInstance() instead, I get a valid object back.
That's about as far as I've made it in debugging for now, but maybe some of that info is helpful.
Updated by Alexander Bigga over 10 years ago
Same problem here on current Arch Linux:
- PHP 5.5.6
- TYPO3 6.1.5 (introduction package)
#1195126772: $toolbarItem "shortcuts" must implement interface TYPO3\CMS\Backend\Toolbar\ToolbarItemHookInterface (More information) UnexpectedValueException thrown in file /[...]/typo3_src-6.1.5/typo3/sysext/backend/Classes/Controller/BackendController.php in line 148.
I was looking for an explanation and never had PHP in mind :-(
Alexander
Updated by Markus Klein over 10 years ago
- Status changed from New to Accepted
- TYPO3 Version changed from 6.2 to 4.5
Joerg Neikes wrote:
graphicsmagic does not work too.
With php 5.5.5 all works fine.
May be a wrong bug fix in php update.
The running system is a gentoo ~x64 distributon with updates from 18.11.2013.
Updated by Markus Klein over 10 years ago
Related bug report: https://bugs.php.net/bug.php?id=66107
Updated by Ernesto Baschny over 10 years ago
See also discussion in this "Tweet" (!!):
Updated by Markus Klein over 10 years ago
The reference in the constructor was introduced with #17795
Updated by Chris Zepernick over 10 years ago
The Problem does not only occur in TYPO3 Version 4.x but also 6.x.
The Bug is not caused by TYPO3 but by PHP ReflectionClass::newInstanceArgs($array);
If a parameter is passed by reference the Bug occurs.
The Bug can be avoided in this case by altering :
- typo3_src/typo3/sysext/backend/Classes/Toolbar/ToolbarItemHookInterface
- typo3_src/typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem
- typo3_src/typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem
- typo3_src/typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem
alter: "public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL)“
to: "public function __construct(\TYPO3\CMS\Backend\Controller\BackendController $backendReference = NULL)“
These "pass by reference" are unnecessary since PHP5 because Objects are always passed by reference.
After that change TYPO3 should mostly work as expected.
Little Testcase attached.
Tested with this VagrantBox: https://github.com/swiftlizard/VagrantTYPO3Flow
Updated by Artus Kolanowski over 10 years ago
Chris Zepernick wrote:
The Problem does not only occur in TYPO3 Version 4.x but also 6.x...
Thanks! Helped me to fix a running TYPO3 6.1.5. The Hoster just switched to PHP 5.5.6 without telling anybody...
Updated by Stefan Neufeind over 10 years ago
It seems PHP is not going to fix this in 5.5.7, though I would have expected that because it's a regression. Preliminary changelog for 5.5.7RC1:
https://github.com/php/php-src/blob/php-5.5.7RC1/NEWS
Updated by Viktor Livakivskyi over 10 years ago
Chris Zepernick wrote:
In my TYPO3 6.0.10 instance I've had also to fix same in these files:The Bug can be avoided in this case by altering :
- typo3_src/typo3/sysext/backend/Classes/Toolbar/ToolbarItemHookInterface
- typo3_src/typo3/sysext/backend/Classes/Toolbar/ShortcutToolbarItem
- typo3_src/typo3/sysext/backend/Classes/Toolbar/LiveSearchToolbarItem
- typo3_src/typo3/sysext/backend/Classes/Toolbar/ClearCacheToolbarItem
alter: "public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL)“
to: "public function __construct(\TYPO3\CMS\Backend\Controller\BackendController $backendReference = NULL)“
- typo3_src/typo3/sysext/workspaces/Classes/ExtDirect/WorkspaceSelectorToolbarItem.php
- typo3_src/typo3/sysext/opendocs/Classes/Controller/OpendocsController.php
- typo3_src/typo3/sysext/sys_action/Classes/ActionToolbarMenu.php
Because they are using same interface.
Updated by Artus Kolanowski over 10 years ago
Here is the next one:
- typo3_src/typo3/sysext/backend/Classes/Form/Element/TreeElement.php
Otherwise I'm not able to edit BE users (Fatal error: Call to a member function renderField() on a non-object in [...]/typo3_src-6.1.6/typo3/sysext/backend/Classes/Form/FormEngine.php on line 1749
).
Updated by David Bruchmann over 10 years ago
Just searching for "&$" in the core including the sysext-folder I found 1346 occurrences in version 6.1.
Some are in comments, some are for arrays, nevertheless the changed behavior of php seems being some work for TYPO3.
Updated by Frenck Lutke over 10 years ago
David Bruchmann wrote:
Just searching for "&$" in the core including the sysext-folder I found 1346 occurrences in version 6.1.
Some are in comments, some are for arrays, nevertheless the changed behavior of php seems being some work for TYPO3.
The only changes needed due to this PHP bug are with references in constructors, of which there are only ~10 occurrences in core (depends on version), of which most were already mentioned in these comments. These are all objects, so there is no functional difference when changing their reference declaration.
You can easily confirm, as well as find any offending extensions in your installation, with a simple regular expression: (?<=__construct\()(.*&.+)(?=\))
Updated by Philipp Gampe over 10 years ago
- File php-5.5.6.patch php-5.5.6.patch added
Attached is a patch against current master that should work across 6.x. Please not that it breaks any extension that uses the interface to add toolbar items.
IMHO we should wait for a patch from the PHP.
Hint: use $ git apply php-5.5.6.patch to read in the patch file
Updated by Philipp Gampe over 10 years ago
Same issue in typo3/sysext/backend/Classes/Form/Element/TreeElement.php
Updated by Markus Klein over 10 years ago
- Subject changed from Backend does not work with PHP 5.5.6 to Exception '$toolbarItem "shortcuts" must implement interface ...\ToolbarItemHookInterface'
Updated by Markus Klein over 10 years ago
Some news from the PHP bug tracker:
I've reverted changes in PHP-5.5 (not in PHP-5.6 and above).
Updated by Stefan Neufeind over 10 years ago
Thanks. So for now we can expect a fixed 5.5.7 some time. But we'll still need the change for 5.6+ then. Planned release for 5.6 is sometime around August 2014.
http://comments.gmane.org/gmane.comp.php.devel/82450
It's already mid-october and according to our release schedule we have to
release PHP 5.6 in 10 months from now.
Updated by Markus Klein over 10 years ago
Yes we indeed need a fix for TYPO3 as well. It does not make sense to pass the parameters as reference (nowadays) since we don't modify the variable in our constructors.
IMHO it is best to go with this breaking change now, before the 6.2 release.
Updated by Philipp Gampe over 10 years ago
Related work-around: https://review.typo3.org/#/c/26344/3
Updated by Gerrit Code Review over 10 years ago
- Status changed from Accepted to Under Review
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26344
Updated by Helmut Hummel over 10 years ago
Markus Klein wrote:
IMHO it is best to go with this breaking change now, before the 6.2 release.
Why not completely remove the constructor from the interface? That is bad style anyway.
Updated by Stefan Neufeind over 10 years ago
Timetable for PHP 5.6: https://wiki.php.net/todo/php56#timetable
alpha1 in January (so we could start testing), final in June
Updated by patr no-lastname-given over 10 years ago
I have typo3 4.7.17 same problem.
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26363
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26363
Updated by Stefan Neufeind over 10 years ago
PHP 5.5.7 has just been released. But if I see a fix for our problem in the changelog :-(
http://www.php.net/ChangeLog-5.php#5.5.7
Updated by Gerrit Code Review over 10 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26363
Updated by Gerrit Code Review over 10 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26363
Updated by Gerrit Code Review over 10 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26363
Updated by Philipp Gampe over 10 years ago
another place for 4.5:
/typo3/sysext/em/classes/repository/class.tx_em_repository_utility.php
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26413
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch TYPO3_6-0 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26414
Updated by Helmut Hummel over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 6eb7a548125a945316f8ad32eb3e5481a28ae2d6.
Updated by Gerrit Code Review over 10 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch TYPO3_4-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26416
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26413
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch TYPO3_6-0 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26414
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch TYPO3_4-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26416
Updated by Gerrit Code Review over 10 years ago
Patch set 3 for branch TYPO3_4-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26416
Updated by Gerrit Code Review over 10 years ago
Patch set 4 for branch TYPO3_4-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26416
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch TYPO3_4-5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/26643
Updated by Helmut Hummel over 10 years ago
- Status changed from Under Review to Resolved
Applied in changeset dd187dd1b3bb2e38ed7dd989efd1055f053cd880.
Updated by Markus Klein over 10 years ago
- Status changed from Resolved to Under Review
Still the 4.7 and 4.5 patches are pending
Updated by Helmut Hummel over 10 years ago
- Status changed from Under Review to Resolved
Applied in changeset 2526bddb5b27ca832575fad809facfa39c7db225.
Updated by Claas Hilbrecht almost 10 years ago
Helmut Hummel wrote:
Applied in changeset 2526bddb5b27ca832575fad809facfa39c7db225.
The changeset was removed with ab6256f from 4.5LTS and is not included anymore (and it seems no other patch that fixes the originating problem). I cherry-picked the patch and it seems to work but I wonder why it was removed without any other fix?
2014-01-17 ab6256f Revert "[TASK] Optimize speed for instantiating class with arguments" (Ernesto Baschny)
2014-01-17 2526bdd #53682 [TASK] Optimize speed for instantiating class with arguments (Helmut Hummel)
Updated by Helmut Hummel almost 10 years ago
Claas Hilbrecht wrote:
2014-01-17 ab6256f Revert "[TASK] Optimize speed for instantiating class with arguments" (Ernesto Baschny)
It was reverted (only) because of a compatibility issue with PHP 5.2 (see: https://review.typo3.org/#/c/26910/)
I would be in favor of getting this in again with self:: instead of static:: for 4.5
Updated by Gerrit Code Review almost 10 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33307
Updated by Gerrit Code Review almost 10 years ago
Patch set 1 for branch TYPO3_4-5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33308
Updated by Claas Hilbrecht almost 10 years ago
Gerrit Code Review wrote:
Patch set 1 for branch TYPO3_4-5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33308
Hello Helmut,
thanks for the really quick fix, I owe you a beer next time we meet ;)
Updated by Helmut Hummel almost 10 years ago
- Status changed from Under Review to Resolved
Applied in changeset 5c8081ad4487a66bad333149c65fe706106ad938.
Updated by Markus Klein almost 10 years ago
This introduced a regression in 4.5; The change is not PHP 5.2 (!) compatible, see #62391
Updated by Benni Mack almost 6 years ago
- Status changed from Resolved to Closed