dbupdater: unify naming
This commit is contained in:
parent
166f2d4666
commit
6426ae559a
|
@ -11,16 +11,16 @@ class DbUpdater {
|
||||||
$this->need_version = (int) $need_version;
|
$this->need_version = (int) $need_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSchemaVersion() {
|
function get_schema_version() {
|
||||||
$row = $this->pdo->query("SELECT schema_version FROM ttrss_version")->fetch();
|
$row = $this->pdo->query("SELECT schema_version FROM ttrss_version")->fetch();
|
||||||
return (int) $row['schema_version'];
|
return (int) $row['schema_version'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUpdateRequired() {
|
function is_update_required() {
|
||||||
return $this->getSchemaVersion() < $this->need_version;
|
return $this->get_schema_version() < $this->need_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSchemaLines($version) {
|
function get_schema_lines($version) {
|
||||||
$filename = "schema/versions/".$this->db_type."/$version.sql";
|
$filename = "schema/versions/".$this->db_type."/$version.sql";
|
||||||
|
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
|
@ -31,10 +31,10 @@ class DbUpdater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function performUpdateTo($version, $html_output = true) {
|
function update_to($version, $html_output = true) {
|
||||||
if ($this->getSchemaVersion() == $version - 1) {
|
if ($this->get_schema_version() == $version - 1) {
|
||||||
|
|
||||||
$lines = $this->getSchemaLines($version);
|
$lines = $this->get_schema_lines($version);
|
||||||
|
|
||||||
if (is_array($lines)) {
|
if (is_array($lines)) {
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class DbUpdater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db_version = $this->getSchemaVersion();
|
$db_version = $this->get_schema_version();
|
||||||
|
|
||||||
if ($db_version == $version) {
|
if ($db_version == $version) {
|
||||||
$this->pdo->commit();
|
$this->pdo->commit();
|
||||||
|
|
|
@ -1143,17 +1143,17 @@ class Handler_Public extends Handler {
|
||||||
$updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION);
|
$updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION);
|
||||||
|
|
||||||
if ($op == "performupdate") {
|
if ($op == "performupdate") {
|
||||||
if ($updater->isUpdateRequired()) {
|
if ($updater->is_update_required()) {
|
||||||
|
|
||||||
print "<h2>" . T_sprintf("Performing updates to version %d", SCHEMA_VERSION) . "</h2>";
|
print "<h2>" . T_sprintf("Performing updates to version %d", SCHEMA_VERSION) . "</h2>";
|
||||||
|
|
||||||
for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
|
for ($i = $updater->get_schema_version() + 1; $i <= SCHEMA_VERSION; $i++) {
|
||||||
print "<ul>";
|
print "<ul>";
|
||||||
|
|
||||||
print "<li class='text-info'>" . T_sprintf("Updating to version %d", $i) . "</li>";
|
print "<li class='text-info'>" . T_sprintf("Updating to version %d", $i) . "</li>";
|
||||||
|
|
||||||
print "<li>";
|
print "<li>";
|
||||||
$result = $updater->performUpdateTo($i, true);
|
$result = $updater->update_to($i, true);
|
||||||
print "</li>";
|
print "</li>";
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -1184,10 +1184,10 @@ class Handler_Public extends Handler {
|
||||||
print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
|
print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($updater->isUpdateRequired()) {
|
if ($updater->is_update_required()) {
|
||||||
|
|
||||||
print "<h2>".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
|
print "<h2>".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
|
||||||
$updater->getSchemaVersion(), SCHEMA_VERSION)."</h2>";
|
$updater->get_schema_version(), SCHEMA_VERSION)."</h2>";
|
||||||
|
|
||||||
if (DB_TYPE == "mysql") {
|
if (DB_TYPE == "mysql") {
|
||||||
print_error("<strong>READ THIS:</strong> Due to MySQL limitations, your database is not completely protected while updating. ".
|
print_error("<strong>READ THIS:</strong> Due to MySQL limitations, your database is not completely protected while updating. ".
|
||||||
|
|
|
@ -380,8 +380,8 @@
|
||||||
|
|
||||||
$updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION);
|
$updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION);
|
||||||
|
|
||||||
if ($updater->isUpdateRequired()) {
|
if ($updater->is_update_required()) {
|
||||||
Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION);
|
Debug::log("Schema update required, version " . $updater->get_schema_version() . " to " . SCHEMA_VERSION);
|
||||||
|
|
||||||
if (DB_TYPE == "mysql")
|
if (DB_TYPE == "mysql")
|
||||||
Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n".
|
Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n".
|
||||||
|
@ -400,10 +400,10 @@
|
||||||
|
|
||||||
Debug::log("Performing updates to version " . SCHEMA_VERSION . "...");
|
Debug::log("Performing updates to version " . SCHEMA_VERSION . "...");
|
||||||
|
|
||||||
for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
|
for ($i = $updater->get_schema_version() + 1; $i <= SCHEMA_VERSION; $i++) {
|
||||||
Debug::log("* Updating to version $i...");
|
Debug::log("* Updating to version $i...");
|
||||||
|
|
||||||
$result = $updater->performUpdateTo($i, false);
|
$result = $updater->update_to($i, false);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
Debug::log("* Completed.");
|
Debug::log("* Completed.");
|
||||||
|
|
Loading…
Reference in New Issue