Version 5.0.6

This commit is contained in:
Neo committed 2025-12-19 18:55:49 -08:00
1 parent a3a4a9ccbd
commit b89858b2ff
1214 files changed
+92828 -14859

No files matched your search

@@ -132,7 +132,7 @@ class Vanilla extends Software
),
'convertAttachments' => array(
'table' => 'Media',
'where' => array( 'ForeignTable=? OR ForeignTable=?', 'discussion', 'comment' )
'where' => [ "ForeignTable IN ('discussion', 'comment', 'embed')" ]
)
);
}
@@ -295,6 +295,7 @@ class Vanilla extends Software
{
/* Content Rebuilds */
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts_first', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 3, array( 'class' ) );
Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
@@ -313,16 +314,22 @@ class Vanilla extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VanillaCore::fixPostData( $post, $className, $contentId );
return VanillaCore::fixPostData( $post, $className, $contentId, $app );
}
/**
* @brief temporarily store post content
*/
protected array $_postContent = array();
/**
* Convert attachments
*
@@ -331,18 +338,41 @@ class Vanilla extends Software
public function convertAttachments(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'MediaID' );
$this->_postContent = [];
foreach( $this->fetch( 'Media', 'MediaID', array( 'ForeignTable=? OR ForeignTable=?', 'discussion', 'comment' ) ) AS $row )
foreach( $this->fetch( 'Media', 'MediaID', [ $this->db->in( 'ForeignTable', [ 'discussion', 'comment', 'embed' ] ) ] ) AS $row )
{
if( $row['ForeignTable'] == 'discussion' )
{
$map = array(
'id1' => 'fp-' . $row['ForeignID'],
'id1' => $row['ForeignID'],
'id2' => $row['ForeignID'],
'first_post' => true
);
}
elseif( $row['ForeignTable'] == 'embed' )
{
$mediaRows = iterator_to_array(
\IPS\Db::i()->select(
'*',
'convert_vanilla_temp',
[ 'media_id=? AND ' . \IPS\Db::i()->in( 'link_type', [ 'forums_posts', 'forums_posts_first'] ), $row['MediaID'] ]
) );
// Nothing to do, attachment must be in another content type
if( !count( $mediaRows ) )
{
$libraryClass->setLastKeyValue( $row['MediaID'] );
continue;
}
$map = [
'id1' => $mediaRows[0]['content_id'],
'id2' => $mediaRows[0]['post_id'],
'first_post' => ( $mediaRows[0]['link_type'] == 'forums_posts_first' ) ? true : false
];
}
else
{
try
@@ -377,9 +407,38 @@ class Vanilla extends Software
$uploadPath = VanillaCore::parseMediaLocation( $row['Path'], $this->app->_session['more_info']['convertAttachments']['attach_location'] );
$libraryClass->convertAttachment( $info, $map, $uploadPath );
$attachId = $libraryClass->convertAttachment( $info, $map, $uploadPath );
/* Do some re-jiggery on the post itself to make sure attachment displays */
if ( $attachId !== FALSE and isset( $mediaRows ) )
{
foreach( $mediaRows as $mediaRow )
{
try
{
$pid = $this->app->getLink( $map['id2'], ( isset( $map['first_post'] ) AND $map['first_post'] === TRUE ) ? 'forums_posts_first' : 'forums_posts' );
if( !isset( $this->_postContent[ $pid ] ) )
{
$this->_postContent[ $pid ] = Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
}
$this->_postContent[ $pid ] = str_replace( "[ATTACH={$row['MediaID']}]", '[attachment=' . $attachId . ':name]', $this->_postContent[ $pid ] );
// dump($this->_postContent[ $pid ]);
}
catch( UnderflowException|OutOfRangeException $e ) {}
}
}
unset( $mediaRows );
$libraryClass->setLastKeyValue( $row['MediaID'] );
}
/* Do the updates */
foreach( $this->_postContent as $pid => $content )
{
Db::i()->update( 'forums_posts', array( 'post' => $content ), array( 'pid=?', $pid ) );
}
}
/**
@@ -394,11 +453,7 @@ class Vanilla extends Software
$uploadsPath = $this->app->_session['more_info']['convertForumsForums']['attach_location'];
$forums = $this->fetch( array( 'Category', 'c' ), 'CategoryID', array( 'c.CategoryID<>?', -1 ),
'c.*, lcu.UserID as LastCommentUserID, lcu.Name as LastCommentUserName, ld.Name as LastDiscussionName'
);
$forums->join( array( 'User', 'lcu' ), 'c.LastCommentID=lcu.UserID' );
$forums->join( array( 'Discussion', 'ld' ), 'c.LastDiscussionID=ld.DiscussionID' );
$forums = $this->fetch( array( 'Category', 'c' ), 'CategoryID', array( 'c.CategoryID<>?', -1 ) );
foreach( $forums AS $row )
{
@@ -409,12 +464,8 @@ class Vanilla extends Software
'description' => $row['Description'],
'topics' => $row['CountDiscussions'],
'posts' => $row['CountComments'],
'last_post' => VanillaCore::mysqlToDateTime( $row['LastDateInserted'] ),
'last_poster_id' => $row['LastCommentID'],
'last_poster_name' => $row['LastCommentUserName'],
'parent_id' => ( (int) $row['ParentCategoryID'] > 0 ) ? $row['ParentCategoryID'] : NULL,
'position' => $row['Sort'],
'last_title' => $row['LastDiscussionName'],
'icon' => $icon,
'sub_can_post' => $row['AllowDiscussions'] ?: 0
];
@@ -584,17 +635,31 @@ class Vanilla extends Software
{
$row['Body'] = '<!--Markdown-->' . $row['Body'];
}
elseif( $row['Format'] == 'Rich' )
{
$row['Body'] = VanillaCore::processQuill( $row['Body'], $this->app, 'forums_posts_first', $row['DiscussionID'], $row['DiscussionID'] );
}
/* Get IP */
try
{
$ipAddress = ( $row['InsertIPAddress'] AND !str_contains( $row['InsertIPAddress'], '.' ) ) ? long2ip( hexdec( bin2hex( $row['InsertIPAddress'] ) ) ) : $row['InsertIPAddress'];
}
catch( \ErrorException $e )
{
$ipAddress = '';
}
// First post
$info = array(
'pid' => 'fp-' . $row['DiscussionID'],
'pid' => $row['DiscussionID'],
'topic_id' => $row['DiscussionID'],
'post' => $row['Body'],
'new_topic' => 1,
'edit_time' => ( $editName === NULL ) ? NULL : VanillaCore::mysqlToDateTime( $row['DateUpdated'] ),
'edit_name' => $editName,
'author_id' => $row['InsertUserID'],
'ip_address' => $row['InsertIPAddress'],
'ip_address' => $ipAddress,
'post_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
);
@@ -675,6 +740,20 @@ class Vanilla extends Software
{
$row['Body'] = '<!--Markdown-->' . $row['Body'];
}
elseif( $row['Format'] == 'Rich' )
{
$row['Body'] = VanillaCore::processQuill( $row['Body'], $this->app, 'forums_posts', $row['DiscussionID'], $row['CommentID'] );
}
/* Get IP */
try
{
$ipAddress = ( $row['InsertIPAddress'] AND !str_contains( $row['InsertIPAddress'], '.' ) ) ? long2ip( hexdec( bin2hex( $row['InsertIPAddress'] ) ) ) : $row['InsertIPAddress'];
}
catch( \ErrorException $e )
{
$ipAddress = '';
}
$info = [
'pid' => $row['CommentID'],
@@ -683,7 +762,7 @@ class Vanilla extends Software
'edit_time' => ( $editName === NULL ) ? NULL : VanillaCore::mysqlToDateTime( $row['DateUpdated'] ),
'edit_name' => $editName,
'author_id' => $row['InsertUserID'],
'ip_address' => $row['InsertIPAddress'],
'ip_address' => $ipAddress,
'post_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
];