Fixed version history issue
This commit is contained in:
parent
57c6414d1c
commit
18b0e01a3e
2
now.json
2
now.json
@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [{ "src": "*.php", "use": "@now/php" }]
|
||||
}
|
||||
|
@ -167,11 +167,11 @@ final class Install
|
||||
if (\defined('GRAV_CLI') && GRAV_CLI) {
|
||||
$errors = "\n\n" . strip_tags($errors) . "\n\n";
|
||||
$errors .= <<<ERR
|
||||
Please install Grav 1.6.28 first by running following commands:
|
||||
Please install Grav 1.6.31 first by running following commands:
|
||||
|
||||
wget -q https://getgrav.org/download/core/grav-update/1.6.28 -O grav-update.zip
|
||||
bin/gpm direct-install -y grav-update.zip
|
||||
rm grav-update.zip
|
||||
wget -q https://getgrav.org/download/core/grav-update/1.6.31 -O tmp/grav-update-v1.6.31.zip
|
||||
bin/gpm direct-install -y tmp/grav-update-v1.6.31.zip
|
||||
rm tmp/grav-update.zip
|
||||
ERR;
|
||||
}
|
||||
|
||||
|
@ -196,8 +196,14 @@ final class Versions
|
||||
public function getHistory(string $extension): array
|
||||
{
|
||||
$name = "{$extension}/history";
|
||||
$history = $this->get($name, []);
|
||||
|
||||
return $this->get($name, []);
|
||||
// Fix for broken Grav 1.6 history
|
||||
if ($extension === 'grav') {
|
||||
$history = $this->fixHistory($history);
|
||||
}
|
||||
|
||||
return $history;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,7 +213,7 @@ final class Versions
|
||||
public function updateHistory(string $extension, ?string $version): void
|
||||
{
|
||||
$name = "{$extension}/history";
|
||||
$history = $this->get($name, []);
|
||||
$history = $this->getHistory($extension);
|
||||
$history[] = ['version' => $version, 'date' => gmdate('Y-m-d H:i:s')];
|
||||
$this->set($name, $history);
|
||||
}
|
||||
@ -222,6 +228,21 @@ final class Versions
|
||||
$this->undef("{$extension}/history");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $history
|
||||
* @return array
|
||||
*/
|
||||
private function fixHistory(array $history): array
|
||||
{
|
||||
if (isset($history['version'], $history['date'])) {
|
||||
$fix = [['version' => $history['version'], 'date' => $history['date']]];
|
||||
unset($history['version'], $history['date']);
|
||||
$history = array_merge($fix, $history);
|
||||
}
|
||||
|
||||
return $history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user