Project

General

Profile

Actions

Bug #53682

closed

Exception '$toolbarItem "shortcuts" must implement interface ...\ToolbarItemHookInterface'

Added by Jost Baron over 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Backend API
Target version:
Start date:
2013-11-15
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

Related issues 7 (0 open7 closed)

Related to TYPO3 Core - Feature #17795: add the workspace selector to the cleaner backend toolbarClosedIngo Renner2007-11-15

Actions
Related to TYPO3 Core - Bug #54425: TYPO3\CMS\Frontend\ContentObject\ContentObject not foundClosed2013-12-15

Actions
Related to TYPO3 Core - Bug #55811: Namespace usage in 4.7Closed2014-02-09

Actions
Related to TYPO3 Core - Bug #62391: TYPO3 4.5.37 requires PHP 5.3Closed2014-10-22

Actions
Related to TYPO3 Core - Bug #33416: Exception thrown by tslib_content->getContentObject when referenced TS objects are emptyClosed2012-01-24

Actions
Has duplicate TYPO3 Core - Bug #53754: Failure in backend with php-5.5.6Closed2013-11-19

Actions
Has duplicate TYPO3 Core - Bug #53777: Exception: $toolbarItem "shortcuts" must implement interface backend_toolbarItem Closed2013-11-20

Actions
Actions #1

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
Actions #2

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.

Actions #3

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

Actions #4

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.

Actions #6

Updated by Ernesto Baschny over 10 years ago

See also discussion in this "Tweet" (!!):

https://twitter.com/SwiftLizard/status/405419858864533504

Actions #7

Updated by Markus Klein over 10 years ago

The reference in the constructor was introduced with #17795

Actions #8

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

Actions #9

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...

Actions #10

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

Actions #11

Updated by Viktor Livakivskyi over 10 years ago

Chris Zepernick wrote:

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)“

In my TYPO3 6.0.10 instance I've had also to fix same in these files:
  • 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.

Actions #12

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).

Actions #13

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.

Actions #14

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\()(.*&.+)(?=\))

Actions #15

Updated by Philipp Gampe over 10 years ago

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

Actions #16

Updated by Philipp Gampe over 10 years ago

Same issue in typo3/sysext/backend/Classes/Form/Element/TreeElement.php

Actions #17

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'
Actions #18

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).

Actions #19

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.

Actions #20

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.

Actions #22

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

Actions #23

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.

Actions #24

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

Actions #25

Updated by patr no-lastname-given over 10 years ago

I have typo3 4.7.17 same problem.

Actions #26

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

Actions #27

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

Actions #28

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

Actions #29

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

Actions #30

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

Actions #31

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

Actions #32

Updated by Philipp Gampe over 10 years ago

another place for 4.5:
/typo3/sysext/em/classes/repository/class.tx_em_repository_utility.php

Actions #33

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

Actions #34

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

Actions #35

Updated by Helmut Hummel over 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #36

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

Actions #37

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

Actions #38

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

Actions #39

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

Actions #40

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

Actions #41

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

Actions #42

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

Actions #43

Updated by Helmut Hummel over 10 years ago

  • Status changed from Under Review to Resolved
Actions #44

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

Actions #45

Updated by Helmut Hummel over 10 years ago

  • Status changed from Under Review to Resolved
Actions #46

Updated by Claas Hilbrecht over 9 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)

Actions #47

Updated by Helmut Hummel over 9 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

Actions #48

Updated by Gerrit Code Review over 9 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

Actions #49

Updated by Gerrit Code Review over 9 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

Actions #50

Updated by Claas Hilbrecht over 9 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 ;)

Actions #51

Updated by Helmut Hummel over 9 years ago

  • Status changed from Under Review to Resolved
Actions #52

Updated by Markus Klein over 9 years ago

This introduced a regression in 4.5; The change is not PHP 5.2 (!) compatible, see #62391

Actions #53

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF