NCIOCPL / cgov-digital-platform

The Cancer.gov Digital Communications Platform
GNU General Public License v2.0
11 stars 33 forks source link

Regenerate URLs fails with a PHP error. #4339

Open blairlearn opened 1 month ago

blairlearn commented 1 month ago

Issue description

The "Regenerate URLs" is unable to run to completion, stalling out midway through the process. Looking into the error logs, this appears to be due to a PHP error.

ESTIMATE TBD

Steps to reproduce the issue

NOTE: This may requires a copy of an ACSF database.

  1. Login as a user with the site_admin role.
  2. Navigate to Configuration > Search and metadata > Regenerate Urls.
  3. Select Media and Content.
  4. Select Update the URL alias for paths having an old URL alias. (Choosing Regenerate URL aliases for all paths will also work, but is likely to take longer.)
  5. Click Update.

What's the expected result?

What's the actual result?

The watchdog log will contain a message similar to https://www-cms-test.cancer.gov|1714750770|php|23.52.15.43|https://www-cms-test.cancer.gov/batch?_format=json&id=2791&op=do|https://www-cms-test.cancer.gov/batch?id=2791&op=start|46||TypeError: Drupal\Core\Entity\EntityRepository::getTranslationFromContext(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in /mnt/www/html/ncigov01test/docroot/profiles/custom/cgov_site/modules/custom/cgov_blog/cgov_blog.tokens.inc on line 88 in Drupal\Core\Entity\EntityRepository->getTranslationFromContext() (line 93 of /mnt/www/html/ncigov01test/docroot/core/lib/Drupal/Core/Entity/EntityRepository.php). request_id="v-54803fc0-0963-11ef-860f-cf6b27598d09"

Additional details / screenshot

Related Tickets

blairlearn commented 1 month ago

The error appears to be due to the lack of a "guard" if for the call to getTranslationFromContext for the scenario where a blog post has no series.

This is a lack of error checking, but the upstream error is caused by #4341.