XOOPS Strict Standards Error

2

XOOPS gave this error in script installed:

  

Strict Standards: Non-static method XoopsLogger :: instance () should not   be called statically in   /home/b81inudo/public_html/portal/include/common.php on line 109

     

Strict Standards: Non-static method XoopsLogger :: instance () should not   be called statically in   /home/b81inudo/public_html/portal/class/logger.php on line 228

I could not resolve, the line of code is logger.php :

function addBlock($name, $cached = false, $cachetime = 0) {
    if ( $this->activated )     $this->blocks[] = array('name' => $name, 'cached' => $cached, 'cachetime' => $cachetime);
}

And that of common.php :

if ( empty( $_SERVER[ 'REQUEST_URI' ] ) ) {         // Not defined by IIS
    // Under some configs, IIS makes SCRIPT_NAME point to php.exe :-(
    if ( !( $_SERVER[ 'REQUEST_URI' ] = @$_SERVER['PHP_SELF'] ) ) {
        $_SERVER[ 'REQUEST_URI' ] = $_SERVER['SCRIPT_NAME'];
    }
    if ( isset( $_SERVER[ 'QUERY_STRING' ] ) ) {
        $_SERVER[ 'REQUEST_URI' ] .= '?' . $_SERVER[ 'QUERY_STRING' ];
    }
}
    
asked by anonymous 07.11.2014 / 15:54

1 answer

4

A static method is defined like this:

class NomeDaClasse {

    public static function nomeDoMetodo( $argumento ) {}
}

And it should be invoked like this:

NomeDaClasse::nomedoMetodo( $valorDoArgumento );

In old versions of PHP you could even invoke a class method of the above form even if its statement did not have the static keyword.

More recent versions have come to characterize this as an error and whenever that happens a Strict Standards is triggered to inform you, the programmer, that what you are doing does not make sense without a method is static , invoke it statically. If it is not, instantiate the object.

Most likely you are using a version of XOOPS designed for older or at least not as modern versions. Or worse, the project has been discontinued and does not receive updates.

And you're running this dinosaur on an install, local or not, with a PHP version higher than the XOOPS developer's recommendation.

You can even disable this error by setting the following statement in the scripts:

error_reporting( E_ALL ^ E_STRICT );

But this is extremely not recommended!

Looking more calmly and thoroughly, this ends up not even being version conflict. I downloaded the current version of XOOPS (2.5.7) which claims to require PHP 5.3.7+ and is compatible with PHP 5.5.x.

It may even be but not following good programming practice because, by analyzing the XoopsLogger class located in /class/logger/xoopslogger.php , it continues to be written in PHP 4, discontinued 7 years ago .

See WordPress, for example. It works perfectly, the way it works, but it works. And it suffers from the same problem as it is enough to enable Strict Standards reporting that starts raining error, especially in the Dashboard .

    
07.11.2014 / 17:31