Problem/Motivation

Steps to reproduce

When trying to checkout a digital product, after the payment confirmation through saferpay, TypeError occurs. The same with simple 'complete checkout'.

Proposed resolution 1

I have added an intermediary step, where I used the intval() function to make sure $interval has an integer value.

Proposed resolution 2

Mark the interval fields as required.

Failed execution info

Drupal Version 9.5.11
PHP Version 8.1.28

Warning: DateInterval::createFromDateString(): Unknown or bad format ( day) at position 0 (d): The timezone could not be found in the database in Drupal\commerce_license\Plugin\Commerce\LicensePeriod\FixedReferenceDateInterval->getDateInterval() (line 133 of /app/web/modules/contrib/commerce_license/src/Plugin/Commerce/LicensePeriod/FixedReferenceDateInterval.php)

License Expiration "Interval based on reference date" and empty interval Days
TypeError: Drupal\commerce_license\Plugin\Commerce\LicensePeriod\FixedReferenceDateInterval::getDateInterval(): Return value must be of type DateInterval, bool returned in Drupal\commerce_license\Plugin\Commerce\LicensePeriod\FixedReferenceDateInterval->getDateInterval() (line 133 of /app/web/modules/contrib/commerce_license/src/Plugin/Commerce/LicensePeriod/FixedReferenceDateInterval.php)

License Expiration "Interval based on reference date" and empty interval Fortnights
TypeError: Unsupported operand types: string * int in Drupal\commerce_license\Plugin\Commerce\LicensePeriod\FixedReferenceDateInterval->getDateInterval() (line 116 of modules/contrib/commerce_license/src/Plugin/Commerce/LicensePeriod/FixedReferenceDateInterval.php).

License Expiration "Interval based on reference date" and empty interval Seconds
TypeError: Unsupported operand types: string / int in Drupal\commerce_license\Plugin\Commerce\LicensePeriod\FixedReferenceDateInterval->getDateInterval() (line 126 of /app/web/modules/contrib/commerce_license/src/Plugin/Commerce/LicensePeriod/FixedReferenceDateInterval.php)

License Expiration "Rolling interval" and empty interval
Drupal\Core\Entity\EntityStorageException: The provided interval number "" is not a numeric value. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\commerce_license\Plugin\Commerce\LicensePeriod\RollingInterval->calculateEnd(Object) (Line: 289)

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

lucian_pana created an issue. See original summary.

lucian_pana’s picture

lucian_pana’s picture

Assigned: lucian_pana » Unassigned
lucian_pana’s picture

Checked on local project, the error occurs when License Expiraton is not set.
Code works as intended.
The patch provided solves the error, but makes the file available for one minute.

knyshuk.vova’s picture

Issue summary: View changes
knyshuk.vova’s picture

Issue summary: View changes
knyshuk.vova’s picture

Marked the interval fields as required.

knyshuk.vova’s picture

Issue summary: View changes
knyshuk.vova’s picture

Status: Active » Needs review

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

benstallings’s picture

Thanks to both of you! I just incorporated your patches into a MR.

benstallings’s picture

Status: Needs review » Reviewed & tested by the community
jsacksick’s picture

Status: Reviewed & tested by the community » Needs work

Tests are failing, so putting this back to needs work. (Unless the failures are unrelated, going to trigger the tests without the changes to see where things are).

jsacksick’s picture

Status: Needs work » Needs review

jsacksick’s picture

Status: Needs review » Fixed
Issue tags: -operand int transform

Status: Fixed » Closed (fixed)

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