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
@@ -11,16 +11,25 @@
|
||||
namespace IPS\core\tasks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* clubrebuild Task
|
||||
*/
|
||||
class _clubrebuild extends \IPS\Task
|
||||
class clubrebuild extends Task
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
@@ -31,26 +40,26 @@ class _clubrebuild extends \IPS\Task
|
||||
* Tasks should execute within the time of a normal HTTP request.
|
||||
*
|
||||
* @return mixed Message to log or NULL
|
||||
* @throws \IPS\Task\Exception
|
||||
* @throws Task\Exception
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : mixed
|
||||
{
|
||||
if ( !\IPS\Settings::i()->clubs )
|
||||
if ( !Settings::i()->clubs )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'clubrebuild' ) );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'clubrebuild' ) );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$this->runUntilTimeout( function()
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', 'core_clubs', array( 'rebuilt is null or rebuilt<?', time() - 1200 ), 'rebuilt ASC', 10 );
|
||||
$select = Db::i()->select( '*', 'core_clubs', array( 'rebuilt is null or rebuilt<?', time() - 1200 ), 'rebuilt ASC', 10 );
|
||||
|
||||
if ( !$select->count() )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\Member\Club' ) as $club )
|
||||
foreach ( new ActiveRecordIterator( $select, 'IPS\Member\Club' ) as $club )
|
||||
{
|
||||
$club->content = 0;
|
||||
$club->last_activity = 0;
|
||||
@@ -62,14 +71,14 @@ class _clubrebuild extends \IPS\Task
|
||||
$nodeClass = $node['node_class'];
|
||||
$node = $nodeClass::load( $node['node_id'] );
|
||||
|
||||
if ( $lastCommentTime = $node->getLastCommentTime( new \IPS\Member ) and $lastCommentTime->getTimestamp() > $club->last_activity )
|
||||
if ( $lastCommentTime = $node->getLastCommentTime( new Member ) and $lastCommentTime->getTimestamp() > $club->last_activity )
|
||||
{
|
||||
$club->last_activity = $lastCommentTime->getTimestamp();
|
||||
}
|
||||
|
||||
$club->content += (int) $node->getContentItemCount();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception $e ) { }
|
||||
}
|
||||
|
||||
$club->rebuilt = time();
|
||||
@@ -78,6 +87,8 @@ class _clubrebuild extends \IPS\Task
|
||||
|
||||
return TRUE;
|
||||
} );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user