commit d14e090bc70c13ba51b3cb40358338c89c633536
parent 8d32c64680eebedf4b44c0d9dc3a2e4b4c28a6b7
Author: markseu <mark2011@mayberg.se>
Date: Thu, 5 May 2022 19:51:46 +0200
Splitted update process into two extensions
Diffstat:
3 files changed, 32 insertions(+), 107 deletions(-)
diff --git a/system/extensions/install.php b/system/extensions/install.php
@@ -2,7 +2,7 @@
// Install extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/install
class YellowInstall {
- const VERSION = "0.8.71";
+ const VERSION = "0.8.72";
const PRIORITY = "1";
public $yellow; // access to API
@@ -313,7 +313,8 @@ class YellowInstall {
foreach ($block as $key=>$value) {
if (strposu($key, "/")) {
list($entry, $flags) = $this->yellow->toolbox->getTextList($value, ",", 2);
- if (!preg_match("/create/i", $flags)) continue;
+ if (preg_match("/delete/i", $flags)) continue;
+ if (preg_match("/additional/i", $flags)) continue;
array_push($fileNames, $key);
}
}
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
@@ -64,11 +64,11 @@ media/images/photo.jpg: photo.jpg, create, optional
media/thumbnails/photo-100x40.jpg: photo-100x40.jpg, create, optional
Extension: Install
-Version: 0.8.71
+Version: 0.8.72
Description: Install a brand new, shiny website.
DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/install
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/install.zip
-Published: 2022-05-03 12:14:50
+Published: 2022-05-05 19:26:16
Developer: Datenstrom
Status: unlisted
system/extensions/install.php: install.php, create
@@ -131,11 +131,12 @@ system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff, crea
system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff, create, update, careful
Extension: Update
-Version: 0.8.74
+Version: 0.8.75
Description: Keep your website up to date.
DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip
-Published: 2022-05-03 12:49:27
+Published: 2022-05-05 10:29:50
Developer: Datenstrom
Tag: feature
system/extensions/update.php: update.php, create, update
+system/extensions/update-patch.bin: @base/source/patch/patch.php, create, additional
diff --git a/system/extensions/update.php b/system/extensions/update.php
@@ -2,7 +2,7 @@
// Update extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/update
class YellowUpdate {
- const VERSION = "0.8.74";
+ const VERSION = "0.8.75";
const PRIORITY = "2";
public $yellow; // access to API
public $extensions; // number of extensions
@@ -41,106 +41,6 @@ class YellowUpdate {
}
if ($statusCode==500) $this->yellow->log("error", "Can't delete files in directory '$path'!");
}
- if ($action=="update") { // TODO: remove later, create settings files when missing
- $fileNameCurrent = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateCurrentFile");
- $fileNameLatest = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateLatestFile");
- if (!is_file($fileNameCurrent) || !is_file($fileNameLatest)) {
- $url = $this->yellow->system->get("updateExtensionUrl")."/raw/master/".$this->yellow->system->get("updateLatestFile");
- list($statusCode, $fileData) = $this->getExtensionFile($url);
- if ($statusCode==200) {
- $fileDataCurrent = $fileDataLatest = $fileData;
- $settings = $this->yellow->toolbox->getTextSettings($fileDataCurrent, "extension");
- foreach ($settings as $key=>$value) {
- if ($this->yellow->extension->isExisting($key)) {
- $settingsNew = new YellowArray();
- $settingsNew["extension"] = ucfirst($key);
- $settingsNew["version"] = $this->yellow->extension->data[$key]["version"];
- $fileDataCurrent = $this->yellow->toolbox->setTextSettings($fileDataCurrent, "extension", $key, $settingsNew);
- } else {
- $fileDataCurrent = $this->yellow->toolbox->unsetTextSettings($fileDataCurrent, "extension", $key);
- }
- }
- if (!is_file($fileNameCurrent) && !$this->yellow->toolbox->createFile($fileNameCurrent, $fileDataCurrent)) {
- $this->yellow->log("error", "Can't write file '$fileNameCurrent'!");
- }
- if (!is_file($fileNameLatest) && !$this->yellow->toolbox->createFile($fileNameLatest, $fileDataLatest)) {
- $this->yellow->log("error", "Can't write file '$fileNameLatest'!");
- }
- }
- }
- }
- if ($action=="update") { // TODO: remove later, convert files for blog/wiki extension
- if ($this->yellow->system->isExisting("blogPagesMax") || $this->yellow->system->isExisting("wikiPagesMax")) {
- $path = $this->yellow->system->get("coreContentDirectory");
- foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.(md|txt)$/", true, false) as $entry) {
- $fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
- $fileDataNew = str_replace("[blogarchive", "[blogmonths", $fileDataNew);
- $fileDataNew = preg_replace("/Layout: blogpages/i", "Layout: blog-start", $fileDataNew);
- $fileDataNew = preg_replace("/Layout: wikipages/i", "Layout: wiki-start", $fileDataNew);
- $fileDataNew = preg_replace("/Layout: draftpages/i", "Layout: draftpages-unsupported", $fileDataNew);
- if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($entry, $fileDataNew)) {
- $this->yellow->log("error", "Can't write file '$entry'!");
- }
- }
- $path = $this->yellow->system->get("coreLayoutDirectory");
- foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.html$/", true, false) as $entry) {
- $fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
- $fileDataNew = str_replace("yellow->page->getPage(\"blog\")", "yellow->page->getPage(\"blogStart\")", $fileDataNew);
- $fileDataNew = str_replace("yellow->page->getPage(\"wiki\")", "yellow->page->getPage(\"wikiStart\")", $fileDataNew);
- if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($entry, $fileDataNew)) {
- $this->yellow->log("error", "Can't write file '$entry'!");
- }
- if (basename($entry)=="draftpages.html" &&
- !$this->yellow->toolbox->deleteFile($entry, $this->yellow->system->get("coreTrashDirectory"))) {
- $this->yellow->log("error", "Can't delete file '$entry'!");
- }
- }
- }
- }
- if ($action=="update") { // TODO: remove later, convert old extension settings
- $fileName = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreSystemFile");
- if ($this->yellow->system->get("galleryStyle")=="photoswipe") {
- if (!$this->yellow->system->save($fileName, array("galleryStyle" => "zoom"))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- }
- if ($this->yellow->system->get("sliderStyle")=="flickity") {
- if (!$this->yellow->system->save($fileName, array("sliderStyle" => "loop"))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- }
- if ($this->yellow->system->isExisting("coreServerTimezone")) {
- $coreTimezone = $this->yellow->system->get("coreServerTimezone");
- if (!$this->yellow->system->save($fileName, array("coreTimezone" => $coreTimezone))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- }
- if ($this->yellow->system->isExisting("blogLocation")) {
- $blogStartLocation = $this->yellow->system->get("blogLocation");
- if (!$this->yellow->system->save($fileName, array("blogStartLocation" => $blogStartLocation))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- }
- if ($this->yellow->system->isExisting("wikiLocation")) {
- $wikiStartLocation = $this->yellow->system->get("wikiLocation");
- if (!$this->yellow->system->save($fileName, array("wikiStartLocation" => $wikiStartLocation))) {
- $this->yellow->log("error", "Can't write file '$fileName'!");
- }
- }
- }
- if ($action=="update") { // TODO: remove later, convert old log file
- $fileNameOld = $this->yellow->system->get("coreExtensionDirectory")."yellow.log";
- $fileNameNew = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("coreWebsiteFile");
- if (is_file($fileNameOld)) {
- $fileDataOld = $this->yellow->toolbox->readFile($fileNameOld);
- $fileDataNew = $this->yellow->toolbox->readFile($fileNameNew);
- if (!$this->yellow->toolbox->deleteFile($fileNameOld, $this->yellow->system->get("coreTrashDirectory"))) {
- $this->yellow->log("error", "Can't delete file '$fileNameOld'!");
- } elseif (!$this->yellow->toolbox->createFile($fileNameNew, $fileDataOld.$fileDataNew)) {
- $this->yellow->log("error", "Can't write file '$fileNameNew'!");
- }
- }
- }
}
// Handle request
@@ -269,6 +169,7 @@ class YellowUpdate {
// Process command for pending events
public function processCommandPending() {
$statusCode = 0;
+ $this->updatePatchPending();
$this->updateEventPending();
if ($this->isExtensionPending()) {
$this->extensions = 0;
@@ -284,6 +185,7 @@ class YellowUpdate {
public function processRequestPending($scheme, $address, $base, $location, $fileName) {
$statusCode = 0;
if ($this->yellow->lookup->isContentFile($fileName)) {
+ $this->updatePatchPending();
$this->updateEventPending();
if ($this->isExtensionPending()) {
$statusCode = $this->updateExtensions("install");
@@ -447,6 +349,27 @@ class YellowUpdate {
return $statusCode;
}
+ // Update pending patches
+ public function updatePatchPending() {
+ $fileName = $this->yellow->system->get("coreExtensionDirectory")."update-patch.bin";
+ if (is_file($fileName)) {
+ if (!$this->yellow->extension->isExisting("patch")) {
+ require_once($fileName);
+ $this->yellow->extension->register("patch", "YellowPatch");
+ }
+ if ($this->yellow->extension->isExisting("patch")) {
+ $value = $this->yellow->extension->data["patch"];
+ if (method_exists($value["object"], "onLoad")) $value["object"]->onLoad($this->yellow);
+ if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate("update");
+ }
+ unset($this->yellow->extension->data["patch"]);
+ if (function_exists("opcache_reset")) opcache_reset();
+ if (!$this->yellow->toolbox->deleteFile($fileName)) {
+ $this->yellow->log("error", "Can't delete file '$fileName'!");
+ }
+ }
+ }
+
// Update pending events
public function updateEventPending() {
if ($this->yellow->system->get("updateCurrentRelease")!="none") {