No Code Attached Yet
avatar Filefabrik
Filefabrik
29 Apr 2025

if ((string) $module->id === $id) { // Found it return $module; }
must cast the incoming "id" because $module->id is an integer
if ($module->id === (int)$id) { // Found it return $module; }

if ((string) $module->id === $id) {

avatar Filefabrik Filefabrik - open - 29 Apr 2025
avatar joomla-cms-bot joomla-cms-bot - change - 29 Apr 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 29 Apr 2025
avatar QuyTon
QuyTon - comment - 29 Apr 2025

Please read the docblock, $id is a string, thus, $module->id is casted to be a string.

avatar Filefabrik
Filefabrik - comment - 29 Apr 2025

protected static function &load() calls public static function getModuleList()

gives back an array with $id as integer

ids in joomla databases are integers.
so the dockblock is wrong!

right?

Image

avatar QuyTon
QuyTon - comment - 29 Apr 2025

$id is parsed here:

if (str_contains($article->text, '{loadmoduleid ')) {
// Find all instances of plugin and put in $matchesmodid for loadmoduleid
preg_match_all($regexmodid, $article->text, $matchesmodid, PREG_SET_ORDER);
// If no matches, skip this
if ($matchesmodid) {
foreach ($matchesmodid as $match) {
$id = trim($match[1]);
$output = $this->loadID($id);
// We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
if (($start = strpos($article->text, $match[0])) !== false) {
$article->text = substr_replace($article->text, $output, $start, \strlen($match[0]));
}
}
}
}

$match[1] is string type.

array:2 [
  0 => "{loadmoduleid 134}"
  1 => "134"
]

The docblock is correct.

avatar Filefabrik
Filefabrik - comment - 29 Apr 2025

Please do something with wood.

Am 29. April 2025 19:09:40 UTC schrieb Quy Ton @.***>:

QuyTon left a comment (#45408)

$id is parsed here:

if (str_contains($article->text, '{loadmoduleid ')) {
// Find all instances of plugin and put in $matchesmodid for loadmoduleid
preg_match_all($regexmodid, $article->text, $matchesmodid, PREG_SET_ORDER);
// If no matches, skip this
if ($matchesmodid) {
foreach ($matchesmodid as $match) {
$id = trim($match[1]);
$output = $this->loadID($id);
// We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
if (($start = strpos($article->text, $match[0])) !== false) {
$article->text = substr_replace($article->text, $output, $start, \strlen($match[0]));
}
}
}
}

$match[1] is string type.

array:2 [
 0 => "{loadmoduleid 134}"
 1 => "134"
]

The docblock is correct.

--
Reply to this email directly or view it on GitHub:
#45408 (comment)
You are receiving this because you authored the thread.

Message ID: @.***>

avatar QuyTon QuyTon - change - 29 Apr 2025
Status New Closed
Closed_Date 0000-00-00 00:00:00 2025-04-29 19:38:22
Closed_By QuyTon
avatar QuyTon QuyTon - close - 29 Apr 2025
avatar QuyTon
QuyTon - comment - 29 Apr 2025

Closing as expected behavior. Thanks for reporting.

Add a Comment

Login with GitHub to post a comment