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;
}
var_dump NULL
var_dump true
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
Labels |
Added:
?
|
Title |
|
Title |
|
Category | ⇒ | com_modules |
Status | New | ⇒ | Discussion |
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.
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.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-09-05 23:12:00 |
Closed_By | ⇒ | mbabker |
@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.
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