X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchEngine.php;h=6bb4e5aebafc6daf2d79f7a71acb3f4972b71d84;hb=b193ef8377c287272a08729bb9cd7b6336880959;hp=90bfebd21319bb753314d7cd5bf6bfc879c6a8b6;hpb=9964ca1a390c446397dcd466916ffed356cdc3c9;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php
index 90bfebd213..6bb4e5aeba 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -72,6 +72,21 @@ abstract class SearchEngine {
return null;
}
+ /**
+ * Perform a title search in the article archive.
+ * NOTE: these results still should be filtered by
+ * matching against PageArchive, permissions checks etc
+ * The results returned by this methods are only sugegstions and
+ * may not end up being shown to the user.
+ *
+ * @param string $term Raw search term
+ * @return Status
+ * @since 1.29
+ */
+ function searchArchiveTitle( $term ) {
+ return Status::newGood( [] );
+ }
+
/**
* Perform a title-only search query and return a result set.
* If title searches are not supported or disabled, return null.
@@ -104,12 +119,25 @@ abstract class SearchEngine {
* @since 1.18
* @param string $feature
* @param mixed $data
- * @return bool
*/
public function setFeatureData( $feature, $data ) {
$this->features[$feature] = $data;
}
+ /**
+ * Way to retrieve custom data set by setFeatureData
+ * or by the engine itself.
+ * @since 1.29
+ * @param string $feature feature name
+ * @return mixed the feature value or null if unset
+ */
+ public function getFeatureData( $feature ) {
+ if ( isset ( $this->features[$feature] ) ) {
+ return $this->features[$feature];
+ }
+ return null;
+ }
+
/**
* When overridden in derived class, performs database-specific conversions
* on text to be used for searching or updating search index.
@@ -707,8 +735,21 @@ abstract class SearchEngine {
public function getSearchIndexFields() {
$models = ContentHandler::getContentModels();
$fields = [];
+ $seenHandlers = new SplObjectStorage();
foreach ( $models as $model ) {
- $handler = ContentHandler::getForModelID( $model );
+ try {
+ $handler = ContentHandler::getForModelID( $model );
+ }
+ catch ( MWUnknownContentModelException $e ) {
+ // If we can find no handler, ignore it
+ continue;
+ }
+ // Several models can have the same handler, so avoid processing it repeatedly
+ if ( $seenHandlers->contains( $handler ) ) {
+ // We already did this one
+ continue;
+ }
+ $seenHandlers->attach( $handler );
$handlerFields = $handler->getFieldsForSearchIndex( $this );
foreach ( $handlerFields as $fieldName => $fieldData ) {
if ( empty( $fields[$fieldName] ) ) {