Make WordPress Core

Opened 21 months ago

Closed 21 months ago

Last modified 19 months ago

#56268 closed enhancement (fixed)

Rename wp-db.php to class-wpdb.php

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Database Keywords: needs-dev-note
Focuses: coding-standards Cc:


Background: #47632, #49373.

wpdb is the only core class that is not an external library and does not follow the class-*.php naming pattern:

| WARNING | Class file names should be based on the class name
|         | with "class-" prepended. Expected class-wpdb.php, but
|         | found wp-db.php.
|         | (WordPress.Files.FileName.InvalidClassFileName)

For consistency with the rest of core classes and to conform to naming conventions in WordPress coding standards, the class should be moved to wp-includes/class-wpdb.php, following the process in comment:33:ticket:47632.

For backward compatibility, the new file should be included from wp-includes/wp-db.php.

Change History (5)

#1 @SergeyBiryukov
21 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 53749:

Coding Standards: Move wp-includes/wp-db.php to wp-includes/class-wpdb.php.

This renames the file containing the wpdb class to conform to the coding standards.

This commit also includes:

  • A new wp-db.php that loads the new file, for anyone that may have been including the file directly.
  • Replacing references to the old filename with the new filename.

Fixes #56268. See #55647.

#2 @SergeyBiryukov
21 months ago

In 53750:

Coding Standards: Replace the old wp-db.php filename in phpcompat.xml.dist.

This ensures the correct file is allowlisted for use of mysql_ extension in PHP < 7.0.

Follow-up to [53749].

See #56268, #55647.

#3 @SergeyBiryukov
21 months ago

In 53755:

Coding Standards: Check if the _deprecated_file() function exists in wp-db.php.

This avoids a fatal error if the file is included directly outside of WordPress core, e.g. by HyperDB.

Additionally, replace WPINC with wp-includes, as the constant may not be defined yet in that context.

Follow-up to [53749], [53750].

See #56268, #55647.

#4 @SergeyBiryukov
21 months ago

In 53756:

Coding Standards: Use __DIR__ instead of ABSPATH in wp-db.php.

If the file is included directly outside of WordPress core, ABSPATH may not be defined.

Follow-up to [53749], [53750], [53755].

See #56268, #55647.

#5 @desrosj
19 months ago

  • Keywords needs-dev-note added

This should be mentioned in the miscellaneous dev note.

Note: See TracTickets for help on using tickets.