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)
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3416414-commerce-liscence-unsupported-operand-7.patch | 1.05 KB | knyshuk.vova |
| #2 | 3416414-commerce-liscence-unsupported-operand.patch | 599 bytes | lucian_pana |
Issue fork commerce_license-3416414
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
Comment #2
lucian_pana commentedComment #3
lucian_pana commentedComment #4
lucian_pana commentedChecked 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.
Comment #5
knyshuk.vova commentedComment #6
knyshuk.vova commentedComment #7
knyshuk.vova commentedMarked the interval fields as required.
Comment #8
knyshuk.vova commentedComment #9
knyshuk.vova commentedComment #12
benstallings commentedThanks to both of you! I just incorporated your patches into a MR.
Comment #13
benstallings commentedComment #14
jsacksick commentedTests 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).
Comment #15
jsacksick commentedThe test failures were due to #3521592: third_party_settings.commerce_license.interval.interval doesn't exist.
Comment #17
jsacksick commented