Support » Plugin: W3 Total Cache » BUG: JavaScript error on admin page

  • Resolved dingdang

    (@dingdang)


    Latest version of the plugin and WordPress 5.0.2

    When making changes to the setup the button that appears “empty the page cache” in the admin / dashboard is not working anymore and generates the following error on click:

    ReferenceError: w3tc_beforeupload_unbind is not defined

    Should be easy to replicate as this happens on sites with different collection of plugins installed and themes.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello @dingdang,

    can you please share a screenshot of that button and the error you are getting?

    First note – while trying to replicate it I found that this happens on a very specific situation:

    a) let say I add a new plugin, and I am still on the main “Plugins” page, the button appears after the activation “empty the page cache” and it WORKS if clicked

    b) then to get the problem case – I don’t click on the above button but instead I go to the page “Updates”. At that page the button “empty the page cache” is not present. Then I click from the top admin bar on “Purge all caches”. After that while on the same page (“Updates”) the button “empty the page cache” reappears (which is also strange – it should be there in the beginning and disappear if I click on the “Purge all caches” but the reverse actually happens). And now if I click on that button I get the specified error message in the console.

    Here are the button and the error as you requested:
    https://i.ibb.co/Rh5wW9R/ice-screenshot-20181228-003609.png
    https://i.ibb.co/ssMr2B8/ice-screenshot-20181228-003644.png

    Plugin Support Marko Vasiljevic

    (@vmarko)

    Hello,
    Unfortunately, we could not replicate the issue. Can you please share a video or take the screenshots with more details so we can see where those messages appear.

    The error message appear in the console. I will try to replicate it again.

    bradman334

    (@bradman334)

    I have a site that is also getting this error.

    Uncaught ReferenceError: w3tc_beforeupload_unbind is not defined
        at HTMLInputElement.onclick (plugins.php:1144)

    It happens on the Plugins page when I click “Empty the page cache” or “Hide this message”.

    We are currently on WP 4.9.9 and W3TC 0.9.7

    bradman334

    (@bradman334)

    Our issue is now resolved. It was not the plugin but an unrelated change that caused the error.

    @vmarko I have the same problem as the others mentioned.

    We are using a multi-site in this case which might be related. Just installed W3tc. I think the problem is that the function “w3tc_beforeupload_unbind” is in a javascript file that is enqueued on the W3tc settings pages, but nowhere else. If you are on another page the JS isn’t loaded, but those buttons use that function with an “onclick” handler. So they are trying to use a function that isn’t defined.

    It is pretty easy to just ignore this error but I imagine you have a lot of people who get this error sometimes, and they are like “huh that doesn’t work”, then just ignore it and it goes away because they leave the page.

    But it should be a straightforward fix. Either include that JS file so the function works, or get rid of that function from the buttons.

    FYI I can consistently reproduce it by going to a custom ACF options page, using the Performance dropdown in the top bar, going to Purge All Caches. It redirects to the network admin area (which is where the W3tc settings are for multisites). Then it redirects back to the ACF options page with those messages that were already mentioned.

    Those messages that appear have the buttons that call the undefined function. And that’s because the W3tc scripts are loaded on this unrelated ACF options page.

    Hope this helps.

    • This reply was modified 3 months, 2 weeks ago by  radgh.
    • This reply was modified 3 months, 2 weeks ago by  radgh.

    Sorry to restart discussion, but i did just an update of w3tc, and facing this issue again, and i assume, the explanation of @radgh is right because i could “hide” a message on the dashboard of w3tc but i was getting this on the core-update page, if i hit “purge all cache” from the top menu:

    Screenshot: http://tinyurl.com/y29acbol

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