[support] hook_load() called several times from menu items

Andy Fowlston andy at pedalo.co.uk
Thu Jan 10 14:31:54 UTC 2013


Hi Marco,

I only skimmed your message, but it looks like you might be hitting a known issue:

http://drupal.org/node/1471554
(see also: http://drupal.stackexchange.com/q/38987/633)

The simple answer now seems to be to implement caching in your loader function.

Thanks,

Andy

. . . . . . . 
Andy Fowlston
+44 (0)20 8747 5068
andy at pedalo.co.uk
Skype: andy.pedalo
www.pedalo.co.uk

Follow us on Twitter: https://twitter.com/#!/pedalowebdesign
Follow us on Facebook: https://www.facebook.com/pages/Pedalo-Ltd-Web-Design-Development-Agency/135676139777332
Check out our blog: http://www.pedalo.co.uk/blog/

This email is intended only for the above named addressee/s. This email may be
confidential or legally privileged. If you have received this email and you
are not a named addressee, you must not use, copy, distribute or disclose the
email or any part of its contents or take any action in reliance on it. If you
have received this email in error, please email the sender by replying to this
message and delete it from your system. All reasonable precautions have been
taken to ensure no viruses are present in this email.

pedalo limited cannot accept responsibility for loss or damage arising from
the use of this email or attachments and recommends that you subject these to
your virus checking procedures prior to use. Any views or opinions presented
are solely those of the author and not necessarily those of Pedalo Limited

Please consider the environment before printing this email
-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of Marco Lechner - IMR
Sent: 09 January 2013 20:39
To: support at drupal.org
Subject: [support] hook_load() called several times from menu items

Hi,

I have a may be weird behaviour in the menu items of my module. To bring it down to simple code I foo-bar-ed it on  [1]

To describe it in a few words:
In my modules-ui I define some paths/routes like /foo, foo/list, foo/add, foo/%bar/delete, foo/%bar/edit ...

foo/list and foo/add are used to show a list if bar-objects or to open a form to add a new one using simple _form()-hooks.

when editing, deleting or cloning an existing bar object a callback function is used to create the form who takes the bar-object as input - provided by the %bar -> bar_load()-hook

As long as foo/%bar/... items are not defined in my menu()-hook
bar_load() is never called, but as soon as foo/%bar/... items are added to menu(), bar_load() is called several times (as often as menu-items with %bar exist) even when I request for foo/add or foo/list (which do not use %bar in any way.

Is this the intented behaviour? Why and which element calls the %bar bar_load()-hook even when my URl request does not fit the path-definition (foo/list instead of foo/%bar/edit -> I have no foo/%bar or foo/%bar/ defined)

May be I still do not understand Drupals architecture and Hook-system in a right way?

Marco

[1] http://pastebin.com/w0waVgX4
--
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list