Skip to content

Commit ba3613c

Browse files
authored
[5.4] Error page fix: prevent modules rendering in the incomplete Application (joomla#46272)
1 parent 1bab008 commit ba3613c

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

administrator/templates/atum/error_full.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,18 @@
8989
$themeModeAttr = $themeModes[$userColorScheme];
9090
} else {
9191
// Check parameters first (User and Template), then look if we have detected the OS color scheme (if it set to 'os')
92-
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
92+
$colorScheme = $app->getIdentity()?->getParam('colorScheme', $colorScheme) ?? 'os';
9393
$osColorScheme = $colorScheme === 'os' ? $app->getInput()->cookie->get('osColorScheme', '') : '';
9494
$themeModeAttr = ($themeModes[$colorScheme] ?? '') . ($themeModes[$osColorScheme] ?? '');
9595
}
9696
}
9797

98-
// @see administrator/templates/atum/html/layouts/status.php
99-
$statusModules = LayoutHelper::render('status', ['modules' => 'status']);
98+
// The module renderer will not work properly due to incomplete Application initialisation
99+
$renderModules = $app->getIdentity() && $app->getLanguage();
100+
101+
// @see administrator/templates/atum/html/layouts/status.php
102+
$statusModules = $renderModules ? LayoutHelper::render('status', ['modules' => 'status']) : '';
103+
100104
?>
101105
<!DOCTYPE html>
102106
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"<?php echo $themeModeAttr; ?>>
@@ -122,9 +126,13 @@
122126
<?php echo HTMLHelper::_('image', $logoBrandSmall, $logoBrandSmallAlt, ['class' => 'logo-collapsed', 'loading' => 'eager', 'decoding' => 'async'], false, 0); ?>
123127
</div>
124128
</div>
125-
<jdoc:include type="modules" name="title" />
129+
<?php if ($renderModules) : ?>
130+
<jdoc:include type="modules" name="title" />
131+
<?php endif; ?>
126132
</div>
127-
<?php echo $statusModules; ?>
133+
<?php if ($renderModules) : ?>
134+
<?php echo $statusModules; ?>
135+
<?php endif; ?>
128136
</header>
129137

130138
<div id="wrapper" class="d-flex wrapper<?php echo $hiddenMenu ? '0' : ''; ?>">
@@ -137,14 +145,18 @@
137145
<div id="container-collapse" class="container-collapse"></div>
138146
<div class="row">
139147
<div class="col-md-12">
140-
<jdoc:include type="modules" name="toolbar" style="none" />
148+
<?php if ($renderModules) : ?>
149+
<jdoc:include type="modules" name="toolbar" style="none" />
150+
<?php endif; ?>
141151
</div>
142152
</div>
143153
</div>
144154
<?php endif; ?>
145155
<section id="content" class="content">
146156
<jdoc:include type="message" />
147-
<jdoc:include type="modules" name="top" style="html5" />
157+
<?php if ($renderModules) : ?>
158+
<jdoc:include type="modules" name="top" style="html5" />
159+
<?php endif; ?>
148160
<div class="row">
149161
<div class="col-md-12">
150162
<h1><?php echo Text::_('JERROR_AN_ERROR_HAS_OCCURRED'); ?></h1>
@@ -179,14 +191,14 @@
179191
</p>
180192
</div>
181193

182-
<?php if ($this->countModules('bottom')) : ?>
194+
<?php if ($renderModules && $this->countModules('bottom')) : ?>
183195
<jdoc:include type="modules" name="bottom" style="html5" />
184196
<?php endif; ?>
185197
</div>
186198
</section>
187199
</div>
188200

189-
<?php if (!$hiddenMenu) : ?>
201+
<?php if ($renderModules && !$hiddenMenu) : ?>
190202
<button class="navbar-toggler toggler-burger collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebar-wrapper" aria-controls="sidebar-wrapper" aria-expanded="false" aria-label="<?php echo Text::_('JTOGGLE_SIDEBAR_MENU'); ?>">
191203
<span class="navbar-toggler-icon"></span>
192204
</button>
@@ -204,6 +216,8 @@
204216
</div>
205217
<?php endif; ?>
206218
</div>
207-
<jdoc:include type="modules" name="debug" style="none" />
219+
<?php if ($renderModules) : ?>
220+
<jdoc:include type="modules" name="debug" style="none" />
221+
<?php endif; ?>
208222
</body>
209223
</html>

administrator/templates/atum/error_login.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,17 @@
9393
$themeModeAttr = $themeModes[$userLastMode];
9494
} else {
9595
// Check parameters first (User and Template), then look if we have detected the OS color scheme (if it set to 'os')
96-
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
96+
$colorScheme = $app->getIdentity()?->getParam('colorScheme', $colorScheme) ?? 'os';
9797
$lastMode = $colorScheme === 'os' ? $app->getInput()->cookie->get('osColorScheme', '') : '';
9898
$themeModeAttr = ($colorScheme === 'os' ? $themeModes['os'] : '') . ($themeModes[$lastMode] ?? '');
9999
}
100100
}
101101

102+
// The module renderer will not work properly due to incomplete Application initialisation
103+
$renderModules = $app->getIdentity() && $app->getLanguage();
104+
102105
// @see administrator/templates/atum/html/layouts/status.php
103-
$statusModules = LayoutHelper::render('status', ['modules' => 'status']);
106+
$statusModules = $renderModules ? LayoutHelper::render('status', ['modules' => 'status']) : '';
104107
?>
105108
<!DOCTYPE html>
106109
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"<?php echo $themeModeAttr; ?>>
@@ -126,7 +129,9 @@
126129
<?php echo HTMLHelper::_('image', $logoBrandSmall, $logoBrandSmallAlt, ['class' => 'logo-collapsed', 'loading' => 'eager', 'decoding' => 'async'], false, 0); ?>
127130
</div>
128131
</div>
129-
<jdoc:include type="modules" name="title" />
132+
<?php if ($renderModules) : ?>
133+
<jdoc:include type="modules" name="title" />
134+
<?php endif; ?>
130135
</div>
131136
<?php echo $statusModules; ?>
132137
</header>
@@ -178,10 +183,14 @@
178183
<a href="<?php echo Uri::root(); ?>"><?php echo Text::_('TPL_ATUM_LOGIN_SIDEBAR_VIEW_WEBSITE'); ?></a>
179184
</div>
180185
<div id="sidebar">
181-
<jdoc:include type="modules" name="sidebar" style="body" />
186+
<?php if ($renderModules) : ?>
187+
<jdoc:include type="modules" name="sidebar" style="body" />
188+
<?php endif; ?>
182189
</div>
183190
</div>
184191
</div>
185-
<jdoc:include type="modules" name="debug" style="none" />
192+
<?php if ($renderModules) : ?>
193+
<jdoc:include type="modules" name="debug" style="none" />
194+
<?php endif; ?>
186195
</body>
187196
</html>

libraries/src/WebAsset/AssetItem/LangActiveAssetItem.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ public function __construct(
4545
parent::__construct($name, $uri, $options, $attributes, $dependencies);
4646

4747
// Prepare Uri depend from the active language
48-
$langTag = Factory::getApplication()->getLanguage()->getTag();
48+
$langTag = Factory::getApplication()->getLanguage()?->getTag();
4949
$client = $this->getOption('client');
5050

51+
if (!$langTag) {
52+
return;
53+
}
54+
5155
// Create Uri <client>/language/<langTag>/<langTag>.css
5256
if ($client) {
5357
$this->uri = $client . '/language/' . $langTag . '/' . $langTag . '.css';

templates/cassiopeia/error.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101

102102
// Get the error code
103103
$errorCode = $this->error->getCode();
104+
105+
// The module renderer will not work properly due to incomplete Application initialisation
106+
$renderModules = $app->getIdentity() && $app->getLanguage();
104107
?>
105108
<!DOCTYPE html>
106109
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
@@ -132,7 +135,7 @@
132135
</div>
133136
</div>
134137
<?php endif; ?>
135-
<?php if ($this->countModules('menu') || $this->countModules('search')) : ?>
138+
<?php if ($renderModules && ($this->countModules('menu') || $this->countModules('search'))) : ?>
136139
<div class="grid-child container-nav">
137140
<?php if ($this->countModules('menu')) : ?>
138141
<jdoc:include type="modules" name="menu" style="none" />
@@ -148,7 +151,7 @@
148151

149152
<div class="site-grid">
150153
<div class="grid-child container-component">
151-
<?php if ($this->countModules('error-' . $errorCode)) : ?>
154+
<?php if ($renderModules && $this->countModules('error-' . $errorCode)) : ?>
152155
<div class="container">
153156
<jdoc:include type="message" />
154157
<main>
@@ -202,14 +205,16 @@
202205
<?php endif; ?>
203206
</div>
204207
</div>
205-
<?php if ($this->countModules('footer')) : ?>
208+
<?php if ($renderModules && $this->countModules('footer')) : ?>
206209
<footer class="container-footer footer full-width">
207210
<div class="grid-child">
208211
<jdoc:include type="modules" name="footer" style="none" />
209212
</div>
210213
</footer>
211214
<?php endif; ?>
212215

213-
<jdoc:include type="modules" name="debug" style="none" />
216+
<?php if ($renderModules) : ?>
217+
<jdoc:include type="modules" name="debug" style="none" />
218+
<?php endif; ?>
214219
</body>
215220
</html>

0 commit comments

Comments
 (0)