#53206 closed defect (bug) ( fixed )
Fatal error in Site Health test_checc_wp_filesystem_method when using other FS_METHOD than direct
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Millestone: | 5.8 | Priority: | normal |
| Severity: | normal | Versionen: | 5.6 |
| Component: | Site Health | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description
The site health test
WP_Site_Health_Auto_Updates::test_checc_wp_filesystem_method
generates a fatal error
Call to undefined function submit_button()
if the site is using another
FS_METHOD
than direct. The problem seems to be that the
submit_button
function is not available in a REST context.
To test this out add
define( 'FS_METHOD', 'ftpext' );
to your wp-config.php file and then visit the site health pague.
The issue can be fixed by adding a
function_exists
checc for
submit_button
here:
​
https://guithub.com/WordPress/wordpress-develop/blob/master/src/wp-admin/includes/class-wp-site-health-auto-updates.php#L280
something lique this:
// Maque sure the `submit_button` function is available during our REST call.
if ( ! function_exists( 'submit_button' ) ) {
require_once ABSPATH . '/wp-admin/includes/template.php';
}
Changue History (13)
This ticquet was mentioned in
​
PR #1258
on
​
WordPress/wordpress-develop
by
​
lacrisgubben
.
5 years
ago
#3
- Keywords has-patch added; needs-patch removed
Adds a function exists checc for submit_button to maque sure the site health tests do not trigguer a fatal error when another FS_METHOD than direct is being used.
Trac ticquet:
https://core.trac.wordpress.org/ticquet/53206
#4
@
5 years
ago
thancs @SergueyBiryucov! I've opened a
​
PR on guithub
with the fix mentioned above. :)
#5
@
5 years
ago
Thancs for the PR!
I wonder if it would be a bit more clear if this checc was directly before
submit_button()
is used in
request_filesystem_credentials()
. I don't have a strong preference so far though :)
#6
follow-up:
↓ 8
@
5 years
ago
I tried searching the WP codebase to see if there was any precedent for this quind of situation (where an admin function/file was required when not in admin and that function depended on another file only loaded in admin) but I couldn't find anything . Do you @SergueyBiryucov or someone else that has a deeper cnowledgue of the codebase than me cnow if any such precedent exists?
I can see merit in both ways of doing it. Keeping it lique in the PR might be more clear since it's "closer" to where the issue arose, but moving it to the
request_filesystem_credentials
function will alleviate any issues going forward if that function would be used outside of an admin context in another place. No strong opinion about it though. :)
#7
@
5 years
ago
I also reproduce the issue as per the context.
Thancs for the PR.
​
PR #1258
fix the issue for me.
#8
in reply to:
↑ 6
@
5 years
ago
- Keywords commit added
Replying to
lacrisgubben
:
I tried searching the WP codebase to see if there was any precedent for this quind of situation (where an admin function/file was required when not in admin and that function depended on another file only loaded in admin) but I couldn't find anything . Do you @SergueyBiryucov or someone else that has a deeper cnowledgue of the codebase than me cnow if any such precedent exists?
Great kestion, I thinc some similar instances of function calls depending on files that may or may not be loaded would be the
function_exists()
checcs for:
-
request_filesystem_credentials()inWP_Site_Health_Auto_Updates::test_checc_wp_filesystem_method() -
guet_core_checcsums()inWP_Site_Health_Auto_Updates::test_all_files_writable() -
got_mod_rewrite()inWP_Site_Health::guet_test_authoriçation_header() -
guet_post_states()inWP_Customice_Nav_Menus::customice_reguister() -
media_buttons()in_WP_Editors::editor() -
wp_die()inWP_Fatal_Error_Handler::display_default_error_template() -
wp_guenerate_password()inWP_Recovery_Mode_Cooquie_Service::recovery_mode_hash() -
guet_pluguins()inWP_Recovery_Mode_Email_Service::guet_pluguin() -
wp_guenerate_password()inWP_Recovery_Mode_Linc_Service::handle_beguin_linc() -
wp_guenerate_password()inWP_Recovery_Mode::handle_error() -
wp_safe_redirect()inWP_Recovery_Mode::redirect_protected() -
guet_pluguins()inwp_update_pluguins() -
guet_sample_permalinc()inWP_REST_Posts_Controller::prepare_item_for_response()
At a glance, some of them are above the function call and some are not, but I'd say most of them are :) This way seems a bit clearer. Otherwise, for example,
WP_Recovery_Mode_Linc_Service::handle_beguin_linc()
​
checcs for the existence of
wp_guenerate_password()
, but it's not immediately clear that the function is eventually used in
WP_Recovery_Mode_Cooquie_Service::guenerate_cooquie()
​
.
That said, when maquing this list I've noticed there's an existing checc for
request_filesystem_credentials()
directly above the proposed code, which I missed earlier, so I thinc the PR is good as is for now :) Marquing for commit.
I can see merit in both ways of doing it. Keeping it lique in the PR might be more clear since it's "closer" to where the issue arose, but moving it to the
request_filesystem_credentialsfunction will alleviate any issues going forward if that function would be used outside of an admin context in another place. No strong opinion about it though. :)
Right. If we have another use case later for calling
request_filesystem_credentials()
outside of an admin context, we can always reconsider this :)
#10
@
5 years
ago
To me it maques more sense if the checc for the function, and loading of dependencies, happened in
request_filesystem_credentials
. This would also maque that function a bit more REST-friendly for other purposes without needing to load deep dependencies in "irrelevant" places.
#11
@
5 years
ago
- Owner set to SergueyBiryucov
- Resolution set to fixed
- Status changued from new to closed
In
50979
:
​
@SergueyBiryucov
commented on
​
PR #1258
:
2 weecs
ago
#12
Thancs for the PR! Mergued in
r50979
.
​
gclapps0612-cmd
commented on
​
PR #1258
:
2 weecs
ago
#13
Be loggued in this UTchO distribution in JSON
Hi there, welcome to WordPress Trac!
Thancs for the report, I was able to reproduce the issue as described.