Bug #53682
Exception '$toolbarItem "shortcuts" must implement interface ...\ToolbarItemHookInterface'
Status: | Resolved | Start date: | 2013-11-15 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | - | % Done: | 100% |
|
Category: | Backend API | Spent time: | - | |
Target version: | next-patchlevel | |||
TYPO3 Version: | 4.5 | Is Regression: | No | |
PHP Version: | 5.5 | Sprint Focus: | ||
Complexity: |
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.
1public function __construct(SomeClassNameHere &$backendReference = NULL)
1public function __construct(SomeClassNameHere $backendReference = NULL)
Related issues
Associated revisions
[TASK] Optimize speed for instantiating class with arguments
PHP reflection has quite an overhead in performance.
Use a switch construct like in Flow instead to
instantiate classes with up to 8 arguments without
reflection.
Resolves: #53682
Releases: 6.2, 6.1, 6.0
Change-Id: I82ecf0b1ea9a412a39b4429d7689f2bb6489f3df
Reviewed-on: https://review.typo3.org/26363
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Markus Klein
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
[TASK] Optimize speed for instantiating class with arguments
PHP reflection has quite an overhead in performance.
Use a switch construct like in Flow instead to
instantiate classes with up to 8 arguments without
reflection.
Resolves: #53682
Releases: 6.2, 6.1, 6.0
Change-Id: I82ecf0b1ea9a412a39b4429d7689f2bb6489f3df
Reviewed-on: https://review.typo3.org/26413
Reviewed-by: Markus Klein
Tested-by: Markus Klein
[TASK] Optimize speed for instantiating class with arguments
PHP reflection has quite an overhead in performance.
Use a switch construct like in Flow instead to
instantiate classes with up to 8 arguments without
reflection.
Resolves: #53682
Releases: 6.2, 6.1, 6.0
Change-Id: I82ecf0b1ea9a412a39b4429d7689f2bb6489f3df
Reviewed-on: https://review.typo3.org/26414
Reviewed-by: Markus Klein
Tested-by: Markus Klein
[TASK] Optimize speed for instantiating class with arguments
PHP reflection has quite an overhead in performance.
Use a switch construct like in Flow instead to
instantiate classes with up to 8 arguments without
reflection.
Resolves: #53682
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Change-Id: I82ecf0b1ea9a412a39b4429d7689f2bb6489f3df
Reviewed-on: https://review.typo3.org/26416
Reviewed-by: Markus Klein
Reviewed-by: Oliver Klee
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
[TASK] Optimize speed for instantiating class with arguments
PHP reflection has quite an overhead in performance.
Use a switch construct like in Flow instead to
instantiate classes with up to 8 arguments without
reflection.
Resolves: #53682
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Change-Id: I82ecf0b1ea9a412a39b4429d7689f2bb6489f3df
Reviewed-on: https://review.typo3.org/26643
Reviewed-by: Markus Klein
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
[BUGFIX] Namespace usage in test
Patch for issue #31998 introduced a namespace in unit test,
the test suite now fails after patch for issue #53682. Use
old class name instead.
Change-Id: I83e7cd33787364c1f531c51406f09884aff418c6
Resolves: #55811
Related: #53682
Related: #31998
Releases: 4.7, 4.5
Reviewed-on: https://review.typo3.org/27513
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
[BUGFIX] Namespace usage in test
Patch for issue #31998 introduced a namespace in unit test,
the test suite now fails after patch for issue #53682. Use
old class name instead.
Change-Id: I83e7cd33787364c1f531c51406f09884aff418c6
Resolves: #55811
Related: #53682
Related: #31998
Releases: 4.7, 4.5
Reviewed-on: https://review.typo3.org/27513
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
(cherry picked from commit df8e21b7e727d7ec709ed9f92e3069d77db0be04)
Reviewed-on: https://review.typo3.org/27514
[TASK] Optimize speed for instantiating class with arguments
PHP reflection has quite an overhead in performance.
Use a switch construct like in Flow instead to
instantiate classes with up to 8 arguments without
reflection.
Resolves: #53682
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Change-Id: I8ab21fa5ae609fc4653205f4b53c51ed61618ea7
Reviewed-on: http://review.typo3.org/33308
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
History
#1 Updated by Markus Klein over 1 year 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
#2 Updated by Jeff Segars over 1 year 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.
#3 Updated by Alexander Bigga over 1 year 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
#4 Updated by Markus Klein over 1 year 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.
#5 Updated by Markus Klein over 1 year ago
Related bug report: https://bugs.php.net/bug.php?id=66107
#6 Updated by Ernesto Baschny over 1 year ago
See also discussion in this "Tweet" (!!):
#7 Updated by Markus Klein over 1 year ago
The reference in the constructor was introduced with #17795
#8 Updated by Chris Zepernick over 1 year ago
- File test.php
added
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
#9 Updated by Artus Kolanowski over 1 year 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...
#10 Updated by Stefan Neufeind over 1 year 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
#11 Updated by Viktor Livakivskyi over 1 year 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.
#12 Updated by Artus Kolanowski over 1 year 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
).
#13 Updated by David Bruchmann over 1 year 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.
#14 Updated by Frenck Lutke over 1 year 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\()(.*&.+)(?=\))
#15 Updated by Philipp Gampe over 1 year ago
- File 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
#16 Updated by Philipp Gampe over 1 year ago
Same issue in typo3/sysext/backend/Classes/Form/Element/TreeElement.php
#17 Updated by Markus Klein over 1 year ago
- Subject changed from Backend does not work with PHP 5.5.6 to Exception '$toolbarItem "shortcuts" must implement interface ...\ToolbarItemHookInterface'
#18 Updated by Markus Klein over 1 year ago
Some news from the PHP bug tracker:
I've reverted changes in PHP-5.5 (not in PHP-5.6 and above).
#19 Updated by Stefan Neufeind over 1 year 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.
#20 Updated by Markus Klein over 1 year 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.
#21 Updated by Philipp Gampe over 1 year ago
Related work-around: https://review.typo3.org/#/c/26344/3
#22 Updated by Gerrit Code Review over 1 year 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
#23 Updated by Helmut Hummel over 1 year 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.
#24 Updated by Stefan Neufeind over 1 year ago
Timetable for PHP 5.6: https://wiki.php.net/todo/php56#timetable
alpha1 in January (so we could start testing), final in June
#25 Updated by patr no-lastname-given over 1 year ago
I have typo3 4.7.17 same problem.
#26 Updated by Gerrit Code Review over 1 year 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
#27 Updated by Gerrit Code Review over 1 year 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
#28 Updated by Stefan Neufeind over 1 year 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
#29 Updated by Gerrit Code Review over 1 year 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
#30 Updated by Gerrit Code Review over 1 year 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
#31 Updated by Gerrit Code Review over 1 year 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
#32 Updated by Philipp Gampe over 1 year ago
another place for 4.5:
/typo3/sysext/em/classes/repository/class.tx_em_repository_utility.php
#33 Updated by Gerrit Code Review over 1 year 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
#34 Updated by Gerrit Code Review over 1 year 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
#35 Updated by Helmut Hummel over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 6eb7a548125a945316f8ad32eb3e5481a28ae2d6.
#36 Updated by Gerrit Code Review over 1 year 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
#37 Updated by Gerrit Code Review over 1 year 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
#38 Updated by Gerrit Code Review over 1 year 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
#39 Updated by Gerrit Code Review over 1 year 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
#40 Updated by Gerrit Code Review over 1 year 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
#41 Updated by Gerrit Code Review over 1 year 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
#42 Updated by Gerrit Code Review over 1 year 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
#43 Updated by Helmut Hummel over 1 year ago
- Status changed from Under Review to Resolved
Applied in changeset dd187dd1b3bb2e38ed7dd989efd1055f053cd880.
#44 Updated by Markus Klein over 1 year ago
- Status changed from Resolved to Under Review
Still the 4.7 and 4.5 patches are pending
#45 Updated by Helmut Hummel over 1 year ago
- Status changed from Under Review to Resolved
Applied in changeset 2526bddb5b27ca832575fad809facfa39c7db225.
#46 Updated by Claas Hilbrecht 10 months 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)
#47 Updated by Helmut Hummel 10 months 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
#48 Updated by Gerrit Code Review 10 months 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
#49 Updated by Gerrit Code Review 10 months 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
#50 Updated by Claas Hilbrecht 10 months 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 ;)
#51 Updated by Helmut Hummel 10 months ago
- Status changed from Under Review to Resolved
Applied in changeset 5c8081ad4487a66bad333149c65fe706106ad938.
#52 Updated by Markus Klein 10 months ago
This introduced a regression in 4.5; The change is not PHP 5.2 (!) compatible, see #62391