]> git.mxchange.org Git - friendica.git/blobdiff - include/dbstructure.php
The function "construct_acl_data" isn't used at all, it seems. it is deactivated now
[friendica.git] / include / dbstructure.php
index c9c37c9390bcca0f45153d0cd33cc6744ced9320..2dec998a7437bbafe0237a494d98596d7f93231a 100644 (file)
@@ -3,11 +3,15 @@
 use Friendica\App;
 use Friendica\Core\Config;
 
-require_once("boot.php");
-require_once("include/text.php");
+require_once "boot.php";
+require_once "include/text.php";
 
 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
 
+const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
+const DB_UPDATE_SUCCESSFUL = 1;  // Database check was successful
+const DB_UPDATE_FAILED = 2;      // Database check failed
+
 /*
  * Converts all tables from MyISAM to InnoDB
  */
@@ -480,6 +484,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
                Config::set('system', 'maintenance_reason', '');
        }
 
+       if ($errors) {
+               Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
+       } else {
+               Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
+       }
+
        return $errors;
 }
 
@@ -1195,7 +1205,7 @@ function db_definition() {
                                        "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
                                        "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
                                        "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
-                                       "created" => array("type" => "datetime", "default" => NULL_DATE),
+                                       "pid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
@@ -1732,6 +1742,9 @@ function db_definition() {
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
+                                       "pid" => array("pid"),
+                                       "parameter" => array("parameter(64)"),
+                                       "priority_created" => array("priority", "created"),
                                        )
                        );
 
@@ -1756,7 +1769,7 @@ function dbstructure_run(&$argv, &$argc) {
                        unset($db_host, $db_user, $db_pass, $db_data);
        }
 
-       if ($argc==2) {
+       if ($argc == 2) {
                switch ($argv[1]) {
                        case "dryrun":
                                update_structure(true, false);
@@ -1766,7 +1779,7 @@ function dbstructure_run(&$argv, &$argc) {
 
                                $build = get_config('system','build');
                                if (!x($build)) {
-                                       set_config('system','build',DB_UPDATE_VERSION);
+                                       set_config('system', 'build', DB_UPDATE_VERSION);
                                        $build = DB_UPDATE_VERSION;
                                }
 
@@ -1776,7 +1789,9 @@ function dbstructure_run(&$argv, &$argc) {
                                // run any left update_nnnn functions in update.php
                                for ($x = $stored; $x < $current; $x ++) {
                                        $r = run_update_function($x);
-                                       if (!$r) break;
+                                       if (!$r) {
+                                               break;
+                                       }
                                }
 
                                set_config('system','build',DB_UPDATE_VERSION);
@@ -1803,7 +1818,7 @@ function dbstructure_run(&$argv, &$argc) {
 
 }
 
-if (array_search(__file__,get_included_files())===0) {
+if (array_search(__FILE__,get_included_files())===0) {
        dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
        killme();
 }