Jump to content

You don't have access to list page /


MarkE
 Share

Recommended Posts

For some reason no users other than superusers can see the page tree on a site. The message is "You don't have access to list page /"

That seems to imply they don't have access to the home page, but looking at the access to the home page, there are no restrictions.

Any ideas?

Link to comment
Share on other sites

I'm not sure that there is an obvious answer to this as it seems to be related to a bunch of other inexplicable problems I have been having which are peculiar to my live envronment. See my comments here.

Link to comment
Share on other sites

  • 3 weeks later...
On 5/21/2024 at 12:21 AM, MarkE said:

For some reason no users other than superusers can see the page tree on a site. The message is "You don't have access to list page /"

That seems to imply they don't have access to the home page, but looking at the access to the home page, there are no restrictions.

Any ideas?

Any update?

Link to comment
Share on other sites

I have now looked into this in more depth and am even more puzzled.

In ready.php, I have two hooks:

wire()->addHookBefore('ProcessPageList::execute', function(HookEvent $event) {
	$process = $event->object;
	$listable = $process->page->listable;
	bd([$process->page, $listable], 'page, listable');
	if(!$listable) bd(debug_backtrace(), 'backtrace not listable');
});

wire()->addHookAfter('Page::listable', function(HookEvent $event) {
	$event->return = true;
	bd($event->return, 'listable return');
});

In the dev environment, this always yields the correct result, regardless of whether the hooks are called from /site/ready.php or my module ready():

1090367850_Screenshot2024-06-14105839.png.c37182b18a7f5818bda0424550b646c4.png

In the live environment, the result is correct only if the hooks are called from /site/ready.php. If the hooks are called from my module ready(), the result is:

2125362591_Screenshot2024-06-14110158.png.d717947aac574ad13f9e395727533682.png

Link to comment
Share on other sites

4 hours ago, BrendonKoz said:

Does it have the same end result if, on your dev environment, you have debug disabled?

Yes - it makes no difference.

On the dev site, I can track exactly what happens by stepping through with Xdebug. The only code between the two bardumps is a couple of WireData 'gets' for 'return' returning true. It would be great to be able to do the same in the live environment!

  • Sad 1
Link to comment
Share on other sites

When I was adjusting the Page's editable, listable, viewable, and addable method hooks, I was testing access for one to determine access to another. This caused a bit of a recursively confusing mess. You aren't by chance doing something similar, are you? If so, different calls of the same method can/will return different values due to context, and data that either is, or hasn't yet been set (typically access to templates in my case).

  • Like 1
Link to comment
Share on other sites

4 hours ago, BrendonKoz said:

You aren't by chance doing something similar, are you?

Interesting thought. I have a hook on viewable within a hook on ProcessPageEdit::buildFormContent. I also have a hook after User::hasPagePermission. I tried removing them temporarily and it made no difference.

Link to comment
Share on other sites

SOLVED!

With many thanks to @BrendonKoz and @flydev for encouraging me to persist in tracking this down. I finally managed to get the error to occur in the dev environment. That was progress as it enabled me to use Xdebug to see what was happening. I found another module with a listable hook in ready().

What was happening was this:

When my hook was in /site/ready.php it ran after any hooks in modules' ready(), because that is the order ProcessWire calls them in. When I put my hook in my module's ready() it still ran after the other module's hook in the dev environment but before it in the live environment. Assigning a higher priority to my hook (1000 - i.e. greater than the default 100) fixed it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...