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