]> git.joonet.de Git - adminer.git/commitdiff
Fix compatibility with PHP 8
authorDavid Grudl <david@grudl.com>
Tue, 20 Oct 2020 19:04:33 +0000 (21:04 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sun, 6 Dec 2020 11:56:01 +0000 (12:56 +0100)
adminer/include/bootstrap.inc.php
adminer/include/functions.inc.php
adminer/include/pdo.inc.php
changes.txt
compile.php

index 6a56945d652dcaf54ebfddcc53708a2352dcdbc7..04fb5cdd12fc83e7b650f2bafce27562cee12eb3 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-error_reporting(6135); // errors and warnings
+error_reporting(6133); // errors
 
 include "../adminer/include/coverage.inc.php";
 
@@ -60,7 +60,7 @@ if (!defined("SID")) {
 
 // disable magic quotes to be able to use database escaping function
 remove_slashes(array(&$_GET, &$_POST, &$_COOKIE), $filter);
-if (get_magic_quotes_runtime()) {
+if (function_exists("get_magic_quotes_runtime") && get_magic_quotes_runtime()) {
        set_magic_quotes_runtime(false);
 }
 @set_time_limit(0); // @ - can be disabled
index ea9d81b3947d0e5b4fa70f222418a25986609ea7..9be33b0de4872f7f6a81330d0af5347a4ce5bde8 100644 (file)
@@ -62,7 +62,7 @@ function number_type() {
 * @return null modified in place
 */
 function remove_slashes($process, $filter = false) {
-       if (get_magic_quotes_gpc()) {
+       if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
                while (list($key, $val) = each($process)) {
                        foreach ($val as $k => $v) {
                                unset($process[$key][$k]);
index 14fb91cea5f15bd4af121c3d03c220475d291494..4d710e277ae23391303a7a42e8507804fad0b414 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 // PDO can be used in several database drivers
 if (extension_loaded('pdo')) {
-       /*abstract*/ class Min_PDO extends PDO {
-               var $_result, $server_info, $affected_rows, $errno, $error;
+       /*abstract*/ class Min_PDO {
+               var $_result, $server_info, $affected_rows, $errno, $error, $pdo;
                
                function __construct() {
                        global $adminer;
@@ -14,21 +14,21 @@ if (extension_loaded('pdo')) {
                
                function dsn($dsn, $username, $password, $options = array()) {
                        try {
-                               parent::__construct($dsn, $username, $password, $options);
+                               $this->pdo = new PDO($dsn, $username, $password, $options);
                        } catch (Exception $ex) {
                                auth_error(h($ex->getMessage()));
                        }
-                       $this->setAttribute(13, array('Min_PDOStatement')); // 13 - PDO::ATTR_STATEMENT_CLASS
-                       $this->server_info = @$this->getAttribute(4); // 4 - PDO::ATTR_SERVER_VERSION
+                       $this->pdo->setAttribute(13, array('Min_PDOStatement')); // 13 - PDO::ATTR_STATEMENT_CLASS
+                       $this->server_info = @$this->pdo->getAttribute(4); // 4 - PDO::ATTR_SERVER_VERSION
                }
                
                /*abstract function select_db($database);*/
                
                function query($query, $unbuffered = false) {
-                       $result = parent::query($query);
+                       $result = $this->pdo->query($query);
                        $this->error = "";
                        if (!$result) {
-                               list(, $this->errno, $this->error) = $this->errorInfo();
+                               list(, $this->errno, $this->error) = $this->pdo->errorInfo();
                                if (!$this->error) {
                                        $this->error = lang('Unknown error.');
                                }
index 14f4cb98923fa4572a509ad096f18e743a1f1966..11ddd26a8b73026ed266aa049ed76ef7bbc16a6b 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 4.7.8-dev:
+Support PHP 8
 
 Adminer 4.7.7 (released 2020-05-11):
 Fix open redirect if Adminer is accessible at //adminer.php%2F@
index 229ba1518be6ccca1bf8f62caac71db2ace373ca..3bb1b6acf4ae265305d790f1fd9a9441443366cf 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env php
 <?php
-error_reporting(6135); // errors and warnings
+error_reporting(6133); // errors
 include dirname(__FILE__) . "/adminer/include/version.inc.php";
 include dirname(__FILE__) . "/externals/JsShrink/jsShrink.php";
 
@@ -233,7 +233,7 @@ function php_shrink($input) {
                $short_variables[$key] = short_identifier($number, $chars); // could use also numbers and \x7f-\xff
        }
        
-       $set = array_flip(preg_split('//', '!"#$%&\'()*+,-./:;<=>?@[\]^`{|}'));
+       $set = array_flip(preg_split('//', '!"#$%&\'()*+,-./:;<=>?@[]^`{|}'));
        $space = '';
        $output = '';
        $in_echo = false;
@@ -315,6 +315,14 @@ function compile_file($match) {
        return '"' . add_quo_slashes($file) . '"';
 }
 
+if (!function_exists("each")) {
+       function each(&$arr) {
+               $key = key($arr);
+               next($arr);
+               return $key === null ? false : array($key, $arr[$key]);
+       }
+}
+
 function min_version() {
        return true;
 }