- Issue created by @sushyl@gmail.com
- 🇮🇳India sushyl@gmail.com Pune
My bad, this was happening due to a patch applied on my site.
I am getting the following error when I use Drupal\entity_usage\EntityUsage->listSources().
The website encountered an unexpected error. Try again later.<br><br><em class="placeholder">TypeError</em>: Drupal\entity_usage\EntityUsage::getSourceEntityLink(): Argument #1 ($source_entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in /var/www/html/docroot/modules/contrib/entity_usage/src/EntityUsage.php on line 268 in <em class="placeholder">Drupal\entity_usage\EntityUsage->getSourceEntityLink()</em> (line <em class="placeholder">416</em> of <em class="placeholder">modules/contrib/entity_usage/src/EntityUsage.php</em>). <pre class="backtrace">Drupal\entity_usage\EntityUsage->listSources(Object) (Line: 56)
I noticed that in the listSources() method, the source entity id was found by the query but when it tries to fetch sourse entity itself, the source entity is NULL.
$source_entity = $type_storage->load($usage->source_id);
Add a check to confirm the entity is an instance of EntityInterface before creating source entity link.
Active
Code
My bad, this was happening due to a patch applied on my site.