• Derick Payne

    (@petrichorpost)


    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.

    I have cleared my browser cache, cleared my website cache, de-activated all plugins and reinstalled main theme.

    Furthermore; I am able to edit php files in other themes without issues. I have also checked my permissions and ownership of all files. Everything seems perfect.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 123 total)
  • Tom-Sec1

    (@mi5rapekids)

    I am having the same sort of problem – I cannot edit the main theme CSS or PHP files, I get a 530 error and it tells me to edit the file via FTP.

    Clearly this is quite a major bug that’s affecting a lot of people so I’m guessing it’ll be fixed soon. Still pretty irresponsible to release an updated version of WP that screws up people’s ability to edit their own themes.

    Moderator Marius L. J.

    (@clorith)

    Hiya,

    Firstly, @mi5rapekids please create your own topic, your error is not the same, and our forum guidelines make a point of this.

    @petrichorpost The error you are seeing is part of the new sandbox feature, after a change is made we test to make sure your site isn’t whitescreened, if we can’t determine the state, we cancel the save to avoid accidental breakage.

    Do you use any services on your site such as loadbalancing, heavy caching etc that may affect cookies being sent, as the error in question is related to the attempt to reach the admin area after a change, and if any of the data sent is being stripped by cache or loadbalancing services that would cause it to fail.

    Thread Starter Derick Payne

    (@petrichorpost)

    @clorith I’m not using any loadbalancing or heavy caching. But, It is an optimized WordPress account. Please note that the problem only effects my main theme and not any other installed themes. Furthermore, on the same host and same account type, I have another website that I am able to edit php theme files without any issues.

    firescue17

    (@firescue17)

    I experienced the same issue on two live sites (1 multisite and 1 regular install) as well as a local test environment.

    – Updated to 4.9
    – Updated all themes and plugins
    – Cleared cache, cookies, rebooted, took a walk
    – tried editing child theme with and without all plugins disabled.

    I was completely unable to edit child theme files without ftp’ing to the server. After uploading, the site ran fine with the edits in place.

    BackuPs

    (@backups)

    Same here. It is not possible to edit any php file any longer even if correct php is used. I tried 5 servers (domains) and they all have the same issue.

    ‘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’

    Wp 4.9 wrecked this nice ability !!!

    anggora

    (@anggora)

    Same here!
    Unable to edit the .php files within the Editor page area. It wants me to edit the files via FTP ??

    Moderator Marius L. J.

    (@clorith)

    So, we have a few other potential causes here.

    Do you have any security plugins running, alternatively do you know if your host uses mod_security which is also known to cause some headaches?

    BackuPs

    (@backups)

    @clorith It happens in any server. I tested now 20 of them today and they all have the same issue. And they are on different hosting providers. It works just fine in 4.8.3 and just not in 4.9

    No security plugins…. I have seen several users who bought themes at themeforest reporting similar issues in the theme support forums.

    This is a wp bug not caused by mod_security, a security plugin or whatever you might be thinking of. Its WP changes causing this.

    Even a clean ubuntu server throws the problem. A windows server running wamp has the issue.

    Moderator Marius L. J.

    (@clorith)

    @gopros I’ve archived your post, it serves no purpose, please calm down ??

    Now, the reason I’m walking you through possible causes for this is that I’ve used the editor my self, and did not have any problems, so we are trying to identify why some of you are having issues. This can be a bothersome and tedious process, we understand that, but it needs to be done to rule out various scenarios so please bare with us as we go through the motions.

    As to why you can edit your non-active themes, this is because we don’t have a way to verify that those edits don’t break anything, so we don’t perform a check on them.

    Back to the question at hand, how to sort out edits on the active themes!
    How long does it take to perform the save, from you hit the save button to the point where you receive the error?

    Alternatively, if you are comfortable making a direct file edit so we can get some proper data on what is going on, please go into wp-admin/includes/file.php, on line 539 (this should be a blank line right before $loopback_request_failure = [...] add the following:

    
    error_log( 'Starting edit check' );
    error_log( 'Body:' );
    error_log( $body );
    

    This should write the response to your error log (you may need to enable debugging for the logging to happen), that we would love it you’d share here so we can see what is going on (

    anggora

    (@anggora)

    “Do you have any security plugins running, alternatively do you know if your host uses mod_security which is also known to cause some headaches?”

    I’ve tested on a test/ demo website (brand new website) with no cache plugin and security plugin, still unable to edit the php files from the Editor page.

    I’ve uninstalled version 4.9, reinstalled the previous version. I’m able to edit the .php files with 4.8.3.

    :-/

    BackuPs

    (@backups)

    @clorith here you go.

    [Fri Nov 17 07:50:10.578713 2017] [:error] [pid 1167] [client 192.168.142.1:51295] Starting edit check, referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen
    [Fri Nov 17 07:50:10.578755 2017] [:error] [pid 1167] [client 192.168.142.1:51295] Body:, referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen
    [Fri Nov 17 07:50:10.578770 2017] [:error] [pid 1167] [client 192.168.142.1:51295] , referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen
    

    View post on imgur.com

    View post on imgur.com

    Note if i replace

    wp-admin/theme-editor.php
    wp-admin/includes/file.php

    With the same named files from build 4.8.3

    I can edit any file again. It seems that the new function added for checking the edited files is not working ok.

    Btw the style.css can be edited without any issue. Just not any php file using wp 4.9.3. Does that make sense?

    BackuPs

    (@backups)

    Hi
    needle start contains this :

    needle ###### wp_scraping_result_start:2a32dbf6e0fff7a63ac3dde1e2aa749e ######, referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen

    body contains this

    referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen

    scrape_result_position contains this

    referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen

    it fails on line 558

    if ( false === $scrape_result_position ) {
    $result = $loopback_request_failure;
    }

    If i delete lines 491-598 in file.php i can at least edit the files again. I know it is less secure, but i can work from the editor.

    BackuPs

    (@backups)

    “Back to the question at hand, how to sort out edits on the active themes!
    How long does it take to perform the save, from you hit the save button to the point where you receive the error?:”

    immediatelly. Even if i just save and dont edit the file at all. I cant even blink with my eyes the error is already there.

    Moderator Marius L. J.

    (@clorith)

    All right, so they’re not managing to create a connection at all, we’re at least getting somewhere, thank you!

    Let’s have a quick look at the actual response as well, although we have a suspicion as to the root cause.
    Add the following log line as well

    
    if ( is_wp_error( $r ) ) {
      error_log( 'Connection failed' );
      error_log( var_export( $r, true ) );
    } else {
      error_log( 'Connection created');
    }
    

    It will check if the connection failed altogether, if it did it will provide a chunk with the error object so that we can see the error codes and messages to nail down the root cause.

    BackuPs

    (@backups)

    well that error makes sense. Since its a localhost install and the website domain name is in the host file and only visible on the pc who has that xxx.xxx.xxx.xxx website.tst in his host file.

    [Fri Nov 17 13:44:37.266751 2017] [:error] [pid 1125] [client 192.168.142.1:53926] WP_Error::__set_state(array(\n 'errors' => \n array (\n 'http_request_failed' => \n array (\n 0 => 'cURL error 6: Could not resolve host: website.tst',\n ),\n ),\n 'error_data' => \n array (\n ),\n)), referer: https://website.tst/wp-admin/theme-editor.php?file=functions.php&theme=twentyseventeen

    So i tried a life server with a domain name that is accessible without modding the hostfile.

    Now i get this

    [17-Nov-2017 13:01:12 UTC] ------------------------------------------->
    [17-Nov-2017 13:01:12 UTC] Starting edit check
    [17-Nov-2017 13:01:12 UTC] Body:
    [17-Nov-2017 13:01:12 UTC] <!DOCTYPE html>
    <html style="height:100%">
    <head><title> 403 Forbidden
    </title></head>
    <body style="color: #444; margin:0;font: normal 14px/20px Arial, Helvetica, sans-serif; height:100%; background-color: #fff;">
    <div style="height:auto; min-height:100%; ">     <div style="text-align: center; width:800px; margin-left: -400px; position:absolute; top: 30%; left:50%;">
            <h1 style="margin:0; font-size:150px; line-height:150px; font-weight:bold;">403</h1>
    <h2 style="margin-top:20px;font-size: 30px;">Forbidden
    </h2>
    <p>Access to this resource on the server is denied!</p>
    </div></div></body></html>
    
    [17-Nov-2017 13:01:12 UTC] Connection created

    But if i remove the lines 491-598 in file.php it just works fine and the file is edited and saved with the correct made modifications.

    So the 403 does not make sense as without that piece of code the file is just edited and saved.

    Please let me know what else i can test for you.

    Note changing the file permissions of that php file to 777 does not resolve the error message. It only works if i remove the complete php functions that checks for something that apparently is not needed as it works without that check.

Viewing 15 replies - 1 through 15 (of 123 total)
  • The topic ‘Can’t edit main theme php files after upgrading to 4.9’ is closed to new replies.