commit b755ba67bbfbe212f4dd549d7d11cc3b92803c65
parent 9df1b47a69402a0f11c4eb52a0365a2d4d20c0c9
Author: markseu <mark2011@mayberg.se>
Date: Wed, 22 Jun 2022 14:44:41 +0200
Updated extensions for PHP 8.1 compatibility
Diffstat:
3 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/system/extensions/core.php b/system/extensions/core.php
@@ -2,7 +2,7 @@
// Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core
class YellowCore {
- const VERSION = "0.8.87";
+ const VERSION = "0.8.88";
const RELEASE = "0.8.20";
public $page; // current page
public $content; // content files
@@ -15,7 +15,6 @@ class YellowCore {
public $toolbox; // toolbox with helper functions
public function __construct() {
- $this->checkRequirements();
$this->page = new YellowPage($this);
$this->content = new YellowContent($this);
$this->media = new YellowMedia($this);
@@ -25,6 +24,7 @@ class YellowCore {
$this->extension = new YellowExtension($this);
$this->lookup = new YellowLookup($this);
$this->toolbox = new YellowToolbox();
+ $this->checkRequirements();
$this->system->setDefault("sitename", "Localhost");
$this->system->setDefault("author", "Datenstrom");
$this->system->setDefault("email", "webmaster");
@@ -61,13 +61,11 @@ class YellowCore {
// Check requirements
public function checkRequirements() {
- $troubleshooting = PHP_SAPI!="cli" ?
- "<a href=\"".$this->getTroubleshootingUrl()."\">See troubleshooting</a>." : "See ".$this->getTroubleshootingUrl();
- version_compare(PHP_VERSION, "7.0", ">=") || die("Datenstrom Yellow requires PHP 7.0 or higher! $troubleshooting\n");
- extension_loaded("curl") || die("Datenstrom Yellow requires PHP curl extension! $troubleshooting\n");
- extension_loaded("gd") || die("Datenstrom Yellow requires PHP gd extension! $troubleshooting\n");
- extension_loaded("mbstring") || die("Datenstrom Yellow requires PHP mbstring extension! $troubleshooting\n");
- extension_loaded("zip") || die("Datenstrom Yellow requires PHP zip extension! $troubleshooting\n");
+ if (!version_compare(PHP_VERSION, "7.0", ">=")) $this->exitFatalError("Datenstrom Yellow requires PHP 7.0 or higher!");
+ if (!extension_loaded("curl")) $this->exitFatalError("Datenstrom Yellow requires PHP curl extension!");
+ if (!extension_loaded("gd")) $this->exitFatalError("Datenstrom Yellow requires PHP gd extension!");
+ if (!extension_loaded("mbstring")) $this->exitFatalError("Datenstrom Yellow requires PHP mbstring extension!");
+ if (!extension_loaded("zip")) $this->exitFatalError("Datenstrom Yellow requires PHP zip extension!");
mb_internal_encoding("UTF-8");
}
@@ -180,6 +178,15 @@ class YellowCore {
}
}
+ // Show error message and terminate immediately
+ public function exitFatalError($errorMessage = "") {
+ @header($this->toolbox->getHttpStatusFormatted(500));
+ $troubleshooting = PHP_SAPI!="cli" ?
+ "<a href=\"".$this->getTroubleshootingUrl()."\">See troubleshooting</a>." : "See ".$this->getTroubleshootingUrl();
+ echo "$errorMessage $troubleshooting\n";
+ exit(1);
+ }
+
// Send page response
public function sendPage($scheme, $address, $base, $location, $fileName, $cacheable, $showSource) {
$rawData = $showSource ? $this->toolbox->readFile($fileName) : $this->page->getRawDataError();
@@ -463,6 +470,7 @@ class YellowPage {
// Parse page meta data
public function parseMetaData() {
$this->metaData = new YellowArray();
+ $this->metaDataOffsetBytes = 0;
if (!is_null($this->rawData)) {
$this->set("title", $this->yellow->toolbox->createTextTitle($this->location));
$this->set("language", $this->yellow->lookup->findContentLanguage($this->fileName, $this->yellow->system->get("language")));
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.74";
+ const VERSION = "0.8.75";
const PRIORITY = "1";
public $yellow; // access to API
@@ -295,11 +295,10 @@ class YellowInstall {
list($name, $version, $os) = $this->yellow->toolbox->detectServerInformation();
echo "YellowInstall::checkServerRequirements for $name $version, $os<br/>\n";
}
- $troubleshooting = "<a href=\"".$this->yellow->getTroubleshootingUrl()."\">See troubleshooting</a>.";
- $this->checkServerComplete() || die("Datenstrom Yellow requires complete upload! $troubleshooting\n");
- $this->checkServerWrite() || die("Datenstrom Yellow requires write access! $troubleshooting\n");
- $this->checkServerConfiguration() || die("Datenstrom Yellow requires configuration file! $troubleshooting\n");
- $this->checkServerRewrite() || die("Datenstrom Yellow requires rewrite support! $troubleshooting\n");
+ if (!$this->checkServerComplete()) $this->yellow->exitFatalError("Datenstrom Yellow requires complete upload!");
+ if (!$this->checkServerWrite()) $this->yellow->exitFatalError("Datenstrom Yellow requires write access!");
+ if (!$this->checkServerConfiguration()) $this->yellow->exitFatalError("Datenstrom Yellow requires configuration file!");
+ if (!$this->checkServerRewrite()) $this->yellow->exitFatalError("Datenstrom Yellow requires rewrite support!");
}
// Check web server complete upload
@@ -370,9 +369,8 @@ class YellowInstall {
list($name, $version, $os) = $this->yellow->toolbox->detectServerInformation();
echo "YellowInstall::checkCommandRequirements for $name $version, $os<br/>\n";
}
- $troubleshooting = "See ".$this->yellow->getTroubleshootingUrl();
- $this->checkServerComplete() || die("Datenstrom Yellow requires complete upload! $troubleshooting\n");
- $this->checkServerWrite() || die("Datenstrom Yellow requires write access! $troubleshooting\n");
+ if (!$this->checkServerComplete()) $this->yellow->exitFatalError("Datenstrom Yellow requires complete upload!");
+ if (!$this->checkServerWrite()) $this->yellow->exitFatalError("Datenstrom Yellow requires write access!");
}
// Detect browser languages
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
@@ -21,11 +21,11 @@ Tag: feature
system/extensions/command.php: command.php, create, update
Extension: Core
-Version: 0.8.87
+Version: 0.8.88
Description: Core functionality of the website.
DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core
DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip
-Published: 2022-06-21 20:16:11
+Published: 2022-06-22 14:36:31
Developer: Datenstrom
Tag: feature
system/extensions/core.php: core.php, create, update
@@ -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.74
+Version: 0.8.75
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-06-21 12:10:31
+Published: 2022-06-22 14:40:35
Developer: Datenstrom
Status: unlisted
system/extensions/install.php: install.php, create