Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\cms\extensions\core\Queue;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -26,7 +26,7 @@ class _ResyncTopicContent
/**
* @brief Number of content items to rebuild per cycle
*/
public $rebuild = 100;
public $rebuild = \IPS\REBUILD_NORMAL;
/**
* Parse data before queuing
@@ -48,7 +48,7 @@ class _ResyncTopicContent
{
$cats = iterator_to_array( \IPS\Db::i()->select( 'category_id', 'cms_database_categories', array( 'category_forum_record=1 AND category_database_id=?', $data['databaseId'] ) ) );
if ( count( $cats ) )
if ( \count( $cats ) )
{
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $data['databaseId'], array( \IPS\Db::i()->in( 'category_id', $cats ) ) )->first();
}
@@ -67,6 +67,8 @@ class _ResyncTopicContent
{
return null;
}
$data['completed'] = 0;
return $data;
}
@@ -79,11 +81,12 @@ class _ResyncTopicContent
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$class = '\IPS\cms\Records' . $data['databaseId'];
$where = NULL;
$parsed = 0;
$class = '\IPS\cms\Records' . $data['databaseId'];
$where = array( 'primary_id_field>?', $offset );
$last = NULL;
try
{
$database = \IPS\cms\Databases::load( $data['databaseId'] );
@@ -101,7 +104,7 @@ class _ResyncTopicContent
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $data['databaseId'] ) )
{
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $data['databaseId'], $where, 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $data['databaseId'], $where, 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
{
try
{
@@ -110,16 +113,17 @@ class _ResyncTopicContent
}
catch( \Exception $ex ) { }
$parsed++;
$data['completed']++;
$last = $row['primary_id_field'];
}
}
if( $parsed != $this->rebuild )
if( $last === NULL )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return ( $offset + $this->rebuild );
return $last;
}
/**
@@ -133,6 +137,6 @@ class _ResyncTopicContent
public function getProgress( $data, $offset )
{
$title = ( \IPS\Application::appIsEnabled('cms') ) ? \IPS\cms\Databases::load( $data['databaseId'] )->_title : 'Database #' . $data['databaseId'];
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_sync_topics', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_sync_topics', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
}
}