From c2a6bef46e84b7d2b38ef18ceb8b774ebb71974a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 26 Jul 2017 11:49:51 +0200 Subject: [PATCH] phperror/error: provide a failsafe error message ...for PHP 5.3 fixes #1033 --- .../controllers/PhperrorController.php | 22 ++++++++++++++++ .../views/scripts/phperror/error.phtml | 8 ++++++ run-php5.3.php | 26 +++++++++++++++++++ run.php | 9 +++++-- 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 application/controllers/PhperrorController.php create mode 100644 application/views/scripts/phperror/error.phtml create mode 100644 run-php5.3.php diff --git a/application/controllers/PhperrorController.php b/application/controllers/PhperrorController.php new file mode 100644 index 00000000..e091db7a --- /dev/null +++ b/application/controllers/PhperrorController.php @@ -0,0 +1,22 @@ +getTabs()->add('error', array( + 'label' => $this->translate('Error'), + 'url' => $this->getRequest()->getUrl() + ))->activate('error'); + $msg = $this->translate( + "PHP version 5.4.x is required for Director >= 1.4.0, you're running %s." + . ' Please either upgrade PHP or downgrade Icinga Director' + ); + $this->view->title = $this->translate('Unsatisfied dependencies'); + $this->view->message = sprintf($msg, PHP_VERSION); + } +} diff --git a/application/views/scripts/phperror/error.phtml b/application/views/scripts/phperror/error.phtml new file mode 100644 index 00000000..c5ef1567 --- /dev/null +++ b/application/views/scripts/phperror/error.phtml @@ -0,0 +1,8 @@ +
+tabs ?> +

escape($this->title) ?>

+
+ +
+

escape($this->message) ?>

+
diff --git a/run-php5.3.php b/run-php5.3.php new file mode 100644 index 00000000..bc992a41 --- /dev/null +++ b/run-php5.3.php @@ -0,0 +1,26 @@ +isCli()) { + throw new IcingaException( + "PHP version 5.4.x is required for Director >= 1.4.0, you're running %s." + . ' Please either upgrade PHP or downgrade Icinga Director', + PHP_VERSION + ); +} else { + $request = Icinga::app()->getRequest(); + $path = $request->getPathInfo(); + if (! preg_match('#^/director#', $path)) { + return; + } + if (preg_match('#^/director/phperror/error#', $path)) { + return; + } + + header('Location: ' . Url::fromPath('director/phperror/error')); + exit; +} diff --git a/run.php b/run.php index c57f5d2c..510ea420 100644 --- a/run.php +++ b/run.php @@ -1,10 +1,16 @@ provideHook('monitoring/HostActions'); $this->provideHook('monitoring/ServiceActions'); @@ -51,7 +57,6 @@ $this->provideHook('director/Job', $prefix . 'Job\\SyncJob'); $this->provideHook('cube/Actions', 'CubeLinks'); // ipl compat, unless it is released: - if (class_exists('ipl\\Html\\ValidHtml')) { return; }