Unable to run access_policy_update_9001

Created on 31 August 2023, about 1 year ago

Problem/Motivation

After upgrading to the beta1 release, I tried to run drush updb and encountered a consistent error with the new 9001 update:

>  [notice] Update started: access_policy_update_9001
>  [error]  Drupal\Core\Entity\EntityDefinitionUpdateManager::uninstallEntityType(): Argument #1 ($entity_type) must be of type Drupal\Core\Entity\EntityTypeInterface, null given, called in /home/ide/project/docroot/modules/contrib/access_policy/access_policy.install on line 17 
>  [error]  Update failed: access_policy_update_9001 
 [error]  Update aborted by: access_policy_update_9001 

I added a check in my local version for $content_access_policy around the uninstall, which resolved that error. Then... I got new errors, like:

>  [notice] Update started: access_policy_update_9001
>  [error]  Cannot add field 'crop_access_policy.delta': table doesn't exist. 
>  [error]  Update failed: access_policy_update_9001 
 [error]  Update aborted by: access_policy_update_9001 
 [error]  Finished performing updates. 

And...

>  [error]  Update failed: access_policy_post_update_revision_support 
>  [warning] Invalid placeholder (severity_level) with string: "%type: @message in %function (line %line of %file)." FormattableMarkup.php:245
>  [warning] Invalid placeholder (exception) with string: "%type: @message in %function (line %line of %file)." FormattableMarkup.php:245
 [error]  Update aborted by: access_policy_post_update_revision_support 
 [error]  Finished performing updates. 

I ended up adding an exclusion into the isSupportedEntityType() method of the AccessPolicyInformation class, but I suspect something more robust / less "crop"-specific is needed.

Proposed resolution

Resolve the errors to smooth the upgrade path for sites that previously used an alpha version.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada mandclu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mandclu
  • @mandclu opened merge request.
  • Status changed to Needs work about 1 year ago
  • πŸ‡¨πŸ‡¦Canada mandclu

    In my specific case the upgrade failed on the crop entity type, but I suspect there would be others that could trigger a similar failure (e.g. storage?) so it probably needs some refactoring of the isSupportedEntityType() method to be more reliable.

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States partdigital

    Hi @mandclu that's a nasty bug, thanks for catching it and creating the MR!

    I've pushed up some changes to it. It basically adds some checks to see if tables exist before attempting to migrate data.

    I've also rolled back some of the support for other entity types. Prior to beta1, it required that entities had a canonical route. I removed that in order to support paragraphs. That's what caused the Crop issue since it fulfilled all the requirements even though it's not really appropriate. I've still maintained paragraphs as an exception.

    I'm going to run this through some more tests, if I don't find any issues I'll release it with beta2 this week.

  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States partdigital
  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States partdigital
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024