Skip to content

Commit dea5a9c

Browse files
committed
Merge branch 'adminer-5.2.1'
2 parents 48079be + e1bbfa8 commit dea5a9c

File tree

4 files changed

+64
-56
lines changed

4 files changed

+64
-56
lines changed

5/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ RUN set -x \
4040

4141
COPY *.php /var/www/html/
4242

43-
ENV ADMINER_VERSION=5.1.0
44-
ENV ADMINER_DOWNLOAD_SHA256=b11edcee53cef7e64776adfcc21bb1971123c7de55b7d4eef3cd0020142b900e
45-
ENV ADMINER_SRC_DOWNLOAD_SHA256=de4dd39ade03d2ebb145782c8fb5bb176eecb8ec4a9cf4ee63b4669be2b1b80c
43+
ENV ADMINER_VERSION=5.2.1
44+
ENV ADMINER_DOWNLOAD_SHA256=572118dff2305f136a4b8d59404d01c3d8450e99e3abd506081ffdddd8816573
45+
ENV ADMINER_SRC_DOWNLOAD_SHA256=64e6b6c9e049ddab694cc8793485f1f1888abaf70ab5a389544c0a1b2926bed6
4646

4747
RUN set -x \
4848
&& curl -fsSL https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -o adminer.php \

5/fastcgi/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ RUN set -x \
3636

3737
COPY *.php /var/www/html/
3838

39-
ENV ADMINER_VERSION=5.1.0
40-
ENV ADMINER_DOWNLOAD_SHA256=b11edcee53cef7e64776adfcc21bb1971123c7de55b7d4eef3cd0020142b900e
41-
ENV ADMINER_SRC_DOWNLOAD_SHA256=de4dd39ade03d2ebb145782c8fb5bb176eecb8ec4a9cf4ee63b4669be2b1b80c
39+
ENV ADMINER_VERSION=5.2.1
40+
ENV ADMINER_DOWNLOAD_SHA256=572118dff2305f136a4b8d59404d01c3d8450e99e3abd506081ffdddd8816573
41+
ENV ADMINER_SRC_DOWNLOAD_SHA256=64e6b6c9e049ddab694cc8793485f1f1888abaf70ab5a389544c0a1b2926bed6
4242

4343
RUN set -x \
4444
&& curl -fsSL https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -o adminer.php \

5/fastcgi/index.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
<?php
22
namespace docker {
3-
final class DefaultServerPlugin {
4-
public function __construct(
5-
private \AdminerPlugin $adminer
6-
) { }
7-
8-
public function loginFormField(...$args) {
9-
return (function (...$args) {
10-
$field = \Adminer\Adminer::loginFormField(...$args);
11-
12-
return \str_replace(
13-
'name="auth[server]" value="" title="hostname[:port]"',
14-
\sprintf('name="auth[server]" value="%s" title="hostname[:port]"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')),
15-
$field,
16-
);
17-
})->call($this->adminer, ...$args);
18-
}
19-
}
20-
213
function adminer_object() {
22-
require_once('plugins/plugin.php');
4+
/**
5+
* Prefills the “Server” field with the ADMINER_DEFAULT_SERVER environment variable.
6+
*/
7+
final class DefaultServerPlugin extends \Adminer\Plugin {
8+
public function __construct(
9+
private \Adminer\Adminer $adminer
10+
) { }
11+
12+
public function loginFormField(...$args) {
13+
return (function (...$args) {
14+
$field = $this->loginFormField(...$args);
15+
16+
return \str_replace(
17+
'name="auth[server]" value="" title="hostname[:port]"',
18+
\sprintf('name="auth[server]" value="%s" title="hostname[:port]"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')),
19+
$field,
20+
);
21+
})->call($this->adminer, ...$args);
22+
}
23+
}
2324

2425
$plugins = [];
2526
foreach (glob('plugins-enabled/*.php') as $plugin) {
2627
$plugins[] = require($plugin);
2728
}
2829

29-
// Load the DefaultServerPlugin last to give other plugins a chance to
30-
// override loginFormField() if they wish to.
31-
$plugins[] = &$loginFormPlugin;
32-
33-
$adminer = new \AdminerPlugin($plugins);
30+
$adminer = new \Adminer\Plugins($plugins);
3431

35-
$loginFormPlugin = new DefaultServerPlugin($adminer);
32+
(function () {
33+
$last = &$this->hooks['loginFormField'][\array_key_last($this->hooks['loginFormField'])];
34+
if ($last instanceof \Adminer\Adminer) {
35+
$defaultServerPlugin = new DefaultServerPlugin($last);
36+
$this->plugins[] = $defaultServerPlugin;
37+
$last = $defaultServerPlugin;
38+
}
39+
})->call($adminer);
3640

3741
return $adminer;
3842
}

5/index.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
<?php
22
namespace docker {
3-
final class DefaultServerPlugin {
4-
public function __construct(
5-
private \AdminerPlugin $adminer
6-
) { }
7-
8-
public function loginFormField(...$args) {
9-
return (function (...$args) {
10-
$field = \Adminer\Adminer::loginFormField(...$args);
11-
12-
return \str_replace(
13-
'name="auth[server]" value="" title="hostname[:port]"',
14-
\sprintf('name="auth[server]" value="%s" title="hostname[:port]"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')),
15-
$field,
16-
);
17-
})->call($this->adminer, ...$args);
18-
}
19-
}
20-
213
function adminer_object() {
22-
require_once('plugins/plugin.php');
4+
/**
5+
* Prefills the “Server” field with the ADMINER_DEFAULT_SERVER environment variable.
6+
*/
7+
final class DefaultServerPlugin extends \Adminer\Plugin {
8+
public function __construct(
9+
private \Adminer\Adminer $adminer
10+
) { }
11+
12+
public function loginFormField(...$args) {
13+
return (function (...$args) {
14+
$field = $this->loginFormField(...$args);
15+
16+
return \str_replace(
17+
'name="auth[server]" value="" title="hostname[:port]"',
18+
\sprintf('name="auth[server]" value="%s" title="hostname[:port]"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')),
19+
$field,
20+
);
21+
})->call($this->adminer, ...$args);
22+
}
23+
}
2324

2425
$plugins = [];
2526
foreach (glob('plugins-enabled/*.php') as $plugin) {
2627
$plugins[] = require($plugin);
2728
}
2829

29-
// Load the DefaultServerPlugin last to give other plugins a chance to
30-
// override loginFormField() if they wish to.
31-
$plugins[] = &$loginFormPlugin;
32-
33-
$adminer = new \AdminerPlugin($plugins);
30+
$adminer = new \Adminer\Plugins($plugins);
3431

35-
$loginFormPlugin = new DefaultServerPlugin($adminer);
32+
(function () {
33+
$last = &$this->hooks['loginFormField'][\array_key_last($this->hooks['loginFormField'])];
34+
if ($last instanceof \Adminer\Adminer) {
35+
$defaultServerPlugin = new DefaultServerPlugin($last);
36+
$this->plugins[] = $defaultServerPlugin;
37+
$last = $defaultServerPlugin;
38+
}
39+
})->call($adminer);
3640

3741
return $adminer;
3842
}

0 commit comments

Comments
 (0)