-
TomTech β
authored 3ed7ba3d on 8.x-2.x
Issue #2920481 by bojanz, jsacksick, rszrama, TomTech: Remove the...
-
TomTech β
authored 3ed7ba3d on 8.x-2.x
- Status changed to Fixed
almost 2 years ago 5:12am 23 March 2023 - πΊπΈUnited States TomTech
The dependency on recurring_period has been removed.
While we initially thought this would be a breaking change, it appears that swapping the plugin type on the field definition seamlessly works, as we kept the same machine names for the plugins.
There was some thought we could also remove the dependency on the interval module. While we removed the plugin invocations, and now use the commerce core Interval class, there are 3 uses of the interval field that prevent us from completely removing the module currently. Luckily, the module is compatible with D10, so with the removal of the recurring_period dependency, we commerce_license should now be installable with D10.
Some considerations given the change in the period plugin:
1. If you created a custom recurring_period plugin, you'll need to convert it to a commerce_license_period plugin. This should simply be changing the annotation name and the class you are extending.
2. Several methods on the recurring period plugin were never used by commerce license, and were therefore not implemented in the commerce license period plugins.These were the deprecated calculateDate, along with the 4 getPeriodXXX() methods. If you made use of these, then you would need to re implement this calls.
3. The commerce interval class does not directly support the periods: seconds, fortnights, and quarters. We have handled fortnight and quarter consistent with the interval module. For seconds, we are rounding to the nearest minute, with a minimum value of 1. - πΊπΈUnited States rclemings
I'm getting a WSOD after updating to 8.x-2.0-beta2+30-dev (composer update drupal/commerce_license). Errors are below.
I can't find anything that's calling RecurringPeriodManager -- i.e. "grep -r RecurringPeriodManager web/" yields no results. Restoring the recurring_period module fixes the problem. Rebuilding the cache does not. No updates are pending. Core is Drupal 9.5.5.
Ideas?
Drupal\Core\Extension\Exception\UnknownExtensionException: The module recurring_period does not exist. in Drupal\Core\Extension\ExtensionList->get() (line 265 of /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/Extension/ExtensionList.php)
Drupal\Core\Extension\Exception\UnknownExtensionException: The module recurring_period does not exist or is not installed. in Drupal\Core\Extension\ExtensionList->getExtensionInfo() (line 346 of /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/Extension/ExtensionList.php).
Error: Class "Drupal\recurring_period\RecurringPeriodManager" not found in Drupal\Component\DependencyInjection\Container->createService() (line 259 of /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Component/DependencyInjection/Container.php) #0 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService() #1 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\Component\DependencyInjection\Container->get() #2 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(273): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters() #3 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService() #4 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/modules/contrib/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php(180): Drupal\Component\DependencyInjection\Container->get() #5 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\admin_toolbar_tools\Controller\ToolbarController::create() #6 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/Controller/ControllerResolver.php(117): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() #7 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/Controller/ControllerResolver.php(69): Drupal\Core\Controller\ControllerResolver->createController() #8 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/Controller/ControllerResolver.php(85): Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition() #9 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php(38): Drupal\Core\Controller\ControllerResolver->getController() #10 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/vendor/symfony/http-kernel/HttpKernel.php(152): Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController() #11 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #12 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle() #13 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #14 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #15 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #16 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #17 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/modules/contrib/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #18 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle() #19 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #20 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle() #21 /home/xxxx/domains/xxxx.xxxx.xxx/public_html/web/index.php(19): Drupal\Core\DrupalKernel->handle() #22 {main}
- πΊπΈUnited States TomTech
@rclemings, thanks for the feedback and sorry you encountered an issue.
Can you try the following steps and see if it resolves it cleanly?
- temporarily add recurring to your composer, e.g.
composer require drupal/recurring_period
- update to the latest dev of commerce_license, e.g.
composer update drupal/commerce_license
(I think you might have already performed these steps.)
Then,
- rebuild the cache:
drush cr
- uninstall recurring period.
drush un recurring_period
- remove recurring period.
composer remove drupal/recurring_period
- temporarily add recurring to your composer, e.g.
- πΊπΈUnited States rclemings
After uninstalling recurring period, I now get this error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: Unable to determine class for field type 'commerce_plugin_item:recurring_period' found in the 'field.field.commerce_product_variation.product.license_expiration' configuration in Drupal\Core\Field\FieldConfigStorageBase->mapFromStorageRecords() (line 31 of core/lib/Drupal/Core/Field/FieldConfigStorageBase.php).
WSOD on every page. I think I'll be reinstalling from a backup.
- πΊπΈUnited States rclemings
OK, I just edited out the reference to 'commerce_plugin_item:recurring_period' from the 'field.field.commerce_product_variation.product.license_expiration' configuration (blob field, groan) and after a drush cr the site is up without restoring the backup.
At this point commerce_license is the latest dev and recurring_period is in the file system but not installed.
If I create an order with a product that has a license, I get this:
Drupal\Core\Entity\EntityStorageException: The "field_item:commerce_plugin_item:recurring_period" plugin does not exist.
So I enabled recurring_period and now it looks as if everything is working, although the original problem remains, as far as I can tell.
- πΊπΈUnited States TomTech
@rclemings Thanks for the additional information.
Appears things are working as expected on a new install, but I'm not getting the field information updated appropriately during an upgrade from a previous release.
Working on a patch for that.
- 1e958850 committed on 8.x-2.x
Issue #2920481 by TomTech, rclemings, bojanz, jsacksick, rszrama: Remove...
- 1e958850 committed on 8.x-2.x
- πΊπΈUnited States rclemings
This may be unrelated, but after all of that installing/uninstalling/etc. I started getting errors when activating a license with an expiration date. I eventually noticed that the "license expiration" block was missing from the product edit page. Turns out these two configs were gone:
field.field.commerce_product_variation.product.license_expiration.yml field.storage.commerce_product_variation.license_expiration.yml
As I said it may not be related to the issue, but just in case ...
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
over 1 year ago 10:22pm 25 May 2023 - πͺπΈSpain aleix
Following the release notes steps I cannot make it work, in my case it still shows:
The "field_item:commerce_plugin_item:recurring_period" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are...
- πͺπΈSpain aleix
Inspecting a little more I see that despite the active definitions is emptied with clearCachedFieldDefinitions cache rebuilt, when rebuilding actives definition in https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21... it rebuilds from cached
cached commerce_product_variation.field_storage_definitions.installed
in getLastInstalledFieldStorageDefinitions ( core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php:122 ) so it gets back to the wrong definition.The only way to success is to manually triggering deleteLastInstalledDefinition of commerce_product_variation.
I make some kind of testing using drush scr// Gets active definitions $fds = \Drupal::service('entity_field.manager')->getActiveFieldStorageDefinitions("commerce_product_variation"); $fd_exp = $fds['license_expiration']; print_r($fds['license_expiration']); // fd_exp is recurring_period again // Gets definitions $fds = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions("commerce_product_variation"); $fd_exp = $fds['license_expiration']; // $fd_exp is commerce_license_period // Gets definitions after clearing cache $efm = \Drupal::service('entity_field.manager'); $efm->clearCachedFieldDefinitions(); $fds = $efm->getActiveFieldStorageDefinitions("commerce_product_variation"); $fd_exp = $fds['license_expiration']; // fd_exp is recurring_period again // CLEARS commerce_product_variation definition $entityLastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository'); $entityLastInstalledSchemaRepository->deleteLastInstalledDefinition('commerce_product_variation'); $efm = \Drupal::service('entity_field.manager'); $efm->clearCachedFieldDefinitions(); $fds = $efm->getActiveFieldStorageDefinitions("commerce_product_variation"); $fd_exp = $fds['license_expiration']; // $fd_exp it's commerce_license_perio
@aleix I ran into the same issue and was able to get the site back up using your drush script (thanks for that!) I'm now getting an error on my status report that says:
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Product variation
The Product variation entity type needs to be installed.I did the standard cache rebuild/run cron and tried re-saving my product variations but it persists. I am able to purchase a license so it's not clearly impacting the functionality as far as I can tell. Is there an extra cleanup step I might have missed?
- πͺπΈSpain aleix
It happens also to me, I need to run this (maybe risky, so better to back up your db):
drush entity-updates
This command is from https://www.drupal.org/project/devel_entity_updates β , and may imply risk (you can read https://www.drupal.org/project/devel_entity_updates/issues/3082442 β ) . If you are sure to continue you will need to run this before:
composer require 'drupal/devel_entity_updates' drush en devel_entity_updates
- π©πͺGermany dercheffe Sersheim, Germany
Upgrade to version 3 is not possible when follow instructions. Can confirm issue in #17. It breaks site completely when uninstalling recurring period module. IMO this is not fixed and also critical.
- π¨πSwitzerland tcrawford
I confirm also the issue.
The simplest workaround I could find (until the issue is resolved) is to install recurring_period module, so that the cache clear can occur and the update hooks in commerce_file can run to convert the recurring_period to commerce_license_periods.
I first tried to install the module with a composer alias to side-step the conflicts constraint added to commerce_file, but this was unsuccessful, so I just copied the module into the docroot/custom folder. Then I could run drush updb to update the config.
I think the issue could be resolved by re-adding the dependency at present. It is always a challenge to cleanly remove dependencies in Drupal as it requires multiple deployments.
- πΊπΈUnited States rclemings
I was able to get it updated to v3 successfully by following EXACTLY the steps listed here:
https://www.drupal.org/project/commerce_license/releases/8.x-2.0 β
It's complicated. It took more than one try, But it worked. The updb step is critical.
Maybe the same steps should be listed on https://www.drupal.org/project/commerce_license/releases/3.0.0 β as well, just so nobody misses it?