• Resolved jmslbam

    (@jmslbam)


    So I found that $antiXss = new AntiXSS(); isn’t properly a global because I get this error.

    When I change it to it works:

    use voku\helper\AntiXSS;

    global $antiXss;
    $antiXss = new AntiXSS();

    The error:

    Fatal error: Uncaught Error: Call to a member function xss_clean() on null
    in /Users/xx/local/yy/app/public/wp-content/mu-plugins/secondary-title/includes/hooks.php on line 125

    Call stack:

    secondary_title_edit_post(12252)
    wp-includes/class-wp-hook.php:326
    WP_Hook::apply_filters(NULL, array)
    wp-includes/class-wp-hook.php:348
    WP_Hook::do_action(array)
    wp-includes/plugin.php:517
    do_action('save_post', 12252, WP_Post, true)
    wp-includes/post.php:5060

    WP 6.7.1

    PHP 8.2.23

    Local by FlyWheel

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author thaikolja

    (@thaikolja)

    Hi @jmslbam,

    Thanks for bringing this up. I’ll verify this on my end and will push an update.

    It’s not that important, but could you tell me how you found this out? That’d help me to do more checks next time.

    Cheers,

    Kolja

    Thread Starter jmslbam

    (@jmslbam)

    Simply by upgrading the plugin and having wp_debug enabled, but even without it would trigger an error.
    I’m using this stack, maybe it’s a config thing in Local by Flywheel?

    WP 6.7.1

    PHP 8.2.23

    Local by FlyWheel

    Plugin Author thaikolja

    (@thaikolja)

    Thanks for the info.

    I’ve made some changes to the AntiXSS library. If you could spare a minute, I’d appreciate it if you could test the version and look for the same (or similar) errors or bugs before I push it to WP.org’s plugin library.

    The input field when adding/editing a post should also allow most HTML tags, but filter out dangerous ones (like <script> or <iframe>).

    You can download the updated version via this link.

    Thanks!

    • This reply was modified 1 year ago by thaikolja.
    Thread Starter jmslbam

    (@jmslbam)

    Hi sorry for the slow reply. Didn’t encoutered this bug anymore, but I just came back to this project with a fresh install and encoutered it again.

    Wanted to download the new file, but it’s not available for download anymore.

    Thread Starter jmslbam

    (@jmslbam)

    Oh btw, the issue is still here in the latest version. I just hardcoded a fix in my project.

    The same solution

    global $antiXss;
    Thread Starter jmslbam

    (@jmslbam)

    Maybe a better solution would be wrapper the $antiXss in a function instead of calling it as a global

    $antiXss = get_anti_xss_for_secondary_title();

    This way you never get a collission on the variable name because your code isn’t namespaced. And your not working with global. And this fixes the problem 😉

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

The topic ‘Call to a member function xss_clean() on null’ is closed to new replies.