Hallo alle zusammen,
Ich entwickle gerade ein Contao-Modul unter Contao 3.3.5 das im $GLOBALS['TL_HOOKS']['initializeSystem'] Hook auf die Datenbank zugreifen soll.
Leider wirft die Methode Contao\BackendUser->__destruct() einen Datenbank-Fehler sobald ich im Modul \Database::getInstance() aufrufe.
Folgender Fehler tritt auf:
Code:
Warning: mysqli::real_escape_string() [mysqli.real-escape-string]: Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 48
#0 [internal function]: __error(2, 'mysqli::real_es...', '/usr/www/users/...', 48, Array)
#1 system/modules/core/library/Contao/Database/Mysqli/Statement.php(48): mysqli->real_escape_string('a:19:{s:7:"refe...')
#2 system/modules/core/library/Contao/Database/Statement.php(335): Contao\Database\Mysqli\Statement->string_escape('a:19:{s:7:"refe...')
#3 system/modules/core/library/Contao/Database/Statement.php(310): Contao\Database\Statement->escapeParams(Array)
#4 system/modules/core/library/Contao/Database/Statement.php(253): Contao\Database\Statement->replaceWildcards(Array)
#5 system/modules/core/classes/BackendUser.php(163): Contao\Database\Statement->execute('a:19:{s:7:"refe...', '2')
#6 [internal function]: Contao\BackendUser->__destruct()
#7 {main}
Warning: mysqli::real_escape_string() [mysqli.real-escape-string]: Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 48
#0 [internal function]: __error(2, 'mysqli::real_es...', '/usr/www/users/...', 48, Array)
#1 system/modules/core/library/Contao/Database/Mysqli/Statement.php(48): mysqli->real_escape_string('2')
#2 system/modules/core/library/Contao/Database/Statement.php(335): Contao\Database\Mysqli\Statement->string_escape('2')
#3 system/modules/core/library/Contao/Database/Statement.php(310): Contao\Database\Statement->escapeParams(Array)
#4 system/modules/core/library/Contao/Database/Statement.php(253): Contao\Database\Statement->replaceWildcards(Array)
#5 system/modules/core/classes/BackendUser.php(163): Contao\Database\Statement->execute('a:19:{s:7:"refe...', '2')
#6 [internal function]: Contao\BackendUser->__destruct()
#7 {main}
Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 78
#0 [internal function]: __error(2, 'mysqli::query()...', '/usr/www/users/...', 78, Array)
#1 system/modules/core/library/Contao/Database/Mysqli/Statement.php(78): mysqli->query('UPDATE tl_user ...')
#2 system/modules/core/library/Contao/Database/Statement.php(281): Contao\Database\Mysqli\Statement->execute_query()
#3 system/modules/core/library/Contao/Database/Statement.php(254): Contao\Database\Statement->query()
#4 system/modules/core/classes/BackendUser.php(163): Contao\Database\Statement->execute('a:19:{s:7:"refe...', '2')
#5 [internal function]: Contao\BackendUser->__destruct()
#6 {main}
Warning: Contao\Database\Mysqli\Statement::get_error() [contao\database\mysqli\statement.get-error]: Couldn't fetch mysqli in system/modules/core/library/Contao/Database/Mysqli/Statement.php on line 89
#0 system/modules/core/library/Contao/Database/Mysqli/Statement.php(89): __error(2, 'Contao\Database...', '/usr/www/users/...', 89, Array)
#1 system/modules/core/library/Contao/Database/Statement.php(110): Contao\Database\Mysqli\Statement->get_error()
#2 system/modules/core/library/Contao/Database/Statement.php(283): Contao\Database\Statement->__get('error')
#3 system/modules/core/library/Contao/Database/Statement.php(254): Contao\Database\Statement->query()
#4 system/modules/core/classes/BackendUser.php(163): Contao\Database\Statement->execute('a:19:{s:7:"refe...', '2')
#5 [internal function]: Contao\BackendUser->__destruct()
#6 {main}
Fatal error: Uncaught exception 'Exception' with message 'Query error: (UPDATE tl_user SET session='' WHERE id='')' in system/modules/core/library/Contao/Database/Statement.php:283
Stack trace:
#0 /usr/www/users/mhneu/system/modules/core/library/Contao/Database/Statement.php(254): Contao\Database\Statement->query()
#1 /usr/www/users/mhneu/system/modules/core/classes/BackendUser.php(164): Contao\Database\Statement->execute('a:19:{s:7:"refe...', '2')
#2 [internal function]: Contao\BackendUser->__destruct()
#3 {main}
thrown in <b>system/modules/core/library/Contao/Database/Statement.php</b> on line <b>283</b><br />
Das Modul ist folgendermaßen aufgebaut:
config.php:
Code:
<?php
$GLOBALS['TL_HOOKS']['initializeSystem'][] = array('SE_IS24_Connector\Test', 'test');
Test.php:
Code:
<?php
namespace SE_IS24_Connector;
class Test {
public function test(){
$database=\Database::getInstance();
}
}
Wenn ich in dieser Function keine Datenbank hole, tritt der Fehler nicht mehr auf.
Sobald ich aber in irgendeiner Form auf die Datenbank zugreife oder Sie importiere taucht der Fehler wieder auf.
Habt Ihr eine Ahnung was ich da falsch mache ?
Lesezeichen