Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\cms\extensions\core\Queue;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -26,7 +26,7 @@ class _RebuildReciprocalMaps
/**
* @brief Number of content items to rebuild per cycle
*/
public $rebuild = 500;
public $rebuild = \IPS\REBUILD_QUICK;
/**
* Parse data before queuing
@@ -53,6 +53,8 @@ class _RebuildReciprocalMaps
return null;
}
$data['completed'] = 0;
return $data;
}
/**
@@ -63,18 +65,18 @@ class _RebuildReciprocalMaps
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$databaseId = $data['database'];
$databaseId = $data['database'];
$fieldId = $data['field'];
$parsed = 0;
$last = NULL;
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) )
{
$fieldsClass = 'IPS\cms\Fields' . $databaseId;
$field = $fieldsClass::load( $fieldId );
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'field_' . $fieldId . ' != \'\' or field_' . $fieldId . ' IS NOT NULL' ), 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'primary_id_field > ? AND (field_' . $fieldId . ' != \'\' or field_' . $fieldId . ' IS NOT NULL)', $offset ), 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
{
$extra = $field->extra;
if ( $row[ 'field_' . $fieldId ] and ! empty( $extra['database'] ) )
@@ -94,16 +96,17 @@ class _RebuildReciprocalMaps
}
}
$parsed++;
$data['completed']++;
$last = $row['primary_id_field'];
}
}
if ( ! $parsed )
if ( $last === NULL )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return $offset + $this->rebuild;
return $last;
}
/**
@@ -117,6 +120,6 @@ class _RebuildReciprocalMaps
public function getProgress( $data, $offset )
{
$databaseId = $data['database'];
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_reciprocal_map', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title, $data['field'] ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_reciprocal_map', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title, $data['field'] ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
}
}