Skip to content
Snippets Groups Projects
Verified Commit d2392d13 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3373328 by catch, keshav.k, Ambient.Impact, longwave: ^10.1 CSS...

Issue #3373328 by catch, keshav.k, Ambient.Impact, longwave: ^10.1 CSS aggregation breaks during maintenance mode

(cherry picked from commit b63275fe)
parent c8c7c08a
No related branches found
No related tags found
20 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5627Issue #3261805: Field not saved when change of 0 on string start,!5427Issue #3338518: send credentials in ajax if configured in CORS settings.,!5395Issue #3387916 by fjgarlin, Spokje: Each GitLab job exposes user email,!5217Issue #3386607 by alexpott: Improve spell checking in commit-code-check.sh,!5064Issue #3379522 by finnsky, Gauravvvv, kostyashupenko, smustgrave, Chi: Revert...,!5040SDC ComponentElement: Transform slots scalar values to #plain_text instead of throwing an exception,!4958Issue #3392147: Whitelist IP for a Ban module.,!4894Issue #3280279: Add API to allow sites to opt in to upload SVG images in CKEditor 5,!4857Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!4856Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!4788Issue #3272985: RSS Feed header reverts to text/html when cached,!4716Issue #3362929: Improve 400 responses for broken/invalid image style routes,!4553Draft: Issue #2980951: Permission to see own unpublished comments in comment thread,!3679Issue #115801: Allow password on registration without disabling e-mail verification,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->),!925Issue #2339235: Remove taxonomy hard dependency on node module,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links
...@@ -133,10 +133,11 @@ public function processAttachments(AttachmentsInterface $response) { ...@@ -133,10 +133,11 @@ public function processAttachments(AttachmentsInterface $response) {
*/ */
protected function buildAttachmentsCommands(AjaxResponse $response, Request $request) { protected function buildAttachmentsCommands(AjaxResponse $response, Request $request) {
$ajax_page_state = $request->get('ajax_page_state'); $ajax_page_state = $request->get('ajax_page_state');
$maintenance_mode = defined('MAINTENANCE_MODE') || \Drupal::state()->get('system.maintenance_mode');
// Aggregate CSS/JS if necessary, but only during normal site operation. // Aggregate CSS/JS if necessary, but only during normal site operation.
$optimize_css = !defined('MAINTENANCE_MODE') && $this->config->get('css.preprocess'); $optimize_css = !$maintenance_mode && $this->config->get('css.preprocess');
$optimize_js = !defined('MAINTENANCE_MODE') && $this->config->get('js.preprocess'); $optimize_js = $maintenance_mode && $this->config->get('js.preprocess');
$attachments = $response->getAttachments(); $attachments = $response->getAttachments();
......
...@@ -311,17 +311,19 @@ protected function renderPlaceholders(HtmlResponse $response) { ...@@ -311,17 +311,19 @@ protected function renderPlaceholders(HtmlResponse $response) {
protected function processAssetLibraries(AttachedAssetsInterface $assets, array $placeholders) { protected function processAssetLibraries(AttachedAssetsInterface $assets, array $placeholders) {
$variables = []; $variables = [];
$maintenance_mode = defined('MAINTENANCE_MODE') || \Drupal::state()->get('system.maintenance_mode');
// Print styles - if present. // Print styles - if present.
if (isset($placeholders['styles'])) { if (isset($placeholders['styles'])) {
// Optimize CSS if necessary, but only during normal site operation. // Optimize CSS if necessary, but only during normal site operation.
$optimize_css = !defined('MAINTENANCE_MODE') && $this->config->get('css.preprocess'); $optimize_css = !$maintenance_mode && $this->config->get('css.preprocess');
$variables['styles'] = $this->cssCollectionRenderer->render($this->assetResolver->getCssAssets($assets, $optimize_css, $this->languageManager->getCurrentLanguage())); $variables['styles'] = $this->cssCollectionRenderer->render($this->assetResolver->getCssAssets($assets, $optimize_css, $this->languageManager->getCurrentLanguage()));
} }
// Print scripts - if any are present. // Print scripts - if any are present.
if (isset($placeholders['scripts']) || isset($placeholders['scripts_bottom'])) { if (isset($placeholders['scripts']) || isset($placeholders['scripts_bottom'])) {
// Optimize JS if necessary, but only during normal site operation. // Optimize JS if necessary, but only during normal site operation.
$optimize_js = !defined('MAINTENANCE_MODE') && !\Drupal::state()->get('system.maintenance_mode') && $this->config->get('js.preprocess'); $optimize_js = !$maintenance_mode && $this->config->get('js.preprocess');
[$js_assets_header, $js_assets_footer] = $this->assetResolver->getJsAssets($assets, $optimize_js, $this->languageManager->getCurrentLanguage()); [$js_assets_header, $js_assets_footer] = $this->assetResolver->getJsAssets($assets, $optimize_js, $this->languageManager->getCurrentLanguage());
$variables['scripts'] = $this->jsCollectionRenderer->render($js_assets_header); $variables['scripts'] = $this->jsCollectionRenderer->render($js_assets_header);
$variables['scripts_bottom'] = $this->jsCollectionRenderer->render($js_assets_footer); $variables['scripts_bottom'] = $this->jsCollectionRenderer->render($js_assets_footer);
......
...@@ -47,7 +47,10 @@ protected function setUp(): void { ...@@ -47,7 +47,10 @@ protected function setUp(): void {
// Configure 'node' as front page. // Configure 'node' as front page.
$this->config('system.site')->set('page.front', '/node')->save(); $this->config('system.site')->set('page.front', '/node')->save();
$this->config('system.performance')->set('js.preprocess', 1)->save(); $this->config('system.performance')
->set('js.preprocess', 1)
->set('css.preprocess', 1)
->save();
// Create a user allowed to access site in maintenance mode. // Create a user allowed to access site in maintenance mode.
$this->user = $this->drupalCreateUser(['access site in maintenance mode']); $this->user = $this->drupalCreateUser(['access site in maintenance mode']);
...@@ -73,8 +76,9 @@ public function testSiteMaintenance() { ...@@ -73,8 +76,9 @@ public function testSiteMaintenance() {
$this->assertSession()->linkByHrefExists(Url::fromRoute('user.login')->toString()); $this->assertSession()->linkByHrefExists(Url::fromRoute('user.login')->toString());
$this->drupalGet(Url::fromRoute('user.page')); $this->drupalGet(Url::fromRoute('user.page'));
// JS should be aggregated, so drupal.js is not in the page source. // Aggregation should be enabled, individual assets should not be rendered.
$this->assertSession()->elementNotExists('xpath', '//script[contains(@src, "/core/misc/drupal.js")]'); $this->assertSession()->elementNotExists('xpath', '//script[contains(@src, "/core/misc/drupal.js")]');
$this->assertSession()->elementNotExists('xpath', '//link[contains(@href, "/core/modules/system/css/components/align.module.css")]');
// Turn on maintenance mode. // Turn on maintenance mode.
$edit = [ $edit = [
'maintenance_mode' => 1, 'maintenance_mode' => 1,
...@@ -87,8 +91,9 @@ public function testSiteMaintenance() { ...@@ -87,8 +91,9 @@ public function testSiteMaintenance() {
$offline_message = $this->config('system.site')->get('name') . ' is currently under maintenance. We should be back shortly. Thank you for your patience.'; $offline_message = $this->config('system.site')->get('name') . ' is currently under maintenance. We should be back shortly. Thank you for your patience.';
$this->drupalGet(Url::fromRoute('user.page')); $this->drupalGet(Url::fromRoute('user.page'));
// JS should not be aggregated, so drupal.js is expected in the page source. // Aggregation should be disabled, individual assets should be rendered.
$this->assertSession()->elementExists('xpath', '//script[contains(@src, "/core/misc/drupal.js")]'); $this->assertSession()->elementExists('xpath', '//script[contains(@src, "/core/misc/drupal.js")]');
$this->assertSession()->elementExists('xpath', '//link[contains(@href, "/core/modules/system/css/components/align.module.css")]');
$this->assertSession()->pageTextContains($admin_message); $this->assertSession()->pageTextContains($admin_message);
$this->assertSession()->linkExists('Go online.'); $this->assertSession()->linkExists('Go online.');
$this->assertSession()->linkByHrefExists(Url::fromRoute('system.site_maintenance_mode')->toString()); $this->assertSession()->linkByHrefExists(Url::fromRoute('system.site_maintenance_mode')->toString());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment