quickapps / cms

Modular CMS powered by CakePHP
GNU General Public License v3.0
164 stars 69 forks source link

Call to function isAdmin() on null in .../cms/config/functions.php on line 410 #179

Closed paulrwest closed 6 years ago

paulrwest commented 7 years ago

Running on Docker on PHP7

After composer update the entire CMS is broken due to the following:

2017-08-10 09:32:41 Error: Fatal Error (1): Uncaught Error: Call to a member function isAdmin() on null in /var/www/site/vendor/quickapps-plugins/cms/config/functions.php:410 Stack trace:

0 /var/www/site/vendor/quickapps-plugins/cms/src/Error/ExceptionRenderer.php(32): theme()

1 /var/www/site/vendor/cakephp/cakephp/src/Error/ErrorHandler.php(136): CMS\Error\ExceptionRenderer->__construct(Object(Cake\Error\PHP7ErrorException))

2 /var/www/site/vendor/cakephp/cakephp/src/Error/BaseErrorHandler.php(187): Cake\Error\ErrorHandler->_displayException(Object(Cake\Error\PHP7ErrorException))

3 /var/www/site/vendor/cakephp/cakephp/src/Error/BaseErrorHandler.php(171): Cake\Error\BaseErrorHandler->handleException(Object(Cake\Error\PHP7ErrorException))

4 [internal function]: Cake\Error\BaseErrorHandler->wrapAndHandleException(Object(Cake\Error\PHP7ErrorException))

5 {main}

thrown in [/var/www/site/vendor/quickapps-plugins/cms/config/functions.php, line 410] Trace: Cake\Error\BaseErrorHandler::handleFatalError() - CORE/src/Error/BaseErrorHandler.php, line 223 Cake\Error\BaseErrorHandler::Cake\Error{closure}() - CORE/src/Error/BaseErrorHandler.php, line 104 [main] - [internal], line ??

functions.php:410:

$option = Router::getRequest()->isAdmin() ? 'back_theme' : 'front_theme';

Router::getRequest is returning null.

debugging Cake/Router shows static::$_requests as an empty array.

Composer file:

"name": "quickapps/website", "description": "QuickAppsCMS website app skeleton", "homepage": "http://quickappscms.org", "type": "project", "license": "GPL-3.0", "minimum-stability": "dev", "prefer-stable": true, "require": { "php": ">=5.6", "cakephp/cakephp": "~3.3", "mobiledetect/mobiledetectlib": "2.", "cakephp/plugin-installer": "", "quickapps-plugins/installer": "*", "developerforce/force.com-toolkit-for-php": "^27.0", "simplesamlphp/simplesamlphp": "^1.14", "cakephp/debug_kit": "^3.4", "cakephp/bake": "~1.1", "aws/aws-sdk-php": "^3.22" },

botchris commented 7 years ago
$option = Router::getRequest() && Router::getRequest()->isAdmin() ? 'back_theme' : 'front_theme';
paulrwest commented 7 years ago

"name": "cakephp/cakephp", "version": "3.4.12",

I tried that and was then erroring about theme being ""

botchris commented 7 years ago

Your CakePHP version seems to be wrong, it should be something "3.3.x". Try forcing it to 3.3.11

"cakephp/cakephp": "3.3.11"
paulrwest commented 7 years ago

Yeah I'm just looking into why it's on 3.4

Clearing cache and snapshot has helped sorry should have tried that earlier. I've added the check for Request which I had tried earlier but was showing other errors but it's now not erroring on CMS code.

let me try forcing it to 3.3

botchris commented 6 years ago

Fixed here: quickapps/website@264d08d