The file entity overrides the url() method to to provide a fake entity URL. This was done to to being able to expose the file URL in hal+json API requests. That implementation no longer relies on that, thanks to #2922487: Follow-up for #2910211: fix all deprecation warnings → .
Original issue description:
If a file entity is loaded, a call to link()
function ($entity->link()
), results in following exception:
Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template "canonical" found for the "file" entity type in Drupal\Core\Entity\Entity->urlInfo() (line 188 of /var/www/html/drupal8/core/lib/Drupal/Core/Entity/Entity.php).
Originally, this issue was about the fact that toUrl() did not implement that behavior and initial implementations and earlier patches attempted to replace that, in a dynamic way depending on having a canonical link template (which e.g. the file_entity project adds).
The new suggested proposed solution is to replace that with an explicit API method that also allows easy access to the root-relative file URL and even makes that the default.
An entity can not have a canonical link template, and every caller must support that.
See change record: https://www.drupal.org/node/3019830 →
$file->createFileUrl() == file_url_transform_relative(file_create_url($file->getFileUri()));
file_create_url($file->getFileUri()) == $file->createFileUrl(FALSE);
Fixed
8.7 ⚰️
file.module
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.