Skip to content

Commit

Permalink
DP-34420: Fix error items in entity usage queue (#2708)
Browse files Browse the repository at this point in the history
* DP-34420: Fix error items in entity usage queue

* fix:

* fix

* fix

* fix

* Composer
  • Loading branch information
arthurbaghdas authored Nov 11, 2024
1 parent 8a9fd6c commit bee2caa
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 4 deletions.
41 changes: 41 additions & 0 deletions changelogs/DP-34420.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Write your changelog entry here. Every pull request must have a changelog yml file.
#
# Change types:
# #############################################################################
# You can use one of the following types:
# - Added: For new features.
# - Changed: For changes to existing functionality.
# - Deprecated: For soon-to-be removed features.
# - Removed: For removed features.
# - Fixed: For any bug fixes.
# - Security: In case of vulnerabilities.
#
# Format
# #############################################################################
# The format is crucial. Please follow the examples below. For reference, the requirements are:
# - All 3 parts are required and you must include "Type", "description" and "issue".
# - "Type" must be left aligned and followed by a colon.
# - "description" must be indented with 2 spaces followed by a colon
# - "issue" must be indented with 4 spaces followed by a colon.
# - "issue" is for the Jira ticket number only e.g. DP-1234
# - No extra spaces, indents, or blank lines are allowed.
#
# Example:
# #############################################################################
# Fixed:
# - description: Fixes scrolling on edit pages in Safari.
# issue: DP-13314
#
# You may add more than 1 description & issue for each type using the following format:
# Changed:
# - description: Automating the release branch.
# issue: DP-10166
# - description: Second change item that needs a description.
# issue: DP-19875
# - description: Third change item that needs a description along with an issue.
# issue: DP-19843
#
Fixed:
- description: Fix error items in entity usage queue.
issue: DP-34420
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@
"Trying to edit embedded entities causes uncaught exception (https://www.drupal.org/project/entity_embed/issues/3416512)": "https://git.drupalcode.org/project/entity_embed/-/merge_requests/39.diff",
"Alt text optional": "patches/DP-33643_entity_embed_alt_optional.patch"
},
"drupal/entity_usage": {
"InvalidArgumentException: The internal path component is invalid. (https://www.drupal.org/project/entity_usage/issues/3378832)": "https://git.drupalcode.org/project/entity_usage/-/merge_requests/55.diff"
},
"drupal/flag": {
"Flags problem with VBO module in views (2893259)": "https://www.drupal.org/files/issues/2020-07-25/flag-vbo-2893259-40.patch"
},
Expand Down
6 changes: 5 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ protected function queries() {
$term_ids[] = $term->id();
}

if (empty($term_ids)) {
return [];
}

$types = [
'advisory',
'binder',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ public function computeValue() {
$queries = $this->queries();
$i = 0;
foreach ($queries as $type => $query) {
foreach ($query->accessCheck(FALSE)->execute() as $id) {
$this->list[$i] = $this->createItem($i, ['target_id' => $id, 'target_type' => $type]);
$i++;
$result = $query->accessCheck(FALSE)->execute();
// Check if the query result is not empty before processing it.
if (!empty($result)) {
foreach ($result as $id) {
$this->list[$i] = $this->createItem($i, ['target_id' => $id, 'target_type' => $type]);
$i++;
}
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions docroot/modules/custom/mass_validation/mass_validation.module
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,42 @@ function mass_validation_get_title_from_uri($uri) {
}
}
}
// Add condition to the helper function to try finding the titles
// from other uri schemas as well even if it is a redirected one.
elseif (stripos($uri, 'internal:/') === 0) {
// Extract the path from the internal URI.
$internal_path = str_replace('internal:/', '', $uri);

// Convert the internal path to its system path.
$path_alias_manager = \Drupal::service('path_alias.manager');
$system_path = $path_alias_manager->getPathByAlias('/' . $internal_path);

// Check if the path corresponds to a node.
if (preg_match('/node\/(\d+)/', $system_path, $matches)) {
$nid = $matches[1];
$node = Node::load($nid);
if ($node) {
return $node->getTitle();
}
}
else {
$redirects = Drupal::entityTypeManager()->getStorage('redirect')->loadByProperties(['redirect_source__path' => $internal_path]);
if ($redirect = reset($redirects)) {
if ($target = $redirect->getRedirectUrl()->toString()) {
$system_path = $path_alias_manager->getPathByAlias($target);
// Check if the path corresponds to a node.
if (preg_match('/node\/(\d+)/', $system_path, $matches)) {
$nid = $matches[1];
$node = Node::load($nid);
if ($node) {
return $node->getTitle();
}
}
}
}
}
}

return NULL;
}

Expand Down

0 comments on commit bee2caa

Please sign in to comment.