]> git.wh0rd.org Git - tt-rss.git/commitdiff
daemon2: check if schema version changed
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 1 Apr 2013 10:29:29 +0000 (14:29 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 1 Apr 2013 10:29:29 +0000 (14:29 +0400)
update_daemon2.php

index fa64b302d8464aee7836fc0db5112dba24f01a10..c87f0c10a60adcf7a69df11dd24ddb09756a4616 100755 (executable)
        // It is unnecessary to start the fork loop if database is not ok.
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       if (!init_connection($link)) return;
+       if (!init_connection($link)) die("Can't initialize db connection.\n");
+
+       $schema_version = get_schema_version($link);
 
        db_close($link);
 
 
                if ($last_checkpoint + $spawn_interval < time()) {
 
+                       /* Check if schema version changed */
+
+                       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
+                       if (!init_connection($link)) die("Can't initialize db connection.\n");
+                       $test_schema_version = get_schema_version($link);
+                       db_close($link);
+
+                       if ($test_schema_version != $schema_version) {
+                               _debug("Expected schema version: $schema_version, got: $test_schema_version");
+                               _debug("Schema version changed while we were running, bailing out");
+                               exit(100);
+                       }
+
                        check_ctimes();
                        reap_children();