Opened 6 years ago
Closed 6 years ago
#44514 closed defect (bug) (duplicate)
Can’t edit main theme php files after upgrading to 4.9
Reported by: | aguidrevitch | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9 |
Component: | Themes | Keywords: | |
Focuses: | multisite | Cc: |
Description
I am unable to edit main theme (php) files using the build in WordPress editor after upgrading to version 4.9. I get the following error:
Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.
The original topic is https://wordpress.org/support/topic/cant-edit-main-theme-php-files-after-upgrading-to-4-9/
I'm getting the same problem, and the reason for it is multisite setup. Here is what happens, when I try to save a php template:
wp_edit_theme_plugin_file() (wp-admin/includes/file.php) tries to fetch /wp-admin/theme-editor.php?theme=themename&file=template-name.php&wp_scrape_key=bc5c7a4ffcba576858c8628c403fff56&wp_scrape_nonce=340388534
And while the response contains ###### wp_scraping_result_start... #####, the response itself is a 302 redirect to /wp-admin/network/theme-editor.php because of multisite setup, so this wp_scraping_result_start is ignored. Then, /wp-admin/network/theme-editor.php does not produce
I can only guess that wp_edit_theme_plugin_file() should use network_admin_url() instead of admin_url() for multisite configurations, when forming loopback request URL in wp_edit_theme_plugin_file().
Please let me know if my explanation is clear
Hello @aguidrevitch, welcome to WordPress Trac!
Sorry it took so long for somebody to respond. We now have another report for this issue which already has a patch so I'm closing yours as a duplicate of #45755.