Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,16 +12,23 @@
|
||||
namespace IPS\nexus\tasks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Task;
|
||||
use IPS\Task\Exception;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expire Purchases Task
|
||||
*/
|
||||
class _expirePurchases extends \IPS\Task
|
||||
class expirePurchases extends Task
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
@@ -31,12 +38,12 @@ class _expirePurchases 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 Exception
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : string|null
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_active=1 AND ps_expire>0 AND ( ps_expire + ps_grace_period < ? )', time() ), 'ps_expire ASC', 100 ), 'IPS\nexus\Purchase' ) as $purchase )
|
||||
foreach ( new ActiveRecordIterator( Db::i()->select( '*', 'nexus_purchases', array( 'ps_active=1 AND ps_expire>0 AND ( ps_expire + ps_grace_period < ? )', time() ), 'ps_expire ASC', 100 ), 'IPS\nexus\Purchase' ) as $purchase )
|
||||
{
|
||||
$purchase->active = FALSE;
|
||||
$purchase->save();
|
||||
@@ -47,6 +54,8 @@ class _expirePurchases extends \IPS\Task
|
||||
'name' => $purchase->name,
|
||||
), FALSE );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +67,7 @@ class _expirePurchases extends \IPS\Task
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cleanup()
|
||||
public function cleanup() : void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user