Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
LaCollision Posted December 7, 2023 Posted December 7, 2023 Hi team, The bug mentioned in my first post has been corrected, thank you. However, I realize that there's another bug in the same part of the code: In \IPS\nexus\Package, at line 3579: if( !$diff->invert and $diff->days > 0 ) { $purchase->expire = $purchase->start->add( $diff ); } The problem is that the above code adds the $diff difference to the purchase date, which is incorrect. Let's take an example: Today is December 7, 2023. The purchase date is November 12, 2023. The initial term is 1 month. We therefore have : $initial = new \DateInterval( "P{$newPackage->initial_term}" ) = 1 month $diff = \IPS\DateTime::create()->diff( $purchase->start->add( $initial ) ) = difference between today and (purchase date + initial term) = difference between December 7 and (November 12 + 1 month) = difference between December 7 and December 12 = 5 days The code : $purchase->expire = $purchase->start->add( $diff ); ... will then set the purchase expiry date to : $purchase->expire = $purchase->start->add( $diff ); = November 12 + 5 days = November 17 ... whereas the expiry date should be December 12. This code therefore causes the purchase to expire prematurely: it is considered to have expired on November 17, whereas it should be valid until December 12. To correct this problem, add to $purchase->start the initial term, not the difference in days. The correct code should be as follows: $purchase->expire = $purchase->start->add( $initial ); Thank you for your help!
Marc Posted December 7, 2023 Posted December 7, 2023 Ive split this into its own topic Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release. LaCollision 1
Recommended Posts