• Resolved bbrenter

    (@bbrenter)


    Environment

    • We’re Open! 2.6
    • WordPress 7.1.2, PHP 8.2
    • Opening hours output with live update enabled (elements with the class .opening-hours.update)

    What happens
    After the page has loaded, the plugin sends its AJAX refresh (action: we_are_open_wp_ajax). When the response arrives, the browser console shows:TypeError: Cannot read properties of null (reading ‘replace’) at HTMLTableElement.<anonymous> (opening-hours/wp/js/js.js) at jQuery.each … at Object.success (opening-hours/wp/js/js.js)

    After the error, the rest of the refresh loop doesn’t run, so the opening hours are no longer updated live on that page.

    Cause
    In wp/js/js.js, inside the success callback of the update action (around line 210), the condition checks the wrong property before calling .replace():content: (typeof data.html == ‘string’) ? data.content.replace(/\\(\’)/gi, ‘$1’) : null,

    If the response element has html set but content is null, then data.content.replace() throws.

    Suggested fix
    Check the property that is actually used:content: (typeof data.content == ‘string’) ? data.content.replace(/\\(\’)/gi, ‘$1’) : null,

    With this one-line change the error is gone and the refresh works as expected. We verified this on our site by serving a patched copy of js.js.

    Thanks for the plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Noah Hearle

    (@designextreme)

    @bbrenter Thanks, and thanks for tracking it down so precisely. Your diagnosis is correct, the condition tests data.html where it should test data.content. Fixed for the next release.

    Thread Starter bbrenter

    (@bbrenter)

    Awesome, thanks

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.