Jump to content

Featured Replies

Posted

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!

Solved by Marc

Go to solution
  • 4 weeks later...
  • Author

Hi team,

I have no news about this issue?

Thank you,

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. 

  • Author

Thanks a lot!

  • 1 month later...
  • Solution

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.

Recently Browsing 0

  • No registered users viewing this page.