[wp-trac] [WordPress Trac] #53298: Checking if wp-config-sample.php file exists before checking if wp-config.php exists

WordPress Trac noreply at wordpress.org
Sun Oct 16 04:21:28 UTC 2022


#53298: Checking if wp-config-sample.php file exists before checking if wp-
config.php exists
-------------------------------------+-------------------------------------
 Reporter:  machineitsvcs            |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Upgrade/Install          |     Version:  5.7.2
 Severity:  trivial                  |  Resolution:
 Keywords:  needs-patch dev-         |     Focuses:  administration,
  feedback                           |  privacy, coding-standards
-------------------------------------+-------------------------------------
Changes (by costdev):

 * keywords:  needs-patch => needs-patch dev-feedback


Comment:

 Hi @machineitsvcs, welcome to Trac and thanks for opening this ticket, and
 providing some potential solutions!

 As you said, if we reverse the conditions, then if `wp-config.php` and
 `wp-config-sample.php` don't exist in `ABSPATH`, the second `wp-config-
 sample.php` check will try to go up one level, and the warning is still
 shown. For that reason, I don't think swapping the order is the solution
 here.

 @SergeyBiryukov The `@` operator seems the most appropriate solution here
 as it's already there for [https://github.com/wordpress/wordpress-
 develop/blob/c39a45cd3f84cb1bb0d7a6dba8660bac45c99447/src/wp-admin/setup-
 config.php#L72 the wp-config.php and wp-settings.php checks].

 However, I know that we're trying to reduce the number of `@` operators in
 Core, and adding a new one seems counter-productive to that effort. That
 said, [https://www.php.net/manual/en/function.file-exists.php
 file_exists()] emits an `E_WARNING`, not a fatal error, and when
 considering consistency with other checks in this file, it may be
 acceptable to add a new `@` operator here.

 I'd appreciate your thoughts on how this might proceed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53298#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list