Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Background processes 'Run Now'
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 28 Jan 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -30,6 +30,11 @@ class _background extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ( \IPS\CIC )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_writes', '2C347/1', 403, '' );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -71,59 +76,22 @@ class _background extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$queueData = \IPS\Db::i()->select( '*', 'core_queue', NULL, 'priority ASC, RAND()', 1 )->first();
|
||||
$newOffset = 0;
|
||||
try
|
||||
{
|
||||
$extensions = \IPS\Application::load( $queueData['app'] )->extensions( 'core', 'Queue', FALSE );
|
||||
if ( !isset( $extensions[ $queueData['key'] ] ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$class = new $extensions[ $queueData['key'] ];
|
||||
$json = json_decode( $queueData['data'], TRUE );
|
||||
$newOffset = $class->run( $json, $queueData['offset'] );
|
||||
|
||||
if ( is_null( $newOffset ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Finished " . json_encode( $queueData ), 'runQueue_log' );
|
||||
\IPS\Db::i()->delete( 'core_queue', array( 'id=?', $queueData['id'] ) );
|
||||
|
||||
/* Update count */
|
||||
$data['count'] = $self->getCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_queue', array( 'offset' => $newOffset ), array( 'id=?', $queueData['id'] ) );
|
||||
|
||||
$newData = json_encode( $json );
|
||||
|
||||
/* Did it change?? */
|
||||
if ( $newData !== $json )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_queue', array( 'data' => $newData ), array( 'id=?', $queueData['id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Finished " . json_encode( $queueData ), 'runQueue_log' );
|
||||
|
||||
\IPS\Db::i()->delete( 'core_queue', array( 'id=?', $queueData['id'] ) );
|
||||
|
||||
/* Update count */
|
||||
$data['count'] = $self->getCount();
|
||||
}
|
||||
{
|
||||
/* Run the next queue task, if any */
|
||||
$queueData = \IPS\Task::runQueue();
|
||||
|
||||
/* Update count */
|
||||
$data['count'] = $self->getCount();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
/* All done */
|
||||
/* If we're here it means there were no rows in core_queue and we are done */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$data['done'] = $data['done'] + ( $newOffset - $queueData['offset'] );
|
||||
$data['done'] = $data['done'] + ( $queueData['offset'] - $queueData['_originalOffset'] );
|
||||
$json = json_decode( $queueData['data'], TRUE );
|
||||
|
||||
$lang = array( $queueData['key'] );
|
||||
|
||||
if ( isset( $json['class'] ) )
|
||||
@@ -141,7 +109,13 @@ class _background extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( isset( $json['count'] ) )
|
||||
{
|
||||
$lang[] = " " . intval( $newOffset ) . ' / ' . $json['count'];
|
||||
/* If the offset is larger than the count, then we should just show the count instead (to avoid situations where it will display 150 / 139, for example) */
|
||||
$offset = intval( $queueData['offset'] );
|
||||
if ( $offset > $json['count'] )
|
||||
{
|
||||
$offset = $json['count'];
|
||||
}
|
||||
$lang[] = " " . $offset . ' / ' . $json['count'];
|
||||
}
|
||||
|
||||
return array( $data, \IPS\Member::loggedIn()->language()->addToStack('background_processes_processing', FALSE, array( 'sprintf' => array( implode( ' - ', $lang ) ) ) ), ( $data['count'] ) ? round( ( 100 / $data['count'] * $data['done'] ), 2 ) : 100 );
|
||||
|
||||
Reference in new issue
Block a user