LaCollision Posted April 15, 2023 Posted April 15, 2023 Hi Team, I think there is a bug in the Commerce app for the Package->upgradeDowngrade() method. When upgrading or downgrading, you check if the new Package has a longer initial term, and then modify the current $purchase->expire date accordingly. In \IPS\nexus\Package, in upgradeDowngrade(), at line 3533: /* Initial Term, apply the difference if the new package has a longer initial term */ if( $term and $newPackage->initial_term ) { $initial = new \DateInterval( "P{$newPackage->initial_term}" ); /* If we're still in the initial period of the new package */ $diff = \IPS\DateTime::create()->diff( $purchase->start->add( $initial ) ); if( $diff->days > 0 ) { $purchase->expire = $purchase->start->add( $diff ); } } You calculate the difference between now and (the purchase start date + the initial term): $diff = \IPS\DateTime::create()->diff( $purchase->start->add( $initial ) ); Then you check if this difference has days: if( $diff->days > 0 ) The issue is the following: the $diff->days will always be positive, as you forget to check if the difference is negative. As a result, the $purchase->expire date could be set in the past, which is really problematic. The correct test, at line 3540, should be: if( !$diff->invert && $diff->days > 0 ) Thank you!
LaCollision Posted May 10, 2023 Author Posted May 10, 2023 Hi team, I have no news about this issue? Thank you,
Marc Posted May 10, 2023 Posted May 10, 2023 Sorry, it appears this may have been missed for some reason. I have gone ahead and got a bug report created on this for you. LaCollision 1
Solution Marc Posted June 14, 2023 Solution Posted June 14, 2023 This issue has been resolved in the latest 4.7.11 release. Please upgrade to resolve this, and let us know if you have any further problems. LaCollision 1
Recommended Posts