Crikey error instead of error page

Hey everybody,

I’m having an odd issue and would love some pointers. I have a site with its own custom error page, and I’m sure it has worked already. I did some refining work afterwards, and now I just noticed that the error page isn’t displayed anymore, instead there’s a Crikey error that says:

"Call to a member function getRoute() on null"

in /grav/user/plugins/flex-objects/flex-objects.php > public function onPageNotFound(Event $event)

I did check whether my redirects were interfering, but taking them out didn’t change a thing. Other than that I don’t know what might be the problem?

Your thoughts and ideas are much appreciated!

@Netzhexe, I’ve had a quick look at all the relevant info you have shared, but didn’t find anything suspicious… :wink:

My thoughts exactly! :laughing: However, the problem exists and there must be a cause somewhere. I’ll try to take the site apart in a testing environment and see if anything comes up.

I was just hoping somebody would have a brilliant inspiration right away… :wink:

I’ve looked into this a little more, and the issue might yet be with my .htaccess redirects. I’m not sure – taking them out doesn’t change the Crikey error, but I’ve had quite a few run-ins with cached redirects in the past :neutral_face: – I’m leaving them out on one site for a few days and see if that changes anything.

What seems to make a strong case for the redirects as the culprits is, on localhost everything is fine. I put this in my .htaccess file as the first redirect rule:

RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} ^domain-name\.de$
RewriteRule ^(.*)$ http://www.domain-name.de/$1 [L,R=301]

Could this affect the retrievability of a custom error page, I’m wondering?

Okay so one step further: the error goes away when I disable the PageLocks plugin… :grinning_face_with_smiling_eyes: However, I also have a website where PageLocks is in use and everything works miraculously, just as it should, so clearly there are some more factors involved here. I’m working on this, will keep you posted :upside_down_face:

This is getting more confusing the longer I look! I meant to track down the code that gives me the Crikey error, or rather, that the Crikey error reports. As you can see in the screenshot, this is supposedly line 287 in user/plugins/flex-objects/flex-objects.php:

$parts = explode('/', $route->getRoute());

But when I check out that file, that line looks like this:

$page = $this->grav['page'] ?? null;

The only file where I can find function onPageNotFound is in user/plugins/error/error.php, line 66, BUT the line from the Crikey error is actually from user/plugins/flex-objects/flex-objects.php line 297

So it seems to me that the error page somehow smashes these two files together. Not sure whether that’s a problem, but it’s definitely confusing me.

Still appreciating all ideas…

Some more information (that also confuses me):

I have two websites that show this error instead of the custom error page (also if there is no custom error page). Both show the error page as expected if I disable the PageLocks plugin.

However, both show NO error on localhost with PageLocks enabled. And to make this really interesting, I have another two websites with PageLocks enabled where everything works just fine. I can’t seem to find any relevant difference between them??

And also, switching the use of flex objects off for pages does not change anything.

I’d bet you’re using different version. And you linked a file to a specific commit, but not latest. This line is there on v1.1.3 and I didn’t really bother to figure out which version you linked to

BTW, current version is 1.1.6