diff options
author | Oliver Schramm <oliver.schramm97@gmail.com> | 2016-08-10 14:55:39 +0200 |
---|---|---|
committer | Oliver Schramm <oliver.schramm97@gmail.com> | 2016-08-11 01:09:11 +0200 |
commit | 8e1461ca61e3f452935a1253d3afe65e7322d6bc (patch) | |
tree | 24b40c1b339cb7a78ee52f834fffdf4d97b067de /phpBB/phpbb/db/migration/helper.php | |
parent | 9fb649793de65a598615c542861281ff15a60439 (diff) | |
download | forums-8e1461ca61e3f452935a1253d3afe65e7322d6bc.tar forums-8e1461ca61e3f452935a1253d3afe65e7322d6bc.tar.gz forums-8e1461ca61e3f452935a1253d3afe65e7322d6bc.tar.bz2 forums-8e1461ca61e3f452935a1253d3afe65e7322d6bc.tar.xz forums-8e1461ca61e3f452935a1253d3afe65e7322d6bc.zip |
[ticket/14742] Avoid loop while reverting data
This combines reverted updata_data and revert_data into a single array.
PHPBB3-14742
Diffstat (limited to 'phpBB/phpbb/db/migration/helper.php')
-rw-r--r-- | phpBB/phpbb/db/migration/helper.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/phpBB/phpbb/db/migration/helper.php b/phpBB/phpbb/db/migration/helper.php index e40deeb37b..bce2efff51 100644 --- a/phpBB/phpbb/db/migration/helper.php +++ b/phpBB/phpbb/db/migration/helper.php @@ -81,4 +81,36 @@ class helper return $steps; } + + /** + * Reverse the update steps from an array of data changes + * + * 'If' statements and custom methods will be skipped, for all + * other calls the reverse method of the tool class will be called + * + * @param array $steps Update changes from migration + * + * @return array + */ + public function reverse_update_data($steps) + { + $reversed_array = array(); + + foreach ($steps as $step) + { + $parts = explode('.', $step[0]); + $parameters = $step[1]; + + $class = $parts[0]; + $method = isset($parts[1]) ? $parts[1] : false; + + if ($class !== 'if' && $class !== 'custom') + { + array_unshift($parameters, $method); + $reversed_array[] = array($class . '.reverse', $parameters); + } + } + + return array_reverse($reversed_array); + } } |