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

@@ -12,30 +12,42 @@
namespace IPS\convert\extensions\core\Queue;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\convert\App;
use IPS\Db;
use IPS\File;
use IPS\Member;
use IPS\Task\Queue\OutOfRangeException;
use UnderflowException;
use function defined;
use const IPS\PHOTO_THUMBNAIL_SIZE;
use const IPS\REBUILD_SLOW;
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;
}
/**
* Background Task
*/
class _RebuildProfilePhotos
class RebuildProfilePhotos
{
/**
* Parse data before queuing
*
* @param array $data Data
* @return array
* @return array|null
*/
public function preQueueData( $data )
public function preQueueData( array $data ): ?array
{
try
{
$data['count'] = \IPS\Db::i()->select( 'count(member_id)', 'core_members', [ 'pp_photo_type=?', 'custom' ] )->first();
$data['count'] = Db::i()->select( 'count(member_id)', 'core_members', [ 'pp_photo_type=?', 'custom' ] )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
throw new \OutOfRangeException;
}
@@ -56,23 +68,23 @@ class _RebuildProfilePhotos
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int|null New offset or NULL if complete
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
* @throws OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( &$data, $offset )
public function run( mixed &$data, int $offset ): int
{
/* Intentionally no try/catch as it means app doesn't exist */
try
{
$app = \IPS\convert\App::load( $data['app'] );
$app = App::load( $data['app'] );
}
catch( \OutOfRangeException $e )
{
throw new \IPS\Task\Queue\OutOfRangeException;
throw new OutOfRangeException;
}
$last = NULL;
foreach( \IPS\Db::i()->select( '*', 'core_members', [ "member_id>? AND pp_photo_type=?", $offset, 'custom' ], 'member_id ASC', [ 0, \IPS\REBUILD_SLOW ] ) AS $member )
foreach( Db::i()->select( '*', 'core_members', [ "member_id>? AND pp_photo_type=?", $offset, 'custom' ], 'member_id ASC', [ 0, REBUILD_SLOW ] ) AS $member )
{
$data['completed']++;
@@ -90,18 +102,18 @@ class _RebuildProfilePhotos
try
{
$photo = \IPS\File::get( 'core_Profile', $member['pp_main_photo'] );
$thumbnail = $photo->thumbnail( 'core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE );
\IPS\Db::i()->update( 'core_members', [ 'pp_thumb_photo' => (string) $thumbnail ], [ 'member_id=?', $member['member_id'] ] );
$photo = File::get( 'core_Profile', $member['pp_main_photo'] );
$thumbnail = $photo->thumbnail( 'core_Profile', PHOTO_THUMBNAIL_SIZE, PHOTO_THUMBNAIL_SIZE, TRUE );
Db::i()->update( 'core_members', [ 'pp_thumb_photo' => (string) $thumbnail ], [ 'member_id=?', $member['member_id'] ] );
}
catch( \Exception $e ) { }
catch( Exception $e ) { }
$last = $member['member_id'];
}
if( $last === NULL )
{
throw new \IPS\Task\Queue\OutOfRangeException;
throw new OutOfRangeException;
}
return $last;
@@ -114,8 +126,8 @@ class _RebuildProfilePhotos
* @param int $offset Offset
* @return array Text explaning task and percentage complete
*/
public function getProgress( $data, $offset )
public function getProgress( mixed $data, int $offset ): array
{
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'queue_rebuilding_profile_photos' ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
return array( 'text' => Member::loggedIn()->language()->addToStack( 'queue_rebuilding_profile_photos' ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
}
}