Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+14 -4
View File
@@ -29,7 +29,7 @@ class _Task extends \IPS\Patterns\ActiveRecord
*/
public static function runQueue()
{
$queueData = \IPS\Db::i()->select( '*', 'core_queue', NULL, 'priority ASC, RAND()', 1 )->first();
$queueData = \IPS\Db::i()->select( '*', 'core_queue', array( 'app_enabled=?', 1 ), 'priority ASC, RAND()', 1 )->join( 'core_applications', "app=app_directory" )->first();
$newOffset = 0;
$queueData['_originalOffset'] = $queueData['offset'];
@@ -276,9 +276,10 @@ class _Task extends \IPS\Patterns\ActiveRecord
* Run until timeout
*
* @param callback $callback The code to run. Should return TRUE if we're happy to keep going, and FALSE if there's no more work to do
* @param int|null $limit A hard limit on the number of times to call $callback, or NULL for no limit
* @return void
*/
public function runUntilTimeout( $callback )
public function runUntilTimeout( $callback, $limit=NULL )
{
/* Work out the maximum execution time */
$timeLeft = 45;
@@ -334,9 +335,10 @@ class _Task extends \IPS\Patterns\ActiveRecord
}
$memoryTheLastRunTook = 0;
/* Run until we run out of time */
/* Run until we run out of time or hit our limit */
$calls = 0;
do
{
{
/* Start a timer */
$timer = microtime( TRUE );
$memoryTimer = function_exists( 'memory_get_usage' ) ? memory_get_usage( TRUE ) : 0;
@@ -346,6 +348,14 @@ class _Task extends \IPS\Patterns\ActiveRecord
{
break;
}
$calls++;
/* If we have a limit and we've hit it, then stop now */
if( $limit !== NULL AND $calls >= $limit )
{
break;
}
/* Decrease the time left */
$timeTheLastRunTook = round( ( microtime( TRUE ) - $timer ), 2 );