Make WordPress Core

Opened 9 years ago

Last modified 8 weeks ago

#36242 reopened enhancement

wpdb set_sql_mode add param

Reported by: spacedmonkey's profile spacedmonkey Owned by: pbearne's profile pbearne
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.9
Component: Database Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

When making a creating a db drop-in that supports multiple databases, I had to override the whole set_sql_mode method. If set_sql_mode accepted a $dbh param, the method could easily be reused.

Attachments (1)

36242.patch (1.5 KB) - added by spacedmonkey 9 years ago.

Download all attachments as: .zip

Change History (8)

@spacedmonkey
9 years ago

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


4 months ago
#1

  • Keywords has-patch added

This change allows specifying a database handle when setting SQL mode, providing more flexibility in handling different database connections. It defaults to using the existing class property if no argument is passed. This ensures backward compatibility while enhancing functionality.

#2 @pbearne
4 months ago

  • Owner set to pbearne
  • Status changed from new to assigned

refresh patch

#3 @SergeyBiryukov
4 months ago

  • Milestone set to 6.8

#4 @flixos90
2 months ago

  • Milestone 6.8 deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed

Since it is possible to extend wpdb in a drop-in, changing the method signature of the public set_sql_mode() method would be a breaking change for any drop-in that already extends this method. Some very popular plugins appear to do that, see https://wpdirectory.net/search/01JHNCFYTVV0JJA4BA56ZRJMTC.

Based on this, I think this should be closed. If there is a very good justification to introduce this breaking change here, we can reconsider, but the argument of more developer convenience is not sufficient to do that I think.

#5 @swissspidy
2 months ago

  • Focuses performance removed

Also not really a performance related change, so removing the focus.

This ticket was mentioned in Slack in #core-performance by swissspidy. View the logs.


2 months ago

#7 @spacedmonkey
8 weeks ago

  • Keywords 2nd-opinion added
  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened

@swissspidy @flixos90 The issue here is that hyperdb and ludicrousdb both extend this method to do this. But when this method is called in other parts of the class, this parameter is not passed, meaning that LOTS of the class has to be override to support overriding this class. Adding this parameter making it much easier to override and testing against core updates easier too. It also makes the code much more testable.

CC @johnjamesjacoby for his thoughts as well.

Note: See TracTickets for help on using tickets.