aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-01-12 18:27:33 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2013-01-12 18:27:33 -0600
commit93f9ebbb258a06e34198cffda0f5fd8dfdf29597 (patch)
treeaae08b6562a1229cde1c214c76d887535f844085 /phpBB/includes/db
parent9f38dc67a80b5fc2a8bb0d01825d7655915e3319 (diff)
downloadforums-93f9ebbb258a06e34198cffda0f5fd8dfdf29597.tar
forums-93f9ebbb258a06e34198cffda0f5fd8dfdf29597.tar.gz
forums-93f9ebbb258a06e34198cffda0f5fd8dfdf29597.tar.bz2
forums-93f9ebbb258a06e34198cffda0f5fd8dfdf29597.tar.xz
forums-93f9ebbb258a06e34198cffda0f5fd8dfdf29597.zip
[feature/migrations] Make load_migrations recursive (optionally)
PHPBB3-9737
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/migrator.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php
index 2ec44a5a45..6b249e3ee0 100644
--- a/phpBB/includes/db/migrator.php
+++ b/phpBB/includes/db/migrator.php
@@ -127,7 +127,6 @@ class phpbb_db_migrator
/**
* Load migration data files from a directory
*
- * This does not loop through sub-directories.
* Migration data files loaded with this function MUST contain
* ONLY ONE class in them (or an exception will be thrown).
*
@@ -137,9 +136,10 @@ class phpbb_db_migrator
* If FALSE, we will not check. You SHOULD check at least once
* to prevent errors (if including multiple directories, check
* with the last call to prevent throwing errors unnecessarily).
- * @return array Array of migrations with names
+ * @param bool $recursive Set to true to also load data files from subdirectories
+ * @return array Array of migration names
*/
- public function load_migrations($path, $check_fulfillable = true)
+ public function load_migrations($path, $check_fulfillable = true, $recursive = true)
{
if (!is_dir($path))
{
@@ -149,6 +149,17 @@ class phpbb_db_migrator
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
+ if ($file == '.' || $file == '..')
+ {
+ continue;
+ }
+
+ // Recursion through subdirectories
+ if (is_dir($path . $file) && $recursive)
+ {
+ $this->load_migrations($path . $file . '/', $check_fulfillable, $recursive);
+ }
+
if (strpos($file, '_') !== 0 && strrpos($file, '.' . $this->php_ext) === (strlen($file) - strlen($this->php_ext) - 1))
{
// We try to find what class existed by comparing the classes declared before and after including the file.