From: William Desportes <williamdes@wdes.fr>
Date: Fri, 14 Apr 2023 18:06:39 +0200
Subject: Require PHP >= 8.0

Due to the delta carried in the Ubuntu PSR stack, phpmyadmin does not run with
PHP versions < 8. This patch makes it fail gracefully instead of allowing
phpmyadmin to abruptly crash, allowing us to provide useful error messages so
users understand what their next steps should be towards getting a functional
phpmyadmin deployment.

Bug: https://github.com/phpmyadmin/phpmyadmin/issues/17503
Bug: https://github.com/phpmyadmin/phpmyadmin/issues/19092
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2016016
Origin: vendor
Forwarded: not-needed
Reviewed-by: Athos Ribeiro <athos.ribeiro@canonical.com>
---
 composer.json            | 1 -
 index.php                | 9 +++++++--
 js/messages.php          | 9 +++++++--
 setup/lib/common.inc.php | 9 +++++++--
 url.php                  | 9 +++++++--
 5 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/composer.json b/composer.json
index 8a2ad70..fc18793 100644
--- a/composer.json
+++ b/composer.json
@@ -71,7 +71,6 @@
         "symfony/expression-language": ">=5.2.3 <7",
         "symfony/polyfill-ctype": "^1.17.0",
         "symfony/polyfill-mbstring": "^1.17.0",
-        "symfony/polyfill-php80": "^1.16",
         "twig/twig": "^3.3.5",
         "webmozart/assert": "^1.10",
         "williamdes/mariadb-mysql-kbs": "^1.2"
diff --git a/index.php b/index.php
index 26fcabf..8831d47 100644
--- a/index.php
+++ b/index.php
@@ -11,8 +11,13 @@ if (! defined('ROOT_PATH')) {
     // phpcs:enable
 }
 
-if (PHP_VERSION_ID < 70205) {
-    die('<p>PHP 7.2.5+ is required.</p><p>Currently installed version is: ' . PHP_VERSION . '</p>');
+if (PHP_VERSION_ID < 80000) {
+    die(
+        '<p>PHP 8.0.0+ is required ('
+        . '<a href="https://bugs.launchpad.net/ubuntu/+source/symfony/+bug/1975892">Ubuntu Launchpad bug #1975892</a>'
+        . '&nbsp;and&nbsp;<a href="https://github.com/phpmyadmin/phpmyadmin/issues/17503">phpMyAdmin issue #17503</a>'
+        . ').</p><p>Currently installed version is: ' . PHP_VERSION . '</p>'
+    );
 }
 
 // phpcs:disable PSR1.Files.SideEffects
diff --git a/js/messages.php b/js/messages.php
index 927226b..1e2b249 100644
--- a/js/messages.php
+++ b/js/messages.php
@@ -15,8 +15,13 @@ if (! defined('ROOT_PATH')) {
     // phpcs:enable
 }
 
-if (PHP_VERSION_ID < 70205) {
-    die('<p>PHP 7.2.5+ is required.</p><p>Currently installed version is: ' . PHP_VERSION . '</p>');
+if (PHP_VERSION_ID < 80000) {
+    die(
+        '<p>PHP 8.0.0+ is required ('
+        . '<a href="https://bugs.launchpad.net/ubuntu/+source/symfony/+bug/1975892">Ubuntu Launchpad bug #1975892</a>'
+        . '&nbsp;and&nbsp;<a href="https://github.com/phpmyadmin/phpmyadmin/issues/17503">phpMyAdmin issue #17503</a>'
+        . ').</p><p>Currently installed version is: ' . PHP_VERSION . '</p>'
+    );
 }
 
 // phpcs:disable PSR1.Files.SideEffects
diff --git a/setup/lib/common.inc.php b/setup/lib/common.inc.php
index 17adc52..b681566 100644
--- a/setup/lib/common.inc.php
+++ b/setup/lib/common.inc.php
@@ -6,8 +6,13 @@ use PhpMyAdmin\Common;
 use PhpMyAdmin\Config\ConfigFile;
 use PhpMyAdmin\DatabaseInterface;
 
-if (PHP_VERSION_ID < 70205) {
-    die('<p>PHP 7.2.5+ is required.</p><p>Currently installed version is: ' . PHP_VERSION . '</p>');
+if (PHP_VERSION_ID < 80000) {
+    die(
+        '<p>PHP 8.0.0+ is required ('
+        . '<a href="https://bugs.launchpad.net/ubuntu/+source/symfony/+bug/1975892">Ubuntu Launchpad bug #1975892</a>'
+        . '&nbsp;and&nbsp;<a href="https://github.com/phpmyadmin/phpmyadmin/issues/17503">phpMyAdmin issue #17503</a>'
+        . ').</p><p>Currently installed version is: ' . PHP_VERSION . '</p>'
+    );
 }
 
 if (! defined('PHPMYADMIN')) {
diff --git a/url.php b/url.php
index 0274481..ebf69df 100644
--- a/url.php
+++ b/url.php
@@ -11,8 +11,13 @@ if (! defined('ROOT_PATH')) {
     // phpcs:enable
 }
 
-if (PHP_VERSION_ID < 70205) {
-    die('<p>PHP 7.2.5+ is required.</p><p>Currently installed version is: ' . PHP_VERSION . '</p>');
+if (PHP_VERSION_ID < 80000) {
+    die(
+        '<p>PHP 8.0.0+ is required ('
+        . '<a href="https://bugs.launchpad.net/ubuntu/+source/symfony/+bug/1975892">Ubuntu Launchpad bug #1975892</a>'
+        . '&nbsp;and&nbsp;<a href="https://github.com/phpmyadmin/phpmyadmin/issues/17503">phpMyAdmin issue #17503</a>'
+        . ').</p><p>Currently installed version is: ' . PHP_VERSION . '</p>'
+    );
 }
 
 // phpcs:disable PSR1.Files.SideEffects
