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

+172 -150
View File
@@ -11,39 +11,64 @@
namespace IPS\Content\Search;
/* 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;
use IPS\Content\Comment;
use IPS\Content\Item;
use IPS\Content\Search\Elastic\MassIndexer;
use IPS\DateTime;
use IPS\Db;
use IPS\Http\Url;
use IPS\IPS;
use IPS\Member;
use IPS\Patterns\Singleton;
use IPS\Settings;
use IPS\Task;
use IPS\Text\Parser;
use LogicException;
use OutOfRangeException;
use RuntimeException;
use UnderflowException;
use function chr;
use function defined;
use function get_class;
use function intval;
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;
}
/**
* Abstract Search Index
*/
abstract class _Index extends \IPS\Patterns\Singleton
abstract class Index extends Singleton
{
/**
* @brief Singleton Instances
*/
protected static $instance = NULL;
protected static ?Singleton $instance = NULL;
/**
* Get instance
*
* @param bool $skipCache Do not use the cached instance if one exists
* @param bool $skipCache Do not use the cached instance if one exists
* @return static
*/
public static function i( $skipCache=FALSE )
public static function i( bool $skipCache=FALSE ): static
{
if( static::$instance === NULL OR $skipCache === TRUE )
{
if ( \IPS\Settings::i()->search_method == 'elastic' )
if ( Settings::i()->search_method == 'elastic' )
{
static::$instance = new \IPS\Content\Search\Elastic\Index( \IPS\Http\Url::external( rtrim( \IPS\Settings::i()->search_elastic_server, '/' ) . '/' . \IPS\Settings::i()->search_elastic_index ) );
static::$instance = new Elastic\Index( Url::external( rtrim( Settings::i()->search_elastic_server, '/' ) . '/' . Settings::i()->search_elastic_index ) );
}
else
{
static::$instance = new \IPS\Content\Search\Mysql\Index;
static::$instance = new Mysql\Index;
}
}
@@ -55,11 +80,11 @@ abstract class _Index extends \IPS\Patterns\Singleton
*
* @return static
*/
public static function massIndexer()
public static function massIndexer(): static
{
if ( \IPS\Settings::i()->search_method == 'elastic' )
if ( Settings::i()->search_method == 'elastic' )
{
return new \IPS\Content\Search\Elastic\MassIndexer( \IPS\Http\Url::external( rtrim( \IPS\Settings::i()->search_elastic_server, '/' ) . '/' . \IPS\Settings::i()->search_elastic_index ) );
return new MassIndexer( Url::external( rtrim( Settings::i()->search_elastic_server, '/' ) . '/' . Settings::i()->search_elastic_index ) );
}
else
{
@@ -72,7 +97,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
*
* @return void
*/
public function init()
public function init(): void
{
// Does nothing by default
}
@@ -82,45 +107,47 @@ abstract class _Index extends \IPS\Patterns\Singleton
*
* @return void
*/
public function rebuild()
public function rebuild(): void
{
/* Delete everything currently in it */
$this->prune();
/* If the queue is already running, clear it out */
\IPS\Db::i()->delete( 'core_queue', array( "`key`=?", 'RebuildSearchIndex' ) );
Db::i()->delete( 'core_queue', array( "`key`=?", 'RebuildSearchIndex' ) );
/* And set the queue in motion to rebuild */
foreach ( \IPS\Content::routedClasses( FALSE ) as $class )
foreach( SearchContent::searchableClasses() as $class )
{
try
{
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) )
{
\IPS\Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => $class ), 5, TRUE );
}
Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => $class ), 5, array( 'class' ) );
}
catch( \OutOfRangeException $ex ) {}
catch( OutOfRangeException ) {}
}
}
/**
* Index a single items comments and reviews if applicable.
*
* @param \IPS\Content\Searchable $object The item to index
* @param Item $object The item to index
* @return void
*/
public function indexSingleItem( \IPS\Content\Searchable $object )
public function indexSingleItem( Item $object ): void
{
if( !SearchContent::isSearchable( $object ) )
{
return;
}
/* It is possible for some items to not have a valid URL */
try
{
if( !$url = (string) $object->url() )
{
throw new \LogicException;
throw new LogicException;
}
}
catch( \LogicException $e )
catch( LogicException )
{
$url = '';
}
@@ -128,66 +155,77 @@ abstract class _Index extends \IPS\Patterns\Singleton
try
{
$idColumn = $object::$databaseColumnId;
if ( isset( $object::$commentClass ) AND is_subclass_of( $object::$commentClass, 'IPS\Content\Searchable' ) )
if ( isset( $object::$commentClass ) AND SearchContent::isSearchable( $object::$commentClass ) )
{
\IPS\Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$commentClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => $url ), 5, TRUE );
Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$commentClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => $url ) );
}
if ( isset( $object::$reviewClass ) AND is_subclass_of( $object::$reviewClass, 'IPS\Content\Searchable' ) )
if ( isset( $object::$reviewClass ) AND SearchContent::isSearchable( $object::$reviewClass ) )
{
\IPS\Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$reviewClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => $url ), 5, TRUE );
Task::queue( 'core', 'IndexSingleItem', array( 'class' => $object::$reviewClass, 'id' => $object->$idColumn, 'title' => $object->mapped('title'), 'url' => $url ) );
}
}
catch( \OutOfRangeException $e ) {}
catch( OutOfRangeException ) {}
}
/**
* Get index data
*
* @param \IPS\Content\Searchable $object Item to add
* @param Content $object Item to add
* @return array|NULL
*/
public function indexData( \IPS\Content\Searchable $object )
public function indexData( Content $object ): array|NULL
{
/* Init */
$class = \get_class( $object );
$class = get_class( $object );
if( !SearchContent::isSearchable( $class ) )
{
return NULL;
}
$extension = SearchContent::extension( $object );
if( $extension === null )
{
return NULL;
}
$extension->setObject( $object );
$idColumn = $class::$databaseColumnId;
$tags = ( $object instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? implode( ',', array_filter( $object->tags() ) ) : NULL;
$prefix = ( $object instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? $object->prefix() : NULL;
$tags = ( IPS::classUsesTrait( $object, 'IPS\Content\Taggable' ) and Settings::i()->tags_enabled ) ? implode( ',', array_filter( $object->tags() ) ) : NULL;
$prefix = ( IPS::classUsesTrait( $object, 'IPS\Content\Taggable' ) and Settings::i()->tags_enabled ) ? $object->prefix() : NULL;
/* If this is an item where the first comment is required, don't index because the comment will serve as both */
if ( $object instanceof \IPS\Content\Item and $class::$firstCommentRequired )
if ( $object instanceof Item and $object::$firstCommentRequired )
{
return NULL;
}
/* Don't index if this is an item to be published in the future */
if ( $object->isFutureDate() )
if ( IPS::classUsesTrait( $object, 'IPS\Content\FuturePublishing' ) AND $object->isFutureDate() )
{
return NULL;
}
/* Or if this *is* the first comment, add the title and replace the tags */
$title = $object->searchIndexTitle();
$title = $extension->searchIndexTitle();
$isForItem = FALSE;
if ( $object instanceof \IPS\Content\Comment )
if ( $object instanceof Comment )
{
$itemClass = $class::$itemClass;
$itemClass = $object::$itemClass;
if ( $itemClass::$firstCommentRequired and $object->isFirst() )
{
try
{
$item = $object->item();
}
catch( \OutOfRangeException $ex )
catch( OutOfRangeException )
{
/* Comment has no working item, return */
return NULL;
}
$title = $item->searchIndexTitle();
$tags = ( $item instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? implode( ',', array_filter( $item->tags() ) ) : NULL;
$prefix = ( $item instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? $item->prefix() : NULL;
$tags = ( IPS::classUsesTrait( $item, 'IPS\Content\Taggable' ) and Settings::i()->tags_enabled ) ? implode( ',', array_filter( $item->tags() ) ) : NULL;
$prefix = ( IPS::classUsesTrait( $item, 'IPS\Content\Taggable' ) and Settings::i()->tags_enabled ) ? $item->prefix() : NULL;
$isForItem = TRUE;
}
}
@@ -202,7 +240,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
{
$dateUpdated = $object->mapped('date');
$dateCommented = $object->mapped('date');
if ( $object instanceof \IPS\Content\Item )
if ( $object instanceof Item )
{
foreach ( array( 'last_comment', 'last_review', 'updated' ) as $k )
{
@@ -221,15 +259,15 @@ abstract class _Index extends \IPS\Patterns\Singleton
}
}
/* Is the the latest content? */
/* Is this the latest content? */
$isLastComment = 0;
if ( $object instanceof \IPS\Content\Comment )
if ( $object instanceof Comment )
{
try
{
$item = $object->item();
}
catch( \OutOfRangeException $ex )
catch( OutOfRangeException )
{
/* Comment has no parent item, return */
return NULL;
@@ -248,9 +286,9 @@ abstract class _Index extends \IPS\Patterns\Singleton
{
$isLastComment = 1;
}
/* If this comment is hidden, don't actually mark as the last comment as that will cause this item to be hidden in search if we are getting only the last comment. */
if ( $isLastComment AND $object->hidden() AND !$object->isFirst() )
if ( $isLastComment and $object->hidden() and !$object->isFirst() )
{
$isLastComment = 0;
}
@@ -265,7 +303,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
}
}
}
else if ( $object instanceof \IPS\Content\Item and ! $class::$firstCommentRequired )
else if ( $object instanceof Item and ! $object::$firstCommentRequired )
{
/* If this is item itself and not a comment, then we will store it as the last comment so the activity stream fetches the data correctly */
$isLastComment = 1;
@@ -281,7 +319,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
/* Is the item itself searchable but the comment not? */
$commentClass = $object::$commentClass;
if ( ! ( is_subclass_of( $commentClass, 'IPS\Content\Searchable' ) ) )
if( !$commentClass OR !SearchContent::isSearchable( $commentClass ) )
{
/* Then make this the last comment so it remains searchable */
$isLastComment = 1;
@@ -289,34 +327,49 @@ abstract class _Index extends \IPS\Patterns\Singleton
}
/* Strip spoilers */
$content = $object->searchIndexContent();
$content = $extension->searchIndexContent();
if ( preg_match( '#<div\s+?class=["\']ipsSpoiler["\']#', $content ) )
{
$content = \IPS\Text\Parser::removeElements( $content, array( 'div[class=ipsSpoiler]' ) );
$content = Parser::removeElements( $content, array( 'div[class=ipsSpoiler]' ) );
}
/* Take the HTML out of the content */
$content = trim( str_replace( \chr(0xC2) . \chr(0xA0), ' ', strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(?:[^>]+?)>.+?(?<!<blockquote)</blockquote>#s", " ", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $content . ' ' ) ) ) ) ) );
$content = trim( str_replace( chr(0xC2) . chr(0xA0), ' ', strip_tags( preg_replace( "/(<br(?: \/)?>|<\/p>)/i", ' ', preg_replace( "#<blockquote(?:[^>]+?)>.+?(?<!<blockquote)</blockquote>#s", " ", preg_replace( "#<script(.*?)>(.*)</script>#uis", "", ' ' . $content . ' ' ) ) ) ) ) );
/* Work out the hidden status */
$hiddenStatus = $object->hidden();
if ( $hiddenStatus === 0 and method_exists( $object, 'item' ) and $object->item()->hidden() )
if( IPS::classUsesTrait( $object, 'IPS\Content\Hideable' ) )
{
$hiddenStatus = $isForItem ? $object->item()->hidden() : 2;
try
{
$hiddenStatus = $object->hidden();
if ( $hiddenStatus === 0 and method_exists( $object, 'item' ) and $object->item()->hidden() )
{
$hiddenStatus = $isForItem ? $object->item()->hidden() : 2;
}
if ( $hiddenStatus !== 0 and method_exists( $object, 'item' ) and IPS::classUsesTrait( $object, 'IPS\Content\FuturePublishing' ) AND $object->isFutureDate() )
{
$hiddenStatus = 0;
}
if ( $hiddenStatus === -3 )
{
return NULL;
}
}
catch( RuntimeException )
{
/* Some classes implement Hideable for other reasons, but don't actually use it. See \IPS\nexus\Package\Item */
$hiddenStatus = 0;
}
}
if ( $hiddenStatus !== 0 and method_exists( $object, 'item' ) and $object->item()->isFutureDate() )
else
{
$hiddenStatus = 0;
}
if ( $hiddenStatus === -3 )
{
return NULL;
}
/* Get the item index ID */
$itemIndexId = NULL;
$itemClass = NULL;
if ( $object instanceof \IPS\Content\Comment )
if ( $object instanceof Comment )
{
$itemClass = $object::$itemClass;
if ( $itemClass::$firstCommentRequired )
@@ -331,7 +384,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
$itemIndexId = $this->getIndexId( $object->item()->firstComment() );
}
catch ( \Exception $e ) { }
catch ( Exception ) { }
}
else
{
@@ -339,22 +392,22 @@ abstract class _Index extends \IPS\Patterns\Singleton
{
$itemIndexId = $this->getIndexId( $object->item() );
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
try
{
/* Try and index parent */
\IPS\Content\Search\Index::i()->index( $object->item() );
Index::i()->index( $object->item() );
$itemIndexId = $this->getIndexId( $object->item() );
}
catch( \Exception $ex )
catch( Exception )
{
return NULL;
}
}
}
}
else if ( $object instanceof \IPS\Content\Item )
else if ( $object instanceof Item )
{
if ( ! $object::$firstCommentRequired )
{
@@ -364,45 +417,35 @@ abstract class _Index extends \IPS\Patterns\Singleton
/* Good, we need the index_item_index_id so this is not wiped on re-index */
$itemIndexId = $this->getIndexId( $object );
}
catch ( \Exception $e ) { }
catch ( Exception ) { }
}
}
/* Club */
$container = NULL;
$containerId = NULL;
$clubId = NULL;
if ( $object instanceof \IPS\Content\Item )
if ( $object instanceof Item )
{
$containerId = (int) $object->searchIndexContainer();
$container = $object->containerWrapper();
}
else
{
$containerId = (int) $object->item()->mapped('container');
$container = $object->item()->containerWrapper();
}
if ( $container and \IPS\IPS::classUsesTrait( $container, 'IPS\Content\ClubContainer' ) )
if ( $container and IPS::classUsesTrait( $container, 'IPS\Content\ClubContainer' ) )
{
$clubId = $container->{$container::clubIdColumn()};
}
/* Work out the container class */
if( $object instanceof \IPS\Content\Item )
{
$containerClass = ( $object->searchIndexContainerClass() ) ? \get_class( $object->searchIndexContainerClass() ) : NULL;
}
else
{
$containerClass = ( $object->item()->searchIndexContainerClass() ) ? \get_class( $object->item()->searchIndexContainerClass() ) : NULL;
}
$containerClass = ( $extension->searchIndexContainerClass() ) ? get_class( $extension->searchIndexContainerClass() ) : null;
/* Do we have an extension to modify this? */
foreach( \IPS\Application::enabledApplications() as $app )
foreach( Application::enabledApplications() as $app )
{
foreach ( $app->extensions( 'core', 'SearchIndex' ) as $extension )
foreach ( $app->extensions( 'core', 'SearchIndex' ) as $searchIndexExtension )
{
$content = $extension->content( $object, $content );
$content = $searchIndexExtension->content( $object, $content );
}
}
@@ -410,26 +453,26 @@ abstract class _Index extends \IPS\Patterns\Singleton
return array(
'index_class' => $class,
'index_object_id' => $object->$idColumn,
'index_item_id' => ( $object instanceof \IPS\Content\Item ) ? $object->$idColumn : $object->mapped('item'),
'index_item_id' => ( $object instanceof Item ) ? $object->$idColumn : $object->mapped('item'),
'index_container_class' => $containerClass,
'index_container_id' => ( $object instanceof \IPS\Content\Item ) ? (int) $object->searchIndexContainer() : (int) $object->item()->mapped('container'),
'index_container_id' => $extension->searchIndexContainer(),
'index_title' => $title,
'index_content' => $content,
'index_permissions' => $object->searchIndexPermissions(),
'index_date_created' => \intval( $object->mapped('date') ),
'index_date_updated' => \intval( $dateUpdated ),
'index_date_commented' => \intval( $dateCommented ),
'index_permissions' => $extension->searchIndexPermissions(),
'index_date_created' => intval( $object->mapped('date') ),
'index_date_updated' => intval( $dateUpdated ),
'index_date_commented' => intval( $dateCommented ),
'index_author' => (int) $object->mapped('author'),
'index_tags' => $tags,
'index_prefix' => $prefix,
'index_hidden' => $hiddenStatus,
'index_item_index_id' => $itemIndexId,
'index_item_author' => \intval( ( $object instanceof \IPS\Content\Item ) ? $object->mapped('author') : $object->item()->mapped('author') ),
'index_item_author' => intval( ( $object instanceof Item ) ? $object->mapped('author') : $object->item()->mapped('author') ),
'index_is_last_comment' => $isLastComment,
'index_club_id' => $clubId,
'index_class_type_id_hash' => md5( $class . ':' . $object->$idColumn ),
'index_is_anon' => (int) $object->isAnonymous(),
'index_item_solved' => ( $itemClass and \IPS\IPS::classUsesTrait( $itemClass, 'IPS\Content\Solvable' ) ) ? ( $object->item()->mapped('solved_comment_id') == $object->$idColumn ) ? 1 : 0 : NULL
'index_is_anon' => (int) ( IPS::classUsesTrait( $object, 'IPS\Content\Anonymous' ) AND $object->isAnonymous() ),
'index_item_solved' => ( $itemClass and IPS::classUsesTrait( $itemClass, 'IPS\Content\Solvable' ) ) ? ( $object->item()->mapped('solved_comment_id') == $object->$idColumn ) ? 1 : 0 : NULL
);
}
@@ -437,12 +480,12 @@ abstract class _Index extends \IPS\Patterns\Singleton
* Get the object ID of the first comment.
* Used for posts, where the index_object_id is NOT the topic ID
*
* @param \IPS\Content\Searchable $object
* @param Content $object
* @return int|null
*/
protected function getFirstCommentId( \IPS\Content\Searchable $object ) : ?int
protected function getFirstCommentId( Content $object ) : ?int
{
if( $object instanceof \IPS\Content\Comment )
if( $object instanceof Comment )
{
$itemClass = $object::$itemClass;
if( $itemClass::$firstCommentRequired )
@@ -471,17 +514,17 @@ abstract class _Index extends \IPS\Patterns\Singleton
/**
* Index an item
*
* @param \IPS\Content\Searchable $object Item to add
* @param Content $object Item to add
* @return void
*/
abstract public function index( \IPS\Content\Searchable $object );
abstract public function index( Content $object ): void;
/**
* Clear out any tasks associated with the search index method
*
* @return void
*/
public function clearTasks()
public function clearTasks(): void
{
// Do nothing by default
}
@@ -489,18 +532,18 @@ abstract class _Index extends \IPS\Patterns\Singleton
/**
* Retrieve the search ID for an item
*
* @param \IPS\Content\Searchable $object Item to add
* @return string
* @param Content $object Item to add
* @return mixed
*/
abstract public function getIndexId( \IPS\Content\Searchable $object ): string;
abstract public function getIndexId( Content $object ): mixed;
/**
* Remove item
*
* @param \IPS\Content\Searchable $object Item to remove
* @param Content $object Item to remove
* @return void
*/
abstract public function removeFromSearchIndex( \IPS\Content\Searchable $object );
abstract public function removeFromSearchIndex( Content $object ): void;
/**
* Removes all content for a classs
@@ -510,42 +553,21 @@ abstract class _Index extends \IPS\Patterns\Singleton
* @param int|NULL $authorId The author ID to delete, or NULL
* @return void
*/
abstract public function removeClassFromSearchIndex( $class, $containerId=NULL, $authorId=NULL );
abstract public function removeClassFromSearchIndex( string $class, int|null $containerId=NULL, int|null $authorId=NULL ): void;
/**
* Removes all content for a specific application from the index (for example, when uninstalling).
*
* @param \IPS\Application $application The application
* @param Application $application The application
* @return void
*/
public function removeApplicationContent( \IPS\Application $application )
public function removeApplicationContent( Application $application ): void
{
foreach ( $application->extensions( 'core', 'ContentRouter' ) as $router )
foreach ( $application->extensions( 'core', 'SearchContent' ) as $extension )
{
foreach( $router->classes AS $class )
foreach( $extension::supportedClasses() as $class )
{
if ( is_subclass_of( $class, 'IPS\Content\Searchable' ) )
{
$this->removeClassFromSearchIndex( $class );
if ( isset( $class::$commentClass ) )
{
$commentClass = $class::$commentClass;
if ( is_subclass_of( $commentClass, 'IPS\Content\Searchable' ) )
{
$this->removeClassFromSearchIndex( $commentClass );
}
}
if ( isset( $class::$reviewClass ) )
{
$reviewClass = $class::$reviewClass;
if ( is_subclass_of( $reviewClass, 'IPS\Content\Searchable' ) )
{
$this->removeClassFromSearchIndex( $reviewClass );
}
}
}
$this->removeClassFromSearchIndex( $class );
}
}
}
@@ -565,61 +587,61 @@ abstract class _Index extends \IPS\Patterns\Singleton
* @param bool $addAuthorToPermissions If true, the index_author_id will be added to $newPermissions - used when changing the permissions for a node which allows access only to author's items
* @return void
*/
abstract public function massUpdate( $class, $containerId = NULL, $itemId = NULL, $newPermissions = NULL, $newHiddenStatus = NULL, $newContainer = NULL, $authorId = NULL, $newItemId = NULL, $newItemAuthorId = NULL, $addAuthorToPermissions = FALSE );
abstract public function massUpdate( string $class, int|null $containerId = NULL, int|null $itemId = NULL, string|null $newPermissions = NULL, int|null $newHiddenStatus = NULL, int|null $newContainer = NULL, int|null $authorId = NULL, int|null $newItemId = NULL, int|null $newItemAuthorId = NULL, bool $addAuthorToPermissions = FALSE ): void;
/**
* Update data for the first and last comment after a merge
* Sets index_is_last_comment on the last comment, and, if this is an item where the first comment is indexed rather than the item, sets index_title and index_tags on the first comment
*
* @param \IPS\Content\Item $item The item
* @param Item $item The item
* @return void
*/
abstract public function rebuildAfterMerge( \IPS\Content\Item $item );
abstract public function rebuildAfterMerge( Item $item ): void;
/**
* Prune search index
*
* @param \IPS\DateTime|NULL $cutoff The date to delete index records from, or NULL to delete all
* @param DateTime|NULL $cutoff The date to delete index records from, or NULL to delete all
* @return void
*/
abstract public function prune( \IPS\DateTime $cutoff = NULL );
abstract public function prune( DateTime $cutoff = NULL ): void;
/**
* Reset the last comment flag in any given class/index_item_id
*
* @param string $class The class
* @param array $classes The class
* @param int|NULL $indexItemId The index item ID
* @param int|NULL $ignoreId ID to ignore because it is being removed
* @param int|null $firstCommentId The first comment in this item, used only if $firstCommentRequired
* @param int|null $firstCommentId The first comment in this item, used only if $firstCommentRequired
* @return void
*/
abstract public function resetLastComment( $class, $indexItemId, $ignoreId = NULL, $firstCommentId = NULL );
abstract public function resetLastComment( array $classes, int|null $indexItemId, int|null $ignoreId = NULL, int|null $firstCommentId=null ): void;
/**
* Given a list of item index IDs, return the ones that a given member has participated in
*
* @param array $itemIndexIds Item index IDs
* @param \IPS\Member $member The member
* @param Member $member The member
* @return array
*/
abstract public function iPostedIn( array $itemIndexIds, \IPS\Member $member );
abstract public function iPostedIn( array $itemIndexIds, Member $member ): array;
/**
* Given a list of "index_class_type_id_hash"s, return the ones that a given member has permission to view
*
* @param array $hashes Hashes
* @param \IPS\Member $member The member
* @param Member $member The member
* @param int|NULL $limit Number of results to return
* @return array
*/
abstract public function hashesWithPermission( array $hashes, \IPS\Member $member, $limit = NULL );
abstract public function hashesWithPermission( array $hashes, Member $member, int|null $limit = NULL ): array;
/**
* Get timestamp of oldest thing in index
*
* @return int|null
*/
abstract public function firstIndexDate();
abstract public function firstIndexDate(): int|NULL;
/**
* Convert terms into stemmed terms for the highlighting JS
@@ -627,7 +649,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
* @param array $terms Terms
* @return array
*/
public function stemmedTerms( $terms )
public function stemmedTerms( array $terms ): array
{
return $terms;
}
@@ -637,7 +659,7 @@ abstract class _Index extends \IPS\Patterns\Singleton
*
* @return bool
*/
public function supportViewFiltering()
public function supportViewFiltering(): bool
{
return TRUE;
}