Skip to content

Commit 2300409

Browse files
authored
Add PHP 8.6 support (WordPress#635)
## Summary This PR adds support for **PHP 8.6**. It fixes two issues found while testing on PHP 8.6, and it adds PHP 8.6 to CI: - **Plugin:** `wpdb::prepare()` no longer raises a deprecation. It called `ReflectionProperty::setAccessible()`, which is deprecated since PHP 8.5 and only needed below PHP 8.1. - **Proxy:** `--password-file` accepts `/dev/stdin` and process substitutions on thread-safe PHP builds, such as the official `php:8.6-cli` Docker image. On these builds, `is_readable()` fails for a pipe on Linux. - **CI:** The driver tests get a PHP 8.6 job. The parser and proxy tests run on the oldest and the latest PHP version, so they move from 8.5 to 8.6. - **Docs:** `README.md` and `AGENTS.md` list PHP 7.2 through 8.6 as supported. ## Why PHP 8.6 was released, and the project should run on it without notices and deprecations. ## Note The WordPress test jobs run on a PHP image pinned to 8.3.10, so they don't test the plugin on PHP 8.5 or 8.6. That is why CI didn't catch the `setAccessible()` deprecation. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Support now extends through PHP 8.6. * **Bug Fixes** * Password-file checks now correctly handle supported file-descriptor paths while continuing to reject unreadable files. * Improved SQLite database compatibility with PHP 8.1 and later. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent e82c914 commit 2300409

8 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎.github/workflows/mysql-parser-tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
php: [ '7.2', '8.5' ]
35+
php: [ '7.2', '8.6' ]
3636

3737
steps:
3838
- name: Checkout repository

‎.github/workflows/mysql-proxy-tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php: ['7.2', '8.5']
21+
php: ['7.2', '8.6']
2222
permissions:
2323
contents: read # Required to clone the repo.
2424

‎.github/workflows/phpunit-tests.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- { php: '8.3', sqlite: '3.46.1' } # Debian 13 (Trixie)
4848
- { php: '8.4', sqlite: '3.51.2' } # First 2026 release
4949
- { php: '8.5', sqlite: 'latest' }
50+
- { php: '8.6', sqlite: 'latest' }
5051

5152
steps:
5253
- name: Checkout repository

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The monorepo packages are placed under the `packages` directory.
2424
The WordPress plugin links the MySQL on SQLite package using a symlink. The build
2525
script replaces the symlink with a copy of the package for release.
2626

27-
The codebase is pure PHP with zero dependencies. It supports PHP 7.2 through 8.5,
27+
The codebase is pure PHP with zero dependencies. It supports PHP 7.2 through 8.6,
2828
MySQL syntax from version 5.7 onward, and requires SQLite 3.37.0 or newer
2929
(with legacy mode down to 3.27.0).
3030

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The monorepo packages are placed under the `packages` directory.
2222
The WordPress plugin links the MySQL on SQLite package using a symlink. The build
2323
script replaces the symlink with a copy of the package for release.
2424

25-
The codebase is pure PHP with zero dependencies. It supports PHP 7.2 through 8.5,
25+
The codebase is pure PHP with zero dependencies. It supports PHP 7.2 through 8.6,
2626
MySQL syntax from version 5.7 onward, and requires SQLite 3.37.0 or newer
2727
(with legacy mode down to 3.27.0).
2828

‎packages/mysql-proxy/bin/wp-mysql-proxy.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,18 @@
125125
$password_file = $opts['password-file'];
126126

127127
// Pipes, such as /dev/stdin or a process substitution, keep the password off the disk.
128-
if ( ! is_readable( $password_file ) || is_dir( $password_file ) ) {
129-
fwrite( STDERR, "Error: --password-file must name a readable file.\n" );
130-
exit( 1 );
131-
}
132-
133128
// On Linux, PHP can't open a pipe by its /dev/fd path, so read a descriptor of
134129
// this process through php://fd. See https://github.com/php/php-src/issues/9551.
135130
$source = $password_file;
136131
if ( '/dev/stdin' === $password_file ) {
137132
$source = 'php://fd/0';
138-
} elseif ( preg_match( '~^/(?:dev|proc/self)/fd/(\d+)$~', $password_file, $match ) ) {
133+
} elseif ( preg_match( '~^/(?:dev|proc/self)/fd/(\d+)\z~', $password_file, $match ) ) {
139134
$source = 'php://fd/' . $match[1];
135+
} elseif ( ! is_readable( $password_file ) || is_dir( $password_file ) ) {
136+
// Only other paths are checked, as is_readable() fails for the path of
137+
// a pipe on thread-safe PHP builds.
138+
fwrite( STDERR, "Error: --password-file must name a readable file.\n" );
139+
exit( 1 );
140140
}
141141

142142
// Report a failed read without PHP's warning, which names the path.

‎packages/mysql-proxy/tests/WP_MySQL_Proxy_Command_Test.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function invalid_arguments(): array {
5959
array( array( '--user=user' ), '', 'Error: A nonempty password without NUL bytes is required.' ),
6060
array( array( '--user=user', '--password-file=/nonexistent/proxy-password' ), 'password', 'must name a readable file' ),
6161
array( array( '--user=user', '--password-file=' . __DIR__ ), 'password', 'must name a readable file' ),
62+
// A descriptor number beyond PHP's limit, so it can't be open in the test process.
63+
array( array( '--user=user', '--password-file=/dev/fd/9999999999' ), 'password', '--password-file could not be read' ),
64+
array( array( '--user=user', "--password-file=/dev/fd/0\n" ), 'password', 'must name a readable file' ),
6265
array( array( '--user=user', '--user=other' ), 'password', 'Invalid command-line options' ),
6366
array( array( '--user=user', '--auth-plugin=mysql_clear_password' ), 'password', 'Error: The authentication plugin must be one of' ),
6467
array( array( '--user=user', '--auth-plugin=' ), 'password', 'Error: The authentication plugin must be one of' ),

‎packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,12 @@ public function prepare( $query, ...$args ) {
524524
$wpdb_allow_unsafe_unquoted_parameters = $this->__get( 'allow_unsafe_unquoted_parameters' );
525525
if ( $wpdb_allow_unsafe_unquoted_parameters !== $this->allow_unsafe_unquoted_parameters ) {
526526
$property = new ReflectionProperty( 'wpdb', 'allow_unsafe_unquoted_parameters' );
527-
$property->setAccessible( true );
527+
528+
// Private properties are accessible since PHP 8.1, and the method is deprecated since PHP 8.5.
529+
if ( PHP_VERSION_ID < 80100 ) {
530+
$property->setAccessible( true );
531+
}
528532
$property->setValue( $this, $this->allow_unsafe_unquoted_parameters );
529-
$property->setAccessible( false );
530533
}
531534

532535
return parent::prepare( $query, ...$args );

0 commit comments

Comments
 (0)