Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief 4.0.0 Alpha 1 Upgrade Code
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 25 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -64,7 +64,23 @@ class _Upgrade
|
||||
|
||||
/* Define temporary table */
|
||||
$membersDefinition = \IPS\Db::i()->getTableDefinition( 'core_members', false, true );
|
||||
$profileDefinition = \IPS\Db::i()->getTableDefinition( 'profile_portal', false, true );
|
||||
|
||||
try
|
||||
{
|
||||
$profileDefinition = \IPS\Db::i()->getTableDefinition( 'profile_portal', false, true );
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
/* Table does not exist: have we already finished the conversion and this step is being re-run accidetally? */
|
||||
if ( isset( $_SESSION['core_40000_step1_finished'] ) )
|
||||
{
|
||||
/* Return TRUE to increase _upgradeStep */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$membersDefinition['name'] = 'core_members_temp';
|
||||
|
||||
/* Inserts into myisam are much faster typically */
|
||||
@@ -111,7 +127,7 @@ class _Upgrade
|
||||
"length" => 1,
|
||||
"null" => false,
|
||||
"default" => 0,
|
||||
"comment" => "Blocked from submitting IP.Downloads files?",
|
||||
"comment" => "Blocked from submitting Downloads files?",
|
||||
"unsigned" => true
|
||||
);
|
||||
}
|
||||
@@ -163,7 +179,7 @@ class _Upgrade
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( "Error in upg_40000/Upgrade.php - About Me: " . $ex->getMessage(), 'upgrade' );
|
||||
\IPS\Log::log( $ex, 'upgrade' );
|
||||
}
|
||||
|
||||
$_SESSION['aboutMe_Field'] = $aboutMe->id;
|
||||
@@ -204,13 +220,22 @@ class _Upgrade
|
||||
}
|
||||
}
|
||||
|
||||
/* Get a list of validating member IDs to make sure we flag the account as validating if appropriate. We grab this here in one query
|
||||
instead of querying each member individually inside the loop later for efficiency. */
|
||||
$validatingMemberIds = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'member_id', 'core_validating', array( 'lost_pass != ?', 1 ) ) as $memberId )
|
||||
{
|
||||
$validatingMemberIds[ $memberId ] = $memberId;
|
||||
}
|
||||
|
||||
/* Try to prevent timeouts to the extent possible */
|
||||
$cutOff = \IPS\core\Setup\Upgrade::determineCutoff();
|
||||
$did = 0;
|
||||
|
||||
/* Import data */
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
$select = \IPS\DB::i()->select( 'core_members.*, profile_portal.*', 'core_members', NULL, 'core_members.member_id', array( $limit, $perCycle ) )
|
||||
$select = \IPS\Db::i()->select( 'core_members.*, profile_portal.*', 'core_members', NULL, 'core_members.member_id', array( $limit, $perCycle ) )
|
||||
->join( 'profile_portal', 'profile_portal.pp_member_id=core_members.member_id' );
|
||||
if ( count( $select ) )
|
||||
{
|
||||
@@ -247,7 +272,8 @@ class _Upgrade
|
||||
$arr = array();
|
||||
list( $arr['date_start'], $arr['date_end'], $arr['timespan'], $arr['unit'] ) = explode( ":", $row[ $column ] );
|
||||
|
||||
$row[ $column ] = $arr['date_end'];
|
||||
|
||||
$row[ $column ] = $arr['date_end'] > 2147483647 ? -1 : $arr['date_end'];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -279,7 +305,7 @@ class _Upgrade
|
||||
"length" => 1,
|
||||
"null" => false,
|
||||
"default" => 0,
|
||||
"comment" => "Blocked from submitting IP.Downloads files?",
|
||||
"comment" => "Blocked from submitting Downloads files?",
|
||||
"unsigned" => true
|
||||
) );
|
||||
}
|
||||
@@ -463,6 +489,12 @@ class _Upgrade
|
||||
{
|
||||
$row['member_group_id'] = $memberGroup;
|
||||
}
|
||||
|
||||
/* Or do we need to set validating flag because they have a row in core_validating? */
|
||||
if( in_array( $row['member_id'], $validatingMemberIds ) )
|
||||
{
|
||||
$row['members_bitoptions'] += 1073741824;
|
||||
}
|
||||
|
||||
/* Make sure the account does not have guest, validating or banned groups in secondary groups */
|
||||
$newSecondaryGroups = array();
|
||||
@@ -604,10 +636,7 @@ class _Upgrade
|
||||
{
|
||||
foreach( $_folders as $k => $folder )
|
||||
{
|
||||
if ( $folder['real'] )
|
||||
{
|
||||
$folders[ $folder['id'] ] = $folder['real'];
|
||||
}
|
||||
$folders[ $folder['id'] ] = $folder['real'] ?: $folder['id'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,28 +705,33 @@ class _Upgrade
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Finish */
|
||||
\IPS\Db::i()->dropTable( 'core_members' );
|
||||
\IPS\Db::i()->dropTable( 'profile_portal' );
|
||||
\IPS\Db::i()->renameTable( 'core_members_temp', 'core_members' );
|
||||
if ( ! isset( \IPS\Request::i()->run_anyway ) )
|
||||
{
|
||||
/* Finish */
|
||||
\IPS\Db::i()->dropTable( 'core_members' );
|
||||
\IPS\Db::i()->dropTable( 'profile_portal' );
|
||||
\IPS\Db::i()->renameTable( 'core_members_temp', 'core_members' );
|
||||
|
||||
if ( $bannedGroup )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_groups', 'g_id=' . $bannedGroup );
|
||||
}
|
||||
|
||||
if ( $validatingGroup )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_groups', 'g_id=' . $validatingGroup );
|
||||
}
|
||||
|
||||
if( isset( $_SESSION['idm_block_submissions'] ) )
|
||||
{
|
||||
unset( $_SESSION['idm_block_submissions'] );
|
||||
}
|
||||
|
||||
unset( $_SESSION['aboutMe_Field'], $_SESSION['_step1Count'] );
|
||||
}
|
||||
|
||||
$_SESSION['core_40000_step1_finished'] = true;
|
||||
|
||||
if ( $bannedGroup )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_groups', 'g_id=' . $bannedGroup );
|
||||
}
|
||||
|
||||
if ( $validatingGroup )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_groups', 'g_id=' . $validatingGroup );
|
||||
}
|
||||
|
||||
if( isset( $_SESSION['idm_block_submissions'] ) )
|
||||
{
|
||||
unset( $_SESSION['idm_block_submissions'] );
|
||||
}
|
||||
|
||||
unset( $_SESSION['aboutMe_Field'], $_SESSION['_step1Count'] );
|
||||
|
||||
/* Do we need to convert the engine? */
|
||||
if( $_SESSION['convertMembersEngine'] == true OR $_SESSION['convertPfieldsEngine'] == true )
|
||||
{
|
||||
@@ -725,10 +759,10 @@ class _Upgrade
|
||||
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
$mr = \IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 2 ) ) );
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 2 ) ) );
|
||||
|
||||
/* Queries to run manually */
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => $mr ) ) ) );
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,6 +805,11 @@ class _Upgrade
|
||||
*/
|
||||
public function step2()
|
||||
{
|
||||
if ( isset( $_SESSION['core_40000_step1_finished'] ) )
|
||||
{
|
||||
unset( $_SESSION['core_40000_step1_finished'] );
|
||||
}
|
||||
|
||||
/* Convert serialized data to json encoded */
|
||||
$did = array();
|
||||
$available = array( 'External', 'Facebook', 'Twitter', 'Internal', 'Ldap', 'Live', 'Linkedin', 'Google', 'Ipsconnect', 'Convert' );
|
||||
@@ -1139,7 +1178,8 @@ class _Upgrade
|
||||
|
||||
foreach( $options as $_index => $option )
|
||||
{
|
||||
list( $fieldKey, $fieldValue ) = explode( '=', $option );
|
||||
/* If you had a checkbox, you may have entered the content as simply "1", or you may have entered it as lines of "1=Something..2=Something Else" */
|
||||
list( $fieldKey, $fieldValue ) = ( mb_strpos( $option, '=' ) !== FALSE ) ? explode( '=', $option ) : array( $option, $option );
|
||||
$realOptions[ $fieldKey ] = array( $fieldValue, $_index );
|
||||
}
|
||||
|
||||
@@ -1162,7 +1202,7 @@ class _Upgrade
|
||||
}
|
||||
else
|
||||
{
|
||||
$update['field_' . $k ] = ( isset( $realOptions[ $row['field_' . $k ] ] ) ) ? $realOptions[ $row['field_' . $k ] ][0] : NULL;
|
||||
$update['field_' . $k ] = ( isset( $realOptions[ $row['field_' . $k ] ] ) ) ? $realOptions[ $row['field_' . $k ] ][1] : NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1239,8 +1279,9 @@ class _Upgrade
|
||||
break;
|
||||
|
||||
case 'cbox':
|
||||
$update['pf_type'] = 'Select';
|
||||
$update['pf_multiple'] = TRUE;
|
||||
$options = explode( '|', $field['pf_content'] );
|
||||
$update['pf_type'] = ( count( $options ) == 1 ) ? 'Checkbox' : 'CheckboxSet';
|
||||
$update['pf_multiple'] = ( $update['pf_type'] == 'CheckboxSet' ) ? TRUE : FALSE;
|
||||
break;
|
||||
|
||||
case 'Editor':
|
||||
@@ -1259,7 +1300,7 @@ class _Upgrade
|
||||
|
||||
foreach( $options as $option )
|
||||
{
|
||||
list( $k, $v ) = explode( '=', $option );
|
||||
list( $k, $v ) = ( mb_strpos( $option, '=' ) !== FALSE ) ? explode( '=', $option ) : array( $option, $option );
|
||||
$newOptions[] = $v;
|
||||
}
|
||||
|
||||
@@ -1434,10 +1475,10 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
$mr = \IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 9 ) ) );
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 9 ) ) );
|
||||
|
||||
/* Queries to run manually */
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => $mr ) ) ) );
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr ) ) ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -1485,7 +1526,7 @@ DROP INDEX like_lookup_area"
|
||||
}
|
||||
|
||||
/* Copy value of cannot ignore to group settings */
|
||||
$groups = array_filter( explode( ',', trim( \IPS\Settings::i()->cannot_ignore_groups, ',' ) ) );
|
||||
$groups = array_filter( explode( ',', trim( str_replace( '{blank}', '', \IPS\Settings::i()->cannot_ignore_groups ), ',' ) ) );
|
||||
|
||||
\IPS\Db::i()->update( 'core_groups', "g_bitoptions=g_bitoptions & (~ 536870912)" );
|
||||
|
||||
@@ -1714,12 +1755,18 @@ DROP INDEX like_lookup_area"
|
||||
}
|
||||
|
||||
$did++;
|
||||
|
||||
/* Bugs in older versions may have a report with a 'status' outside of 1, 2, or 3, which can fail when using MySQL Strict with a Data truncated error. We set it to 3 here, so reports are not suddenly shown as "new" */
|
||||
if ( !in_array( $report['status'], array( 1, 2, 3 ) ) )
|
||||
{
|
||||
$report['status'] = 3;
|
||||
}
|
||||
|
||||
/* Convert to new format */
|
||||
$insert = array(
|
||||
'id' => $report['id'],
|
||||
'class' => null,
|
||||
'content_id' => $report['exdat3'] ?: ( $report['exdat2'] ?: $report['exdat1'] ),
|
||||
'content_id' => 0,
|
||||
'perm_id' => 0,
|
||||
'status' => $report['status'],
|
||||
'num_reports' => $report['num_reports'],
|
||||
@@ -1731,75 +1778,135 @@ DROP INDEX like_lookup_area"
|
||||
);
|
||||
|
||||
/* Now we need to figure out the class and database table - can only handle first-party applications. We need the table as it may have been renamed */
|
||||
$table = NULL;
|
||||
$table = NULL;
|
||||
$column = $report['exdat3'] ? 'exdat2' : 'exdat1';
|
||||
|
||||
switch( $classes[ $report['rc_class'] ] )
|
||||
{
|
||||
case 'post':
|
||||
/* Posts were always reported, not topics. 3=pid, 2=tid, 1=forum id */
|
||||
$insert['class'] = "IPS\\forums\\Topic\\Post";
|
||||
$table = "posts";
|
||||
$itemTable = "topics";
|
||||
$containerTable = "forums";
|
||||
$table = "posts";
|
||||
$itemTable = "topics";
|
||||
$containerTable = "forums";
|
||||
$column = 'exdat3';
|
||||
break;
|
||||
|
||||
case 'blog':
|
||||
if( $report['exdat2'] )
|
||||
/* If 3 is present, a comment was reported. 2=entry id and 1=blog id */
|
||||
if( $report['exdat3'] )
|
||||
{
|
||||
$insert['class'] = "IPS\\blog\\Entry\\Comment";
|
||||
$table = "blog_comments";
|
||||
$itemTable = "blog_entries";
|
||||
$column = 'exdat3';
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert['class'] = "IPS\\blog\\Entry";
|
||||
$table = "blog_entries";
|
||||
$column = 'exdat2';
|
||||
}
|
||||
|
||||
$containerTable = "blog_blogs";
|
||||
break;
|
||||
|
||||
case 'gallery':
|
||||
/* If 2 is present, a comment was reported. 1=image id */
|
||||
if( $report['exdat2'] )
|
||||
{
|
||||
$insert['class'] = "IPS\\gallery\\Image\\Comment";
|
||||
$table = "gallery_comments";
|
||||
$itemTable = "gallery_images";
|
||||
$column = 'exdat2';
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert['class'] = "IPS\\gallery\\Image";
|
||||
$table = "gallery_images";
|
||||
$column = 'exdat1';
|
||||
}
|
||||
|
||||
$containerTable = "gallery_categories";
|
||||
break;
|
||||
|
||||
case 'downloads':
|
||||
/* If 2 is present, a comment was reported. 1=file id, 3=st id (page offset) */
|
||||
if( $report['exdat2'] )
|
||||
{
|
||||
$insert['class'] = "IPS\\downloads\\File\\Comment";
|
||||
$table = "downloads_comments";
|
||||
$itemTable = "downloads_files";
|
||||
$column = 'exdat2';
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert['class'] = "IPS\\downloads\\File";
|
||||
$table = "downloads_files";
|
||||
$column = 'exdat1';
|
||||
}
|
||||
|
||||
$containerTable = "downloads_categories";
|
||||
break;
|
||||
|
||||
case 'messages':
|
||||
/* Messages were always reported, not topics. 1=topic id, 2=message id, 3=st id (page offset) */
|
||||
$insert['class'] = "IPS\\core\\Messenger\\Message";
|
||||
$table = "message_posts";
|
||||
$table = "message_posts";
|
||||
$column = 'exdat2';
|
||||
|
||||
/* Message containers don't use \IPS\Content\Permissions, PermID should always be NULL */
|
||||
$insert['perm_id'] = NULL;
|
||||
|
||||
break;
|
||||
|
||||
case 'calendar':
|
||||
$insert['class'] = "IPS\\calendar\\Event";
|
||||
break;
|
||||
|
||||
case 'ccs':
|
||||
if( $report['exdat3'] )
|
||||
/* If 2 is present, a comment was reported. 1=event id, 3=st id (page offset) */
|
||||
if( $report['exdat2'] )
|
||||
{
|
||||
$insert['class'] = "IPS\\cms\\Records\\Comment";
|
||||
$insert['class'] = "IPS\\calendar\\Event\\Comment";
|
||||
$table = "cal_event_comments";
|
||||
$itemTable = "cal_events";
|
||||
$column = 'exdat2';
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert['class'] = "IPS\\cms\\Records" . $report['exdata1'];
|
||||
$insert['class'] = "IPS\\calendar\\Event";
|
||||
$table = "cal_events";
|
||||
$column = 'exdat1';
|
||||
}
|
||||
$table = "ccs_custom_database_" . $report['exdata1'];
|
||||
|
||||
$containerTable = "cal_calendars";
|
||||
break;
|
||||
|
||||
case 'ccs':
|
||||
/* If 3 is present, a comment was reported. 1=database id, 2=record id */
|
||||
if( $report['exdat3'] )
|
||||
{
|
||||
$insert['class'] = "IPS\\cms\\Records\\Comment" . $report['exdat1'];
|
||||
$column = 'exdat3';
|
||||
$itemTable = "ccs_custom_database_" . $report['exdat1'];
|
||||
$table = 'ccs_database_comments';
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert['class'] = "IPS\\cms\\Records" . $report['exdat1'];
|
||||
$table = "ccs_custom_database_" . $report['exdat1'];
|
||||
$column = 'exdat2';
|
||||
}
|
||||
|
||||
$containerTable = "ccs_databases";
|
||||
break;
|
||||
|
||||
case 'nexus':
|
||||
$insert['class'] = "IPS\\nexus\\Package\\Review";
|
||||
$column = 'exdat1';
|
||||
$table = "nexus_reviews";
|
||||
break;
|
||||
}
|
||||
|
||||
$insert['content_id'] = $report[ $column ];
|
||||
|
||||
if( $insert['class'] === NULL )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_rc_reports', array( 'rid=?', $report['id'] ) );
|
||||
@@ -1822,36 +1929,47 @@ DROP INDEX like_lookup_area"
|
||||
/* Some tables haven't been renamed yet so build the data manually */
|
||||
if( $table )
|
||||
{
|
||||
$row = \IPS\DB::i()->select( "*", $table, array( "{$className::$databaseColumnId} = ?", $report['exdat3'] ? $report['exdat2'] : $report['exdat1'] ) )->first();
|
||||
$content = $className::constructFromData( $row );
|
||||
$item = NULL;
|
||||
$row = \IPS\DB::i()->select( "*", $table, array( "{$className::$databasePrefix}{$className::$databaseColumnId} = ?", $insert['content_id'] ) )->first();
|
||||
$content = $className::constructFromData( $row );
|
||||
|
||||
if( $itemTable )
|
||||
if( isset( $className::$itemClass ) AND $className::$itemClass AND $itemTable )
|
||||
{
|
||||
$itemClass = $className::$itemClass;
|
||||
$itemRow = \IPS\DB::i()->select("*", $itemTable, array("{$itemClass::$databaseColumnId} = ?", $content->mapped('item')))->first();
|
||||
$item = $itemClass::constructFromData($itemRow);
|
||||
$itemClass = $className::$itemClass;
|
||||
$itemRow = \IPS\DB::i()->select("*", $itemTable, array( "{$itemClass::$databasePrefix}{$itemClass::$databaseColumnId} = ?", $content->mapped('item')))->first();
|
||||
$item = $itemClass::constructFromData($itemRow);
|
||||
}
|
||||
elseif( isset( $className::$containerNodeClass ) AND $className::$containerNodeClass )
|
||||
{
|
||||
$item = $content;
|
||||
}
|
||||
|
||||
$containerClass = $itemClass::$containerNodeClass;
|
||||
$containerRow = \IPS\DB::i()->select("*", $containerTable, array("{$containerClass::$databaseColumnId} = ?", $item->mapped('container')))->first();
|
||||
$container = $containerClass::constructFromData($containerRow);
|
||||
if( $containerTable AND $item !== NULL )
|
||||
{
|
||||
$containerClass = $item::$containerNodeClass;
|
||||
|
||||
$permissions = $container->permissions();
|
||||
$insert['perm_id'] = $permissions['perm_id'];
|
||||
if ( in_array( 'IPS\Node\Permissions', class_implements( $containerClass ) ) )
|
||||
{
|
||||
$containerRow = \IPS\DB::i()->select( "*", $containerTable, array( "{$containerClass::$databasePrefix}{$containerClass::$databaseColumnId} = ?", $item->mapped('container') ) )->first();
|
||||
$container = $containerClass::constructFromData( $containerRow );
|
||||
|
||||
$permissions = $container->permissions();
|
||||
$insert['perm_id'] = $permissions['perm_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = $className::load( $report['exdat3'] ? $report['exdat2'] : $report['exdat1'] );
|
||||
$content = $className::load( $insert['content_id'] );
|
||||
$insert['perm_id'] = $content->permId();
|
||||
}
|
||||
|
||||
$insert['author'] = $content->mapped('author');
|
||||
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
|
||||
/* Insert new report */
|
||||
\IPS\Db::i()->insert( 'core_rc_index', $insert );
|
||||
\IPS\Db::i()->replace( 'core_rc_index', $insert );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1913,9 +2031,9 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
/* Convert to dateinterval specs */
|
||||
$update = array(
|
||||
'wl_mq' => ( $log['wl_mq_unit'] AND $log['wl_mq'] AND $log['wl_mq'] != -1 ) ? 'P' . $log['wl_mq'] . ( ( mb_strtoupper( $log['wl_mq_unit'] ) == 'H' ) ? 'T' : '' ) . mb_strtoupper( $log['wl_mq_unit'] ) : null,
|
||||
'wl_rpa' => ( $log['wl_rpa_unit'] AND $log['wl_rpa'] AND $log['wl_rpa'] != -1 ) ? 'P' . $log['wl_rpa'] . ( ( mb_strtoupper( $log['wl_rpa_unit'] ) == 'H' ) ? 'T' : '' ) . mb_strtoupper( $log['wl_rpa_unit'] ) : null,
|
||||
'wl_suspend' => ( $log['wl_suspend_unit'] AND $log['wl_suspend'] AND $log['wl_suspend'] != -1 ) ? 'P' . $log['wl_suspend'] . ( ( mb_strtoupper( $log['wl_suspend_unit'] ) == 'H' ) ? 'T' : '' ) . mb_strtoupper( $log['wl_suspend_unit'] ) : null,
|
||||
'wl_mq' => ( $log['wl_mq_unit'] AND $log['wl_mq'] AND $log['wl_mq'] != -1 ) ? 'P' . ( ( mb_strtoupper( $log['wl_mq_unit'] ) == 'H' ) ? 'T' : '' ) . $log['wl_mq'] . mb_strtoupper( $log['wl_mq_unit'] ) : null,
|
||||
'wl_rpa' => ( $log['wl_rpa_unit'] AND $log['wl_rpa'] AND $log['wl_rpa'] != -1 ) ? 'P' . ( ( mb_strtoupper( $log['wl_rpa_unit'] ) == 'H' ) ? 'T' : '' ) . $log['wl_rpa'] . mb_strtoupper( $log['wl_rpa_unit'] ) : null,
|
||||
'wl_suspend' => ( $log['wl_suspend_unit'] AND $log['wl_suspend'] AND $log['wl_suspend'] != -1 ) ? 'P' . ( ( mb_strtoupper( $log['wl_suspend_unit'] ) == 'H' ) ? 'T' : '' ) . $log['wl_suspend'] . mb_strtoupper( $log['wl_suspend_unit'] ) : null,
|
||||
'wl_content_module' => $log['wl_content_app'],
|
||||
);
|
||||
|
||||
@@ -1992,12 +2110,29 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
/* We're just going to do the best we can to convert the attach_rel_module to the location_key - it is near impossible
|
||||
to account for third party apps here, but they can run their own updates later */
|
||||
$id1 = $attach['attach_parent_id'] ? $attach['attach_parent_id'] : $attach['attach_rel_id'];
|
||||
$id2 = $attach['attach_parent_id'] ? $attach['attach_rel_id'] : NULL;
|
||||
$id3 = NULL;
|
||||
$locationKey = $attach['attach_rel_module'];
|
||||
|
||||
switch( $attach['attach_rel_module'] )
|
||||
{
|
||||
case 'post':
|
||||
$locationKey = 'forums_Forums';
|
||||
|
||||
/* If the parent isn't set because this is legacy data, we can't just let id1 be the post id and id2 be null - that won't work */
|
||||
if( !$attach['attach_parent_id'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* This is still 'posts' rather than 'forums_posts' at this point */
|
||||
$topic = \IPS\Db::i()->select( 'topic_id', 'posts', array( 'pid=?', $attach['attach_rel_id'] ) )->first();
|
||||
|
||||
$id1 = $topic;
|
||||
$id2 = $attach['attach_rel_id'];
|
||||
}
|
||||
catch( \UnderflowException $e ){}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'msg':
|
||||
@@ -2007,13 +2142,23 @@ DROP INDEX like_lookup_area"
|
||||
try
|
||||
{
|
||||
$message = \IPS\Db::i()->select( 'msg_topic_id', 'core_message_posts', array( 'msg_id=?', $attach['attach_rel_id'] ) )->first();
|
||||
$attach['attach_parent_id'] = $message;
|
||||
$id1 = $message;
|
||||
$id2 = $attach['attach_rel_id'];
|
||||
}
|
||||
catch( \UnderflowException $e ){}
|
||||
break;
|
||||
|
||||
case 'ccs':
|
||||
$locationKey = 'content_Records';
|
||||
$locationKey = 'cms_Records';
|
||||
|
||||
try
|
||||
{
|
||||
$map = \IPS\Db::i()->select( '*', 'ccs_attachments_map', array( 'map_attach_id=?', $attach['attach_id'] ) )->first();
|
||||
$id1 = $map['map_record_id'];
|
||||
$id2 = $map['map_field_id'];
|
||||
$id3 = $map['map_database_id'];
|
||||
}
|
||||
catch( \UnderflowException $e ){}
|
||||
break;
|
||||
|
||||
case 'blogentry':
|
||||
@@ -2034,15 +2179,21 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
case 'support':
|
||||
$locationKey = 'nexus_Support';
|
||||
try
|
||||
{
|
||||
$id2 = $id1;
|
||||
$id1 = \IPS\Db::i()->select( 'reply_request', 'nexus_support_replies', array( 'reply_id=?', $id2 ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
break;
|
||||
}
|
||||
|
||||
$map = array(
|
||||
'attachment_id' => $attach['attach_id'],
|
||||
'location_key' => $locationKey ?: '',
|
||||
'id1' => $attach['attach_parent_id'] ? $attach['attach_parent_id'] : $attach['attach_rel_id'],
|
||||
'id2' => $attach['attach_parent_id'] ? $attach['attach_rel_id'] : NULL,
|
||||
'id3' => NULL,
|
||||
'id1' => $id1,
|
||||
'id2' => $id2,
|
||||
'id3' => $id3,
|
||||
'temp' => NULL,
|
||||
);
|
||||
|
||||
@@ -2109,9 +2260,12 @@ DROP INDEX like_lookup_area"
|
||||
*/
|
||||
public function step14()
|
||||
{
|
||||
\IPS\Db::i()->dropTable( 'core_voters', true );
|
||||
\IPS\Db::i()->renameTable( 'voters', 'core_voters' );
|
||||
|
||||
if ( ! isset( \IPS\Request::i()->run_anyway ) )
|
||||
{
|
||||
\IPS\Db::i()->dropTable( 'core_voters', true );
|
||||
\IPS\Db::i()->renameTable( 'voters', 'core_voters' );
|
||||
}
|
||||
|
||||
$toRun = \IPS\core\Setup\Upgrade::runManualQueries( array( array(
|
||||
'table' => 'core_voters',
|
||||
'query' => "ALTER TABLE " . \IPS\Db::i()->prefix . "core_voters ADD COLUMN poll MEDIUMINT UNSIGNED NOT NULL COMMENT 'The poll ID',
|
||||
@@ -2122,10 +2276,10 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
$mr = \IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 15 ) ) );
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 15 ) ) );
|
||||
|
||||
/* Queries to run manually */
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => $mr, 'extra' => 0 ) ) ) );
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr, 'extra' => 0 ) ) ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -2201,17 +2355,28 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
if( is_array( $data ) AND $_decoded )
|
||||
{
|
||||
$newPoll = array();
|
||||
|
||||
foreach( $data as $_key => $_data )
|
||||
{
|
||||
$data[ $_key ]['question'] = utf8_encode( $_data[ $_key ]['question'] );
|
||||
|
||||
if( is_array( $_data['choice'] ) )
|
||||
if( isset( $_data['question'] ) )
|
||||
{
|
||||
foreach( $_data['choice'] as $_idx => $_choice )
|
||||
$data[ $_key ]['question'] = utf8_encode( $_data['question'] );
|
||||
|
||||
if( is_array( $_data['choice'] ) )
|
||||
{
|
||||
$data[ $_key ]['choice'][ $_idx ] = utf8_encode( $_choice );
|
||||
foreach( $_data['choice'] as $_idx => $_choice )
|
||||
{
|
||||
$data[ $_key ]['choice'][ $_idx ] = utf8_encode( $_choice );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$newPoll[0]['question'] = $poll['poll_question'];
|
||||
|
||||
$newPoll[0]['choice'][] = utf8_encode( $_data[1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2465,6 +2630,13 @@ DROP INDEX like_lookup_area"
|
||||
$item_id = $row['topic_id'];
|
||||
}
|
||||
|
||||
/* In the rare circumstance the topic title contains malformed UTF-8, we forcefully re-encode to salvage what we can and prevent json_encode from failing (#936969) */
|
||||
@json_encode( array( 'topic' => false, $row['http_referer'] => false, $row['topic_title'] => false ) );
|
||||
if ( json_last_error() === \JSON_ERROR_UTF8 )
|
||||
{
|
||||
$row['topic_title'] = mb_convert_encoding( $row['topic_title'], 'UTF-8', 'UTF-8' );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_moderator_logs', array(
|
||||
'member_id' => $row['member_id'],
|
||||
'ctime' => $row['ctime'],
|
||||
@@ -2541,9 +2713,17 @@ DROP INDEX like_lookup_area"
|
||||
$limit = (int) \IPS\Request::i()->extra;
|
||||
}
|
||||
|
||||
/* Try to prevent timeouts to the extent possible */
|
||||
$cutOff = \IPS\core\Setup\Upgrade::determineCutoff();
|
||||
|
||||
/* We need to loop through all tags and fix up tag_aai_lookup as the area has changed. Normally we could just use MySQL MD5, but we need to update core_tags_perms too... */
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_tags', NULL, 'tag_id ASC', array( $limit, $perCycle ) ) AS $row )
|
||||
{
|
||||
if( $cutOff !== null AND time() >= $cutOff )
|
||||
{
|
||||
return ( $limit + $did );
|
||||
}
|
||||
|
||||
$did++;
|
||||
if ( $row['tag_meta_app'] === 'ccs' )
|
||||
{
|
||||
@@ -2643,6 +2823,11 @@ DROP INDEX like_lookup_area"
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( in_array( $row['conf_key'], array( 'upload_url', 'gallery_images_url', 'idm_screenshot_url', 'blog_upload_url' ) ) )
|
||||
{
|
||||
$row['conf_value'] = str_replace( \IPS\Http\Url::baseUrl(), '', $row['conf_value'] );
|
||||
}
|
||||
|
||||
$settings[ $row['conf_key'] ] = $row['conf_value'];
|
||||
}
|
||||
else if( $row['conf_default'] )
|
||||
@@ -2715,7 +2900,7 @@ DROP INDEX like_lookup_area"
|
||||
if( isset( $settings['gallery_images_path'] ) AND $settings['gallery_images_path'] AND $settings['gallery_images_path'] != $settings['upload_dir'] )
|
||||
{
|
||||
$url = $settings['gallery_images_url'] ?: rtrim( \IPS\Settings::i()->base_url, '/' ) . '/applications/gallery/interface/legacy/image.php?path=';
|
||||
$gallery = \IPS\Db::i()->insert( 'core_file_storage', array( 'method' => 'FileSystem', 'configuration' => json_encode( array( 'dir' => str_replace( \IPS\ROOT_PATH, '{root}', $settings['gallery_images_path'] ), 'url' => str_replace( $strReplace, '', $url ) ) ) ) );
|
||||
$gallery = \IPS\Db::i()->insert( 'core_file_storage', array( 'method' => 'FileSystem', 'configuration' => json_encode( array( 'dir' => str_replace( \IPS\ROOT_PATH, '{root}', $settings['gallery_images_path'] ), 'url' => $url ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2725,7 +2910,7 @@ DROP INDEX like_lookup_area"
|
||||
/* Blog */
|
||||
if( isset( $settings['blog_upload_dir'] ) AND $settings['blog_upload_dir'] AND $settings['blog_upload_dir'] != $settings['upload_dir'] )
|
||||
{
|
||||
$blog = \IPS\Db::i()->insert( 'core_file_storage', array( 'method' => 'FileSystem', 'configuration' => json_encode( array( 'dir' => str_replace( \IPS\ROOT_PATH, '{root}', $settings['blog_upload_dir'] ), 'url' => str_replace( $strReplace, '', $settings['blog_upload_url'] ) ) ) ) );
|
||||
$blog = \IPS\Db::i()->insert( 'core_file_storage', array( 'method' => 'FileSystem', 'configuration' => json_encode( array( 'dir' => str_replace( \IPS\ROOT_PATH, '{root}', $settings['blog_upload_dir'] ), 'url' => $settings['blog_upload_url'] ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3048,7 +3233,6 @@ DROP INDEX like_lookup_area"
|
||||
{
|
||||
$limit = 0;
|
||||
$table = null;
|
||||
$count = 0;
|
||||
|
||||
if( isset( \IPS\Request::i()->extra ) )
|
||||
{
|
||||
@@ -3058,7 +3242,7 @@ DROP INDEX like_lookup_area"
|
||||
|
||||
if( !isset( $_SESSION['_step18' . $table . 'Count'] ) )
|
||||
{
|
||||
$_SESSION['_step18' . $table . 'Count'] = ( \IPS\Db::i()->checkForTable( $table ) ) ? \IPS\Db::i()->select( 'COUNT(*)', $table )->first() : 0;;
|
||||
$_SESSION['_step18' . $table . 'Count'] = ( \IPS\Db::i()->checkForTable( $table ) ) ? \IPS\Db::i()->select( 'COUNT(*)', $table )->first() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3147,34 +3331,19 @@ DROP INDEX like_lookup_area"
|
||||
*/
|
||||
public function step20()
|
||||
{
|
||||
$perCycle = 1000;
|
||||
$did = 0;
|
||||
$limit = intval( \IPS\Request::i()->extra );
|
||||
$toRun = \IPS\core\Setup\Upgrade::runManualQueries( array( array(
|
||||
'table' => 'core_follow',
|
||||
'query' => "UPDATE " . \IPS\Db::i()->prefix . "core_follow SET follow_notify_sent=" . time()
|
||||
) ) );
|
||||
|
||||
/* Try to prevent timeouts to the extent possible */
|
||||
$cutOff = \IPS\core\Setup\Upgrade::determineCutoff();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_follow', null, 'follow_id ASC', array( $limit, $perCycle ) ) as $follow )
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
if( $cutOff !== null AND time() >= $cutOff )
|
||||
{
|
||||
return ( $limit + $did );
|
||||
}
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 21 ) ) );
|
||||
|
||||
$did++;
|
||||
|
||||
\IPS\Db::i()->update( 'core_follow', array( 'follow_notify_sent' => time() ), array( 'follow_id=?', $follow['follow_id'] ) );
|
||||
}
|
||||
|
||||
if( $did )
|
||||
{
|
||||
return ( $limit + $did );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $_SESSION['_step20Count'] );
|
||||
return TRUE;
|
||||
/* Queries to run manually */
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr ) ) ) );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3184,14 +3353,7 @@ DROP INDEX like_lookup_area"
|
||||
*/
|
||||
public function step20CustomTitle()
|
||||
{
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
|
||||
if( !isset( $_SESSION['_step20Count'] ) )
|
||||
{
|
||||
$_SESSION['_step20Count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_follow' )->first();
|
||||
}
|
||||
|
||||
return "Upgrading last notify times for follows (Upgraded so far: " . ( ( $limit > $_SESSION['_step20Count'] ) ? $_SESSION['_step20Count'] : $limit ) . ' out of ' . $_SESSION['_step20Count'] . ')';
|
||||
return "Upgrading last notify times for follows";
|
||||
}
|
||||
|
||||
/* ! Other stuff */
|
||||
@@ -3231,6 +3393,9 @@ DROP INDEX like_lookup_area"
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', "conf_value=conf_default", "conf_key='validate_day_prune'" );
|
||||
}
|
||||
|
||||
/* Fix sitemap URL back to the default */
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( "conf_value" => \IPS\Settings::i()->base_url . 'sitemap.php' ), "conf_key='sitemap_url'" );
|
||||
|
||||
/* "Copy value of nexus_ads_circmode setting (if available) to ads_circulation" */
|
||||
if( isset( \IPS\Settings::i()->nexus_ads_circmode ) )
|
||||
{
|
||||
@@ -3263,7 +3428,7 @@ DROP INDEX like_lookup_area"
|
||||
{
|
||||
$guidelines = \IPS\Text\Parser::parseStatic( \IPS\Settings::i()->gl_guidelines, TRUE, NULL, NULL, TRUE, TRUE, TRUE );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( \Exception $e )
|
||||
{
|
||||
if( $e->getcode() == 103014 )
|
||||
{
|
||||
@@ -3281,7 +3446,7 @@ DROP INDEX like_lookup_area"
|
||||
{
|
||||
$reg_rules = \IPS\Text\Parser::parseStatic( \IPS\Settings::i()->reg_rules, TRUE, NULL, NULL, TRUE, TRUE, TRUE );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( \Exception $e )
|
||||
{
|
||||
if( $e->getcode() == 103014 )
|
||||
{
|
||||
@@ -3299,7 +3464,7 @@ DROP INDEX like_lookup_area"
|
||||
{
|
||||
$priv_body = \IPS\Text\Parser::parseStatic( \IPS\Settings::i()->priv_body, TRUE, NULL, NULL, TRUE, TRUE, TRUE );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( \Exception $e )
|
||||
{
|
||||
if( $e->getcode() == 103014 )
|
||||
{
|
||||
@@ -3399,7 +3564,7 @@ DROP INDEX like_lookup_area"
|
||||
'auth_allow_dnames', 'auth_dnames_nologinname', 'autohide_bday', 'autohide_calendar', 'au_cutoff', 'bbcode_automatic_media', 'board_offline', 'calendar_date_select_locale', 'calendar_limit',
|
||||
'cal_date_format', 'cal_time_format', 'cannot_ignore_groups', 'charset_conv_method', 'clock_date', 'clock_joined', 'clock_long', 'clock_short', 'clock_short2', 'clock_tiny', 'cookie_domain',
|
||||
'cookie_id', 'cookie_path', 'custom_profile_topic', 'days_to_keep_deletions', 'debug_level', 'default_vnc_method', 'disable_gzip', 'disable_lightbox', 'disable_prefetching',
|
||||
'disable_subforum_show', 'disable_summary', 'disable_text_ajax', 'display_max_posts', 'display_max_topics', 'email_use_html', 'error_log_notify', 'etfilter_punct', 'etfilter_shout', 'fbc_appid',
|
||||
'disable_subforum_show', 'disable_summary', 'disable_text_ajax', 'email_use_html', 'error_log_notify', 'etfilter_punct', 'etfilter_shout', 'fbc_appid',
|
||||
'fbc_enable', 'fbc_mgid', 'fbc_secret', 'fb_locale', 'fb_realname', 'force_login', 'force_sql_vnc', 'forums_enabled_also_tagged', 'gb_char_set', 'gl_show', 'guests_sig', 'guest_name_pre',
|
||||
'guest_name_suf', 'header_redirect', 'hide_ftext_note', 'hot_topic', 'http_auth_password', 'http_auth_username', 'img_ext', 'incoming_emails_textpref', 'ipb_cache_path', 'ipb_cache_url',
|
||||
'ipb_css_url', 'ipb_display_version', 'ipb_img_url', 'ipb_js_url', 'ipb_prune_admin', 'ipb_prune_email', 'ipb_prune_emailerror', 'ipb_prune_mod', 'ipb_prune_spam', 'ipb_prune_sql', 'ipb_prune_task',
|
||||
@@ -3824,8 +3989,6 @@ DROP INDEX like_lookup_area"
|
||||
\IPS\Task::queue( 'core', 'RebuildNonContentPosts', array( 'extension' => 'core_Staffdirectory' ), 2 );
|
||||
\IPS\Task::queue( 'core', 'RebuildNonContentPosts', array( 'extension' => 'core_Reports' ), 2 );
|
||||
\IPS\Task::queue( 'core', 'RebuildNonContentPosts', array( 'extension' => 'core_Modcp' ), 2 );
|
||||
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
|
||||
/* Recount content */
|
||||
\IPS\Task::queue( 'core', 'RecountMemberContent', array(), 4 );
|
||||
|
||||
Reference in new issue
Block a user