When a module defines a menu item whose page and access callbacks are in a separate file (pages.inc), the access callback function is not loaded prior to the call.

When visiting the page, this results in a "non-valid callback, access denied" message.

Page callback works fine in a separate file, even without declaring that file to the menu system. Access callback doesn't.

Comments

cburschka’s picture

Status: Active » Needs review
StatusFileSize
new776 bytes

Here is a patch that seems to fix the problem. I hope that hitting the registry an additional time in this place is not a performance drag.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. Go registry.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Let's get some tests for this behaviour, please, so we don't accidentally re-introduce it.

cburschka’s picture

Status: Needs work » Needs review
StatusFileSize
new4.3 KB

Here is a test that should fail prior the patch and pass with it. I say should because my site still refuses to run tests properly. It's possible that a typo snuck in there, I wrote this "offline".

The test checks both a simple page callback in a separate file, and an access callback like the above.

While looking at the menu.test, I noticed that it really tests only very little of the full API - stuff like wildcards, tokens, returning a boolean in 'access callback' etc. is never done. But that is way out of this patch's scope, and besides I'm really not good at unit tests.

This is not a replacement for patch #1, but an addition to it. This is to allow running the test without the patch applied.

cburschka’s picture

I think there is something wrong here, as the testing site should have rejected this last patch which is supposed to introduce a failing test without fixing it. As said, this needs someone with working simpletest to fix.

cburschka’s picture

Nope, test works as it should. After reinstalling my test site, SimpleTest once again works (I might have been using a pre-final version of the SQLite driver earlier).

The testing patch #4 causes one failed test that disappears when the fix in #1 is added. I don't know why the test-bed disagrees.

Status: Needs review » Needs work

The last submitted patch failed testing.

webprods’s picture

Status: Needs work » Needs review
retester2010’s picture

Status: Needs review » Needs work

The last submitted patch, test-menu-callback-registry-337907-4.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.