Support » Plugin: WP Reset - Best WordPress Reset Plugin » Error trying to compare snapshot (conflict with WordFence?)

  • Resolved EddyM



    I’ve just tried to use the “Compare snapshot to current database tables” function, and got a popup message saying “An undocumented error has occurred”. This is on a relatively fresh install of WordPress 5.2.3 on PHP 7.3 (I’ve only tried a couple of themes and installed a couple of plugins so far).

    The page it requests on the server seems to be returning a HTTP 500 status code, so I found the relevant error_log file on the server, which shows:

    PHP Fatal error: Cannot declare class Diff, because the name is already in use in /home/[username]/public_html/wp-content/plugins/wp-reset/libs/diff.php on line 46

    I then tried to track down where the class was already declared, and it seems to be in a file which is part of the Wordfence plugin, located at: /wp-content/plugins/wp-reset/libs/diff.php wp-content/plugins/wordfence/lib/Diff.php

    I’ve done a diff of the two diff.php files and it seems like they are the same thing, but with some slight modifications (yours seems to have some extra bits which the Wordfence version doesn’t – but I’m guessing the other files included as part of it might also have further differences). So the next thing I tried was to avoid redeclaring the class by adding this to the beginning of your diff.php file (I don’t really have that much experience with classes in PHP, so I don’t know whether this would really the best way to do it):


    That dealt with that error message, but then the same issue occurred with the class “Diff_Renderer_Html_SideBySide”, and for some reason the same fix didn’t work in that file (it seems to be not even running any code that comes before it hits the error with the class definition in that one, even though I can’t see any difference from the first file other than the fact that it’s extending a class rather than being a standalone one). So I ended up completely hacking round that by just renaming that class, just to see if I could get it working at all.

    After doing all that (so effectively using the Diff classes defined by WordFence instead), the comparison actually works fine. So one fix might be to check whether these classes are defined before attempting to define them, even though they aren’t exactly the same – but I’m not sure why WordFence needs to include those classes in every request to the site, which is what they seem to be doing. So perhaps it’s really them that should be resolving this issue?

Viewing 1 replies (of 1 total)
  • Plugin Author WebFactory


    Hi, thank you for the detailed report! We appreciate it!

    We’ll most likely rename our class to WPR_Diff or something like that. That way the 2 “same” classes can live happily together 🙂 We’ll definitely include this fix in the next release.

    Again, thank you for reporting. This really helps as we can’t catch all bugs on our own 🙂

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.