Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+24 -29
View File
@@ -82,26 +82,27 @@ class _archive extends \IPS\Task
try
{
/* Get the topic */
$inProgress = \IPS\Db::i()->select( 'tid', 'forums_topics', array( 'topic_archive_status=?', \IPS\forums\Topic::ARCHIVE_WORKING ) )->first();
$topic = \IPS\forums\Topic::constructFromData( \IPS\Db::i()->select( '*', 'forums_topics', array( 'topic_archive_status=?', \IPS\forums\Topic::ARCHIVE_WORKING ) )->first() );
/* Do as many posts as we can */
$offset = $this->storage->select( 'MAX(archive_id)', 'forums_archive_posts', array( 'archive_topic_id=?', $inProgress ) )->first();
$posts = \IPS\Db::i()->select( 'forums_posts.*,forums_topics.forum_id', 'forums_posts', array( 'pid>? AND topic_id=?', intval( $offset ), $inProgress ), 'pid ASC', static::PROCESS_PER_BATCH, NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS )->join( 'forums_topics', 'tid=topic_id' );
$offset = $this->storage->select( 'MAX(archive_id)', 'forums_archive_posts', array( 'archive_topic_id=?', $topic->tid ) )->first();
$posts = \IPS\Db::i()->select( 'forums_posts.*,forums_topics.forum_id', 'forums_posts', array( 'pid>? AND topic_id=?', intval( $offset ), $topic->tid ), 'pid ASC', static::PROCESS_PER_BATCH, NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS )->join( 'forums_topics', 'tid=topic_id' );
foreach ( $posts as $post )
{
$this->archive( $post, $post['forum_id'] );
$postsProcessed++;
}
/* If we did them all, mark that this topic is done */
/* If we did them all, mark that this topic is done and remove from search index */
if ( $postsProcessed == $posts->count( TRUE ) )
{
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_DONE ), array( 'tid=?', $inProgress ) );
{
$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_DONE;
$topic->save();
\IPS\Db::i()->delete( 'forums_posts', array( 'topic_id=?', $inProgress ) );
\IPS\Content\Search\Index::i()->removeFromSearchIndex( $topic );
}
/* Update search index */
\IPS\Db::i()->update( 'core_search_index', array( 'index_class' => 'IPS\forums\Topic\Post' ), array( 'index_item_id=? AND index_class=?', $inProgress, 'IPS\forums\Topic\ArchivedPost' ) );
}
catch ( \UnderflowException $e ) { }
}
@@ -110,13 +111,14 @@ class _archive extends \IPS\Task
if ( $postsProcessed < static::PROCESS_PER_BATCH )
{
/* Loop topics */
foreach ( \IPS\Db::i()->select( 'tid', 'forums_topics', array( 'topic_archive_status=?', \IPS\forums\Topic::ARCHIVE_RESTORE ), 'tid ASC', 250 ) as $topic )
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 )
{
/* Do as many posts as we can */
$offset = \IPS\Db::i()->select( 'MAX(pid)', 'forums_posts', array( 'topic_id=?', $topic ) )->first();
foreach ( $this->storage->select( '*', 'forums_archive_posts', array( 'archive_id>? AND archive_topic_id=?', intval( $offset ), $topic ), 'archive_id ASC', static::PROCESS_PER_BATCH - $postsProcessed ) as $post )
$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 )
{
$this->unarchive( $post );
\IPS\Content\Search\Index::i()->index( \IPS\forums\Topic\Post::load( $post['archive_id'] ) );
$postsProcessed++;
if ( $postsProcessed >= static::PROCESS_PER_BATCH )
{
@@ -125,11 +127,8 @@ class _archive extends \IPS\Task
}
/* Set that it's done */
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_EXCLUDE ), array( 'tid=?', $topic ) );
$this->storage->delete( 'forums_archive_posts', array( 'archive_topic_id=?', $topic ) );
/* Update search index */
\IPS\Db::i()->update( 'core_search_index', array( 'index_class' => 'IPS\forums\Topic\Post' ), array( 'index_item_id=? AND index_class=?', $topic['tid'], 'IPS\forums\Topic\ArchivedPost' ) );
\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 ) );
}
}
@@ -140,15 +139,15 @@ class _archive extends \IPS\Task
if ( $postsProcessed < static::PROCESS_PER_BATCH )
{
/* Loop topics */
foreach ( \IPS\Db::i()->select( 'tid,forum_id', 'forums_topics', $query, 'tid ASC', 250 ) as $topic )
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_topics', $query, 'tid ASC', 250 ), 'IPS\forums\Topic' ) as $topic )
{
/* First set it as working */
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_WORKING ), array( 'tid=?', $topic['tid'] ) );
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_WORKING ), array( 'tid=?', $topic->tid ) );
/* Do as many posts as we can */
foreach ( \IPS\Db::i()->select( '*', 'forums_posts', array( 'topic_id=?', $topic['tid'] ), 'pid ASC', static::PROCESS_PER_BATCH - $postsProcessed ) as $post )
foreach ( \IPS\Db::i()->select( '*', 'forums_posts', array( 'topic_id=?', $topic->tid ), 'pid ASC', static::PROCESS_PER_BATCH - $postsProcessed ) as $post )
{
$this->archive( $post, $topic['forum_id'] );
$this->archive( $post, $topic->forum_id );
$postsProcessed++;
if ( $postsProcessed >= static::PROCESS_PER_BATCH )
{
@@ -157,11 +156,11 @@ class _archive extends \IPS\Task
}
/* Set that it's done */
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_DONE ), array( 'tid=?', $topic['tid'] ) );
\IPS\Db::i()->delete( 'forums_posts', array( 'topic_id=?', $topic['tid'] ) );
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_DONE ), array( 'tid=?', $topic->tid ) );
\IPS\Db::i()->delete( 'forums_posts', array( 'topic_id=?', $topic->tid ) );
/* Update search index */
\IPS\Db::i()->update( 'core_search_index', array( 'index_class' => 'IPS\forums\Topic\ArchivedPost' ), array( 'index_item_id=? AND index_class=?', $topic['tid'], 'IPS\forums\Topic\Post' ) );
/* Remove from search index */
\IPS\Content\Search\Index::i()->removeFromSearchIndex( $topic );
}
}
}
@@ -194,8 +193,6 @@ class _archive extends \IPS\Task
'archive_added' => time(),
'archive_attach_key' => $post['post_key'],
'archive_html_mode' => $post['post_htmlstate'],
'archive_show_signature' => $post['use_sig'],
'archive_show_emoticons' => $post['use_emo'],
'archive_show_edited_by' => $post['append_edit'],
'archive_edit_time' => intval( $post['edit_time'] ),
'archive_edit_name' => (string) $post['edit_name'],
@@ -230,8 +227,6 @@ class _archive extends \IPS\Task
'post_bwoptions' => $post['archive_bwoptions'],
'post_key' => $post['archive_attach_key'],
'post_htmlstate' => $post['archive_html_mode'],
'use_sig' => $post['archive_show_signature'],
'use_emo' => $post['archive_show_emoticons'],
'append_edit' => $post['archive_show_edited_by'],
'edit_time' => $post['archive_edit_time'],
'edit_name' => $post['archive_edit_name'],