Zeromax / contao-sb-admin

Contao CMS Backend Theme
GNU Lesser General Public License v3.0
7 stars 0 forks source link

Function "chooseTemplates" causes errors in frontend #27

Closed fw2 closed 8 years ago

fw2 commented 8 years ago

I just installed sb-admin on a couple of Contao installations. On one it works fine on the other it causes error messages like this:

Warning: mysqli::real_escape_string(): Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 51

#0 [internal function]: __error(2, 'mysqli::real_es...', '/var/www/htdocs...', 51, Array)
#1 system/modules/core/library/Contao/Database/Mysqli/Statement.php(51): mysqli->real_escape_string('a:2:{s:7:"refer...')
#2 system/modules/core/library/Contao/Database/Statement.php(350): Contao\Database\Mysqli\Statement->string_escape('a:2:{s:7:"refer...')
#3 system/modules/core/library/Contao/Database/Statement.php(325): Contao\Database\Statement->escapeParams(Array)
#4 system/modules/core/library/Contao/Database/Statement.php(262): Contao\Database\Statement->replaceWildcards(Array)
#5 system/modules/core/classes/FrontendUser.php(98): Contao\Database\Statement->execute('a:2:{s:7:"refer...', '9')
#6 [internal function]: Contao\FrontendUser->__destruct()
#7 {main}

Warning: mysqli::real_escape_string(): Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 51

#0 [internal function]: __error(2, 'mysqli::real_es...', '/var/www/htdocs...', 51, Array)
#1 system/modules/core/library/Contao/Database/Mysqli/Statement.php(51): mysqli->real_escape_string('9')
#2 system/modules/core/library/Contao/Database/Statement.php(350): Contao\Database\Mysqli\Statement->string_escape('9')
#3 system/modules/core/library/Contao/Database/Statement.php(325): Contao\Database\Statement->escapeParams(Array)
#4 system/modules/core/library/Contao/Database/Statement.php(262): Contao\Database\Statement->replaceWildcards(Array)
#5 system/modules/core/classes/FrontendUser.php(98): Contao\Database\Statement->execute('a:2:{s:7:"refer...', '9')
#6 [internal function]: Contao\FrontendUser->__destruct()
#7 {main}

Warning: mysqli::query(): Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 81

#0 [internal function]: __error(2, 'mysqli::query()...', '/var/www/htdocs...', 81, Array)
#1 system/modules/core/library/Contao/Database/Mysqli/Statement.php(81): mysqli->query('UPDATE tl_membe...')
#2 system/modules/core/library/Contao/Database/Statement.php(293): Contao\Database\Mysqli\Statement->execute_query()
#3 system/modules/core/library/Contao/Database/Statement.php(264): Contao\Database\Statement->query()
#4 system/modules/core/classes/FrontendUser.php(98): Contao\Database\Statement->execute('a:2:{s:7:"refer...', '9')
#5 [internal function]: Contao\FrontendUser->__destruct()
#6 {main}

Warning: Contao\Database\Mysqli\Statement::get_error(): Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 92

#0 system/modules/core/library/Contao/Database/Mysqli/Statement.php(92): __error(2, 'Contao\\Database...', '/var/www/htdocs...', 92, Array)
#1 system/modules/core/library/Contao/Database/Statement.php(116): Contao\Database\Mysqli\Statement->get_error()
#2 system/modules/core/library/Contao/Database/Statement.php(295): Contao\Database\Statement->__get('error')
#3 system/modules/core/library/Contao/Database/Statement.php(264): Contao\Database\Statement->query()
#4 system/modules/core/classes/FrontendUser.php(98): Contao\Database\Statement->execute('a:2:{s:7:"refer...', '9')
#5 [internal function]: Contao\FrontendUser->__destruct()
#6 {main}

I found that this is caused by the instantiation of the Backend User on line 58 of the SbTemplate class:

$objUser = \Controller::importStatic('BackendUser');
$loggedIn = $this->beUserLoggedIn($objUser);

As soon as I wrap these lines in an if clause to check TL_MODE to only execute this when working in the backend the errors disappear. I don't know if this is the best solution and I also haven't found out what exactly causes the error messages to appear on the one Contao installation only. Could be any combination of extensions I guess, but I disabled all extensions (including core extension, but excluding sb-admin of course) on the problematic installation but that made no difference.

By the way: thanks for the awesome new backend theme! It looks great and I look forward to hopefully use it on as many of my Contao installations as possible.

Arno

Zeromax commented 8 years ago

Which Contao Version are you using?

fw2 commented 8 years ago

In this case version 3.5.4.

Zeromax commented 8 years ago

Hm. I am not able to reproduce this. Which version do you have installed? What are the steps to reproduce? Any further thirdparty extension installed?

fw2 commented 8 years ago

I have now updated to Contao 3.5.6. I cannot tell you the steps to reproduce the error as I only had them occur on one specific installation of Contao. On that installation they occur as soon as I log in as a member in the frontend. I have many third party extensions installed, but I disabled them all and the error still occured. That's about all the information I can give you, I guess.

Zeromax commented 8 years ago

Ah perfect. There it is: Logged in FE Member. fixed in abb7dda

fw2 commented 8 years ago

Great! Thanks!