LaCollision Posted April 15 Share Posted April 15 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! Link to comment Share on other sites More sharing options...
LaCollision Posted May 10 Author Share Posted May 10 Hi team, I have no news about this issue? Thank you, Link to comment Share on other sites More sharing options...
Marc Stridgen Posted May 10 Share Posted May 10 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 Link to comment Share on other sites More sharing options...
LaCollision Posted May 10 Author Share Posted May 10 Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts