Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#59118 closed enhancement (fixed)

Remove support for the mysql extension

Reported by: johnbillion's profile johnbillion Owned by: johnbillion's profile johnbillion
Milestone: 6.4 Priority: normal
Severity: normal Version: 6.3
Component: Database Keywords: has-patch has-unit-tests needs-testing
Focuses: Cc:

Description

The mysql extension is no longer used in PHP 7 or above. There's a good amount of conditional code in wpdb that can be removed now that only the mysqli functions are used.

It's unlikely there will be a noticeable performance gain from the removal of the dead conditional code, but every little helps, and maintenance will be simplified.

Change History (15)

This ticket was mentioned in PR #5017 on WordPress/wordpress-develop by @johnbillion.


3 years ago
#1

  • Keywords has-patch has-unit-tests added

Trac ticket:

This ticket was mentioned in PR #5017 on WordPress/wordpress-develop by @johnbillion.


3 years ago
#2

Trac ticket:

@mukesh27 commented on PR #5017:


3 years ago
#3

@johnbillion The PR have list of PHPCS issues that need to fix.

#4 @Hareesh Pillai
3 years ago

  • Keywords needs-testing added

Adding the needs-testing keyword.

On having a cursory glance, the changes look ok. This PR requires in-depth testing.

@johnbillion commented on PR #5017:


3 years ago
#5

@mukeshpanchal27 Yeah they _should_ all be about indentation as mentioned in the PR description. I didn't fix the indentation in order to keep the diff clean and it can be addressed in the commit.

#6 @johnbillion
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56475:

Database: Remove support for the mysql extension.

The mysql extension is no longer used in PHP 7 or above. There's a good amount of conditional code in wpdb and the health checks that can be removed now that only the mysqli functions are used.

Fixes #59118

#8 @jason_the_adams
2 years ago

Friendly note, while I totally agree with this change, I wish it would've been mentioned in the Field Guide as a backwards-incompatible change, since the $wpdb->use_mysqli property is being removed. The GiveWP team only found it because it threw an error and our QA team saw it.

Again, totally agree with everything done in this ticket! A bit more of a heads up would've been helpful. 🙂

#9 @ReneHermi
2 years ago

It would have been nice if it had been marked as deprecated or if we had received a "core" email about this fundamental change in the $wpdb object.
Our plugin is now breaking 100k WordPress sites. I don't blame anyone but us for this because we weren't able to do our testing for 6.4 yet, but we would have prioritized it if we had been notified of the removal beforehand.

Version 1, edited 2 years ago by ReneHermi (previous) (next) (diff)

#10 @johnjamesjacoby
2 years ago

Apologies for not commenting here sooner. I have been working on & off on use_mysqli throwing the error that @jason_the_adams mentioned, thanks to a colleague noticing it a few weeks ago.

I think this error/warning deserves addressing for 6.4.1.

I also think, subsequently, it may be a good idea for the WPDB class to maintain its own internal lists of deprecated properties & methods, so that as they grow over years worth of MySQL & PHP versions, there is a natural & obvious way to prevent this in the future (a magic __call() method or some such...)

cc @johnbillion @SergeyBiryukov for consult?

#11 @johnbillion
2 years ago

@jason_the_adams @ReneHermi @johnjamesjacoby Thanks for the comments. The wpdb:$use_mysqli property had private access until it was removed, therefore there should be no means of referencing outside of the core wpdb class. Can you provide an example of code that triggers an error due to its removal?

#12 @johnbillion
2 years ago

I took a look at the PR for GiveWP that fixed their issue and the underlying problem is that a private property was being accessed from outside of its access scope. I don't know how this code ever worked, because accessing a private property from outside the class results in a fatal error.

Is there something else going on?

#13 @johnbillion
2 years ago

Okay here's the culprit: https://github.com/WordPress/wordpress-develop/blob/a31c785af19787a39893816b735be96a08a15412/src/wp-includes/class-wpdb.php#L755-L769 . The wpdb::__get() magic method exposes all properties publicly regardless of whether they're private or protected.

#14 @johnbillion
2 years ago

Follow-up ticket: #59846

This ticket was mentioned in Slack in #core by jorbin. View the logs.


2 years ago

Note: See TracTickets for help on using tickets.