When I opened the /admin/appearance I got this message:

Notice: Trying to get property of non-object in shortcut_preprocess_page() (line 542 of /modules/shortcut/shortcut.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Tresler’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide any more detail on this? Are you at HEAD? Does this happen consistently? Are you logged in as user 1 or other?

I looked over the code in that function and can't see where it would be throwing that error. Which is not to say it isn't possible, but that I can't recreate the error.

Thanks.

arpeggio’s picture

I downloaded the 7.x-dev and installed as minimal profile and installed some modules which I already forgot (sorry). From what I remember not only in /admin/appearance but in all the pages I went I got that error message. I was logged in as user 1. Then I emptied my database and installed the alpha-2 version as standard profile, that error message was gone.

David_Rothstein’s picture

Were you definitely using a recent version of 7.x-dev when you experienced this? A while ago, there was a bug in the overlay module that caused this issue when the overlay and shortcut module were turned on at the same time. However, that was fixed a while ago - see #658118: Overlay prevents other modules turned on at the same time from being enabled correctly

See if you can still reproduce this with the latest codebase and if so, list the exact steps you took to trigger it (which modules you turned on, etc). Thanks!

arpeggio’s picture

Status: Postponed (maintainer needs more info) » Fixed

I updated my drupal in CVS and tried to reproduce the setup, it seems fine now. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

goldcrusaider’s picture

Status: Closed (fixed) » Active

Hi Can I reopen this? I have the same problem as the user above.Im running windows xp and Drupal 7.1.x installed a packaged drupal install with a theme template. Im getting the error: "Trying to get property of non-object in shortcut_preprocess_page() "

This happened after a new install. I don't have any php background can someone help?

alexpott’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs review
FileSize
1.47 KB
848 bytes

This still occurs in drupal 8.x

To reproduce:

  • Install Drupal with minimal profile
  • Log in as admin
  • Enable shortcut module

You will see the following error once the module is installed...

Notice: Undefined property: Drupal\shortcut\Plugin\Core\Entity\Shortcut::$links in shortcut_preprocess_page() (line 557 of core/modules/shortcut/shortcut.module).
Warning: Invalid argument supplied for foreach() in shortcut_preprocess_page() (line 557 of core/modules/shortcut/shortcut.module).

Unfortunately just adding a default links property to the Shortcut ConfigEntity fixes the issue but causes test failures.

alexpott’s picture

The fix in #8 was not quite right...

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Status: Needs review » Needs work

There's actually a deeper bug here, I'll post something in a bit.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
4.98 KB
alexpott’s picture

Status: Needs review » Reviewed & tested by the community

Tim's patch fixes the shortcut entity to always only have valid menu links by implementing hook_menu_link_delete() in the shortcut module. The patch also tidies up the shortcut entity so that the links property is always an array which results in some nice removals of if (isset($entity->links)) {... good work!

These changes look good to go to me.

tim.plunkett’s picture

Title: Trying to get property of non-object in shortcut_preprocess_page() » Shortcut doesn't properly clean up or store menu links
Dries’s picture

Somehow I thought we had deleted the shortcut module. :p

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Not yet, unfortunately. :) Can't until/unless Menu module provides the option to do per-user derivatives.

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.