@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move directory SQL patch construction to abstract base class

Summary:
Ref T6238. I'm building the instance management application now, but not putting it in the upstream -- I think the only use case for it is to build SAAS. If someone comes up with a use case (maybe a college course that wants to create an instance per-class or something?) we could open it up eventually, but it seems cleaner to keep it out of the upstream until we have such a use case.

I need to add schema patches. Make it easier for a subclass to just "add all the patches in this directory", like "autopatches/" works.

Test Plan:
- Ran `bin/storage status`, saw all normal patches still valid.
- In some future diff, the instances application will use this to apply patches.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6238

Differential Revision: https://secure.phabricator.com/D10848

+33 -19
+1 -1
src/applications/base/controller/PhabricatorController.php
··· 527 527 } 528 528 529 529 protected function buildTransactionTimeline( 530 - PhabricatorLiskDAO $object, 530 + PhabricatorApplicationTransactionInterface $object, 531 531 PhabricatorApplicationTransactionQuery $query, 532 532 PhabricatorMarkupEngine $engine = null) { 533 533
+1 -18
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 39 39 40 40 $root = dirname(phutil_get_library_root('phabricator')); 41 41 $auto_root = $root.'/resources/sql/autopatches/'; 42 - $auto_list = Filesystem::listDirectory($auto_root, $include_hidden = false); 43 - sort($auto_list); 44 - 45 - foreach ($auto_list as $auto_patch) { 46 - $matches = null; 47 - if (!preg_match('/\.(sql|php)$/', $auto_patch, $matches)) { 48 - throw new Exception( 49 - pht( 50 - 'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.', 51 - $auto_patch, 52 - $auto_root)); 53 - } 54 - 55 - $patches[$auto_patch] = array( 56 - 'type' => $matches[1], 57 - 'name' => $auto_root.$auto_patch, 58 - ); 59 - } 42 + $patches += $this->buildPatchesFromDirectory($auto_root); 60 43 61 44 return $patches; 62 45 }
+31
src/infrastructure/storage/patch/PhabricatorSQLPatchList.php
··· 5 5 abstract function getNamespace(); 6 6 abstract function getPatches(); 7 7 8 + /** 9 + * Examine a directory for `.php` and `.sql` files and build patch 10 + * specifications for them. 11 + */ 12 + protected function buildPatchesFromDirectory($directory) { 13 + $patch_list = Filesystem::listDirectory( 14 + $directory, 15 + $include_hidden = false); 16 + 17 + sort($patch_list); 18 + $patches = array(); 19 + 20 + foreach ($patch_list as $patch) { 21 + $matches = null; 22 + if (!preg_match('/\.(sql|php)$/', $patch, $matches)) { 23 + throw new Exception( 24 + pht( 25 + 'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.', 26 + $patch, 27 + $directory)); 28 + } 29 + 30 + $patches[$patch] = array( 31 + 'type' => $matches[1], 32 + 'name' => rtrim($directory, '/').'/'.$patch, 33 + ); 34 + } 35 + 36 + return $patches; 37 + } 38 + 8 39 final public static function buildAllPatches() { 9 40 $patch_lists = id(new PhutilSymbolLoader()) 10 41 ->setAncestorClass('PhabricatorSQLPatchList')