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

+136 -153
View File
@@ -19,16 +19,15 @@ use ErrorException;
use InvalidArgumentException;
use IPS\Application;
use IPS\Content;
use IPS\Content\Reaction;
use IPS\convert\App;
use IPS\convert\Library;
use IPS\convert\Software;
use IPS\core\Acronym;
use IPS\core\Announcements\Announcement;
use IPS\core\Ignore;
use IPS\core\ProfileFields\Field;
use IPS\core\StaffDirectory\User;
use IPS\Data\Store;
use IPS\Date\Time;
use IPS\DateTime;
use IPS\Db;
use IPS\Db\Exception;
@@ -46,7 +45,6 @@ use IPS\Request;
use IPS\Settings;
use IPS\Text\ConverterParser;
use IPS\Text\LegacyParser;
use IPS\Text\Parser;
use LogicException;
use OutOfRangeException;
use UnderflowException;
@@ -78,7 +76,7 @@ class Core extends Library
/**
* @brief Application
*/
public $app = 'core';
public string $app = 'core';
/**
* 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
@@ -86,7 +84,7 @@ class Core extends Library
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ): array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -570,11 +568,12 @@ class Core extends Library
* @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();
@@ -757,7 +756,7 @@ class Core extends Library
}
}
return isset( $return[ $method ] ) ? $return[ $method ] : array();
return $return[$method] ?? array();
}
/**
@@ -768,9 +767,9 @@ class Core extends Library
/**
* A note on logging -
* If the data is missing and it is unlikely that any source software would be able to provide this, we do not need to log anything and can use default data (for example, group_layout in convertLeaderGroups).
* If the data is missing and it is likely that a majority of the source software can provide this, we should log a NOTICE and use default data (for example, a_casesensitive in convertAcronyms).
* If the data is missing and it is required to convert the item, we should log a WARNING and return FALSE.
* If the data is missing, and it is unlikely that any source software would be able to provide this, we do not need to log anything and can use default data (for example, group_layout in convertLeaderGroups).
* If the data is missing, and it is likely that a majority of the source software can provide this, we should log a NOTICE and use default data (for example, a_casesensitive in convertAcronyms).
* If the data is missing, and it is required to convert the item, we should log a WARNING and return FALSE.
* If the conversion absolutely cannot proceed at all (filestorage locations not writable, for example), then we should log an ERROR and throw an \IPS\convert\Exception to completely halt the process and redirect to an error screen showing the last logged error.
*/
@@ -782,7 +781,7 @@ class Core extends Library
* @param string|NULL $imageData Binary image data, or NULL.
* @return bool|int The ID of the newly inserted badge, or FALSE on failure
*/
public function convertAchievementBadge( array $info=[], string $imagePath=NULL, string $imageData=NULL )
public function convertAchievementBadge( array $info=[], ?string $imagePath=NULL, ?string $imageData=NULL ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -844,7 +843,7 @@ class Core extends Library
* @param string|NULL $imageData Binary image data, or NULL.
* @return bool|int The ID of the newly inserted badge, or FALSE on failure
*/
public function convertAchievementRank( array $info=[], string $imagePath=NULL, string $imageData=NULL )
public function convertAchievementRank( array $info=[], ?string $imagePath=NULL, ?string $imageData=NULL ) : bool|int
{
/* We don't really need an ID for these, so if one isn't specified, then that's okay. */
$hasId = TRUE;
@@ -902,9 +901,9 @@ class Core extends Library
* Convert an Acronym
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted acronym, or FALSE on failure
* @return bool|int The ID of the newly inserted acronym, or FALSE on failure
*/
public function convertAcronym( $info=array() )
public function convertAcronym( array $info=array() ) : bool|int
{
/**
* The below are examples of when we should use an error or a notice, depending on the situation.
@@ -950,9 +949,9 @@ class Core extends Library
* Convert an Administrator
*
* @param array $info Data to insert
* @return boolean TRUE on success, FALSE on failure
* @return bool TRUE on success, FALSE on failure
*/
public function convertAdministrator( $info=array() )
public function convertAdministrator( array $info=array() ) : bool
{
if ( !isset( $info['row_id'] ) )
{
@@ -1019,15 +1018,16 @@ class Core extends Library
}
Db::i()->insert( 'core_admin_permission_rows', $info );
return true;
}
/**
* Convert an Announcement
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted announcement, or FALSE on failure
* @return bool|int The ID of the newly inserted announcement, or FALSE on failure
*/
public function convertAnnouncement( $info=array() )
public function convertAnnouncement( array $info=array() ) : bool|int
{
if ( !isset( $info['announce_id'] ) )
{
@@ -1152,9 +1152,9 @@ class Core extends Library
* @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
{
if ( !isset( $info['attach_id'] ) )
{
@@ -1476,9 +1476,9 @@ class Core extends Library
* Convert a Ban Filter
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted ban filter, or FALSE on failure
* @return bool|int The ID of the newly inserted ban filter, or FALSE on failure
*/
public function convertBanfilter( $info=array() )
public function convertBanfilter( array $info=array() ) : bool|int
{
if ( !isset( $info['ban_id'] ) )
{
@@ -1520,9 +1520,9 @@ class Core extends Library
* Convert Custom BBCode for the LegacyParser to use
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted BBCode, or FALSE on failure.
* @return bool|int The ID of the newly inserted BBCode, or FALSE on failure.
*/
public function convertCustomBbcode( $info=array() )
public function convertCustomBbcode( array $info=array() ) : bool|int
{
if ( !isset( $info['bbcode_id'] ) )
{
@@ -1586,9 +1586,9 @@ class Core extends Library
* Convert Display Name History
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Display Name History, or FALSE on failure.
* @return bool|int The ID of the newly inserted Display Name History, or FALSE on failure.
*/
public function convertDnameChange( $info=array() )
public function convertDnameChange( array $info=array() ) : bool|int
{
// not sure if we really need this?
if ( !isset( $info['old_id'] ) )
@@ -1658,9 +1658,9 @@ class Core extends Library
* Convert an Edit History Log
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Edit History, or FALSE on failure.
* @return bool|int The ID of the newly inserted Edit History, or FALSE on failure.
*/
public function convertEditHistory( $info=array() )
public function convertEditHistory( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -1668,7 +1668,7 @@ class Core extends Library
return FALSE;
}
if ( !isset( $info['class'] ) OR !in_array( $info['class'], \IPS\Content::routedClasses() ) )
if ( !isset( $info['class'] ) OR !in_array( $info['class'], Content::routedClasses() ) )
{
$this->software->app->log( 'edit_history_missing_class', __METHOD__, App::LOG_WARNING, $info['id'] );
return FALSE;
@@ -1752,7 +1752,7 @@ class Core extends Library
if ( isset( $info['public'] ) )
{
$info['public'] = (boolean) $info['public'];
$info['public'] = (bool) $info['public'];
}
else
{
@@ -1777,15 +1777,15 @@ class Core extends Library
*
* @param array $info Data to insert
* @param NULL|array $set Set to store this emoticon in.
* @param boolean $keepExisting If TRUE, then if an emoticon code already exists in our database, we'll keep that one. FALSE means overwrite it.
* @param bool $keepExisting If TRUE, then if an emoticon code already exists in our database, we'll keep that one. FALSE means overwrite it.
* @param NULL|string $filepath Path to 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 $filepathx2 Path to the x2 size emoticon, or NULL if it doesn't exist.
* @param NULL|string $filedatax2 File Data for the x2 size emoticon, or NULL if it doesn't exist.
* @return boolean|integer The ID of the newly inserted emoticon, or FALSE on failure.
* @return bool|int The ID of the newly inserted emoticon, or FALSE on failure.
* @todo Handle emoticons without a defined set.
*/
public function convertEmoticon( $info=array(), $set=NULL, $keepExisting=TRUE, $filepath=NULL, $filedata=NULL, $filepathx2=NULL, $filedatax2=NULL )
public function convertEmoticon( array $info=array(), ?array $set=NULL, bool $keepExisting=TRUE, ?string $filepath=NULL, ?string $filedata=NULL, ?string $filepathx2=NULL, ?string $filedatax2=NULL ) : bool|int
{
/* We don't really need an ID for these */
$haveID = TRUE;
@@ -1858,7 +1858,7 @@ class Core extends Library
$info['emo_set'] = $set['set'];
$info['emo_set_position'] = $set['position'];
if ( Member::loggedIn()->language()->checkKeyExists( "core_emoticon_group_{$info['emo_set']}" ) == FALSE )
if ( !Member::loggedIn()->language()->checkKeyExists( "core_emoticon_group_{$info['emo_set']}" ) )
{
Lang::saveCustom( 'core', "core_emoticon_group_{$info['emo_set']}", $set['title'] );
}
@@ -1904,11 +1904,7 @@ class Core extends Library
$filex2 = File::create( 'core_Emoticons', $info['filenamex2'], $filedatax2, 'emoticons', FALSE, NULL, static::$obscureFilenames );
$info['image_2x'] = (string) $filex2;
}
catch( \Exception $e )
{
$info['image_2x'] = NULL;
}
catch( ErrorException $e )
catch( \Exception|ErrorException $e )
{
$info['image_2x'] = NULL;
}
@@ -1935,10 +1931,10 @@ class Core extends Library
* Convert Follow Data
*
* @param array $info Data to insert
* @return boolean Unlike other methods, we do not need to return an ID for the converted follow - so simply return TRUE on success, or FALSE on failure.
* @return bool Unlike other methods, we do not need to return an ID for the converted follow - so simply return TRUE on success, or FALSE on failure.
* @note This method should not have an individual step, but rather be called during others (ex. when converting topics, insert any follows at that point)
*/
public function convertFollow( $info=array() )
public function convertFollow( array $info=array() ) : bool
{
if ( !isset( $info['follow_app'] ) )
{
@@ -2057,7 +2053,7 @@ class Core extends Library
/**
* @brief Bitwise are protected in \IPS\Member\Group, so copying here.
*/
protected static $groupBitOptions = array(
protected static array $groupBitOptions = array(
'gbw_mod_post_unit_type' => 1, // Lift moderation after x. 1 is days, 0 is posts. Corresponds to g_mod_post_unit
'gbw_ppd_unit_type' => 2, // Lift post-per-day limit after x. 1 is days, 0 is posts. Corresponds to g_ppd_unit
'gbw_displayname_unit_type' => 4, // Username change restrictions. 1 is days, 0 is posts. Corresponds to g_displayname_unit
@@ -2095,13 +2091,13 @@ class Core extends Library
* Convert a Member Group
*
* @param array $info Data to insert
* @param integer|NULL $mergeWith THe ID of the group to merge this one into, or NULL to create new.
* @param int|NULL $mergeWith THe ID of the group to merge this one into, or NULL to create new.
* @param string|NULL $iconpath Path to Icon file for the group, or NULL.
* @param string|NULL $icondata Binary Icon Data, or NULL.
* @return boolean|integer The ID of the newly inserted group, or FALSE on failure.
* @return bool|int The ID of the newly inserted group, or FALSE on failure.
* @note Other libraries will handle their own settings
*/
public function convertGroup( $info=array(), $mergeWith=NULL, $iconpath=NULL, $icondata=NULL )
public function convertGroup( array $info=array(), ?int $mergeWith=NULL, ?string $iconpath=NULL, ?string $icondata=NULL ) : bool|int
{
if ( !isset( $info['g_id'] ) )
{
@@ -2140,11 +2136,7 @@ class Core extends Library
$file = File::create( 'core_Theme', $info['g_icon'], $icondata );
$info['g_icon'] = (string) $file;
}
catch( \Exception $e )
{
$info['g_icon'] = NULL;
}
catch( ErrorException $e )
catch( \Exception|ErrorException $e )
{
$info['g_icon'] = NULL;
}
@@ -2209,7 +2201,7 @@ class Core extends Library
continue;
}
if ( isset( $info['g_bitoptions'][$key] ) AND $info['g_bitoptions'][$key] == TRUE )
if ( isset( $info['g_bitoptions'][$key] ) AND $info['g_bitoptions'][$key] )
{
$bitoptions += $value;
}
@@ -2256,10 +2248,6 @@ class Core extends Library
$info[$otherDefault] = '';
break;
case 'g_max_mass_pm':
$info[$otherDefault] = 10;
break;
case 'g_search_flood':
$info[$otherDefault] = 3;
break;
@@ -2270,6 +2258,7 @@ class Core extends Library
case 'g_rep_max_positive':
case 'g_rep_max_negative':
case 'g_max_mass_pm':
$info[$otherDefault] = 10;
break;
}
@@ -2338,15 +2327,15 @@ class Core extends Library
/**
* @brief Store group promotion values temporarily to convert after groups are done
*/
public $groupPromotions = array();
public array $groupPromotions = array();
/**
* Convert a group promotion rule
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted promotion rule, or FALSE on error.
* @return bool|int The ID of the newly inserted promotion rule, or FALSE on error.
*/
public function convertGroupPromotion( $info=array() )
public function convertGroupPromotion( array $info=array() ) : bool|int
{
if ( !isset( $info['newgroup'] ) OR !isset( $info['oldgroup'] ) )
{
@@ -2415,9 +2404,9 @@ class Core extends Library
* Convert an Ignored User
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Ignore, or FALSE on error.
* @return bool|int The ID of the newly inserted Ignore, or FALSE on error.
*/
public function convertIgnoredUser( $info=array() )
public function convertIgnoredUser( array $info=array() ) : bool|int
{
if ( !isset( $info['ignore_id'] ) )
{
@@ -2480,9 +2469,9 @@ class Core extends Library
* Convert a Staff Directory Entry
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Leader, or FALSE on failure.
* @return bool|int The ID of the newly inserted Leader, or FALSE on failure.
*/
public function convertLeader( $info=array() )
public function convertLeader( array $info=array() ) : bool|int
{
if ( !isset( $info['leader_id'] ) )
{
@@ -2548,7 +2537,7 @@ class Core extends Library
$info['leader_group_id'] = $this->software->app->getLink( $info['leader_group_id'], 'core_leader_groups' );
}
catch( LogicException $e ) /* LogicException here so as to accommodate for catching both OutOfRangeException and DomainException - we don't care which was thrown */
catch( LogicException $e ) /* LogicException here to accommodate for catching both OutOfRangeException and DomainException - we don't care which was thrown */
{
try
{
@@ -2585,9 +2574,9 @@ class Core extends Library
* Convert a Staff Directory Group
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted Staff Directory Group, or FALSE on failure.
* @return bool|int The ID of the newly inserted Staff Directory Group, or FALSE on failure.
*/
public function convertLeaderGroup( $info=array() )
public function convertLeaderGroup( array $info=array() ) : bool|int
{
if ( !isset( $info['group_id'] ) )
{
@@ -2630,9 +2619,9 @@ class Core extends Library
* @param array $info Data to insert
* @param string|NULL $iconpath Icon File Path, or NULL
* @param string|NULL $icondata Icon File Data, or NULL
* @return boolean|integer The ID of the newly inserted Rank, or FALSE on failure.
* @return bool|int The ID of the newly inserted Rank, or FALSE on failure.
*/
public function convertRank( $info=array(), $iconpath=NULL, $icondata=NULL )
public function convertRank( array $info=array(), ?string $iconpath=NULL, ?string $icondata=NULL ) : bool|int
{
$this->software->app->log( 'method_deprecated', __METHOD__, App::LOG_WARNING );
return FALSE;
@@ -2641,7 +2630,7 @@ class Core extends Library
/**
* @brief Cache login handlers
*/
protected static $_loginMethods = NULL;
protected static ?array $_loginMethods = NULL;
/**
* Convert a Member
@@ -2654,10 +2643,10 @@ class Core extends Library
* @param NULL|string $coverPhotoName Filename for the users Cover Photo or NULL if none set.
* @param NULL|string $coverPhotoPath Path to Cover Photos, or NULL to load from the database.
* @param NULL|string $coverFileData If loading from the database, the filedatafor the cover photo from the Binary column.
* @return boolean|integer The ID of the newly inserted member, or FALSE on failure.
* @return bool|int The ID of the newly inserted member, or FALSE on failure.
* @todo Work out if we can convert Social Login Stuff.
*/
public function convertMember( $info=array(), $profileFields=array(), $profilePhotoName=NULL, $profilePhotoPath=NULL, $profileFileData=NULL, $coverPhotoName=NULL, $coverPhotoPath=NULL, $coverFileData=NULL )
public function convertMember( array $info=array(), array $profileFields=array(), ?string $profilePhotoName=NULL, ?string $profilePhotoPath=NULL, ?string $profileFileData=NULL, ?string $coverPhotoName=NULL, ?string $coverPhotoPath=NULL, ?string $coverFileData=NULL ) : bool|int
{
if ( !isset( $info['member_id'] ) )
{
@@ -3078,7 +3067,7 @@ class Core extends Library
{
foreach( Member::$bitOptions['members_bitoptions']['members_bitoptions'] AS $key => $value )
{
if ( isset( $info['members_bitoptions'][$key] ) AND $info['members_bitoptions'][$key] == TRUE )
if ( isset( $info['members_bitoptions'][$key] ) AND $info['members_bitoptions'][$key] )
{
$bitoptions += $value;
}
@@ -3096,7 +3085,7 @@ class Core extends Library
{
foreach( Member::$bitOptions['members_bitoptions']['members_bitoptions2'] AS $key => $value )
{
if ( isset( $info['members_bitoptions2'][$key] ) AND $info['members_bitoptions2'] == TRUE )
if ( isset( $info['members_bitoptions2'][$key] ) AND $info['members_bitoptions2'] )
{
$bitoptions2 += $value;
}
@@ -3214,7 +3203,7 @@ class Core extends Library
$cover = File::create( 'core_Profile', $coverPhotoName, $coverFileData );
$info['pp_cover_photo'] = (string) $cover;
/* Designs are different so this will never likely be correct, we'll try it if one is supplied though */
$info['pp_cover_offset'] = isset( $info['pp_cover_offset'] ) ? $info['pp_cover_offset'] : 0;
$info['pp_cover_offset'] = $info['pp_cover_offset'] ?? 0;
}
catch( ErrorException | \Exception $e )
{
@@ -3270,7 +3259,7 @@ class Core extends Library
if ( isset( $info['allow_admin_mails'] ) )
{
$info['allow_admin_mails'] = (boolean) $info['allow_admin_mails'];
$info['allow_admin_mails'] = (bool) $info['allow_admin_mails'];
}
else
{
@@ -3354,9 +3343,9 @@ class Core extends Library
* Convert member history
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted member history record, or FALSE on failure
* @return bool|int The ID of the newly inserted member history record, or FALSE on failure
*/
public function convertMemberHistory( $info=array() )
public function convertMemberHistory( array $info=array() ) : bool|int
{
if ( !isset( $info['log_id'] ) )
{
@@ -3492,9 +3481,9 @@ class Core extends Library
* Convert a Warning Action
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted warning action, or FALSE on failure.
* @return bool|int The ID of the newly inserted warning action, or FALSE on failure.
*/
public function convertWarnAction( $info=array() )
public function convertWarnAction( array $info=array() ) : bool|int
{
/* We do not really need an ID here */
$hasId = TRUE;
@@ -3564,10 +3553,10 @@ class Core extends Library
* Convert a Warning Log
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted warning log, or FALSE on failure.
* @return bool|int The ID of the newly inserted warning log, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertWarnLog( $info=array() )
public function convertWarnLog( array $info=array() ) : bool|int
{
if ( !isset( $info['wl_id'] ) )
{
@@ -3745,9 +3734,9 @@ class Core extends Library
* Convert a Warning Reason
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted warning reason, or FALSE on failure.
* @return bool|int The ID of the newly inserted warning reason, or FALSE on failure.
*/
public function convertWarnReason( $info=array() )
public function convertWarnReason( array $info=array() ) : bool|int
{
if ( !isset( $info['wr_id'] ) )
{
@@ -3811,9 +3800,9 @@ class Core extends Library
*
* @param array $topic The Message Topic Data to insert
* @param array $maps The User Map Data to insert. Example: array( memberId => array( data ) )
* @return boolean|integer The ID of the newly inserted Message Topic, or FALSE on failure.
* @return bool|int The ID of the newly inserted Message Topic, or FALSE on failure.
*/
public function convertPrivateMessage( $topic=array(), $maps=array() )
public function convertPrivateMessage( array $topic=array(), array $maps=array() ) : bool|int
{
if ( !isset( $topic['mt_id'] ) )
{
@@ -3949,7 +3938,7 @@ class Core extends Library
/* We already know this */
$map['map_topic_id'] = $topicInsertedId;
if ( !isset( $map['map_folder_id'] ) OR ( isset( $map['map_folder_id'] ) AND empty( $map['map_folder_id'] ) ) )
if ( !isset( $map['map_folder_id'] ) OR empty( $map['map_folder_id'] ) )
{
$map['map_folder_id'] = 'myconvo';
}
@@ -4079,7 +4068,7 @@ class Core extends Library
* @param array $info Data to insert
* @return bool|int The ID of the newly inserted reply, or FALSE on failure.
*/
public function convertPrivateMessageReply( $info=array() )
public function convertPrivateMessageReply( array $info=array() ) : bool|int
{
if ( !isset( $info['msg_id'] ) )
{
@@ -4155,9 +4144,9 @@ class Core extends Library
* Convert a Moderator
*
* @param array $info Data to insert
* @return boolean TRUE on success, or FALSE on failure.
* @return bool TRUE on success, or FALSE on failure.
*/
public function convertModerator( $info=array() )
public function convertModerator( array $info=array() ) : bool
{
if ( !isset( $info['type'] ) OR !in_array( $info['type'], array( 'g', 'm' ) ) )
{
@@ -4224,10 +4213,10 @@ class Core extends Library
* Convert Permissions
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted permission row, or FALSE on failure.
* @return bool|int The ID of the newly inserted permission row, or FALSE on failure.
* @note These should be converted when the relevant node is converted.
*/
public function convertPermission( $info=array() )
public function convertPermission( array $info=array() ) : bool|int
{
/* Valid app? */
if ( !isset( $info['app'] ) )
@@ -4240,7 +4229,7 @@ class Core extends Library
{
$application = Application::load( $info['app'] );
if ( Application::appIsEanbled( $info['app'] ) === FALSE )
if ( Application::appIsEnabled( $info['app'] ) === FALSE )
{
throw new UnexpectedValueException;
}
@@ -4392,7 +4381,7 @@ class Core extends Library
continue;
}
if ( !in_array( $currentGroups ) )
if ( !in_array( $group, $currentGroups ) )
{
$groupsToAdd[] = $group;
}
@@ -4418,10 +4407,10 @@ class Core extends Library
* Convert a Profile Field Group
*
* @param array $info Data to insert
* @param integer|NULL $mergeWith The group we are merging with, or NULL to not merge.
* @return boolean|integer The ID of the newly inserted profile field group, or FALSE on failure
* @param int|NULL $mergeWith The group we are merging with, or NULL to not merge.
* @return bool|int The ID of the newly inserted profile field group, or FALSE on failure
*/
public function convertProfileFieldGroup( $info=array(), $mergeWith=NULL )
public function convertProfileFieldGroup( array $info=array(), ?int $mergeWith=NULL ) : bool|int
{
if ( !isset( $info['pf_group_id'] ) )
{
@@ -4467,11 +4456,11 @@ class Core extends Library
* Convert a Profile Field
*
* @param array $info Data to insert
* @param integer|NULL $mergeWith THe ID of an existing profile field to merge this one with, or NULL to create new.
* @return boolean|integer The ID of the newly inserted profile field, or FALSE on failure.
* @param int|NULL $mergeWith THe ID of an existing profile field to merge this one with, or NULL to create new.
* @return bool|int The ID of the newly inserted profile field, or FALSE on failure.
* @note Profile Field Content for individual members needs to be done during the members step, not here.
*/
public function convertProfileField( $info=array(), $mergeWith=NULL )
public function convertProfileField( array $info=array(), ?int $mergeWith=NULL ) : bool|int
{
/* Get valid fields while taking hooks into account */
$validFields = array_merge( static::$fieldTypes, Field::$additionalFieldTypes );
@@ -4657,7 +4646,7 @@ class Core extends Library
/**
* @brief All local custom fields
*/
protected $cachedFields = NULL;
protected ?array $cachedFields = NULL;
/**
* Get profile fields using cache
@@ -4666,13 +4655,11 @@ class Core extends Library
* @return array
* @throws UnderflowException
*/
protected function _getField( $fieldId )
protected function _getField( int $fieldId ) : array
{
if( $this->cachedFields === NULL )
{
$fields = iterator_to_array( Db::i()->select( '*', 'core_pfields_data' )->setKeyField('pf_id') );
$this->cachedFields = ( is_array( $fields ) ) ? $fields : array();
$this->cachedFields = iterator_to_array( Db::i()->select( '*', 'core_pfields_data' )->setKeyField('pf_id') );
}
if( !isset( $this->cachedFields[ $fieldId ] ) )
@@ -4686,7 +4673,7 @@ class Core extends Library
/**
* @brief Store of field IDs to skip formatting
*/
protected $_skipFields = [];
protected array $_skipFields = [];
/**
* Format Member Profile Field Content
@@ -4695,7 +4682,7 @@ class Core extends Library
* @param array $fieldInfo The Profile Field Information to format. This SHOULD be in $foreign_id => $content format, however field_$foreign_id => $content is also accepted.
* @return array An array of data formatted for core_pfields_content
*/
protected function _formatMemberProfileFieldContent( $member_id, $fieldInfo )
protected function _formatMemberProfileFieldContent( int $member_id, array $fieldInfo ) : array
{
$return = array( 'member_id' => $member_id );
@@ -4774,10 +4761,10 @@ class Core extends Library
*
* @param array $info Data to insert
* @param array $votes Vote Data
* @return boolean|integer The ID of the newly inserted Poll, or false on failure.
* @return bool|int The ID of the newly inserted Poll, or false on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertPoll( $info=array(), $votes=array() )
public function convertPoll( array $info=array(), array $votes=array() ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -4973,9 +4960,9 @@ class Core extends Library
* Convert a Profanity Filter
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted profanity filter, or FALSE on failure.
* @return bool|int The ID of the newly inserted profanity filter, or FALSE on failure.
*/
public function convertProfanityFilter( $info=array() )
public function convertProfanityFilter( array $info=array() ) : bool|int
{
if ( !isset( $info['wid'] ) )
{
@@ -5016,11 +5003,11 @@ class Core extends Library
/**
* Convert Question and Answer Spam Prevention
*
* @param string $info Data to insert
* @param array $info Data to insert
* @param array $answers The answers
* @return boolean|integer The ID of the newly insert Q&A, or FALSE on failure.
* @return bool|int The ID of the newly insert Q&A, or FALSE on failure.
*/
public function convertQuestionAndAnswer( $info, $answers=array() )
public function convertQuestionAndAnswer( array $info, array $answers=array() ) : bool|int
{
$haveId = TRUE;
if ( !isset( $info['qa_id'] ) )
@@ -5067,10 +5054,10 @@ class Core extends Library
* Convert a Rating
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted rating, or FALSE on failure.
* @return bool|int The ID of the newly inserted rating, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertRating( $info=array() )
public function convertRating( array $info=array() ) : bool|int
{
$haveId = TRUE;
if ( !isset( $info['id'] ) )
@@ -5158,10 +5145,10 @@ class Core extends Library
* Convert a Report Index
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted report index, or FALSE on failure.
* @return bool|int The ID of the newly inserted report index, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertReportIndex( $info=array() )
public function convertReportIndex( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -5169,7 +5156,7 @@ class Core extends Library
return FALSE;
}
$contentClasses = \IPS\Content::routedClasses();
$contentClasses = Content::routedClasses();
if ( !isset( $info['class'] ) OR !in_array( $info['class'], $contentClasses ) )
{
$this->software->app->log( 'report_index_invalid_class', __METHOD__, App::LOG_WARNING, $info['id'] );
@@ -5276,10 +5263,10 @@ class Core extends Library
* @param array $info Data to insert
* @param NULL|string $filePath Path to files, or NULL if loading from the database.
* @param NULL|string $fileData If loading from the database, the content of the Binary column.
* @param integer|NULL $mergeWith The ID of the group to merge this one into, or NULL to create new.
* @param int|NULL $mergeWith The ID of the group to merge this one into, or NULL to create new.
* @return bool|int ID of new record on success, FALSE on failure
*/
public function convertReaction( $info=array(), $filePath=NULL, $fileData=NULL, int $mergeWith=NULL )
public function convertReaction( array $info=array(), ?string $filePath=NULL, ?string $fileData=NULL, ?int $mergeWith=NULL ) : bool|int
{
if ( !isset( $info['reaction_id'] ) )
{
@@ -5345,7 +5332,7 @@ class Core extends Library
try
{
$file = File::create( 'core_Reaction', $info['filename'], $fileData, 'reactions', FALSE, NULL );
$file = File::create( 'core_Reaction', $info['filename'], $fileData, 'reactions' );
unset( $info['filename'] );
$info['reaction_icon'] = (string) $file;
$file->getImageDimensions();
@@ -5380,10 +5367,10 @@ class Core extends Library
* Convert a Report
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted report, or FALSE on failure.
* @return bool|int The ID of the newly inserted report, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
*/
public function convertReport( $info=array() )
public function convertReport( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -5461,10 +5448,10 @@ class Core extends Library
* Convert a Report Comment
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted comment, or FALSE on failure.
* @return bool|int The ID of the newly inserted comment, or FALSE on failure.
* @note UNLIKE report indexes, this can be done separately.
*/
public function convertReportComment( $info=array() )
public function convertReportComment( array $info=array() ) : bool|int
{
if ( !isset( $info['id'] ) )
{
@@ -5559,10 +5546,10 @@ class Core extends Library
* Convert Reputation
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted reputation, or FALSE on failure.
* @return bool|int The ID of the newly inserted reputation, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached to is being converted.
*/
public function convertReputation( $info=array() )
public function convertReputation( array $info=array() ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -5610,7 +5597,7 @@ class Core extends Library
{
try
{
/* Try to lookup a reaction ID link */
/* Try to lookup reaction ID link */
try
{
$info['reaction'] = $this->software->app->getLink( $info['reaction'], 'core_reactions' );
@@ -5777,9 +5764,9 @@ class Core extends Library
* @param array $info Data to insert
* @param string|NULL $badgepath Path to Reputation Badge file.
* @param string|NULL $badgedata Binary data for Reputation Badge file.
* @return boolean|integer The ID of the newly inserted reputation level, or FALSE on failure.
* @return bool|int The ID of the newly inserted reputation level, or FALSE on failure.
*/
public function convertReputationLevel( $info=array(), $badgepath=NULL, $badgedata=NULL )
public function convertReputationLevel( array $info=array(), ?string $badgepath=NULL, ?string $badgedata=NULL ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -5815,11 +5802,7 @@ class Core extends Library
$file = File::create( 'core_Theme', $info['level_image'], $badgedata );
$info['level_image'] = (string) $file;
}
catch( \Exception $e )
{
$info['level_image'] = '';
}
catch( ErrorException $e )
catch( \Exception|ErrorException $e )
{
$info['level_image'] = '';
}
@@ -5851,11 +5834,11 @@ class Core extends Library
* Convert an RSS Import Feed
*
* @param array $info Data to insert
* @param array $containerType Container Link Type
* @param string $containerType Container Link Type
* @param string $newLinkType Link type to use
* @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 convertRssImport( $info, $containerType='forums_forums', $newLinkType='core_rss_import' )
public function convertRssImport( array $info, string $containerType='forums_forums', string $newLinkType='core_rss_import' ) : bool|int
{
if ( !isset( $info['rss_import_id'] ) )
{
@@ -5975,10 +5958,10 @@ class Core extends Library
*
* @param array $info Data to insert
* @param string $type Link type for RSS Feed
* @param mixed $contentType Content Link Type
* @return boolean TRUE on success, or FALSE on failure.
* @param string $contentType Content Link Type
* @return bool TRUE on success, or FALSE on failure.
*/
public function convertRssImported( $info=array(), $type='core_rss_import', $contentType='' )
public function convertRssImported( array $info=array(), string $type='core_rss_import', string $contentType='' ) : bool
{
/* Godspeed */
if ( isset( $info['rss_imported_import_id'] ) )
@@ -6031,9 +6014,9 @@ class Core extends Library
* Convert a Setting
*
* @param array $settings Settings to convert
* @return boolean|array An array of settings changed, or FALSE on failure.
* @return bool|array An array of settings changed, or FALSE on failure.
*/
public function convertSettings( $settings=array() )
public function convertSettings( array $settings=array() ) : bool|array
{
if ( !count( $settings ) )
{
@@ -6054,17 +6037,17 @@ class Core extends Library
/**
* @brief Store valid content class set by child converters, if contentrouter verification cannot be relied upon.
*/
protected $_ipsTagContentClass = NULL;
protected ?string $_ipsTagContentClass = NULL;
/**
* Convert a Tag
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted tag, or FALSE on failure.
* @return bool|int The ID of the newly inserted tag, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
* @note core_tags_cache and core_tags_perms need to be populated by the converter.
*/
public function convertTag( $info=array() )
public function convertTag( array $info=array() ) : bool|int
{
/* Another instance where we really don't need this, but will store if we have it */
$hasId = TRUE;
@@ -6229,9 +6212,9 @@ class Core extends Library
* @param string|NULL $icondata Binary data for the icon file
* @param string|NULL $coverfile Path to the club cover photo file
* @param string|NULL $coverdata Binary data for the icon file
* @return boolean|integer The ID of the newly inserted club, or FALSE on failure.
* @return bool|int The ID of the newly inserted club, or FALSE on failure.
*/
public function convertClub( $info=array(), $iconfile=NULL, $icondata=NULL, $coverfile=NULL, $coverdata=NULL )
public function convertClub( array $info=array(), ?string $iconfile=NULL, ?string $icondata=NULL, ?string $coverfile=NULL, ?string $coverdata=NULL ) : bool|int
{
if ( !isset( $info['club_id'] ) )
{
@@ -6352,7 +6335,7 @@ class Core extends Library
if ( isset( $info['last_activity'] ) )
{
if ( $info['last_activity'] instanceof Time )
if ( $info['last_activity'] instanceof DateTime )
{
$info['last_activity'] = $info['last_activity']->getTimestamp();
}
@@ -6383,9 +6366,9 @@ class Core extends Library
* Convert a Club Member
*
* @param array $info The data to insert
* @return boolean|string The unique ID of the newly inserted club member, or FALSE on failure.
* @return bool|int The unique ID of the newly inserted club member, or FALSE on failure.
*/
public function convertClubMember( $info=array() )
public function convertClubMember( array $info=array() ) : bool|int
{
if ( !isset( $info['club_id'] ) OR !isset( $info['member_id'] ) )
{
@@ -6475,9 +6458,9 @@ class Core extends Library
* Convert a Club Member
*
* @param array $info The data to insert
* @return boolean|string The unique ID of the newly inserted club member, or FALSE on failure.
* @return bool|int The unique ID of the newly inserted club member, or FALSE on failure.
*/
public function convertClubPage( array $info=array() )
public function convertClubPage( array $info=array() ) : bool|int
{
if ( !isset( $info['page_id'] ) OR !isset( $info['page_club'] ) )
{
@@ -6512,7 +6495,7 @@ class Core extends Library
if( is_array( $info['page_can_view'] ) )
{
$info['page_can_view'] = implode( ',', array_filter( $info['page_can_view'], function( $value ) {
return (bool) in_array( $value, array( 'nonmember', 'member', 'moderator' ) );
return in_array( $value, array( 'nonmember', 'member', 'moderator' ) );
} ) );
}
}