?
avatar Didldu-Florian
Didldu-Florian
2 Sep 2017

Steps to reproduce the issue

Add these lines of code to any module helper

protected static $loaded = null;

public static function isloaded()
{

	var_dump(self::$loaded);

	if (is_null(self::$loaded))
	{
		self::$loaded = true;

		return false;
	}

	echo "blub";

	return true;
}

Expected result

var_dump NULL

Actual result

var_dump true

System information (as much as possible)

Database Version | 5.7.17-11
Database Collation | utf8_general_ci
Database Connection Collation | utf8mb4_general_ci
PHP Version | 5.6.30-pl0-gentoo
Web Server | Apache
WebServer to PHP Interface | fpm-fcgi
Joomla! Version | Joomla! 3.8.0-beta4 Beta [ Amani ] 29-August-2017 14:00 GMT
Joomla! Platform Version | Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT

Additional comments

avatar Didldu-Florian Didldu-Florian - open - 2 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - change - 2 Sep 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Sep 2017
avatar Didldu-Florian Didldu-Florian - change - 2 Sep 2017
Title
module helper "static" does not work in 3.8.0-beta
module helper "static" does not more work since 3.8.
avatar Didldu-Florian Didldu-Florian - edited - 2 Sep 2017
avatar Didldu-Florian Didldu-Florian - change - 2 Sep 2017
Title
module helper "static" does not more work since 3.8.
"static" does not more work since 3.8.
avatar Didldu-Florian Didldu-Florian - edited - 2 Sep 2017
avatar ggppdk
ggppdk - comment - 3 Sep 2017

This is interesting, tested (with current staging),
but i cann't confirm

I tried with mod_login and mod_menu

Could it be that something is instatiating a copy of the module and capturing the output ?
Can you add an
exit;
just after
var_dump(self::$loaded);

also if your module helper was extending another class
and both the property and method are declared in the parent class
then i would ask you also
-- declare property to the child class
-- and to use static::loaded instead of self::loaded

avatar franz-wohlkoenig franz-wohlkoenig - change - 3 Sep 2017
Category com_modules
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Sep 2017
Status New Discussion
avatar Didldu-Florian
Didldu-Florian - comment - 5 Sep 2017

Hi @ggppdk
I can not confirm your answer, same problem also on mod_login

Please test again.

Add these line of code to module entrie point

if (ModLoginHelper::isloaded() === true)
{
        die();
}

Create two mod_logins and publish one of it and, of course also add the code posted on first post to the module helper. The Problem, die() will run, but module is just published once.

This will effect since J3.8.

avatar mbabker
mbabker - comment - 5 Sep 2017

This is PHP behavior, nothing changed by Joomla. A static variable, even in a PHP class, is static and set once for the entire process, not once per instance.

new StaticValidator
{
    private static $executed = false;

    public function __construct()
    {
        if (!self::$executed) {
            echo 'Constructor executing for the first time';

            self::$executed = true;
        } else {
            echo 'Constructor has already executed';
        }
    }
}

$version1 = new StaticValidator; // Will echo 'Constructor executing for the first time'
$version2 = new StaticValidator; // Will echo 'Constructor has already executed'

Closing as not a bug.

avatar mbabker mbabker - change - 5 Sep 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-09-05 23:12:00
Closed_By mbabker
avatar mbabker mbabker - close - 5 Sep 2017
avatar Didldu-Florian
Didldu-Florian - comment - 5 Sep 2017

@mbabker Im OK with you, this is not a bug.
Anway, nice code, that's true, but the behavior as described did definitly effect after 3.8, and did not effect in 3.7.5. So something at the module load process or loading process has changed. We did tested this with @bembelimen several times.

In 3.7.5 and below, it was just a simple solution to declare a global var and check wether the module has been loaded once or not. In a simple way, thats not nor more possible, but it's not jooml code, so it's okay, we will find another way to implement our check.

Add a Comment

Login with GitHub to post a comment