Reproduce:

Edit a node, the path being /node/{nid}/edit

An entry will be written as a notice in the logs:

Easy Breadcrumb could not determine the title to use for /node/{node}/edit

It's not appropriate to be doing this. Not sure if there are other (similar) paths that need to be excluded as well at this?

Comments

klidifia created an issue. See original summary.

martinma’s picture

Category: Task » Bug report
Priority: Normal » Minor
Status: Active » Needs work

For me its a bug, because such misleading message in dblog are confusing people ...

In my dblog there are some dozens messages of this. It seems, all messages are in conjunction with edit path.

greg boggs’s picture

When the getTitle method fails, Easy Breadcrumb logs the failure. The next step here is to either edit Easy Breadcrumb code so that it can get the title from that route, or to fix the core node edit form so that it sets a title callback. Patches, are of course, welcome!

~G

deaom’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB

My attempt at resolving this is in the attached patch. It seems it goes two times through the code of getting the title and the first time, title is null on the node/{node}/edit path, so the notice is displayed, but the second time, the title can be obtained, because the route changes to node/{node}. So added a check if the path is node/{node}/edit do not get the title, because it does not exist yet.

pgrandeg’s picture

As I can see, #4 is right and there is a redirection, but the paths I found are: "/node/{node}" and "/node" instead of /node/{node}/edit.
So, should be the patch path changed from "/node/{node}/edit" to "/node"?

nace_fr’s picture

Status: Needs review » Reviewed & tested by the community

Hi. I was able to reproduce the issue and tested patch from #4. It applied successfully and solved the issue.
Also I have checked the #5 comment and I don't think the patch should be changed. I checked and paths are /node/{node}/edit and ‌/node/{node}, so patch from #4 solves the issue and doesn't need to be changed.
Changing status to RTBC.

greg boggs’s picture

To solve this Easy Breadcrumb should print the title. I don't know why node edit forms don't have title callbacks, but this is probably a core bug. We can either work around it by getting the title with some hacky code, or open an issue on node and get the title set on the form.

I see a page title when I load the page, so I'm sure the title is on the page somehow :)

greg boggs’s picture

Status: Reviewed & tested by the community » Needs work
oriol_e9g’s picture

Title: Unnecessary processing and logging of variable routes » Easy Breadcrumb could not determine the title in node edit

Better issue title to improve issue discoverability. Same problem, I agree that not report the warning is a temporally fix that not solves the bug.

oriol_e9g’s picture

Extra. The patch in #4 only works if you not use an alternative path and only fix nodes, not other entities. For example, if you alter the path to edit the node:

Will fail again:

    if ($route = $collection->get('entity.node.edit_form')) {
      $route->setPath('/new-route/{node}/edit');
    }

The final solution should be fix in getTitleString or fix titleResolver in core that only looks for '_title_callback' or '_title' on the route. Core titleResolver return false in all routes without _title or _title_callback.

oriol_e9g’s picture

StatusFileSize
new1.01 KB

Ok. This is my patch to catch the title in node.edit instead of hide the warning, works in my site.

We can add this temporally fix for 'node.edit' and wait for a core solution in titleResolver, or try a more general solution to catch title in all entity forms if resolver not return a title. The second aproach is more general but it's harder and needs to inject form builder to retrive the title.

oriol_e9g’s picture

Investigating I have seen that pages can provide a title in $main_content['#title'] and this title can override the title provided by titleResolver. That's the reason why some pages like 'node.edit' not provide a title through routing+titleResolver and uses directly $main_content['#title'].

Ideally, to solve this problem we have to see first $main_content['#title'] and if it's empty use titleResolver to get the page title. Using the same logic used in Drupal\Core\Render\MainContent\HtmlRenderer::prepare

// Determine the title: use the title provided by the main content if any,
// otherwise get it from the routing information.
$get_title = function (array $main_content) use ($request, $route_match) {
  return isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject());
};
oriol_e9g’s picture

StatusFileSize
new1.86 KB

I have done a patch to set a title for core routes that fail, all comes from: _entity_form: "{$entity_type_id}.{$operation}".

This is not the final solution, but it may be useful for someone.

oriol_e9g’s picture

greg boggs’s picture

Status: Needs work » Reviewed & tested by the community

  • Greg Boggs committed f232c80 on 8.x-1.x authored by oriol_e9g
    Issue #3071782 by oriol_e9g, DeaOm: Easy Breadcrumb could not determine...
greg boggs’s picture

Status: Reviewed & tested by the community » Fixed
kvantstudio’s picture

After uninstal custom content entity i have error. Path #13 not resolve the problem.

InvalidArgumentException: The controller for URI "" is not callable. in Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition() (line 75 of core\lib\Drupal\Core\Controller\ControllerResolver.php).

Trace

Drupal\Core\Controller\TitleResolver->getTitle() (Line: 602)
Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->getTitleString() (Line: 437)
Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (Line: 83)
Drupal\Core\Breadcrumb\BreadcrumbManager->build() (Line: 72)
Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 171)
oriol_e9g’s picture

This is a diferente bug, it's failing in title resolver call before the new code. This should be addresed in other issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.