Re: Trying to access array offset on value of type bool in Setup.php:563

Jeffrey Walton <[email protected]>
Newsgroups gmane.org.wikimedia.mediawiki
Message-ID <CAH8yC8nWFVchVAXDNFK4Dry61pTod5-zfZJa9yW2+WFR+hW_TA@mail.gmail.com>
On Tue, Mar 30, 2021 at 10:37 AM Jeffrey Walton <[email protected]> wrote:
>
> Hi Everyone,
>
> This caught my eye when running one of my maintenance scripts. The
> Setup.php:563 warning is new.
>
> The warning was not present on the old CentOS machine. The new machine
> is Ubuntu 20, PHP 7.4, MySQL 8, Mediawiki 1.35.1.
>
> # php /var/www/html/w/maintenance/generateSitemap.php ...
>
> PHP Notice:  Trying to access array offset on value of type bool in
> /var/www/html/w/includes/Setup.php on line 563

Here is the code in question:

   557  // Set server name
   558  $serverParts = wfParseUrl( $wgCanonicalServer );
   559  if ( $wgServerName !== false ) {
   560          wfWarn( '$wgServerName should be derived from
$wgCanonicalServer, '
   561                  . 'not customized. Overwriting $wgServerName.' );
   562  }
   563  $wgServerName = $serverParts['host'];
   564  unset( $serverParts );

Would adding an:

    if ( is_array( $serverParts ) )
        $wgServerName = $serverParts['host'];

Be the proper fix here?

If not, what is the proper fix?

Thanks in advance.

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.