Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-existent page: Call to a member function slug() on null #66

Closed
zegkljan opened this issue Aug 4, 2022 · 3 comments
Closed

Non-existent page: Call to a member function slug() on null #66

zegkljan opened this issue Aug 4, 2022 · 3 comments
Assignees

Comments

@zegkljan
Copy link

zegkljan commented Aug 4, 2022

When I go to a page that does not exist, instead of 404 page, I'm greeted with an ugly error caused by langswitcher:

Error thrown with message "Call to a member function slug() on null"

Stacktrace:
#48 Error in /var/www/html/user/plugins/langswitcher/langswitcher.php:80
#47 Grav\Plugin\LangSwitcherPlugin:_getTranslatedUrl in /var/www/html/user/plugins/langswitcher/langswitcher.php:143
#46 Grav\Plugin\LangSwitcherPlugin:onTwigSiteVariables in /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php:264
#45 Symfony\Component\EventDispatcher\EventDispatcher:doDispatch in /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php:239
#44 Symfony\Component\EventDispatcher\EventDispatcher:callListeners in /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php:73
#43 Symfony\Component\EventDispatcher\EventDispatcher:dispatch in /var/www/html/system/src/Grav/Common/Grav.php:592
#42 Grav\Common\Grav:fireEvent in /var/www/html/system/src/Grav/Common/Twig/Twig.php:413
#41 Grav\Common\Twig\Twig:processSite in /var/www/html/system/src/Grav/Common/Service/OutputServiceProvider.php:36
#40 Grav\Common\Service\OutputServiceProvider:Grav\Common\Service\{closure} in /var/www/html/vendor/pimple/pimple/src/Pimple/Container.php:122
#39 Pimple\Container:offsetGet in /var/www/html/system/src/Grav/Common/Processors/RenderProcessor.php:40
#38 Grav\Common\Processors\RenderProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#37 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#36 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php:38
#35 Grav\Common\Processors\DebuggerAssetsProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#34 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#33 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/PagesProcessor.php:112
#32 Grav\Common\Processors\PagesProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#31 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#30 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/TwigProcessor.php:38
#29 Grav\Common\Processors\TwigProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#28 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#27 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/AssetsProcessor.php:39
#26 Grav\Common\Processors\AssetsProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#25 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#24 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/SchedulerProcessor.php:40
#23 Grav\Common\Processors\SchedulerProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#22 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#21 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/BackupsProcessor.php:39
#20 Grav\Common\Processors\BackupsProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#19 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#18 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/TasksProcessor.php:69
#17 Grav\Common\Processors\TasksProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#16 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#15 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/RequestProcessor.php:64
#14 Grav\Common\Processors\RequestProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#13 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#12 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/ThemesProcessor.php:38
#11 Grav\Common\Processors\ThemesProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#10 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#9 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/PluginsProcessor.php:39
#8 Grav\Common\Processors\PluginsProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#7 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#6 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Processors/InitializeProcessor.php:130
#5 Grav\Common\Processors\InitializeProcessor:Grav\Common\Processors\{closure} in /var/www/html/system/src/Grav/Common/Debugger.php:546
#4 Grav\Common\Debugger:profile in /var/www/html/system/src/Grav/Common/Processors/InitializeProcessor.php:131
#3 Grav\Common\Processors\InitializeProcessor:process in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:50
#2 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php:62
#1 Grav\Framework\RequestHandler\RequestHandler:handle in /var/www/html/system/src/Grav/Common/Grav.php:307
#0 Grav\Common\Grav:process in /var/www/html/index.php:47
@rhukster
Copy link
Member

rhukster commented Aug 4, 2022

i’ll look at this today.

@rhukster rhukster self-assigned this Aug 4, 2022
@maofree
Copy link

maofree commented Aug 4, 2022

Hi
in langswitcher.php to fix it is necessary to add a condition to the while cycle pf the function _getTranslatedUrl

while ($max_recursions > 0 && $current_node !== null && $current_node->slug() != 'pages' && $path != 'pages') {

$current_node !== null

I got the same problem and I fix it in this mode
so the page return a 404 error in the right mode

1

@rhukster
Copy link
Member

rhukster commented Aug 4, 2022

Good call.. i've used your solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants