File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,15 @@ public function createCache() {
1919 return false ;
2020 }
2121
22+ /**
23+ * Flush our local cache, may be required for upgrades
24+ * or other places where we need live data
25+ **/
26+ public function flushCache () {
27+ $ this ->cache = array ();
28+ return true ;
29+ }
30+
2231 /**
2332 * Fetch a value from our table
2433 * @param name string Setting name
Original file line number Diff line number Diff line change 1313
1414// Helper functions
1515function run_db_upgrade ($ db_version_now ) {
16+ // Dirty, but need it here
17+ global $ setting ;
18+
19+ // Drop caches from our settings for live data
20+ $ setting ->flushCache ();
21+
1622 // Find upgrades
1723 $ files = glob (dirname (__FILE__ ) . "/definitions/ $ {db_version_now}_to_* " );
1824 if (count ($ files ) == 0 ) die ('No upgrade definitions found for ' . $ db_version_now . PHP_EOL );
@@ -23,14 +29,19 @@ function run_db_upgrade($db_version_now) {
2329 if (!require_once ($ file )) die ('Failed to load upgrade definition: ' . $ file );
2430 echo "+ Running upgrade from $ db_version_now to $ db_version_to " . PHP_EOL ;
2531 $ run = "run_ $ run_string " ;
26- $ run ();
27- run_db_upgrade ($ db_version_to );
32+ if (function_exists ($ run )) {
33+ $ run ();
34+ run_db_upgrade ($ db_version_to );
35+ } else {
36+ echo 'Could find upgrade function ' . $ run . '! ' . PHP_EOL ;
37+ exit (1 );
38+ }
2839 }
2940}
3041function execute_db_upgrade ($ aSql ) {
3142 global $ mysqli ;
3243 // Run the upgrade
33- echo '- Starting database migration to version ' . $ db_version_new . PHP_EOL ;
44+ echo '- Starting database migration ' . PHP_EOL ;
3445 foreach ($ aSql as $ sql ) {
3546 echo '- Preparing: ' . $ sql . PHP_EOL ;
3647 $ stmt = $ mysqli ->prepare ($ sql );
You can’t perform that action at this time.
0 commit comments