Bug description:
When theme registry is overwritten, the latter $info['includes'] is lost.
Suppose someA module defines the following hook_theme() function:
function someA_theme()
{
$path=\drupal::moduleHandler()->getModule("someA")->getPath();
return [
'yunke' => [
'variables' => ['title' => null, 'msg' => null],
'includes' => ["$path/someA_a.php","$path/someA_b.php"],
],
];
}
Another someB module defines the following hook_theme() function:
function someB_theme()
{
$path=\drupal::moduleHandler()->getModule("someB")->getPath();
return [
'yunke' => [
'variables' => ['title' => null, 'msg' => null],
'includes' => ["$path/someB_a.php","$path/someB_b.php"],
],
];
}
SomeB_theme () is executed after someA_theme(). In the result, someB_a.php and someB_b.php is missing.
This bug comes from:
\Drupal\Core\Theme\Registry::processExtension line 464-473
The fix is as follows:
if (isset($info['includes'])) {
foreach ($info['includes'] as $include_file) {
include_once $this->root . '/' . $include_file;
if(!in_array($include_file, $result[$hook]['includes']))
{
$result[$hook]['includes'][] = $include_file;
}
}
}