Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,16 +12,42 @@
|
||||
namespace IPS\core\setup\upg_106100;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Content\Search\Index;
|
||||
use IPS\core\Achievements\Badge;
|
||||
use IPS\core\Achievements\Rank;
|
||||
use IPS\core\Achievements\Rule;
|
||||
use IPS\core\ProfileFields\Field;
|
||||
use IPS\core\ProfileFields\Group;
|
||||
use IPS\core\Feature;
|
||||
use IPS\core\Setup\Upgrade as UpgradeClass;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Exception as DbException;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Log;
|
||||
use IPS\Notification;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use function call_user_func_array;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 4.6.0 Beta 1 Upgrade Code
|
||||
*/
|
||||
class _Upgrade
|
||||
class Upgrade
|
||||
{
|
||||
/**
|
||||
* ...
|
||||
@@ -62,9 +88,9 @@ JSON;
|
||||
{
|
||||
try
|
||||
{
|
||||
$run = \call_user_func_array( array( \IPS\Db::i(), $query['method'] ), $query['params'] );
|
||||
$run = call_user_func_array( array( Db::i(), $query['method'] ), $query['params'] );
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
catch( DbException $e )
|
||||
{
|
||||
if( !in_array( $e->getCode(), array( 1007, 1008, 1050, 1060, 1061, 1062, 1091, 1051 ) ) )
|
||||
{
|
||||
@@ -93,7 +119,7 @@ JSON;
|
||||
*/
|
||||
public function step2()
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -115,10 +141,10 @@ JSON;
|
||||
*/
|
||||
public function step3()
|
||||
{
|
||||
if( \IPS\Db::i()->select( 'count(*)', 'core_rc_comments', array( \IPS\Db::i()->like( 'comment', 'imageproxy.php' ) ) ) )
|
||||
if( Db::i()->select( 'count(*)', 'core_rc_comments', array( Db::i()->like( 'comment', 'imageproxy.php' ) ) ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->currentImageProxyRebuild );
|
||||
\IPS\Task::queue( 'core', 'RebuildImageProxyNonContent', array( 'extension' => 'core_Reports' ), 4, array( 'extension' ) );
|
||||
unset( Store::i()->currentImageProxyRebuild );
|
||||
Task::queue( 'core', 'RebuildImageProxyNonContent', array( 'extension' => 'core_Reports' ), 4, array( 'extension' ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -142,7 +168,7 @@ JSON;
|
||||
public function step4()
|
||||
{
|
||||
/* It is likely this will be attempted before settings are created */
|
||||
$currentDefaults = iterator_to_array( \IPS\Db::i()->select( '*', 'core_sys_conf_settings' )->setKeyField('conf_key')->setValueField('conf_default') );
|
||||
$currentDefaults = iterator_to_array( Db::i()->select( '*', 'core_sys_conf_settings' )->setKeyField('conf_key')->setValueField('conf_default') );
|
||||
|
||||
foreach ( array(
|
||||
array( 'key' => 'vapid_public_key', 'default' => '' ),
|
||||
@@ -150,19 +176,19 @@ JSON;
|
||||
{
|
||||
if ( ! array_key_exists( $setting['key'], $currentDefaults ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_sys_conf_settings', array( 'conf_key' => $setting['key'], 'conf_value' => $setting['default'], 'conf_default' => $setting['default'], 'conf_app' => 'core' ), TRUE );
|
||||
Db::i()->insert( 'core_sys_conf_settings', array( 'conf_key' => $setting['key'], 'conf_value' => $setting['default'], 'conf_default' => $setting['default'], 'conf_app' => 'core' ), TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate VAPID keys for web push notifications */
|
||||
try
|
||||
{
|
||||
$vapid = \IPS\Notification::generateVapidKeys();
|
||||
\IPS\Settings::i()->changeValues( array( 'vapid_public_key' => $vapid['publicKey'], 'vapid_private_key' => $vapid['privateKey'] ) );
|
||||
$vapid = Notification::generateVapidKeys();
|
||||
Settings::i()->changeValues( array( 'vapid_public_key' => $vapid['publicKey'], 'vapid_private_key' => $vapid['privateKey'] ) );
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
catch (Exception $ex)
|
||||
{
|
||||
\IPS\Log::log( $ex, 'create_vapid_keys' );
|
||||
Log::log( $ex, 'create_vapid_keys' );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -186,13 +212,13 @@ JSON;
|
||||
public function step5()
|
||||
{
|
||||
$perCycle = 500;
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
$limit = isset( Request::i()->extra ) ? Request::i()->extra : 0;
|
||||
$did = 0;
|
||||
|
||||
/* Make sure we have included Application.php files, since Pages has its own autoloader, we need to define it */
|
||||
\IPS\Application::applications();
|
||||
Application::applications();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_content_meta', [ 'meta_type=?', 'core_FeaturedComments' ], 'meta_id ASC', [ $limit, $perCycle ] ) as $row )
|
||||
foreach( Db::i()->select( '*', 'core_content_meta', [ 'meta_type=?', 'core_FeaturedComments' ], 'meta_id ASC', [ $limit, $perCycle ] ) as $row )
|
||||
{
|
||||
$did++;
|
||||
$class = $row['meta_class'];
|
||||
@@ -204,13 +230,13 @@ JSON;
|
||||
{
|
||||
$commentClass = $class::$commentClass;
|
||||
$comment = $commentClass::load( $data['comment'] );
|
||||
\IPS\Db::i()->update( 'core_content_meta', [
|
||||
Db::i()->update( 'core_content_meta', [
|
||||
'meta_item_author' => $comment->author()->member_id,
|
||||
'meta_added' => $comment->mapped('date')
|
||||
],
|
||||
[ 'meta_id=?', $row['meta_id'] ] );
|
||||
}
|
||||
catch( \Exception $e ){ }
|
||||
catch( Exception $e ){ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +250,7 @@ JSON;
|
||||
*/
|
||||
public function step5CustomTitle()
|
||||
{
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
$limit = isset( Request::i()->extra ) ? Request::i()->extra : 0;
|
||||
return "Updating recommended content ({$limit} processed so far)";
|
||||
}
|
||||
|
||||
@@ -236,10 +262,10 @@ JSON;
|
||||
public function step6()
|
||||
{
|
||||
$perCycle = 500;
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
$limit = isset( Request::i()->extra ) ? Request::i()->extra : 0;
|
||||
$did = 0;
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_social_promote', NULL, 'promote_id ASC', [ $limit, $perCycle ] ) as $row )
|
||||
foreach( Db::i()->select( '*', 'core_social_promote', NULL, 'promote_id ASC', [ $limit, $perCycle ] ) as $row )
|
||||
{
|
||||
$did++;
|
||||
|
||||
@@ -250,11 +276,11 @@ JSON;
|
||||
|
||||
try
|
||||
{
|
||||
$promote = \IPS\core\Promote::constructFromData( $row );
|
||||
$promote = Feature::constructFromData( $row );
|
||||
$promote->author_id = $promote->objectAuthor->member_id;
|
||||
$promote->save();
|
||||
}
|
||||
catch( \Exception $e ){ }
|
||||
catch( Exception $e ){ }
|
||||
}
|
||||
|
||||
return ( $did ) ? ( $limit + $did ) : TRUE;
|
||||
@@ -267,7 +293,7 @@ JSON;
|
||||
*/
|
||||
public function step6CustomTitle()
|
||||
{
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
$limit = isset( Request::i()->extra ) ? Request::i()->extra : 0;
|
||||
return "Updating promoted content ({$limit} processed so far)";
|
||||
}
|
||||
|
||||
@@ -278,7 +304,7 @@ JSON;
|
||||
*/
|
||||
public function step7()
|
||||
{
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter' ) as $extension )
|
||||
foreach ( Application::allExtensions( 'core', 'ContentRouter' ) as $extension )
|
||||
{
|
||||
foreach ( $extension->classes as $class )
|
||||
{
|
||||
@@ -286,9 +312,9 @@ JSON;
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'Upgrade46FeaturedContent', array( 'class' => $class ), 2 );
|
||||
Task::queue( 'core', 'Upgrade46FeaturedContent', array( 'class' => $class ), 2 );
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
catch( Exception $e ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,19 +339,19 @@ JSON;
|
||||
*/
|
||||
public function step8()
|
||||
{
|
||||
$core = \IPS\Application::load('core');
|
||||
$core = Application::load('core');
|
||||
|
||||
/* Manually installed badges are good for recognize system and aren't tied to rules */
|
||||
\IPS\core\Achievements\Badge::importXml( $core->getApplicationPath() . "/data/achievements/badges.xml" );
|
||||
Badge::importXml( $core->getApplicationPath() . "/data/achievements/badges.xml" );
|
||||
|
||||
if ( $_SESSION['upgrade_options']['core']['106000']["rule_option"] == 'new' )
|
||||
{
|
||||
\IPS\core\Achievements\Rule::importXml( $core->getApplicationPath() . "/data/achievements/rules.xml", TRUE );
|
||||
\IPS\core\Achievements\Rank::importXml( $core->getApplicationPath() . "/data/achievements/ranks.xml", 'wipe' );
|
||||
Rule::importXml( $core->getApplicationPath() . "/data/achievements/rules.xml", TRUE );
|
||||
Rank::importXml( $core->getApplicationPath() . "/data/achievements/ranks.xml", 'wipe' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_achievements_rules', [
|
||||
Db::i()->insert( 'core_achievements_rules', [
|
||||
'action' => 'core_Comment',
|
||||
'filters' => NULL,
|
||||
'milestone' => 0,
|
||||
@@ -336,7 +362,7 @@ JSON;
|
||||
'enabled' => 1
|
||||
]);
|
||||
|
||||
\IPS\Db::i()->insert( 'core_achievements_rules', [
|
||||
Db::i()->insert( 'core_achievements_rules', [
|
||||
'action' => 'core_NewContentItem',
|
||||
'filters' => NULL,
|
||||
'milestone' => 0,
|
||||
@@ -348,10 +374,10 @@ JSON;
|
||||
]);
|
||||
|
||||
/* Reset the member's achievement points to the same number of posts to retain existing rank position */
|
||||
\IPS\Db::i()->update( 'core_members', "achievements_points=member_posts" );
|
||||
Db::i()->update( 'core_members', "achievements_points=member_posts" );
|
||||
|
||||
/* Set the rebuild date so the badge times are not from 1970 */
|
||||
\IPS\Settings::i()->changeValues( array( 'achievements_last_rebuilt' => time() ) );
|
||||
Settings::i()->changeValues( array( 'achievements_last_rebuilt' => time() ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -375,13 +401,13 @@ JSON;
|
||||
*/
|
||||
public function step9()
|
||||
{
|
||||
$group = new \IPS\core\ProfileFields\Group;
|
||||
$group = new Group;
|
||||
$group->save();
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_pfieldgroups_{$group->id}", 'Retained' );
|
||||
Lang::saveCustom( 'core', "core_pfieldgroups_{$group->id}", 'Retained' );
|
||||
|
||||
/* Create the about me profile field */
|
||||
$memberTitleField = new \IPS\core\ProfileFields\Field;
|
||||
$memberTitleField = new Field;
|
||||
$memberTitleField->group_id = $group->id;
|
||||
$memberTitleField->type = "Text";
|
||||
$memberTitleField->content = NULL;
|
||||
@@ -398,13 +424,13 @@ JSON;
|
||||
try
|
||||
{
|
||||
$memberTitleField->save();
|
||||
\IPS\Lang::saveCustom( 'core', 'core_pfield_' . $memberTitleField->id, "Member Title" );
|
||||
\IPS\Lang::saveCustom( 'core', 'core_pfield_' . $memberTitleField->id . '_desc', "" );
|
||||
Lang::saveCustom( 'core', 'core_pfield_' . $memberTitleField->id, "Member Title" );
|
||||
Lang::saveCustom( 'core', 'core_pfield_' . $memberTitleField->id . '_desc', "" );
|
||||
$_SESSION['106100-TITLE-FIELD'] = $memberTitleField->id;
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
catch( Exception $ex )
|
||||
{
|
||||
\IPS\Log::log( $ex, 'upgrade' );
|
||||
Log::log( $ex, 'upgrade' );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -432,17 +458,17 @@ JSON;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$toRun = \IPS\core\Setup\Upgrade::runManualQueries( array( array(
|
||||
$toRun = UpgradeClass::runManualQueries( array( array(
|
||||
'table' => 'core_members',
|
||||
'query' => "UPDATE " . \IPS\Db::i()->prefix . "core_pfields_content c INNER JOIN " . \IPS\Db::i()->prefix . "core_members m ON m.member_id=c.member_id SET c.field_" . $_SESSION['106100-TITLE-FIELD'] . "=m.member_title WHERE LENGTH(m.member_title) > 0"
|
||||
'query' => "UPDATE " . Db::i()->prefix . "core_pfields_content c INNER JOIN " . Db::i()->prefix . "core_members m ON m.member_id=c.member_id SET c.field_" . $_SESSION['106100-TITLE-FIELD'] . "=m.member_title WHERE LENGTH(m.member_title) > 0"
|
||||
) ) );
|
||||
|
||||
if ( \count( $toRun ) )
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 11 ) ) );
|
||||
UpgradeClass::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 11 ) ) );
|
||||
|
||||
/* 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 array( 'html' => Theme::i()->getTemplate( 'forms' )->queries( $toRun, Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => Request::i()->mr ) ) ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -455,9 +481,9 @@ JSON;
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
if( isset( \IPS\Settings::i()->search_method ) AND \IPS\Settings::i()->search_method == 'mysql' )
|
||||
if( isset( Settings::i()->search_method ) AND Settings::i()->search_method == 'mysql' )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
Index::i()->rebuild();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
Reference in new issue
Block a user