• Resolved hakre

    (@hakre)


    On 3.4 we see fatal errors in JsonUtil:

    PHP Fatal error: Uncaught Error: Call to a member functi on getWord() on null in ./wp-content/plugins/weglot/vendor/weglot/weglot-php/src/Util/JsonUtil.php:55.

    This may go along with another notice or two:

    Error (E_NOTICE): “Undefined offset: 108“ at ./wp-content/plugins/weglot/vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php:53.

    but that is a different file. Both 3.4.

    The fatal error is especially boggling as you can imagine. Using a previous version (e.g. 3.3.6) didn’t resolve (and would also not be my first option, but trying doesn’t hurt).

    • This topic was modified 3 years ago by hakre.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Edson Galina Fortes

    (@glx77)

    Hi @hakre,

    hope you’re fine?
    To have a quick fix, you can try to modify directly /wp-content/plugins/weglot/vendor/weglot/weglot-php/src/Util/JsonUtil.php:55 by replace
    $current = $words[$nextJson]->getWord();
    by

     if(!empty($words[$nextJson])){
                $current = $words[$nextJson]->getWord();
            }

    So far, the error should come from an invalid dom or json structure. Do you have a live page where I can see the structure where you have this fatal error ?

    Best

    Thread Starter hakre

    (@hakre)

    Slt Edson Galina Fortes,

    merci.

    Its on a 404 page so it’s not taking the whole site down. Just wanted to report as it’s a fatal error in the code and thought you might want to know about at least.

    Using the W3C checker I’ve checked the page and there are only two errors: a missing alt attribute on an img tag and a css directive with too many values – if it helps.

    And they told me the Weglot Pro thing was on the limit, so perhaps this for the JSON?

    Plugin Contributor Edson Galina Fortes

    (@glx77)

    Hi @hakre ,

    thanks for your reply it’s help.

    so much the better if it doesn’t break the whole site, but I’m still curious to understand where the problem comes from.

    Having a pro account does not block the use of features linked to the json format.

    Could you send the pieces of code you tested with the w3c checker?

    Best

    Thread Starter hakre

    (@hakre)

    @glx77 Sorry, that was / is not possible, now not any longer. It was the old design and it’s now gone. Unfortunately for the new server, I would need to double-check if it still provokes the error. At least I’ve kept the way on how to reproduce.

    Perhaps just as a take-away that for any data structure in JSON every access needs to be guarded unless it has been asserted already earlier on (from a stability standpoint for these errors).

    Could take a couple more weeks until I stumble over this again, just saying.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Fatal error: Uncaught Error: Call to a member functi on getWord() on null’ is closed to new replies.