Skip to content

ClickHouse driver plugin cannot be loaded into the compiled release #1325

Description

@cmanzur

Adminer version: 6.0.1
Compiled: single file
Driver: ClickHouse (bundled driver plugin plugins/drivers/clickhouse.php)
Database version: n/a — this fails before any connection is attempted
Plugins used: plugins/drivers/clickhouse.php from v6.0.1


The bundled ClickHouse driver plugin cannot be loaded into the compiled single-file release:

Fatal error: Declaration of Adminer\Driver::slowQuery(string $query, int $timeout)
must be compatible with Adminer\SqlDriver::slowQuery($G, $cl)
in clickhouse.php on line 210

Cause

The compile step removes scalar parameter type declarations from the base classes while keeping array. Comparing adminer/include/driver.inc.php with the compiled adminer-6.0.1.php:

Source SqlDriver Compiled SqlDriver
slowQuery(string $query, int $timeout) slowQuery($G, $cl)
update(string $table, array $set, string $queryWhere, int $limit = 0, string $separator = "\n") update($R, array $O, $Vi, $z = 0, $Lj = "\n")
insert(string $table, array $set) insert($R, array $O)
supportsAlterIndex(array $table_status): bool supportsAlterIndex(array $S)

The driver plugins are distributed as uncompiled source and keep their scalar types. PHP does not allow a subclass to narrow parameter types, so Driver::slowQuery(string $query, int $timeout) can never extend SqlDriver::slowQuery($G, $cl).

plugins/drivers/clickhouse.php:210 is the only bundled driver where this occurs. plugins/drivers/simpledb.php:255 declares the same method untyped (slowQuery($query, $timeout)) and loads fine, which suggests the annotation was added inconsistently in 6.0 rather than deliberately. The Elasticsearch driver also declares a scalar-typed method (view(string $name): array) but does not hit this.

This is a regression in 6.0: the 5.5.1 ClickHouse driver had no slowQuery() override, so it loaded.

Reproduction

mkdir adminer-repro && cd adminer-repro
curl -fsSLO https://github.com/vrana/adminer/releases/download/v6.0.1/adminer-6.0.1.php
mv adminer-6.0.1.php adminer.php
curl -fsSLO https://raw.githubusercontent.com/vrana/adminer/v6.0.1/plugins/drivers/clickhouse.php

index.php:

<?php
function adminer_object() {
	require_once 'clickhouse.php';
	return new \Adminer\Plugins([]);
}
require('adminer.php');
php -S localhost:8080

Open http://localhost:8080/?clickhouse= — the fatal error appears immediately. Verified on PHP 8.4; no Docker image or custom compilation involved.

Expected

The bundled driver plugins should load into the compiled release, since that is the distribution most people run.

Possible fixes

  1. Remove the scalar parameter types from plugins/drivers/clickhouse.php::slowQuery(), matching simpledb.php.
  2. Keep scalar parameter types in the compiled output.
  3. Apply the compile step to the bundled driver plugins so both sides are consistent.

Workaround

Strip scalar parameter types from the driver file before loading it:

sed -i -E '/^[[:space:]]*function /s/(string|int|bool|float) \$/$/g' clickhouse.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions