Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

+21 -12
View File
@@ -27,7 +27,7 @@ class _unarchive extends \IPS\Task
* @brief Number of items to process per cycle
*/
const PROCESS_PER_BATCH = 250;
/**
* @brief Storage database
*/
@@ -56,9 +56,6 @@ class _unarchive extends \IPS\Task
return NULL;
}
/* Init */
$postsProcessed = 0;
/* Connect to the remote DB if needed */
if ( \IPS\CIC2 )
{
@@ -77,10 +74,21 @@ class _unarchive extends \IPS\Task
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
) );
}
/* Loop topics */
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_topics', array( 'topic_archive_status=?', \IPS\forums\Topic::ARCHIVE_RESTORE ), 'tid ASC', 250 ), 'IPS\forums\Topic' ) as $topic )
{
$this->runUntilTimeout( function(){
/* Init */
$postsProcessed = 0;
/* Loop topics */
try
{
$topic = \IPS\forums\Topic::constructFromData( \IPS\Db::i()->select( '*', 'forums_topics', array( 'topic_archive_status=?', \IPS\forums\Topic::ARCHIVE_RESTORE ), 'tid ASC', 1 )->first() );
}
catch( \UnderflowException $e )
{
return FALSE;
}
/* Do as many posts as we can */
$offset = \IPS\Db::i()->select( 'MAX(pid)', 'forums_posts', array( 'topic_id=?', $topic->tid ) )->first();
foreach ( $this->storage->select( '*', 'forums_archive_posts', array( 'archive_id>? AND archive_topic_id=?', \intval( $offset ), $topic->tid ), 'archive_id ASC', static::PROCESS_PER_BATCH - $postsProcessed ) as $post )
@@ -89,7 +97,7 @@ class _unarchive extends \IPS\Task
$postsProcessed++;
if ( $postsProcessed >= static::PROCESS_PER_BATCH )
{
break 2;
return TRUE;
}
}
@@ -97,9 +105,9 @@ class _unarchive extends \IPS\Task
\IPS\Content\Search\Index::i()->indexSingleItem( $topic );
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_EXCLUDE ), array( 'tid=?', $topic->tid ) );
$this->storage->delete( 'forums_archive_posts', array( 'archive_topic_id=?', $topic->tid ) );
}
return NULL;
return TRUE;
});
}
/**
@@ -134,8 +142,9 @@ class _unarchive extends \IPS\Task
/* Insert */
\IPS\Db::i()->replace( 'forums_posts', $row );
/* Update reports table */
/* Update reports and promotes tables */
\IPS\Db::i()->update( 'core_rc_index', array( 'class' => 'IPS\forums\Topic\Post' ), array( 'class=? AND content_id=?', 'IPS\forums\Topic\ArchivedPost', $post['archive_id'] ) );
\IPS\Db::i()->update( 'core_social_promote', array( 'promote_class' => 'IPS\forums\Topic\Post' ), array( "promote_class=? AND promote_class_id=?", 'IPS\forums\Topic\ArchivedPost', $post['archive_id'] ) );
return \IPS\forums\Topic\Post::constructFromData( $row );
}