Skip to content

Commit

Permalink
Coding Standards: Move wp-includes/wp-db.php to `wp-includes/class-…
Browse files Browse the repository at this point in the history
…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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53749 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jul 21, 2022
1 parent b01c8f1 commit fdb6e13
Show file tree
Hide file tree
Showing 6 changed files with 4,032 additions and 4,017 deletions.
6 changes: 3 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@

<!-- Whitelist the WP DB Class and related tests for usage of direct database access functions. -->
<rule ref="WordPress.DB.RestrictedFunctions">
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
</rule>

Expand Down Expand Up @@ -325,10 +325,10 @@
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCapital">
<exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
</rule>

<!-- Exclude some incorrectly named files that won't be renamed. -->
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
require_once ABSPATH . 'wp-admin/includes/translation-install.php';

/** Load wpdb */
require_once ABSPATH . WPINC . '/wp-db.php';
require_once ABSPATH . WPINC . '/class-wpdb.php';

This comment has been minimized.

Copy link
@Glomberg

Glomberg Jul 25, 2022

Can you add an additional condition check WP version or the file existence? Example:

if ( file_exists(ABSPATH . WPINC . '/class-wpdb.php') ) {
	require_once ABSPATH . WPINC .  '/class-wpdb.php';
} else {
	require_once ABSPATH . WPINC . '/wp-db.php';
}

This comment has been minimized.

Copy link
@peterwilsoncc

peterwilsoncc Jul 25, 2022

Contributor

@Glomberg Are you able to clarify why you think this is needed? This version of the install file will only be in new downloads in which the file has been moved to class-wpdb.php.

This comment has been minimized.

Copy link
@Glomberg

Glomberg Jul 26, 2022

Of course. It is need for the unit testing now while 6.1 not released. The autotests flow is such:

  1. Getting latest WP released distributive from https://wordpress.org/latest.tar.gz
  2. Getting testing environment from https://develop.svn.wordpress.org/trunk/tests/phpunit/
  3. When the unit tests are starting also started an installation of WP from testing invironment by phpunit/includes/install.php
  4. In line 43 of install.php the installation breaks because file class-wpdb.php not presents in the WP distributive received on step 1.

This comment has been minimized.

Copy link
@ocean90

ocean90 Jul 26, 2022

Member

This comment has been minimized.

Copy link
@Glomberg

Glomberg Jul 26, 2022

@ocean90
Or you have to use https://develop.svn.wordpress.org/branches/6.0/tests/phpunit/ if you want to test the latest stable version.
Yes we want to use the latest stable version to testing. For now it is very inconvenient - we have to edit our config separately for the every WP release these lines https://github.com/CleanTalk/wordpress-antispam/blob/master/tests/wp-test-setup.sh#L24-L26
Is there hyperlink to the last stable testing environment version something like https://develop.svn.wordpress.org/latest/tests/phpunit/ (such as the latest WP version link https://wordpress.org/latest.tar.gz)

This comment has been minimized.

Copy link
@ocean90

ocean90 Jul 26, 2022

Member

You may want to take a look at https://github.com/wp-cli/scaffold-command/blob/master/templates/install-wp-tests.sh. It handles all types of versions and downloads the correct test suite.

This comment has been minimized.

Copy link
@Glomberg

Glomberg Jul 26, 2022

@ocean90
Thank you. It suits us.


nocache_headers();

Expand Down
Loading

0 comments on commit fdb6e13

Please sign in to comment.