Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/deployment_helper.php
Show First 20 Lines • Show All 390 Lines • ▼ Show 20 Line(s) | |||||
preg_match_all("/# r([\d]+)([^\:]*):.*?(\n|$)/s", $sqls, $matches, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); | preg_match_all("/# r([\d]+)([^\:]*):.*?(\n|$)/s", $sqls, $matches, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); | ||||
if ( !$matches ) { | if ( !$matches ) { | ||||
$this->displayStatus('FAILED' . PHP_EOL . 'No Database Revisions Found'); | $this->displayStatus('FAILED' . PHP_EOL . 'No Database Revisions Found'); | ||||
return false; | return false; | ||||
} | } | ||||
$revision_numbers = array(); | |||||
foreach ($matches as $index => $match) { | foreach ( $matches as $index => $match ) { | ||||
$revision = $match[1][0]; | $revision = $match[1][0]; | ||||
if ( $this->revisionApplied($revision) ) { | if ( in_array($revision, $revision_numbers) ) { | ||||
// skip applied revisions | |||||
continue; | |||||
} | |||||
if ( isset($this->revisionSqls[$revision]) ) { | |||||
// duplicate revision among non-applied ones | |||||
$this->displayStatus('FAILED' . PHP_EOL . 'Duplicate revision #' . $revision . ' found'); | $this->displayStatus('FAILED' . PHP_EOL . 'Duplicate revision #' . $revision . ' found'); | ||||
return false; | return false; | ||||
} | } | ||||
// get revision sqls | $revision_numbers[] = $revision; | ||||
if ( $this->revisionApplied($revision) ) { | |||||
// Skip applied revisions. | |||||
continue; | |||||
} | |||||
// Get revision sqls. | |||||
$start_pos = $match[0][1] + strlen($match[0][0]); | $start_pos = $match[0][1] + strlen($match[0][0]); | ||||
$end_pos = isset($matches[$index + 1]) ? $matches[$index + 1][0][1] : strlen($sqls); | $end_pos = isset($matches[$index + 1]) ? $matches[$index + 1][0][1] : strlen($sqls); | ||||
$revision_sqls = substr($sqls, $start_pos, $end_pos - $start_pos); | $revision_sqls = substr($sqls, $start_pos, $end_pos - $start_pos); | ||||
if ( !$revision_sqls ) { | if ( !$revision_sqls ) { | ||||
// resision without sqls | // resision without sqls | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |