Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15472163
D10848.id26040.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10848.id26040.diff
View Options
diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
--- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
+++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
@@ -39,24 +39,7 @@
$root = dirname(phutil_get_library_root('phabricator'));
$auto_root = $root.'/resources/sql/autopatches/';
- $auto_list = Filesystem::listDirectory($auto_root, $include_hidden = false);
- sort($auto_list);
-
- foreach ($auto_list as $auto_patch) {
- $matches = null;
- if (!preg_match('/\.(sql|php)$/', $auto_patch, $matches)) {
- throw new Exception(
- pht(
- 'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.',
- $auto_patch,
- $auto_root));
- }
-
- $patches[$auto_patch] = array(
- 'type' => $matches[1],
- 'name' => $auto_root.$auto_patch,
- );
- }
+ $patches += $this->buildPatchesFromDirectory($auto_root);
return $patches;
}
diff --git a/src/infrastructure/storage/patch/PhabricatorSQLPatchList.php b/src/infrastructure/storage/patch/PhabricatorSQLPatchList.php
--- a/src/infrastructure/storage/patch/PhabricatorSQLPatchList.php
+++ b/src/infrastructure/storage/patch/PhabricatorSQLPatchList.php
@@ -5,6 +5,37 @@
abstract function getNamespace();
abstract function getPatches();
+ /**
+ * Examine a directory for `.php` and `.sql` files and build patch
+ * specifications for them.
+ */
+ protected function buildPatchesFromDirectory($directory) {
+ $patch_list = Filesystem::listDirectory(
+ $directory,
+ $include_hidden = false);
+
+ sort($patch_list);
+ $patches = array();
+
+ foreach ($patch_list as $patch) {
+ $matches = null;
+ if (!preg_match('/\.(sql|php)$/', $patch, $matches)) {
+ throw new Exception(
+ pht(
+ 'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.',
+ $patch,
+ $directory));
+ }
+
+ $patches[$patch] = array(
+ 'type' => $matches[1],
+ 'name' => rtrim($directory, '/').'/'.$patch,
+ );
+ }
+
+ return $patches;
+ }
+
final public static function buildAllPatches() {
$patch_lists = id(new PhutilSymbolLoader())
->setAncestorClass('PhabricatorSQLPatchList')
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 6, 11:11 AM (1 d, 13 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7734373
Default Alt Text
D10848.id26040.diff (2 KB)
Attached To
Mode
D10848: Move directory SQL patch construction to abstract base class
Attached
Detach File
Event Timeline
Log In to Comment