CMS MODx i błąd The mysql extension is deprecated
W CMS MODx Evolution pojawia się następujący błąd:
„mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead”
Rozszerzenie mysql jest niezbędne dla prawidłowego funkcjonowania strony opartej na tym oprogramowaniu, bo odpowiada za łączenie się z
bazą danych. Poniżej instrukcja jak przywrócić działanie witryny.
plik:
/index.php
usuwamy linijkę kodu:
error_reporting(E_ALL & ~E_NOTICE);
plik:
/manager/index.php
usuwamy linijkę kodu:
error_reporting(E_ALL & ~E_NOTICE);
plik:
/manager/includes/config.inc.php
usuwamy linijkę kodu:
error_reporting(E_ALL & ~E_NOTICE);
plik:
/manager/includes/protect.inc.php
wstawiamy na początku linijkę kodu:
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
plik:
/manager/includes/document.parser.class.inc.php
znajdujemy funkcję:
executeParser()
zastępujemy początkowy kod w tej funcji:
//error_reporting(0);
if (version_compare(phpversion(), "5.0.0", ">="))
set_error_handler(array (
& $this,
"phpError"
), E_ALL);
else
set_error_handler(array (
& $this,
"phpError"
));
$this->db->connect();
// get the settings
if (empty ($this->config)) {
$this->getSettings();
}
kodem:
//error_reporting(0);
set_error_handler(array (
& $this,
"phpError"
), E_ALL);
$this->db->connect();
// get the settings
if (empty ($this->config)) {
$this->getSettings();
}
usuwamy całą funkcję:
phpError()
i na jej miejsce wklejamy jej nową postać:
function phpError($nr, $text, $file, $line) {
if (error_reporting() == 0 || $nr == 0) {
return true;
}
if($this->stopOnNotice == false)
{
switch($nr)
{
case E_NOTICE:
if($this->error_reporting <= 2) return true;
break;
case E_STRICT:
case E_DEPRECATED:
if($this->error_reporting <= 1) return true;
break;
default:
if($this->error_reporting === 0) return true;
}
}
if (is_readable($file)) {
$source= file($file);
$source= htmlspecialchars($source[$line -1]);
} else {
$source= "";
} //Error $nr in $file at $line: $source
$this->messageQuit("PHP Parse Error", '', true, $nr, $file, $source, $text, $line);
}

