flipboxfactory / saml-sp

SAML Service Provider (SP) Plugin for Craft CMS
https://saml-sp.flipboxfactory.com/
Other
19 stars 5 forks source link

saml-sp/_cp/login template UrlHelper::cpUrl() TypeError #97

Closed benjaminkohl closed 3 years ago

benjaminkohl commented 3 years ago

Plugin version: 2.6.1 Craft version: 3.5.19.1

In the template saml-sp/_cp/login, there is an instance where the UrlHelper::cpUrl helper is being called and the fallback parameter is null. The result is a TypeError being thrown when I log out of the control panel because the cpUrl function expects a non-null string value as the parameter.

Looking at the Twig template, I see {{ cpUrl(dashboard) }} which gets compiled to craft\helpers\UrlHelper::cpUrl(($context["dashboard"] ?? null)).

Here is the stack trace:

2021-02-10 09:34:05 [-][-][jfjopr219vgrmbansqcvcc95gt][error][TypeError] TypeError: Argument 1 passed to craft\helpers\UrlHelper::cpUrl() must be of the type string, null given, called in /path/to/prod/storage/runtime/compiled_templates/f9/f90465843fe892fda8c430ece441c42b3c41d6ecdb5c47ccb8206b19854251c7.php on line 171 and defined in /path/to/prod/vendor/craftcms/cms/src/helpers/UrlHelper.php:265
Stack trace:
#0 /path/to/prod/storage/runtime/compiled_templates/f9/f90465843fe892fda8c430ece441c42b3c41d6ecdb5c47ccb8206b19854251c7.php(171): craft\helpers\UrlHelper::cpUrl(NULL)
#1 /path/to/prod/vendor/twig/twig/src/Template.php(405): __TwigTemplate_62f675017afac0bb056792290aebb81fec82ab18fa90e2474801234354d31820->doDisplay(Array, Array)
#2 /path/to/prod/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#3 /path/to/prod/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#4 /path/to/prod/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#5 /path/to/prod/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#6 /path/to/prod/vendor/craftcms/cms/src/web/View.php(389): Twig\Environment->render('saml-sp/_cp/log...', Array)
#7 /path/to/prod/vendor/craftcms/cms/src/web/View.php(450): craft\web\View->renderTemplate('saml-sp/_cp/log...', Array)
#8 /path/to/prod/vendor/craftcms/cms/src/web/Controller.php(241): craft\web\View->renderPageTemplate('saml-sp/_cp/log...', Array, 'cp')
#9 /path/to/prod/vendor/flipboxfactory/saml-sp/src/controllers/cp/view/LoginController.php(34): craft\web\Controller->renderTemplate('saml-sp/_cp/log...', Array)
#10 [internal function]: flipbox\saml\sp\controllers\cp\view\LoginController->actionIndex()
#11 /path/to/prod/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /path/to/prod/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#13 /path/to/prod/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('', Array)
#14 /path/to/prod/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('', Array)
#15 /path/to/prod/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('saml-sp/cp/view...', Array)
#16 /path/to/prod/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('saml-sp/cp/view...', Array)
#17 /path/to/prod/vendor/craftcms/cms/src/web/Application.php(259): yii\web\Application->handleRequest(Object(craft\web\Request))
#18 /path/to/prod/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 /path/to/prod/public/index.php(28): yii\base\Application->run()
dsmrt commented 3 years ago

Just found this myself! You beat the tag going up by a minunte! Checkout: https://github.com/flipboxfactory/saml-sp/releases/tag/2.6.2

dsmrt commented 3 years ago

Actually. Let me verify this works with your craft version.

dsmrt commented 3 years ago

Ok ... just double checked.

You should be good to go. Craft CMS version 3.5.18 was the change that requires the new login page where the bug was introduced.

Note to future @dsmrt: Craft CMS version 3.4 to < 3.5.18 has the dashboard string encapsulated with the single quotes appropriately.