diff options
author | Brion Vibber <brion@pobox.com> | 2010-10-13 16:11:02 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-10-13 16:11:02 -0700 |
commit | c0bb3062f63638601a9855df93cdaef963ef628e (patch) | |
tree | ce03688d44351638c3941ca53214eccbb67deffd /lib/schema.php | |
parent | 229c7726344714187dad2641879cb9c4211cc85d (diff) |
suppress notices for non-present sections
Diffstat (limited to 'lib/schema.php')
-rw-r--r-- | lib/schema.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/schema.php b/lib/schema.php index da43c0559..f42226bad 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -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); |