Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+28 -20
View File
@@ -12,16 +12,28 @@
namespace IPS\nexus\tasks;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use IPS\Db;
use IPS\Log;
use IPS\nexus\Customer\BillingAgreement;
use IPS\Patterns\ActiveRecordIterator;
use IPS\Task;
use Throwable;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* billingAgreements Task
*/
class _billingAgreements extends \IPS\Task
class billingAgreements extends Task
{
/**
* Execute
@@ -31,13 +43,14 @@ class _billingAgreements extends \IPS\Task
* If an error occurs which means the task could not finish running, throw an \IPS\Task\Exception - do not log an error as a normal log.
* Tasks should execute within the time of a normal HTTP request.
*
* @return mixed Message to log or NULL
* @throws \IPS\Task\Exception
* @return string|null Message to log or NULL
* @throws Task\Exception
*/
public function execute()
public function execute() : string|null
{
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_billing_agreements', array( 'ba_next_cycle<?', time() ), 'ba_next_cycle ASC', 50 ), 'IPS\nexus\Customer\BillingAgreement' ) as $billingAgreement )
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'nexus_billing_agreements', array( 'ba_next_cycle<?', time() ), 'ba_next_cycle ASC', 50 ), 'IPS\nexus\Customer\BillingAgreement' ) as $billingAgreement )
{
/* @var BillingAgreement $billingAgreement */
try
{
/* Get the status? */
@@ -47,7 +60,7 @@ class _billingAgreements extends \IPS\Task
{
$billingAgreement->canceled = TRUE;
}
throw new \DomainException("{$billingAgreement->id} - {$billingAgreement->status()}");
throw new DomainException("{$billingAgreement->id} - {$billingAgreement->status()}");
}
/* Get the term */
@@ -56,27 +69,22 @@ class _billingAgreements extends \IPS\Task
/* Check for a recent transaction */
$billingAgreement->checkForLatestTransaction();
}
catch( \UnderflowException $e ){} // We intentionally ignore this because it's normal
catch( UnderflowException ){} // We intentionally ignore this because it's normal
catch ( \IPS\Http\Url\Exception $e )
{
/* Just log the issue, but don't do anything here,.. this was probably a temporary issue so let the next call run this again */
\IPS\Log::log( $e, 'ba_sync_fail' );
Log::log( $e, 'ba_sync_fail' );
}
catch ( \Exception $e )
catch ( Exception|Throwable $e )
{
\IPS\Log::log( $e, 'ba_sync_fail' );
$billingAgreement->next_cycle = NULL;
$billingAgreement->save();
}
catch ( \Throwable $e )
{
\IPS\Log::log( $e, 'ba_sync_fail' );
Log::log( $e, 'ba_sync_fail' );
$billingAgreement->next_cycle = NULL;
$billingAgreement->save();
}
}
return null;
}
/**
@@ -88,7 +96,7 @@ class _billingAgreements extends \IPS\Task
*
* @return void
*/
public function cleanup()
public function cleanup() : void
{
}