Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+31 -23
View File
@@ -12,29 +12,37 @@
namespace IPS\blog\setup\upg_105013;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\blog\Blog;
use IPS\blog\Category;
use IPS\Db;
use IPS\Lang;
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.5.0 Beta 1 Upgrade Code
*/
class _Upgrade
class Upgrade
{
/**
* Set up categories
*
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
* @return bool|array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
*/
public function step1()
public function step1() : bool|array
{
$category = new \IPS\blog\Category;
$category = new Category;
$category->seo_name = 'general';
$category->save();
\IPS\Lang::saveCustom( 'blog', "blog_category_{$category->id}", "General" );
Lang::saveCustom( 'blog', "blog_category_{$category->id}", "General" );
return TRUE;
}
@@ -42,29 +50,29 @@ class _Upgrade
/**
* Convert RSS imports over
*
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
* @return bool|array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
*/
public function step2()
public function step2() : bool|array
{
/* Make sure we have the table first */
if( !\IPS\Db::i()->checkForTable('blog_rss_import') )
if( !Db::i()->checkForTable('blog_rss_import') )
{
return TRUE;
}
/* Move over blog_rss_import to core_rss_import */
foreach( \IPS\Db::i()->select( '*', 'blog_rss_import' ) as $rss )
foreach( Db::i()->select( '*', 'blog_rss_import' ) as $rss )
{
try
{
$blog = \IPS\blog\Blog::load( $rss['rss_blog_id'] );
$blog = Blog::load( $rss['rss_blog_id'] );
}
catch( \Exception $e )
catch( Exception $e )
{
continue;
}
$newImportId = \IPS\Db::i()->insert( 'core_rss_import', array(
$newImportId = Db::i()->insert( 'core_rss_import', array(
'rss_import_enabled' => 1,
'rss_import_title' => $blog->titleForLog(),
'rss_import_url' => $rss['rss_url'],
@@ -86,13 +94,13 @@ class _Upgrade
/* Prevent multiple runs from breaking */
try
{
\IPS\Db::i()->delete( 'core_rss_imported', array( 'rss_imported_import_id=?', $newImportId ) );
Db::i()->delete( 'core_rss_imported', array( 'rss_imported_import_id=?', $newImportId ) );
\IPS\Db::i()->query( "INSERT INTO " . \IPS\Db::i()->prefix . "core_rss_imported
Db::i()->query( "INSERT INTO " . Db::i()->prefix . "core_rss_imported
(rss_imported_guid, rss_imported_content_id, rss_imported_import_id )
( SELECT a.rss_imported_guid, a.rss_imported_entry_id, {$newImportId} FROM " . \IPS\Db::i()->prefix . "blog_rss_imported a)" );
( SELECT a.rss_imported_guid, a.rss_imported_entry_id, {$newImportId} FROM " . Db::i()->prefix . "blog_rss_imported a)" );
}
catch( \Exception $e ) { }
catch( Exception $e ) { }
}
return TRUE;
@@ -101,17 +109,17 @@ class _Upgrade
/**
* Finish
*
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
* @return bool|array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
*/
public function finish()
public function finish() : bool|array
{
/* Delete old language strings */
\IPS\Db::i()->delete( 'core_tasks', array( '`key`=?', 'blogrssimport' ) );
Db::i()->delete( 'core_tasks', array( '`key`=?', 'blogrssimport' ) );
/* Delete old RSS Table */
if( \IPS\Db::i()->checkForTable('blog_rss_import') )
if( Db::i()->checkForTable('blog_rss_import') )
{
\IPS\Db::i()->dropTable( array( 'blog_rss_import', 'blog_rss_imported' ) );
Db::i()->dropTable( array( 'blog_rss_import', 'blog_rss_imported' ) );
}
return TRUE;