Skip to content
Snippets Groups Projects
Commit 996b3578 authored by catch's avatar catch
Browse files

Issue #3210372 by pfrenssen, claudiu.cristea: Fatal error when passing...

Issue #3210372 by pfrenssen, claudiu.cristea: Fatal error when passing non-existing ID to entity parameter converter
parent c2103890
No related branches found
No related tags found
25 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1896Issue #2940605: Can only intentionally re-render an entity with references 20 times,!1101Issue #2412669 by claudiu.cristea, Julfabre, sidharrell, catch, daffie,...,!1039Issue #2556069 by claudiu.cristea, bnjmnm, lauriii, pfrenssen, Tim Bozeman,...,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!1012Issue #3226887: Hreflang on non-canonical content pages,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!825Issue #3211838 by mondrake, longwave: Convert assertions involving use of...,!795Issue #3212005 by guilhermevp, tedbow, phenaproxima: Add @throws docs to...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!748#1091852 Display Bug when using #states (Forms API) with Ajax Request,!731Add a new recipe to Umami demo - Chicken souvlaki and couscous,!730Issue #3211810 by alexpott, xjm, Spokje, Amber Himes Matz, Kristen Pol,...,!700Issue #3185165 by Spokje, vipin.mittal18, Suresh Prabhu Parkala, lauriii,...,!594Put each entity type table into a details element on admin/config/regional/content-language,!592Issue #2957953: Editing menus user-experience has regressed,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!512Issue #3207771: Menu UI node type form documentation points to non-existent function,!485Sets the autocomplete attribute for username/password input field on login form.,!449Issue #2784233: Allow multiple vocabularies in the taxonomy filter,!231Issue #2671162: summary text wysiwyg patch working fine on 9.2.0-dev,!43Resolve #3173180: Add UI for 'loading' html attribute to images,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Core\ParamConverter; namespace Drupal\Core\ParamConverter;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Context\Context; use Drupal\Core\Plugin\Context\Context;
...@@ -142,7 +143,11 @@ public function convert($value, $definition, $name, array $defaults) { ...@@ -142,7 +143,11 @@ public function convert($value, $definition, $name, array $defaults) {
} }
$entity = $this->entityRepository->getCanonical($entity_type_id, $value, $contexts); $entity = $this->entityRepository->getCanonical($entity_type_id, $value, $contexts);
if (!empty($definition['bundle']) && !in_array($entity->bundle(), $definition['bundle'], TRUE)) { if (
!empty($definition['bundle']) &&
$entity instanceof EntityInterface &&
!in_array($entity->bundle(), $definition['bundle'], TRUE)
) {
return NULL; return NULL;
} }
......
...@@ -85,6 +85,10 @@ public function testRouteParamWithBundleDefinition(): void { ...@@ -85,6 +85,10 @@ public function testRouteParamWithBundleDefinition(): void {
$converted = $converter->convert($entity3->id(), $definition, 'qux', []); $converted = $converter->convert($entity3->id(), $definition, 'qux', []);
$this->assertNull($converted); $this->assertNull($converted);
// A non-existing entity returns NULL.
$converted = $converter->convert('some-non-existing-entity-id', $definition, 'qux', []);
$this->assertNull($converted);
$definition = [ $definition = [
'type' => 'entity:entity_test', 'type' => 'entity:entity_test',
]; ];
...@@ -96,6 +100,8 @@ public function testRouteParamWithBundleDefinition(): void { ...@@ -96,6 +100,8 @@ public function testRouteParamWithBundleDefinition(): void {
$this->assertSame($entity2->id(), $converted->id()); $this->assertSame($entity2->id(), $converted->id());
$converted = $converter->convert($entity3->id(), $definition, 'qux', []); $converted = $converter->convert($entity3->id(), $definition, 'qux', []);
$this->assertSame($entity3->id(), $converted->id()); $this->assertSame($entity3->id(), $converted->id());
$converted = $converter->convert('some-non-existing-entity-id', $definition, 'qux', []);
$this->assertNull($converted);
} }
} }
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