Page MenuHomeIn-Portal Phabricator

D21.id66.diff
No OneTemporary

File Metadata

Created
Mon, Jan 6, 4:19 AM

D21.id66.diff

Index: core/units/helpers/deployment_helper.php
===================================================================
--- core/units/helpers/deployment_helper.php
+++ core/units/helpers/deployment_helper.php
@@ -21,6 +21,10 @@
*/
const SQL_TRIM_LENGTH = 120;
+ const STAGE_DB_MIGRATE = 'db-migrate';
+
+ const STAGE_CACHE_RESET = 'cache-reset';
+
/**
* Name of module, that is processed right now.
*
@@ -78,6 +82,16 @@
public $ip = '';
/**
+ * Deployment stages to run.
+ *
+ * @var array
+ */
+ public $stages = array(
+ self::STAGE_DB_MIGRATE,
+ self::STAGE_CACHE_RESET,
+ );
+
+ /**
* Event, that triggered deployment.
*
* @var kEvent
@@ -106,8 +120,21 @@
if ( !$this->isCommandLine ) {
$this->ip = $this->Application->getClientIp();
}
- elseif ( isset($GLOBALS['argv'][3]) ) {
- $this->ip = $GLOBALS['argv'][3];
+ else {
+ if ( isset($GLOBALS['argv'][3]) ) {
+ $this->ip = $GLOBALS['argv'][3];
+ }
+
+ if ( isset($GLOBALS['argv'][4]) ) {
+ $new_stages = explode(',', $GLOBALS['argv'][4]);
+ $unknown_stages = array_diff($new_stages, $this->stages);
+
+ if ( $unknown_stages ) {
+ throw new InvalidArgumentException('Unknown deployment stages: ' . implode(', ', $unknown_stages));
+ }
+
+ $this->stages = $new_stages;
+ }
}
}
@@ -173,19 +200,23 @@
$ret = true;
$this->dryRun = $dry_run;
- foreach ( $this->Application->ModuleInfo as $module_name => $module_info ) {
- $this->moduleName = $module_name;
+ if ( in_array(self::STAGE_DB_MIGRATE, $this->stages) ) {
+ foreach ( $this->Application->ModuleInfo as $module_name => $module_info ) {
+ $this->moduleName = $module_name;
- if ( !file_exists($this->getModuleFile('project_upgrades.sql')) ) {
- continue;
- }
+ if ( !file_exists($this->getModuleFile('project_upgrades.sql')) ) {
+ continue;
+ }
- $ret = $ret && $this->deploy($module_name);
+ $ret = $ret && $this->deploy($module_name);
+ }
}
- if ( $ret && !$this->dryRun ) {
- $this->resetCaches();
- $this->refreshThemes();
+ if ( in_array(self::STAGE_CACHE_RESET, $this->stages) ) {
+ if ( $ret && !$this->dryRun ) {
+ $this->resetCaches();
+ $this->refreshThemes();
+ }
}
if ( !$this->isCommandLine ) {
@@ -719,4 +750,4 @@
return $this;
}
-}
\ No newline at end of file
+}

Event Timeline