Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\forums\tasks;
|
||||
|
||||
/* 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;
|
||||
@@ -23,6 +23,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _archive extends \IPS\Task
|
||||
{
|
||||
/**
|
||||
* @brief Number of items to process per cycle
|
||||
*/
|
||||
const PROCESS_PER_BATCH = 250;
|
||||
|
||||
/**
|
||||
@@ -56,16 +59,23 @@ class _archive extends \IPS\Task
|
||||
$postsProcessed = 0;
|
||||
|
||||
/* Connect to the remote DB if needed */
|
||||
$this->storage = !\IPS\Settings::i()->archive_remote_sql_host ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
|
||||
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
|
||||
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
|
||||
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
|
||||
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
|
||||
'sql_port' => \IPS\Settings::i()->archive_sql_port,
|
||||
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
|
||||
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
$this->storage = \IPS\Cicloud\getForumArchiveDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->storage = !\IPS\Settings::i()->archive_remote_sql_host ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
|
||||
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
|
||||
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
|
||||
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
|
||||
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
|
||||
'sql_port' => \IPS\Settings::i()->archive_sql_port,
|
||||
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
|
||||
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
}
|
||||
|
||||
/* Do we have a topic we are working on? */
|
||||
try
|
||||
@@ -74,8 +84,9 @@ class _archive extends \IPS\Task
|
||||
$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=?', $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' );
|
||||
$offset = $this->storage->select( 'MAX(archive_id)', 'forums_archive_posts', array( 'archive_topic_id=?', $topic->tid ) )->first();
|
||||
$total = \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', array( 'pid>? AND topic_id=?', \intval( $offset ), $topic->tid ) )->join( 'forums_topics', 'tid=topic_id' )->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 )->join( 'forums_topics', 'tid=topic_id' );
|
||||
foreach ( $posts as $post )
|
||||
{
|
||||
$this->archive( $post, $post['forum_id'] );
|
||||
@@ -83,7 +94,7 @@ class _archive extends \IPS\Task
|
||||
}
|
||||
|
||||
/* If we did them all, mark that this topic is done and remove from search index */
|
||||
if ( $postsProcessed == $posts->count( TRUE ) )
|
||||
if ( $postsProcessed == $total )
|
||||
{
|
||||
$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_DONE;
|
||||
$topic->save();
|
||||
@@ -140,25 +151,25 @@ class _archive extends \IPS\Task
|
||||
{
|
||||
/* Translate the fields */
|
||||
$archive = array(
|
||||
'archive_id' => intval( $post['pid'] ),
|
||||
'archive_author_id' => intval( $post['author_id'] ),
|
||||
'archive_id' => \intval( $post['pid'] ),
|
||||
'archive_author_id' => \intval( $post['author_id'] ),
|
||||
'archive_author_name' => $post['author_name'],
|
||||
'archive_ip_address' => $post['ip_address'],
|
||||
'archive_content_date' => intval( $post['post_date'] ),
|
||||
'archive_content_date' => \intval( $post['post_date'] ),
|
||||
'archive_content' => $post['post'],
|
||||
'archive_queued' => $post['queued'],
|
||||
'archive_topic_id' => intval( $post['topic_id'] ),
|
||||
'archive_is_first' => intval( $post['new_topic'] ),
|
||||
'archive_topic_id' => \intval( $post['topic_id'] ),
|
||||
'archive_is_first' => \intval( $post['new_topic'] ),
|
||||
'archive_bwoptions' => $post['post_bwoptions'],
|
||||
'archive_added' => time(),
|
||||
'archive_attach_key' => $post['post_key'],
|
||||
'archive_html_mode' => $post['post_htmlstate'],
|
||||
'archive_show_edited_by' => $post['append_edit'],
|
||||
'archive_edit_time' => intval( $post['edit_time'] ),
|
||||
'archive_show_edited_by' => \intval( $post['append_edit'] ),
|
||||
'archive_edit_time' => \intval( $post['edit_time'] ),
|
||||
'archive_edit_name' => (string) $post['edit_name'],
|
||||
'archive_edit_reason' => $post['post_edit_reason'],
|
||||
'archive_field_int' => intval( $post['post_field_int'] ),
|
||||
'archive_forum_id' => $forumId ?: \IPS\Db::i()->select( 'forum_id', 'forums_topics', array( 'tid=?', intval( $post['topic_id'] ) ) )->first()
|
||||
'archive_field_int' => \intval( $post['post_field_int'] ),
|
||||
'archive_forum_id' => $forumId ?: \IPS\Db::i()->select( 'forum_id', 'forums_topics', array( 'tid=?', \intval( $post['topic_id'] ) ) )->first()
|
||||
);
|
||||
|
||||
/* Insert */
|
||||
|
||||
Reference in new issue
Block a user