Skip to content

Update MySQL PDO compression attribute for PHP 8.5 compatibility #2229

@phpukr

Description

@phpukr

File affected: core/classes/database/pdo/connection.php

Currently, FuelPHP sets the PDO compression attribute using PDO::MYSQL_ATTR_COMPRESS.
Starting from PHP 8.5, this constant is deprecated and replaced by Pdo\Mysql::ATTR_COMPRESS.

Proposed solution to maintain compatibility with both PHP <=8.4 and PHP 8.5+:

// enable compression if needed
if (!empty($this->_config['connection']['compress']))
{
    if (class_exists('\Pdo\Mysql')) {
        // PHP 8.5+
        $this->_config['attrs'][\Pdo\Mysql::ATTR_COMPRESS] = true;
    } elseif (defined('\PDO::MYSQL_ATTR_COMPRESS')) {
        // PHP <= 8.4
        $this->_config['attrs'][\PDO::MYSQL_ATTR_COMPRESS] = true;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions