Version 5.0.0 beta 8
This commit is contained in:
1 parent
54d5dcd0a0
commit
214f649f1d
483 files changed
+35354
-33568
No files matched your search
@@ -12,6 +12,9 @@
|
||||
|
||||
namespace IPS\Extensions;
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
use IPS\Task\Queue\OutOfRangeException as QueueOutOfRangeException;
|
||||
use OutOfRangeException;
|
||||
use const IPS\REBUILD_NORMAL;
|
||||
@@ -30,6 +33,39 @@ abstract class QueueAbstract
|
||||
*/
|
||||
public int $rebuild = REBUILD_NORMAL;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param string $classname
|
||||
* @return array
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
protected function getCountDataFromClass( string $classname ) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
/* Check table size before running a count query */
|
||||
if( Db::i()->recommendManualQuery( $classname::$databaseTable ) )
|
||||
{
|
||||
$data['count'] = $data['realCount'] = Db::i()->getTableData( $classname::$databaseTable )['rows'];
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
/* @var ActiveRecord $classname */
|
||||
$data['count'] = $classname::db()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable, ( is_subclass_of( $classname, 'IPS\Content\Comment' ) ) ? $classname::commentWhere() : array() )->first();
|
||||
$data['realCount'] = $classname::db()->select( 'COUNT(*)', $classname::$databaseTable, ( is_subclass_of( $classname, 'IPS\Content\Comment' ) ) ? $classname::commentWhere() : array() )->first();
|
||||
}
|
||||
catch( Exception $ex )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user