Problem/Motivation

If you have a product type that is not a ticket and you try to re assign it via commerce backend the subscriber
(onOrderAssign) will throw an error

Steps to reproduce

1) create normal default product that is not associated with tickets
2) Buy it and go through all checkout steps ...
this will be very hard if you don't have a payment gateway on your site but here is a patch for this (https://www.drupal.org/project/commerce_ticketing/issues/3250757)

3) as an admin user attempt to re assign the order at:
(admin/commerce/orders/YOUR-ORDERID-HERE/reassign)
see error

The website encountered an unexpected error. Please try again later.
InvalidArgumentException: Field tickets is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 587 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityBase->get('tickets') (Line: 194)
Drupal\commerce_ticketing\EventSubscriber\OrderEventSubscriber->onOrderAssign(Object, 'commerce_order.order.assign', Object)
call_user_func(Array, Object, 'commerce_order.order.assign', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'commerce_order.order.assign') (Line: 48)

Proposed resolution

Use the attached patch...

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

taggartj created an issue. See original summary.

taggartj’s picture

StatusFileSize
new1.48 KB
pcambra’s picture

Version: 2.0.0-alpha5 » 2.x-dev
Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks for reporting! I think we should have a test for this so we avoid regressions.

aleix made their first commit to this issue’s fork.

aleix’s picture

In fact it doesn't affect only the assign event, it will affect the events without the conditional that checks if order entity hasn't the tickets field. The test in MR shows just the assign and paid event. But It's clear that the subscription will affect orders without tickets enabled, and testing all events will add noise to test files.

I think that title must be wider too to help others facing issues : Enabling this module breaks order events without tickets ??

aleix’s picture

Priority: Minor » Critical
Status: Needs work » Needs review

After adding the conditional, tests confirm that tickets Field tickets is unknown errors are not there anymore :) .

Adding critical as this issue breaks some sites that are mixing orders with enabled and disabled tickets...

aleix’s picture

StatusFileSize
new9.49 KB

(patch for composer purposes)

pcambra’s picture

Priority: Critical » Normal
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.