Fixed a bug when the language file is not yet available.
This commit is contained in:
parent
ff93b288c2
commit
ab55fd9abb
|
@ -18,10 +18,7 @@ const SUPPORTED_RELEASE_MINOR = 2;
|
|||
*/
|
||||
class UpdateController
|
||||
{
|
||||
private $pdo;
|
||||
|
||||
|
||||
function handleUpdate()
|
||||
function handleUpdate(): void
|
||||
{
|
||||
define(constant_name: "PHPBB_ROOT_PATH", value: dirname(path: __DIR__, levels: 2));
|
||||
|
||||
|
@ -58,7 +55,7 @@ class UpdateController
|
|||
/** @var String $dbname */
|
||||
/** @var String $dbuser */
|
||||
/** @var String $dbpasswd */
|
||||
$this->pdo = new PDO(
|
||||
$pdo = new PDO(
|
||||
dsn : "mysql:host=$dbhost;port=$dbport;charset=utf8mb4;dbname=$dbname",
|
||||
username: $dbuser,
|
||||
password: $dbpasswd
|
||||
|
@ -67,7 +64,7 @@ class UpdateController
|
|||
|
||||
/** @var String $table_prefix */
|
||||
$sql = "SELECT config_value FROM ${table_prefix}config WHERE config_name = 'version'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
$statement->execute();
|
||||
$result = $statement->fetch();
|
||||
|
||||
|
@ -112,41 +109,49 @@ class UpdateController
|
|||
|
||||
// check for available language files
|
||||
|
||||
$useLangDeDu = false;
|
||||
if (file_exists(filename: $phpBBRootPath . 'language/de')) {
|
||||
$useLangDeDu = true;
|
||||
// https://downloads.phpbb.de/pakete/deutsch/3.3/3.3.7/phpBB_lang_de-3.3.7.tar.bz2
|
||||
$languageFile = "phpBB_lang_de-$availableUpdate.tar.bz2";
|
||||
$langDeDuTarget = "dist/$languageFile";
|
||||
|
||||
if (!file_exists(filename: $langDeDuTarget)) {
|
||||
echo "Downloading language $languageFile" . PHP_EOL;
|
||||
$filePath = "https://downloads.phpbb.de/pakete/deutsch/$major.$minor/$availableUpdate/$languageFile";
|
||||
if (file_exists(filename: $filePath)) {
|
||||
$phpBBtbz = file_get_contents(filename: $filePath);
|
||||
file_put_contents(filename: $langDeDuTarget, data: $phpBBtbz);
|
||||
} else {
|
||||
echo "Language file $languageFile does not exist." . PHP_EOL;
|
||||
$useLangDeDu = false;
|
||||
}
|
||||
} else {
|
||||
echo 'Language file ' . $languageFile . ' already exists' . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
$useLangDeDu = false;
|
||||
echo 'Language Deutsch "Du" ist not installed, skipping' . PHP_EOL;
|
||||
}
|
||||
|
||||
$useLangDeSie = false;
|
||||
if (file_exists(filename: $phpBBRootPath . 'language/de_x_sie')) {
|
||||
$useLangDeSie = true;
|
||||
//https://downloads.phpbb.de/pakete/deutsch/3.3/3.3.7/phpBB_lang_de_x_sie-3.3.7.tar.bz2
|
||||
$languageFile = "phpBB_lang_de_x_sie-$availableUpdate.tar.bz2";
|
||||
$langDeSieTarget = "dist/$languageFile";
|
||||
|
||||
if (!file_exists(filename: $langDeSieTarget)) {
|
||||
echo "Downloading language $languageFile" . PHP_EOL;
|
||||
$filePath = "https://downloads.phpbb.de/pakete/deutsch/$major.$minor/$availableUpdate/$languageFile";
|
||||
if (file_exists(filename: $filePath)) {
|
||||
$phpBBtbz = file_get_contents(filename: $filePath);
|
||||
file_put_contents(filename: $langDeSieTarget, data: $phpBBtbz);
|
||||
} else {
|
||||
echo 'Language file ' . $languageFile . ' does not exist' . PHP_EOL;
|
||||
$useLangDeSie = false;
|
||||
}
|
||||
} else {
|
||||
echo 'Language file ' . $languageFile . ' already exists' . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
$useLangDeSie = false;
|
||||
echo 'Language Deutsch "Sie" ist not installed, skipping' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
@ -158,10 +163,10 @@ class UpdateController
|
|||
$now = date(format: 'd.m.Y H:i');
|
||||
$disableMsg = "Software-update at $now, the forum ist down due to maintenance. We'll be back soon.";
|
||||
$sql = "UPDATE ${table_prefix}config SET config_value = :disable_message WHERE config_name = 'board_disable_msg'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
$statement->bindParam(param: 'disable_message', var: $disableMsg);
|
||||
|
||||
if ($result = $statement->execute()) {
|
||||
if ($statement->execute()) {
|
||||
echo "Disable Message set …", PHP_EOL;
|
||||
} else {
|
||||
echo 'There was an error talking to the DB.' . PHP_EOL;
|
||||
|
@ -170,8 +175,8 @@ class UpdateController
|
|||
}
|
||||
|
||||
$sql = "UPDATE ${table_prefix}config SET config_value = '1' WHERE config_name = 'board_disable'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
if ($result = $statement->execute()) {
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
if ($statement->execute()) {
|
||||
echo "Board disabled …", PHP_EOL;
|
||||
} else {
|
||||
echo 'There was an error talking to the DB.' . PHP_EOL;
|
||||
|
@ -186,7 +191,7 @@ class UpdateController
|
|||
} else {
|
||||
// check for enabled extensions
|
||||
$sql = "SELECT ext_name FROM ${table_prefix}ext WHERE ext_active = '1'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
if ($statement->execute()) {
|
||||
$result = $statement->fetchAll();
|
||||
|
||||
|
@ -201,7 +206,7 @@ class UpdateController
|
|||
|
||||
// disable all extensions
|
||||
$sql = "UPDATE ${table_prefix}ext SET ext_active = '0' WHERE ext_active = '1'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
if ($statement->execute()) {
|
||||
echo 'Disabled all extensions';
|
||||
}
|
||||
|
@ -216,7 +221,7 @@ class UpdateController
|
|||
} else {
|
||||
// check for enabled style
|
||||
$sql = "SELECT style_name FROM ${table_prefix}styles WHERE style_active = '1'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
if ($statement->execute()) {
|
||||
$result = $statement->fetchAll();
|
||||
|
||||
|
@ -231,7 +236,7 @@ class UpdateController
|
|||
|
||||
// disable all styles except prosilver
|
||||
$sql = "UPDATE ${table_prefix}styles SET style_active = '0' WHERE NOT style_name = 'prosilver'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
if ($statement->execute()) {
|
||||
echo 'Disabled all styles except prosilver.' . PHP_EOL;
|
||||
}
|
||||
|
@ -296,7 +301,6 @@ class UpdateController
|
|||
|
||||
$command = <<<EOC
|
||||
cd ..
|
||||
pwd
|
||||
php install/phpbbcli.php update update-config.yml
|
||||
EOC;
|
||||
|
||||
|
@ -327,6 +331,7 @@ class UpdateController
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// update langDeSie
|
||||
if ($useLangDeSie) {
|
||||
$data = new PharData(filename: $langDeSieTarget);
|
||||
|
@ -342,7 +347,7 @@ class UpdateController
|
|||
|
||||
|
||||
$sql = "UPDATE ${table_prefix}config SET config_value = '0' WHERE config_name = 'board_disable'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
$statement->execute();
|
||||
|
||||
echo "Board reenabled …", PHP_EOL;
|
||||
|
@ -357,7 +362,7 @@ class UpdateController
|
|||
foreach ($extensions as $extension) {
|
||||
$ext = $extension['ext_name'];
|
||||
$sql = "UPDATE ${table_prefix}ext SET ext_active = '1' WHERE ext_name = '$ext'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
$statement->execute();
|
||||
echo '.';
|
||||
}
|
||||
|
@ -375,7 +380,7 @@ class UpdateController
|
|||
foreach ($styles as $style) {
|
||||
$style = $style['style_name'];
|
||||
$sql = "UPDATE ${table_prefix}styles SET style_active = '1' WHERE style_name = '$style'";
|
||||
$statement = $this->pdo->prepare(query: $sql);
|
||||
$statement = $pdo->prepare(query: $sql);
|
||||
$statement->execute();
|
||||
echo '.';
|
||||
}
|
||||
|
@ -470,7 +475,7 @@ class UpdateController
|
|||
$skip = true;
|
||||
}
|
||||
}
|
||||
if ($skip == false) {
|
||||
if (!$skip) {
|
||||
rmdir(directory: $dir);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue