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,10 +2,10 @@
|
||||
/**
|
||||
* @brief rssimport Task
|
||||
* @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
|
||||
* @subpackage Board
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Forums
|
||||
* @since 05 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -37,21 +37,42 @@ class _rssimport extends \IPS\Task
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
$feed = \IPS\forums\Feed::constructFromData( \IPS\Db::i()->select( '*', 'forums_rss_import', array( 'rss_import_enabled=1' ), 'rss_import_last_import ASC', 1 )->first() );
|
||||
$feed->run();
|
||||
}
|
||||
/* UnderflowException means there's no feed, so we can disable the task */
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
\IPS\DB::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'rssimport' ) );
|
||||
}
|
||||
/* Any other exception means an error which should be logged */
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
throw new \IPS\Task\Exception( $this, $e->getMessage() );
|
||||
}
|
||||
$timeCheck = new \IPS\DateTime;
|
||||
$timeCheck->sub( new \DateInterval( 'PT10M' ) );
|
||||
|
||||
$this->runUntilTimeout(function() use ( $timeCheck ) {
|
||||
try
|
||||
{
|
||||
$feed = \IPS\forums\Feed::constructFromData( \IPS\Db::i()->select( '*', 'forums_rss_import', array( 'rss_import_enabled=1 AND rss_import_last_import<?', $timeCheck->getTimestamp() ), 'rss_import_last_import ASC', 1 )->first() );
|
||||
$feed->run();
|
||||
}
|
||||
/* There's nothing more left to process */
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
/* Check to see if there are any feeds.. If no feed, we can disable the task */
|
||||
if( !\IPS\Db::i()->select( 'count(rss_import_id)', 'forums_rss_import', array( 'rss_import_enabled=1' ), NULL, 1 )->first() )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'rssimport' ) );
|
||||
}
|
||||
|
||||
/* No further processing needed */
|
||||
return FALSE;
|
||||
}
|
||||
/* Any other exception means an error which should be logged */
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
/* If there is an error, we need to log it but the error should not prevent other feeds from importing */
|
||||
if ( isset( $feed ) AND ( $feed instanceof \IPS\forums\Feed ) )
|
||||
{
|
||||
$feed->last_import = time();
|
||||
$feed->save();
|
||||
}
|
||||
throw new \IPS\Task\Exception( $this, $e->getMessage() );
|
||||
}
|
||||
|
||||
/* Run again to see if there's anything left */
|
||||
return TRUE;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user