From 50bb83dbf2e1f5eba42ffd8f7c2ccfb990b1610a Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 20 Oct 2020 21:04:33 +0200 Subject: [PATCH] Fix compatibility with PHP 8 --- adminer/include/bootstrap.inc.php | 4 ++-- adminer/include/functions.inc.php | 2 +- adminer/include/pdo.inc.php | 14 +++++++------- changes.txt | 1 + compile.php | 12 ++++++++++-- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 6a56945d..04fb5cdd 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -1,5 +1,5 @@ $v) { unset($process[$key][$k]); diff --git a/adminer/include/pdo.inc.php b/adminer/include/pdo.inc.php index 14fb91ce..4d710e27 100644 --- a/adminer/include/pdo.inc.php +++ b/adminer/include/pdo.inc.php @@ -1,8 +1,8 @@ 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.'); } diff --git a/changes.txt b/changes.txt index 14f4cb98..11ddd26a 100644 --- a/changes.txt +++ b/changes.txt @@ -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@ diff --git a/compile.php b/compile.php index 229ba151..3bb1b6ac 100755 --- a/compile.php +++ b/compile.php @@ -1,6 +1,6 @@ #!/usr/bin/env php ?@[\]^`{|}')); + $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; }