Version 5.0.0 beta 4

This commit is contained in:
Neo committed 2025-12-19 16:57:00 -08:00
1 parent e86153356a
commit 2f24f9de48
276 files changed
+8614 -6044

No files matched your search

+44 -46
View File
@@ -16,6 +16,7 @@ namespace IPS\convert\Library;
use ErrorException;
use IPS\convert\App;
use IPS\convert\Exception;
use IPS\convert\Software;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
@@ -50,7 +51,7 @@ class Forums extends Core
/**
* @brief Application
*/
public $app = 'forums';
public string $app = 'forums';
/**
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
@@ -58,7 +59,7 @@ class Forums extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$classname = get_class( $this->software );
@@ -145,7 +146,7 @@ class Forums extends Core
$return[ $k ] = array(
'step_title' => 'convert_forums_rss_imported',
'step_method' => 'convertForumsRssImported',
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_rss_imported', array( 'rss_imported_import_id IN(' . (string) Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) )->first(),
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_rss_imported', array( 'rss_imported_import_id IN(' . Db::i()->select( 'rss_import_id', 'core_rss_import', array( "rss_import_class='IPS\\forums\\Topic'" ) ) . ')' ) )->first(),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertForumsTopics', 'convertForumsRssImports' ),
@@ -205,7 +206,7 @@ class Forums extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_topics',
'step_method' => 'convertClubTopics',
'ips_rows' => Db::i()->select( 'COUNT(tid)', 'forums_topics', array( 'forum_id IN ( ' . (string) Db::i()->select( 'id', 'forums_forums', array( "club_id IS NOT NULL" ) ) . ')' ) ),
'ips_rows' => Db::i()->select( 'COUNT(tid)', 'forums_topics', array( 'forum_id IN ( ' . Db::i()->select( 'id', 'forums_forums', array( "club_id IS NOT NULL" ) ) . ')' ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubForums' ),
@@ -254,7 +255,7 @@ class Forums extends Core
* @param bool $rowCount Count local rows
* @return array
*/
public function getMethodFromMenuRows( $method, $rowCount=FALSE )
public function getMethodFromMenuRows( string $method, bool $rowCount=FALSE ) : array
{
if( $method == 'convertForumsBoards' )
{
@@ -270,11 +271,12 @@ class Forums extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
if( $classname::canConvert() === NULL )
{
return array();
@@ -327,11 +329,11 @@ class Forums extends Core
break;
case 'convertForumsRssImported':
$retun['convertForumsRssImported'] = array( 'forums_rss_imported' => NULL );
$return['convertForumsRssImported'] = array( 'forums_rss_imported' => NULL );
break;
case 'convertForumsQuestionRatings':
$retun['convertForumsQuestionRatings'] = array( 'forums_question_ratings' => NULL );
$return['convertForumsQuestionRatings'] = array( 'forums_question_ratings' => NULL );
break;
case 'convertForumsAnswerRatings':
@@ -352,11 +354,11 @@ class Forums extends Core
break;
case 'convertClubTopics':
$return['convertClubTopics'] = array( 'forums_topics' => array( 'tid IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_topics' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubTopics'] = array( 'forums_topics' => array( 'tid IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_topics' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
case 'convertClubPosts':
$return['convertClubPosts'] = array( 'forums_posts' => array( 'pid IN ( ' . (string) Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_posts' AND app={$this->software->app->app_id}" ) ) . ')' ) );
$return['convertClubPosts'] = array( 'forums_posts' => array( 'pid IN ( ' . Db::i()->select( 'ipb_id', 'convert_link', array( "type='core_clubs_posts' AND app={$this->software->app->app_id}" ) ) . ')' ) );
break;
}
}
@@ -384,9 +386,9 @@ class Forums extends Core
* @param array|NULL $perms Permissions or NULL to insert no permissions.
* @param string|NULL $iconpath The path to the forums icon, or NULL.
* @param string|NULL $icondata The binary data for the forums icon, or NULL.
* @return integer|boolean The ID of the newly inserted forum, or FALSE on failure.
* @return int|bool The ID of the newly inserted forum, or FALSE on failure.
*/
public function convertForumsForum( $info=array(), $perms=NULL, $iconpath=NULL, $icondata=NULL )
public function convertForumsForum( array $info=array(), ?array $perms=NULL, ?string $iconpath=NULL, ?string $icondata=NULL ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -810,15 +812,11 @@ class Forums extends Core
$info['icon'] = NULL;
}
}
catch( \Exception $e )
catch( \Exception|ErrorException $e )
{
$info['icon'] = NULL;
}
catch( ErrorException $e )
{
$info['icon'] = NULL;
}
if ( isset( $info['club_id'] ) )
{
try
@@ -881,9 +879,9 @@ class Forums extends Core
/**
* Get Parent Forum ID for Orphaned Forums
*
* @return integer The ID of the forum created for forums that do not have a parent forum.
* @return int The ID of the forum created for forums that do not have a parent forum.
*/
protected function _getOrphanedForumCategory()
protected function _getOrphanedForumCategory() : int
{
try
{
@@ -905,9 +903,9 @@ class Forums extends Core
* Convert a topic
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted topic, or FALSE on failure
* @return int|bool The ID of the newly inserted topic, or FALSE on failure
*/
public function convertForumsTopic( $info=array() )
public function convertForumsTopic( array $info=array() ) : bool|int
{
if ( !isset( $info['tid'] ) )
{
@@ -1249,9 +1247,9 @@ class Forums extends Core
* Convert a Forum Post
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted post, or FALSE on failure.
* @return int|bool The ID of the newly inserted post, or FALSE on failure.
*/
public function convertForumsPost( $info=array() )
public function convertForumsPost( array $info=array() ) : bool|int
{
if ( !isset( $info['pid'] ) )
{
@@ -1441,7 +1439,7 @@ class Forums extends Core
$topicUpdate['topic_firstpost'] = $inserted_id;
}
if ( $isBestAnswer == TRUE )
if ( $isBestAnswer )
{
$topicUpdate['topic_answered_pid'] = $inserted_id;
}
@@ -1458,9 +1456,9 @@ class Forums extends Core
* Convert an Archived Post
*
* @param array $info Data to insert
* @param integer|boolean The ID of the newly inserted Archived Post, or FALSE on failure.
* @return int|bool The ID of the newly inserted Archived Post, or FALSE on failure.
*/
public function convertForumsArchivedPost( $info=array() )
public function convertForumsArchivedPost( array $info=array() ) : bool|int
{
/* This works a little differently... we actually need to insert it into the main posts table first, then move it. As such, the $info array should match that of the main posts method EXCEPT for a few keys which we'll extract out. */
if ( isset( $info['archive_added'] ) )
@@ -1478,7 +1476,7 @@ class Forums extends Core
/* If $return is FALSE, stop here. Something went wrong. */
if ( $return === FALSE )
{
return $return;
return false;
}
/* Re-extract the post. We need the topic too. */
@@ -1528,9 +1526,9 @@ class Forums extends Core
* Convert a forums topic multimod
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted Multi Mod, or FALSE on failure.
* @return int|bool The ID of the newly inserted Multi Mod, or FALSE on failure.
*/
public function convertForumsTopicMultimod( $info=array() )
public function convertForumsTopicMultimod( array $info=array() ) : bool|int
{
/* Another instance where we do not necessarily need this, but will store anyway if we have it */
$hasId = TRUE;
@@ -1687,9 +1685,9 @@ class Forums extends Core
* Convert an RSS Import Feed
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted import feed, or FALSE on failure.
* @return int|bool The ID of the newly inserted import feed, or FALSE on failure.
*/
public function convertForumsRssImport( $info=array() )
public function convertForumsRssImport( array $info=array() ) : bool|int
{
$info['rss_import_class'] = 'IPS\\forums\\Topic';
@@ -1713,9 +1711,9 @@ class Forums extends Core
* Convert an RSS Imported Topic... or try to, anyway.
*
* @param array $info Data to insert
* @return boolean TRUE on success, or FALSE on failure.
* @return bool|int TRUE on success, or FALSE on failure.
*/
public function convertForumsRssImported( $info=array() )
public function convertForumsRssImported( array $info=array() ) : bool|int
{
return parent::convertRssImported( $info, 'forums_rss_import', 'forums_topics' );
}
@@ -1724,9 +1722,9 @@ class Forums extends Core
* Convert a question rating
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted rating, or FALSE on failure.
* @return int|bool The ID of the newly inserted rating, or FALSE on failure.
*/
public function convertForumsQuestionRating( $info=array() )
public function convertForumsQuestionRating( array $info=array() ) : bool|int
{
/* We do not need to store an ID if one isn't present */
$hasId = TRUE;
@@ -1844,9 +1842,9 @@ class Forums extends Core
* Convert an Answer Rating
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted rating, or FALSE on failure.
* @return int|bool The ID of the newly inserted rating, or FALSE on failure.
*/
public function convertForumsAnswerRating( $info=array() )
public function convertForumsAnswerRating( array $info=array() ) : bool|int
{
/* We do not need to store an ID if one is not present */
$hasId = TRUE;
@@ -1968,9 +1966,9 @@ class Forums extends Core
* @param NULL|string $filepath The path to the attachment files or NULL if loading from the database.
* @param NULL|string $filedata If loading from the database, the content of the Binary column.
* @param NULL|string $thumbnailpath Path to thumbnail image
* @return boolean|integer The ID of the newly inserted attachment, or FALSE on failure.
* @return bool|int The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath=NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath=NULL ) : bool|int
{
/* The Core Library handles most of this. We just need to make sure forum specific data is set. */
$map['id1_type'] = 'forums_topics';
@@ -1986,9 +1984,9 @@ class Forums extends Core
* Convert a Club Forum
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted forum, or FALSE on failure.
* @return int|bool The ID of the newly inserted forum, or FALSE on failure.
*/
public function convertClubForum( $info=array() )
public function convertClubForum( array $info=array() ) : bool|int
{
$insertedId = $this->convertForumsForum( $info );
if ( $insertedId )
@@ -2002,9 +2000,9 @@ class Forums extends Core
* Convert a Club Topic
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted topic, or FALSE on failure.
* @return int|bool The ID of the newly inserted topic, or FALSE on failure.
*/
public function convertClubTopic( $info=array() )
public function convertClubTopic( array $info=array() ) : bool|int
{
$insertedId = $this->convertForumsTopic( $info );
if ( $insertedId )
@@ -2018,9 +2016,9 @@ class Forums extends Core
* Convert a Club Post
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted post, or FALSE on failure.
* @return int|bool The ID of the newly inserted post, or FALSE on failure.
*/
public function convertClubPost( $info=array() )
public function convertClubPost( array $info=array() ) : bool|int
{
$insertedId = $this->convertForumsPost( $info );
if ( $insertedId )