Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore compatibility with WordPress <6.1 #748

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Ensure the `WPLoader` module will initialize correctly when used in `loadOnly` mode not using the `EventDispatcherBridge` extension.
- Ensure the `WPLoader` module will initialize correctly when used in `loadOnly` mode not using the `EventDispatcherBridge` extension. (thanks @lxbdr)
- Support loading the `wpdb` class from either the `class-wpdb.php` file or the `wp-db.php` one, supporting older versions of WordPress (thanks @BrianHenryIE)

## [4.2.5] 2024-06-26;

Expand Down
1 change: 1 addition & 0 deletions bin/update_core_phpunit_includes
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rm -rf "${root_dir}"/includes/core-phpunit/includes &&
cd .. &&
mv wordpress-develop/tests/phpunit/includes ./includes &&
rm -rf wordpress-develop &&
git apply "${root_dir}"/config/patches/core-phpunit/includes/install.php.patch &&
git apply "${root_dir}"/config/patches/core-phpunit/includes/abstract-testcase.php.patch &&
git apply "${root_dir}"/config/patches/core-phpunit/includes/testcase-ajax.php.patch &&
git apply "${root_dir}"/config/patches/core-phpunit/includes/testcase-canonical.php.patch &&
Expand Down
23 changes: 23 additions & 0 deletions config/patches/core-phpunit/includes/install.php.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/includes/core-phpunit/includes/install.php b/includes/core-phpunit/includes/install.php
index 8a595903..dbb13b5f 100644
--- a/includes/core-phpunit/includes/install.php
+++ b/includes/core-phpunit/includes/install.php
@@ -40,8 +40,17 @@
require_once ABSPATH . 'wp-settings.php';

require_once ABSPATH . 'wp-admin/includes/upgrade.php';
-require_once ABSPATH . 'wp-includes/class-wpdb.php';

+/**
+ * File was renamed in WordPress 6.1.
+ *
+ * @see https://core.trac.wordpress.org/ticket/56268
+ * @see https://github.com/WordPress/WordPress/commit/8484c7babb6b6ee951f83babea656a294157665d
+ */
+require_once file_exists( ABSPATH . 'wp-includes/class-wpdb.php' )
+ ? ABSPATH . 'wp-includes/class-wpdb.php'
+ : ABSPATH . 'wp-includes/wp-db.php';
+
// Override the PHPMailer.
global $phpmailer;
require_once __DIR__ . '/mock-mailer.php';
11 changes: 10 additions & 1 deletion includes/core-phpunit/includes/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@
require_once ABSPATH . 'wp-settings.php';

require_once ABSPATH . 'wp-admin/includes/upgrade.php';
require_once ABSPATH . 'wp-includes/class-wpdb.php';

/**
* File was renamed in WordPress 6.1.
*
* @see https://core.trac.wordpress.org/ticket/56268
* @see https://github.com/WordPress/WordPress/commit/8484c7babb6b6ee951f83babea656a294157665d
*/
require_once file_exists( ABSPATH . 'wp-includes/class-wpdb.php' )
? ABSPATH . 'wp-includes/class-wpdb.php'
: ABSPATH . 'wp-includes/wp-db.php';

// Override the PHPMailer.
global $phpmailer;
require_once __DIR__ . '/mock-mailer.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ protected function check_post_data( $post, $data, $context, $links ) {
// Check filtered values.
if ( post_type_supports( $post->post_type, 'title' ) ) {
add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
add_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
$this->assertSame( get_the_title( $post->ID ), $data['title']['rendered'] );
remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
if ( 'edit' === $context ) {
$this->assertSame( $post->post_title, $data['title']['raw'] );
} else {
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance.suite.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ modules:
X_WPBROWSER_REQUEST: 1
X_TEST_REQUEST: 1
X_APM_REQUEST: 1
connect_timeout: 3
connect_timeout: 3.0
timeout: 3.0
lucatume\WPBrowser\Module\WPDb:
dsn: '%WORDPRESS_DB_DSN%'
user: %WORDPRESS_DB_USER%
Expand Down
Loading