Skip to content

Commit

Permalink
Merge pull request #891 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
Main -> Develop - v2.16.0
  • Loading branch information
orakili committed Sep 18, 2024
2 parents 0359e9d + ecc3914 commit 26cb30a
Show file tree
Hide file tree
Showing 22 changed files with 1,208 additions and 492 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/composer-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
id: update-action
uses: UN-OCHA/actions/composer-update@main
with:
aws_access_key_id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
github_access_token: ${{ secrets.PAT }}
patch_branch: 'develop'
patch_maintainers: ${{ vars.DRUPAL_MAINTAINERS }}
patch_branch: ${{ github.head_ref || github.ref_name }}
patch_maintainers: ${{ secrets.DRUPAL_MAINTAINERS }}
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel_name: ${{ vars.SLACK_CHANNEL }}
255 changes: 204 additions & 51 deletions PATCHES/core--drupal--3467860-aggregation.patch
Original file line number Diff line number Diff line change
@@ -1,37 +1,189 @@
diff --git a/core/core.libraries.yml b/core/core.libraries.yml
index d6136b22aa..8151d7e33e 100644
--- a/core/core.libraries.yml
+++ b/core/core.libraries.yml
@@ -823,8 +823,7 @@ drupal.touchevents-test:
drupal.vertical-tabs:
version: VERSION
js:
- # Load before core/drupal.collapse.
- misc/vertical-tabs.js: { weight: -1 }
+ misc/vertical-tabs.js: {}
css:
component:
misc/vertical-tabs.css: {}
diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php
index fcd294a649..8f29d18be5 100644
index fcd294a649..8182f2cc59 100644
--- a/core/lib/Drupal/Core/Asset/AssetResolver.php
+++ b/core/lib/Drupal/Core/Asset/AssetResolver.php
@@ -235,6 +235,27 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize, ?Languag
$theme_info = $this->themeManager->getActiveTheme();
$libraries_to_load = $this->getLibrariesToLoad($assets);

+ // Remove all libraries without JS as we can ignore.
+ foreach ($libraries_to_load as $key => $library) {
+ [$extension, $name] = explode('/', $library, 2);
+ $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
+ if (empty($definition['js'])) {
+ unset($libraries_to_load[$key]);
+ }
+ }
@@ -91,31 +91,77 @@ public function __construct(LibraryDiscoveryInterface $library_discovery, Librar
* $assets = new AttachedAssets();
* $assets->setLibraries(['core/a', 'core/b', 'core/c']);
* $assets->setAlreadyLoadedLibraries(['core/c']);
- * $resolver->getLibrariesToLoad($assets) === ['core/a', 'core/b', 'core/d']
+ * $resolver->getLibrariesToLoad($assets, 'js') === ['core/a', 'core/b', 'core/d']
* @endcode
*
+ * The attached assets tend to be in the order that libraries were attached
+ * during a request. To minimize the number of unique aggregated asset URLs
+ * and files, we normalize the list by filtering out libraries that don't
+ * include the asset type being built as well as ensuring a reliable order of
+ * the libraries based on their dependencies.
+ *
* @param \Drupal\Core\Asset\AttachedAssetsInterface $assets
* The assets attached to the current response.
+ * @param string|null $asset_type
+ * The asset type to load.
*
* @return string[]
* A list of libraries and their dependencies, in the order they should be
* loaded, excluding any libraries that have already been loaded.
*/
- protected function getLibrariesToLoad(AttachedAssetsInterface $assets) {
- // The order of libraries passed in via assets can differ, so to reduce
- // variation, first normalize the requested libraries to the minimal
- // representative set before then expanding the list to include all
- // dependencies.
+ protected function getLibrariesToLoad(AttachedAssetsInterface $assets, ?string $asset_type = NULL) {
// @see Drupal\FunctionalTests\Core\Asset\AssetOptimizationTestUmami
// @todo https://www.drupal.org/project/drupal/issues/1945262
- $libraries = $assets->getLibraries();
- if ($libraries) {
- $libraries = $this->libraryDependencyResolver->getMinimalRepresentativeSubset($libraries);
+ $libraries_to_load = array_diff(
+ $this->libraryDependencyResolver->getLibrariesWithDependencies($assets->getLibraries()),
+ $this->libraryDependencyResolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries())
+ );
+ if ($asset_type) {
+ $libraries_to_load = $this->filterLibrariesByType($libraries_to_load, $asset_type);
}
- return array_diff(
- $this->libraryDependencyResolver->getLibrariesWithDependencies($libraries),
+
+ // Need to ensure that the order of the JavaScript we want to include is
+ // based on the minimal representative subset in a specific order. This is
+ // needed to ensure that groups produced here and groups produced from
+ // generating optimized scripts are the same. If we don't get the same
+ // groups in the same order, user will not fetch the correct scripts.
+ // We now have a complete list of libraries requested. However, this list
+ // could be in any order depending on when libraries were attached during
+ // the page request, which can result in different file contents and URLs
+ // even for an otherwise identical set of libraries. To ensure that any
+ // particular set of libraries results in the same aggregate URL, sort the
+ // libraries, then generate the minimum representative set again.
+ sort($libraries_to_load);
+ $minimum_libraries = $this->libraryDependencyResolver->getMinimalRepresentativeSubset($libraries_to_load);
+ $libraries_to_load = array_diff(
+ $this->libraryDependencyResolver->getLibrariesWithDependencies($minimum_libraries),
+ $this->libraryDependencyResolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries())
+ );
$this->libraryDependencyResolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries())
);
+
+ // Now remove any libraries without the relevant asset type again, since
+ // they have been brought back in via dependencies.
+ if ($asset_type) {
+ $libraries_to_load = $this->filterLibrariesByType($libraries_to_load, $asset_type);
+ }
+
+ return $libraries_to_load;
+ }
+
+ /**
+ * Filter libraries that don't contain an asset type.
+ *
+ * @param array $libraries
+ * An array of library definitions.
+ * @param string $asset_type
+ * The type of asset, either 'js' or 'css'.
+ *
+ * @return array
+ * The filtered libraries array.
+ */
+ protected function filterLibrariesByType(array $libraries, string $asset_type): array {
+ foreach ($libraries as $key => $library) {
+ [$extension, $name] = explode('/', $library, 2);
+ $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
+ if (empty($definition[$asset_type])) {
+ unset($libraries[$key]);
+ }
+ }
+ return $libraries;
}

/**
@@ -125,15 +171,9 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize, ?Langua
if (!$assets->getLibraries()) {
return [];
}
- $libraries_to_load = $this->getLibrariesToLoad($assets);
- foreach ($libraries_to_load as $key => $library) {
- [$extension, $name] = explode('/', $library, 2);
- $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
- if (empty($definition['css'])) {
- unset($libraries_to_load[$key]);
- }
- }
- $libraries_to_load = array_values($libraries_to_load);
+ // Get the complete list of libraries to load including dependencies.
+ $libraries_to_load = $this->getLibrariesToLoad($assets, 'css');
+
if (!$libraries_to_load) {
return [];
}
@@ -157,7 +197,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize, ?Langua
'preprocess' => TRUE,
];

- foreach ($libraries_to_load as $key => $library) {
+ foreach ($libraries_to_load as $library) {
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
foreach ($definition['css'] as $options) {
@@ -211,7 +251,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize, ?Langua
protected function getJsSettingsAssets(AttachedAssetsInterface $assets) {
$settings = [];

- foreach ($this->getLibrariesToLoad($assets) as $library) {
+ foreach ($this->getLibrariesToLoad($assets, 'js') as $library) {
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
if (isset($definition['drupalSettings'])) {
@@ -233,24 +273,19 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize, ?Languag
$language = $this->languageManager->getCurrentLanguage();
}
$theme_info = $this->themeManager->getActiveTheme();
- $libraries_to_load = $this->getLibrariesToLoad($assets);
+
+ // Get the complete list of libraries to load including dependencies.
+ $libraries_to_load = $this->getLibrariesToLoad($assets, 'js');

// Collect all libraries that contain JS assets and are in the header.
// Also remove any libraries with no JavaScript from the libraries to
// load.
- // Also remove any libraries with no JavaScript from the libraries to
- // load.
$header_js_libraries = [];
foreach ($libraries_to_load as $key => $library) {
[$extension, $name] = explode('/', $library, 2);
$definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
- if (empty($definition['js'])) {
- unset($libraries_to_load[$key]);
- continue;
- }
if (!empty($definition['header'])) {
$header_js_libraries[] = $library;
}
}
- $libraries_to_load = array_values($libraries_to_load);

// If all the libraries to load contained only CSS, there is nothing further
// to do here, so return early.
diff --git a/core/modules/ckeditor5/ckeditor5.libraries.yml b/core/modules/ckeditor5/ckeditor5.libraries.yml
index 70ebcf5170..73d3e7ea00 100644
--- a/core/modules/ckeditor5/ckeditor5.libraries.yml
+++ b/core/modules/ckeditor5/ckeditor5.libraries.yml
@@ -99,6 +99,7 @@ internal.drupal.ckeditor5.filter.admin:
- core/once
- core/drupal.ajax
- core/drupalSettings
+ - core/drupal.vertical-tabs

internal.drupal.ckeditor5.table:
css:
diff --git a/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php b/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php
index d5e2190439..4630ad647d 100644
index 31340bf472..a7cec55b3e 100644
--- a/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php
@@ -8,6 +8,8 @@
Expand Down Expand Up @@ -140,19 +292,24 @@ index d5e2190439..4630ad647d 100644
$this->moduleHandler = $this->createMock('\Drupal\Core\Extension\ModuleHandlerInterface');
$this->themeManager = $this->createMock('\Drupal\Core\Theme\ThemeManagerInterface');
$active_theme = $this->getMockBuilder('\Drupal\Core\Theme\ActiveTheme')
@@ -169,22 +194,12 @@ protected function setUp(): void {
@@ -169,22 +194,17 @@ protected function setUp(): void {
* @dataProvider providerAttachedCssAssets
*/
public function testGetCssAssets(AttachedAssetsInterface $assets_a, AttachedAssetsInterface $assets_b, $expected_css_cache_item_count): void {
- $this->libraryDiscovery->expects($this->any())
- ->method('getLibraryByName')
- ->willReturnOnConsecutiveCalls(
- $this->libraries['drupal'],
- $this->libraries['llama'],
- $this->libraries['llama'],
- $this->libraries['piggy'],
- $this->libraries['piggy'],
- );
- $map = [
- ['core', 'drupal', $this->libraries['drupal']],
- ['core', 'jquery', $this->libraries['jquery']],
- ['llama', 'css', $this->libraries['llama']],
- ['piggy', 'css', $this->libraries['piggy']],
- ];
- $this->libraryDiscovery->method('getLibraryByName')
- ->willReturnMap($map);
-
+ $this->libraryDiscovery->expects($this->any())
+ ->method('getLibraryByName')
+ ->willReturnCallback(function ($extension, $name) {
+ return $this->libraries[$extension . '/' . $name];
+ });
$this->assetResolver->getCssAssets($assets_a, FALSE, $this->english);
$this->assetResolver->getCssAssets($assets_b, FALSE, $this->english);
$this->assertCount($expected_css_cache_item_count, $this->cache->getAllCids());
Expand All @@ -163,30 +320,26 @@ index d5e2190439..4630ad647d 100644
return [
'one js only library and one css only library' => [
(new AttachedAssets())->setAlreadyLoadedLibraries([])->setLibraries(['core/drupal']),
@@ -204,16 +219,6 @@ public static function providerAttachedCssAssets() {
@@ -204,13 +224,11 @@ public static function providerAttachedCssAssets() {
* @dataProvider providerAttachedJsAssets
*/
public function testGetJsAssets(AttachedAssetsInterface $assets_a, AttachedAssetsInterface $assets_b, $expected_js_cache_item_count, $expected_multilingual_js_cache_item_count): void {
- $this->libraryDiscovery->expects($this->any())
- ->method('getLibraryByName')
- ->willReturnOnConsecutiveCalls(
- $this->libraries['drupal'],
- $this->libraries['drupal'],
- $this->libraries['jquery'],
- $this->libraries['drupal'],
- $this->libraries['drupal'],
- $this->libraries['jquery'],
- );
- $map = [
- ['core', 'drupal', $this->libraries['drupal']],
- ['core', 'jquery', $this->libraries['jquery']],
- ];
- $this->libraryDiscovery->method('getLibraryByName')
- ->willReturnMap($map);
-
+ $this->libraryDiscovery->expects($this->any())
+ ->method('getLibraryByName')
+ ->willReturnCallback(function ($extension, $name) {
+ return $this->libraries[$extension . '/' . $name];
+ });
$this->assetResolver->getJsAssets($assets_a, FALSE, $this->english);
$this->assetResolver->getJsAssets($assets_b, FALSE, $this->english);
$this->assertCount($expected_js_cache_item_count, $this->cache->getAllCids());
@@ -236,11 +241,37 @@ public static function providerAttachedJsAssets() {
(new AttachedAssets())->setAlreadyLoadedLibraries([])->setLibraries(['core/drupal'])->setSettings(['currentTime' => $time]),
(new AttachedAssets())->setAlreadyLoadedLibraries([])->setLibraries(['core/drupal', 'core/jquery'])->setSettings(['currentTime' => $time]),
2,
- 3,
+ 4,
],
@@ -238,6 +256,32 @@ public static function providerAttachedJsAssets() {
];
}

Expand Down
17 changes: 17 additions & 0 deletions PATCHES/openid_connect-3390668-6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/src/Controller/OpenIDConnectRedirectController.php b/src/Controller/OpenIDConnectRedirectController.php
index 3271c54..a4fc578 100644
--- a/src/Controller/OpenIDConnectRedirectController.php
+++ b/src/Controller/OpenIDConnectRedirectController.php
@@ -295,7 +295,11 @@ class OpenIDConnectRedirectController implements ContainerInjectionInterface, Ac
if ($op === 'login') {
$success = $this->openIDConnect->completeAuthorization($openid_connect_client, $tokens);

- if (!$success) {
+ // We need the full user object to check if the account is blocked.
+ $account = $this->currentUser->getAccount();
+
+ // Display an error if the current user is blocked and not anonymous.
+ if (!$success && $this->currentUser->id() && !$account->isBlocked()) {
$this->messenger()->addError($this->t('Logging in with @provider could not be completed due to an error.', $provider_param));
}
}
13 changes: 13 additions & 0 deletions PATCHES/openid_connect_windows_aad-3346603-5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/Plugin/OpenIDConnectClient/WindowsAad.php b/src/Plugin/OpenIDConnectClient/WindowsAad.php
index 8845843..6431581 100644
--- a/src/Plugin/OpenIDConnectClient/WindowsAad.php
+++ b/src/Plugin/OpenIDConnectClient/WindowsAad.php
@@ -318,7 +318,7 @@ as the mapping between Azure AD accounts and Drupal users.<br/>
case 2:
$v2 = str_contains($endpoints['token'], '/oauth2/v2.0/');
if (!$v2) {
- $request_options['form_params']['resource'] = 'https://graph.microsoft.com';
+ $request_options['form_params']['scope'] = 'https://graph.microsoft.com/.default';
}
break;
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"drupal/geofield": "^1.52",
"drupal/google_tag": "^1.6",
"drupal/guidelines": "^1.0",
"drupal/honeypot": "^2.1",
"drupal/honeypot": "2.1.4",
"drupal/imageapi_optimize_binaries": "^1.0@beta",
"drupal/imageapi_optimize_webp": "^2.0",
"drupal/imagemagick": "^4.0",
Expand All @@ -50,6 +50,8 @@
"drupal/memcache": "^2.5",
"drupal/metatag": "^1.22",
"drupal/mimemail": "^1.0@alpha",
"drupal/openid_connect": "dev-3.x",
"drupal/openid_connect_windows_aad": "^2.0@beta",
"drupal/pathauto": "^1.11",
"drupal/redirect": "^1.8",
"drupal/seckit": "^2.0",
Expand Down
Loading

0 comments on commit 26cb30a

Please sign in to comment.