]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/schema.php
Make StatusNet::initDefaults() public so we can call it from the installer.
[quix0rs-gnu-social.git] / lib / schema.php
index da43c0559ab8255cfcd549e264b5caca3975a6f1..2793906a461657c6b8815dab66257a87969484b1 100644 (file)
@@ -492,9 +492,9 @@ class Schema
         $def = $this->filterDef($def);
 
         // @fixme check if not present
-        $fields = $this->diffArrays($old['fields'], $def['fields'], array($this, 'columnsEqual'));
-        $uniques = $this->diffArrays($old['unique keys'], $def['unique keys']);
-        $indexes = $this->diffArrays($old['indexes'], $def['indexes']);
+        $fields = $this->diffArrays($old, $def, 'fields', array($this, 'columnsEqual'));
+        $uniques = $this->diffArrays($old, $def, 'unique keys');
+        $indexes = $this->diffArrays($old, $def, 'indexes');
 
         $total = $fields['count'] + $uniques['count'] + $indexes['count'];
         if ($total == 0) {
@@ -535,11 +535,13 @@ class Schema
         return array($sql);
     }
 
-    function diffArrays($old, $new, $compareCallback=null)
+    function diffArrays($oldDef, $newDef, $section, $compareCallback=null)
     {
+        $old = isset($oldDef[$section]) ? $oldDef[$section] : array();
+        $new = isset($newDef[$section]) ? $newDef[$section] : array();
 
-        $oldKeys = array_keys($old ? $old : array());
-        $newKeys = array_keys($new ? $new : array());
+        $oldKeys = array_keys($old);
+        $newKeys = array_keys($new);
 
         $toadd  = array_diff($newKeys, $oldKeys);
         $todrop = array_diff($oldKeys, $newKeys);
@@ -553,7 +555,7 @@ class Schema
             if ($compareCallback) {
                 $same = call_user_func($compareCallback, $old[$name], $new[$name]);
             } else {
-                $same = ($old[$name] != $new[$name]);
+                $same = ($old[$name] == $new[$name]);
             }
             if ($same) {
                 $tokeep[] = $name;