Merge pull request #1734 from PrivateBin/php85

Enable PHP 8.5 testing and handle deprecations
This commit is contained in:
El RIDO 2025-12-03 19:10:03 +01:00 committed by GitHub
commit 52c0846dad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

View file

@ -27,11 +27,11 @@ jobs:
continue-on-error: "${{ matrix.experimental }}" continue-on-error: "${{ matrix.experimental }}"
strategy: strategy:
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
experimental: [false] experimental: [false]
# uncomment this to start testing on development release # uncomment this to start testing on development release
# include: # include:
# - php-versions: '8.5' # development release, things can break # - php-versions: '8.6' # development release, things can break
# experimental: true # experimental: true
env: env:
extensions: gd, sqlite3 extensions: gd, sqlite3

View file

@ -84,8 +84,13 @@ class Database extends AbstractData
); );
// MySQL uses backticks to quote identifiers by default, // MySQL uses backticks to quote identifiers by default,
// tell it to expect ANSI SQL double quotes // tell it to expect ANSI SQL double quotes
if ($this->_type === 'mysql' && defined('PDO::MYSQL_ATTR_INIT_COMMAND')) { if ($this->_type === 'mysql') {
$options['opt'][PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION sql_mode='ANSI_QUOTES'"; // deprecated as of PHP 8.5
if (version_compare(PHP_VERSION, '8.5') < 0 && defined('PDO::MYSQL_ATTR_INIT_COMMAND')) {
$options['opt'][PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION sql_mode='ANSI_QUOTES'";
} elseif (defined('Pdo\Mysql::ATTR_INIT_COMMAND')) {
$options['opt'][Pdo\Mysql::ATTR_INIT_COMMAND] = "SET SESSION sql_mode='ANSI_QUOTES'";
}
} }
$tableQuery = $this->_getTableQuery($this->_type); $tableQuery = $this->_getTableQuery($this->_type);
$this->_db = new PDO( $this->_db = new PDO(

View file

@ -155,7 +155,12 @@ class ControllerTest extends TestCase
{ {
$newConfig = new class extends Configuration {}; $newConfig = new class extends Configuration {};
$configValue = (new ReflectionClass(Controller::class))->getProperty('_conf'); $configValue = (new ReflectionClass(Controller::class))->getProperty('_conf');
$configValue->setAccessible(true); if (version_compare(PHP_VERSION, '8.1') < 0) {
// > This function has been DEPRECATED as of PHP 8.5.0. [...]
// > As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default.
// @see: https://www.php.net/manual/en/reflectionproperty.setaccessible.php
$configValue->setAccessible(true);
}
ob_start(); ob_start();
$controller = new Controller($newConfig); $controller = new Controller($newConfig);
ob_end_clean(); ob_end_clean();