Make WordPress Core

Opened 20 months ago

Closed 17 months ago

Last modified 17 months ago

#58201 closed defect (bug) (fixed)

Incorrect condition in wp_check_php_mysql_versions()

Reported by: mikeyzm's profile mikeyzm Owned by: audrasjb's profile audrasjb
Milestone: 6.3 Priority: normal
Severity: normal Version: 6.3
Component: Bootstrap/Load Keywords: has-patch needs-testing
Focuses: Cc:

Description

Changeset [49161] introduced an incorrect condition in wp_check_php_mysql_versions():

// This runs before default constants are defined, so we can't assume WP_CONTENT_DIR is set yet.
&& ( defined( 'WP_CONTENT_DIR' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' )
    || ! file_exists( ABSPATH . 'wp-content/db.php' ) )

This will check for the existence of db.php at the default path ABSPATH . 'wp-content/db.php', even if WP_CONTENT_DIR is defined and db.php is placed in WP_CONTENT_DIR.

Change History (11)

This ticket was mentioned in PR #4384 on WordPress/wordpress-develop by mikeyzm.


20 months ago
#1

  • Keywords has-patch added

#2 @SergeyBiryukov
20 months ago

  • Milestone changed from Awaiting Review to 6.3

@hztyfoon commented on PR #4384:


20 months ago
#3

@mikeyzm
Thanks for the PR. It looks good to me.
But, I just added a review proposing using ternary operator. can U check it please?

mikeyzm commented on PR #4384:


20 months ago
#4

@hz-tyfoon You're right, using a ternary does make it more readable. I'll make the change. Thanks for the suggestion.

#5 @oglekler
18 months ago

  • Keywords needs-testing added

#6 @audrasjb
18 months ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

@SergeyBiryukov commented on PR #4384:


18 months ago
#7

Thanks for the PR! I think we can simplify the logic here a bit further, see 29c1984.

#8 follow-up: @audrasjb
17 months ago

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

In 56152:

Boostrap/Load: Incorrect condition in wp_check_php_mysql_versions().

This changeset adds a check for the existence of db.php at the default path ABSPATH . 'wp-content/db.php', even if WP_CONTENT_DIR is defined and db.php
is placed in WP_CONTENT_DIR.

Follow-up to [49161].

Props mikeyzm, SergeyBiryukov, hztyfoon,
Fixes #58201.

#10 in reply to: ↑ 8 ; follow-up: @SergeyBiryukov
17 months ago

Thanks for the commit!

Replying to audrasjb:

This changeset adds a check for the existence of db.php at the default path ABSPATH . 'wp-content/db.php', even if WP_CONTENT_DIR is defined and db.php is placed in WP_CONTENT_DIR.

Just to clarify for future reference, that's not what this changeset does :)

As noted in the ticket description, that's what [49161] did, which turned out to be incorrect.

[56152] removes the unnecessary check for db.php at ABSPATH . 'wp-content', if WP_CONTENT_DIR is defined.

If WP_CONTENT_DIR is not defined, it checks the default location at ABSPATH . 'wp-content/db.php'.

#11 in reply to: ↑ 10 @hztyfoon
17 months ago

Replying to SergeyBiryukov:

Thanks for the commit!

Replying to audrasjb:

This changeset adds a check for the existence of db.php at the default path ABSPATH . 'wp-content/db.php', even if WP_CONTENT_DIR is defined and db.php is placed in WP_CONTENT_DIR.

Just to clarify for future reference, that's not what this changeset does :)

+1 from me.
Thanks sergey for pointing it out and clarifying.
Looks to me the clarification in your comment is helpful for future reference and clarity.

Looks to me the ticket description by mikeyzm is pretty clear. But let me try to add a bit more clarity.

Changeset [49161] (please check that changesheet first) introduced an incorrect condition.
And that is, even if WP_CONTENT_DIR is defined & db.php file does exist, it (the mentioned [49161] changesheet's code) goes on to check for the existance of the db.php using ABSPATH (ABSPATH . 'wp-content/db.php') even though it already checked using WP_CONTENT_DIR and found the db.php to be existent. Which is not right.

Because if WP_CONTENT_DIR is defined and db.php is found to be existant, why should it then go again to check for the existance of the same file using ABSPATH. That's totally unnecessary.

Hope my explanation adds bit more clarity about this ticket it's commit/changesheet ([56152]). Thanks 😊.

Note: See TracTickets for help on using tickets.