Issue #3409895 by acbramley, longwave, smustgrave: [regression] toUrl can...
Issue #3409895 by acbramley, longwave, smustgrave: [regression] toUrl can incorrectly return edit-form url when another link template shares the canonical url
@@ -167,12 +167,13 @@ public function toUrl($rel = NULL, array $options = []) {
...
@@ -167,12 +167,13 @@ public function toUrl($rel = NULL, array $options = []) {
// Use the canonical link template by default, or edit-form if there is not
// Use the canonical link template by default, or edit-form if there is not
// a canonical one.
// a canonical one.
if($rel===NULL){
if($rel===NULL){
$rel_candidates=array_intersect(
if(isset($link_templates['canonical'])){
['canonical','edit-form'],
$rel='canonical';
array_flip($link_templates),
}
);
elseif(isset($link_templates['edit-form'])){
$rel=array_shift($rel_candidates);
$rel='edit-form';
if($rel===NULL){
}
else{
thrownewUndefinedLinkTemplateException("Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the '{$this->getEntityTypeId()}' entity type");
thrownewUndefinedLinkTemplateException("Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the '{$this->getEntityTypeId()}' entity type");
$this->expectExceptionMessage("Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the '".$this->entityTypeId."' entity type");
$this->expectExceptionMessage("Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the '".$this->entityTypeId."' entity type");
$entity->toUrl();
$entity->toUrl();
}
/**
* Tests the toUrl() method without specifying the $rel parameter.
*
* It should return the edit-form or canonical link templates by default if