• Resolved Austin Ginder

    (@austinginder)


    I have Google Language Translator v6.0.18 running on a multisite network. Some of my subsites are seeing PHP fatals errors on the home page. My server is running PHP 8 so I suspect it’s just a compatibility issue. This is the error from the error log.

    PHP Fatal error: Uncaught TypeError: array_values(): Argument #1 ($array) must be of type array, null given in /wp-content/plugins/google-language-translator/google-language-translator.php:268

    I was able to patch the code by changing that line to the following:

    $comma_separated = empty( $items ) ? $items : implode(",",array_values($items));
Viewing 1 replies (of 1 total)
  • Plugin Author edo888

    (@edo888)

    Hi,

    The context is this:

    public function googlelanguagetranslator_included_languages() {
        $get_language_choices = get_option ('language_display_settings');
    
        foreach ($get_language_choices as $key=>$value):
          if ($value == 1):
            $items[] = $key;
          endif;
        endforeach;
    
        // -------> line 268
        $comma_separated = implode(",",array_values($items));
        $lang = ", includedLanguages:'".$comma_separated."'";
        return $lang;
      }

    I have no idea how you can have a case when $items is null. Most likely language_display_settings is altered somewhere in the database and in that case it is good to have a fatal error to catch your attention and make sure the configuration is done properly.

    Thanks! 🙂

    • This reply was modified 2 years, 12 months ago by edo888.
Viewing 1 replies (of 1 total)

The topic ‘PHP 8 error’ is closed to new replies.