From 2e98784e5ca28e4bdf7bc81d32c92d8a8794770e Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 10 Aug 2017 13:05:02 +0200 Subject: [PATCH] mvc: allow to run targeted migration (for plugins) --- src/opnsense/mvc/script/run_migrations.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/opnsense/mvc/script/run_migrations.php b/src/opnsense/mvc/script/run_migrations.php index 4b1a95f35..372cec261 100755 --- a/src/opnsense/mvc/script/run_migrations.php +++ b/src/opnsense/mvc/script/run_migrations.php @@ -34,12 +34,19 @@ require_once('script/load_phalcon.php'); use OPNsense\Core\Config; +$classprefix = !empty($argv[1]) ? str_replace('/', '\\', $argv[1]) : ''; + $class_info = new \ReflectionClass("OPNsense\\Base\\BaseModel"); $executed_migration = false; $model_dir = dirname($class_info->getFileName())."/../../"; foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir)) as $x) { if (strtolower(substr($x->getPathname(), -4)) == '.php') { $classname = str_replace('/', '\\', explode('.', str_replace($model_dir, '', $x->getPathname()))[0]); + /* XXX we match the prefix here, but should eventually switch to component exploded by "\" */ + if (!empty($classprefix) && strpos($classname, $classprefix) !== 0) { + /* not our requested class */ + continue; + } try { $mdl_class_info = new \ReflectionClass($classname); $parent = $mdl_class_info->getParentClass();