Kovah / LinkAce

LinkAce is a self-hosted archive to collect links of your favorite websites.
https://www.linkace.org
GNU General Public License v3.0
2.53k stars 159 forks source link

Fix requirement name on setup screen #706

Closed chrissawyerfan4 closed 10 months ago

chrissawyerfan4 commented 10 months ago

I was confused, while doing a new setup, about apt install php-pdo saying it's already satisfied:

$ apt install php-pdo
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'php8.2-common' instead of 'php-pdo'
php8.2-common is already the newest version (8.2.7-1~deb12u1).
php8.2-common set to manually installed.

The command phpenmod pdo also ran fine, yet the page still complained that PDO is missing. Diving into the source code, I find:

app/Http/Controllers/Setup/RequirementsController.php

    protected function checkRequirements(): array
    {
        $results = [
            'php_version' => PHP_VERSION_ID >= 70400,
            'extension_bcmath' => extension_loaded('bcmath'),
            'extension_ctype' => extension_loaded('ctype'),
            'extension_json' => extension_loaded('json'),
            'extension_mbstring' => extension_loaded('mbstring'),
            'extension_openssl' => extension_loaded('openssl'),
            'extension_pdo_mysql' => extension_loaded('pdo_mysql'),
            'extension_tokenizer' => extension_loaded('tokenizer'),
            'extension_xml' => extension_loaded('xml'),
            'env_writable' => File::isWritable(base_path('.env')),
            'storage_writable' => File::isWritable(storage_path()) && File::isWritable(storage_path('logs')),
        ];

        $success = !in_array(false, $results, true);

        return [$success, $results];
    }

The requirement being checked for is pdo_mysql rather than generic pdo. Indeed, apt install php-pdo-mysql + phpenmod pdo_mysql + systemctl restart apache2 worked.

I'd propose to update the translations to match what people need to install. If you agree with the change, the markdown documentation should also be updated.