• WordPress has a mechanism that checks files for errors before saving them from Theme Editor, Plugin Editor, etc. It is a good thing.

    But why is it clearing the entire file? Once the error “WordPress unable to communicate back with site to check for fatal errors” has hit and if we reload to check the file again, the entire content inside it is gone. Why is it happening?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator t-p

    (@t-p)

    Thread Starter muhammedswalihct

    (@muhammedswalihct)

    @t-p I think, you didn’t understand my actual question. I already saw that thread before.

    My question is “Why” WordPress “Clears” the content inside the files when it should just prevent us from updating. It is OKAY if it just stops us from updating the files because we can edit them via FTP. But “Why does it clear the existing content”?

    Moderator t-p

    (@t-p)

    I think, you didn’t understand my actual question.

    My apology if I did understand the question.

    I already saw that thread before.

    Sorry, I did not know that for there is no mention of it in the ‘OP’.

    Thread Starter muhammedswalihct

    (@muhammedswalihct)

    @t-p are you familiar with any such problems reported earlier? On any thread or core tickets?

    Hi, @muhammedswalihct

    Once the error “WordPress unable to communicate back with site to check for fatal errors” has hit and if we reload to check the file again, the entire content inside it is gone.

    It happened to me once a few weeks ago, but I can’t replicate now anymore. Are you on WP 5.6.1?

    Now it behaves like this:

    1. Going to wp-admin/plugin-editor.php?plugin=my-plugin.php
    2. Inserting intentionally a syntax error
    3. Hit update
    4. Your PHP code changes were rolled back due to an error…
    5. Hit F5
    6. It pops up: Reload? Changes you made may not be saved.
    7. Indeed changes has not been saved – it rolls back to previous verison

    But I recall your described behaviour (the edited file became empty) happening to me once, although I can’t replicate it now. Also, I wasn’t able to find a ticket that addresses this.

    I personally prefer to use a FTP client instead of any browser editor, since I have more control, but I know in some cases one needs those too.

    I’ll test and see if I can replicate this eventually. Maybe there are some certain errors that trigger this and we need to open a ticket.

    Kind regards.

    Thread Starter muhammedswalihct

    (@muhammedswalihct)

    Hi @vladytimy

    I was facing this issue earlier as well. I am running the latest versions of everything including WordPress, plugins, PHP, etc. So this is not related to the versions I guess because it also happened several times in the past.

    I didn’t find it as a big issue initially because it will only happen when there are some issues that prevent WordPress from checking the backend.

    But now, I lost the entire functions.php file due to this “suspected” bug which I noticed a long ago but ignored.

    So, if this is an actual bug in the core, it should be fixed. It is not a problem if WordPress doesn’t allow to “update” the file in case of any errors. We can do that via FTP. But it is unacceptable if it clears the entire file with too many customizations we make over time. As it also happens for plugins, using a separate plugin for customization doesn’t also help. It seems like something is wrong with the code verification feature of WordPress.

    Thread Starter muhammedswalihct

    (@muhammedswalihct)

    Just found a Core ticket posted 2 years ago about this issue…

    https://core.trac.wordpress.org/ticket/46637

    Thanks for the update. Nice job finding that ticket!

    If I see anything relevant while testing, I’ll add my input there on the ticket. I see Sergey’s on it. Thanks for reporting this. Hopefully there will be a fix soon.

    Regards!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WordPress clears Entire content inside files if it cannot check the backed’ is closed to new replies.