Not a bug The phrase_duration template function raises an error for a non-existent duration

NikitOS

Registered
Registered
Upgrade Coupons
Credit System
Joined
May 15, 2020
Messages
23
Reaction score
7
Hello

As in the title.
Passing null to the function will throw an error:
[E_WARNING] Attempt to read property "length_unit" on null

To avoid this, you use the following condition in your template:
Code:
{{ $active.Uud ? phrase_duration($active.Uud) : $upgrade.cost_phrase }}

It seems to me that this is not the best solution. I would pass a UserUpgradeActive object to the function and calculate the phrase based on start_date and end_date.
 
Back
Top Bottom