diff --git a/5/Dockerfile b/5/Dockerfile index 62a1fea..70a0e7f 100644 --- a/5/Dockerfile +++ b/5/Dockerfile @@ -40,9 +40,9 @@ RUN set -x \ COPY *.php /var/www/html/ -ENV ADMINER_VERSION=5.1.0 -ENV ADMINER_DOWNLOAD_SHA256=b11edcee53cef7e64776adfcc21bb1971123c7de55b7d4eef3cd0020142b900e -ENV ADMINER_SRC_DOWNLOAD_SHA256=de4dd39ade03d2ebb145782c8fb5bb176eecb8ec4a9cf4ee63b4669be2b1b80c +ENV ADMINER_VERSION=5.2.1 +ENV ADMINER_DOWNLOAD_SHA256=572118dff2305f136a4b8d59404d01c3d8450e99e3abd506081ffdddd8816573 +ENV ADMINER_SRC_DOWNLOAD_SHA256=64e6b6c9e049ddab694cc8793485f1f1888abaf70ab5a389544c0a1b2926bed6 RUN set -x \ && curl -fsSL https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -o adminer.php \ diff --git a/5/fastcgi/Dockerfile b/5/fastcgi/Dockerfile index c4300a9..7b4b612 100644 --- a/5/fastcgi/Dockerfile +++ b/5/fastcgi/Dockerfile @@ -36,9 +36,9 @@ RUN set -x \ COPY *.php /var/www/html/ -ENV ADMINER_VERSION=5.1.0 -ENV ADMINER_DOWNLOAD_SHA256=b11edcee53cef7e64776adfcc21bb1971123c7de55b7d4eef3cd0020142b900e -ENV ADMINER_SRC_DOWNLOAD_SHA256=de4dd39ade03d2ebb145782c8fb5bb176eecb8ec4a9cf4ee63b4669be2b1b80c +ENV ADMINER_VERSION=5.2.1 +ENV ADMINER_DOWNLOAD_SHA256=572118dff2305f136a4b8d59404d01c3d8450e99e3abd506081ffdddd8816573 +ENV ADMINER_SRC_DOWNLOAD_SHA256=64e6b6c9e049ddab694cc8793485f1f1888abaf70ab5a389544c0a1b2926bed6 RUN set -x \ && curl -fsSL https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -o adminer.php \ diff --git a/5/fastcgi/index.php b/5/fastcgi/index.php index e676bbb..f336caf 100644 --- a/5/fastcgi/index.php +++ b/5/fastcgi/index.php @@ -1,38 +1,42 @@ call($this->adminer, ...$args); - } - } - function adminer_object() { - require_once('plugins/plugin.php'); + /** + * Prefills the “Server” field with the ADMINER_DEFAULT_SERVER environment variable. + */ + final class DefaultServerPlugin extends \Adminer\Plugin { + public function __construct( + private \Adminer\Adminer $adminer + ) { } + + public function loginFormField(...$args) { + return (function (...$args) { + $field = $this->loginFormField(...$args); + + return \str_replace( + 'name="auth[server]" value="" title="hostname[:port]"', + \sprintf('name="auth[server]" value="%s" title="hostname[:port]"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')), + $field, + ); + })->call($this->adminer, ...$args); + } + } $plugins = []; foreach (glob('plugins-enabled/*.php') as $plugin) { $plugins[] = require($plugin); } - // Load the DefaultServerPlugin last to give other plugins a chance to - // override loginFormField() if they wish to. - $plugins[] = &$loginFormPlugin; - - $adminer = new \AdminerPlugin($plugins); + $adminer = new \Adminer\Plugins($plugins); - $loginFormPlugin = new DefaultServerPlugin($adminer); + (function () { + $last = &$this->hooks['loginFormField'][\array_key_last($this->hooks['loginFormField'])]; + if ($last instanceof \Adminer\Adminer) { + $defaultServerPlugin = new DefaultServerPlugin($last); + $this->plugins[] = $defaultServerPlugin; + $last = $defaultServerPlugin; + } + })->call($adminer); return $adminer; } diff --git a/5/index.php b/5/index.php index e676bbb..f336caf 100644 --- a/5/index.php +++ b/5/index.php @@ -1,38 +1,42 @@ call($this->adminer, ...$args); - } - } - function adminer_object() { - require_once('plugins/plugin.php'); + /** + * Prefills the “Server” field with the ADMINER_DEFAULT_SERVER environment variable. + */ + final class DefaultServerPlugin extends \Adminer\Plugin { + public function __construct( + private \Adminer\Adminer $adminer + ) { } + + public function loginFormField(...$args) { + return (function (...$args) { + $field = $this->loginFormField(...$args); + + return \str_replace( + 'name="auth[server]" value="" title="hostname[:port]"', + \sprintf('name="auth[server]" value="%s" title="hostname[:port]"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')), + $field, + ); + })->call($this->adminer, ...$args); + } + } $plugins = []; foreach (glob('plugins-enabled/*.php') as $plugin) { $plugins[] = require($plugin); } - // Load the DefaultServerPlugin last to give other plugins a chance to - // override loginFormField() if they wish to. - $plugins[] = &$loginFormPlugin; - - $adminer = new \AdminerPlugin($plugins); + $adminer = new \Adminer\Plugins($plugins); - $loginFormPlugin = new DefaultServerPlugin($adminer); + (function () { + $last = &$this->hooks['loginFormField'][\array_key_last($this->hooks['loginFormField'])]; + if ($last instanceof \Adminer\Adminer) { + $defaultServerPlugin = new DefaultServerPlugin($last); + $this->plugins[] = $defaultServerPlugin; + $last = $defaultServerPlugin; + } + })->call($adminer); return $adminer; }