Smalyshev has uploaded a new change for review.
https://gerrit.wikimedia.org/r/281078
Change subject: [WIP] Add deleted archive titles search
......................................................................
[WIP] Add deleted archive titles search
Bug: T109561
Change-Id: Id6099fe9fbf18481068a6f0a329bbde0d218135f
---
M includes/search/SearchEngine.php
M includes/specials/SpecialUndelete.php
2 files changed, 42 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/78/281078/1
diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php
index 10e56bf..97dcd20 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -65,6 +65,16 @@
}
/**
+ * Perform a title search in the article archive.
+ *
+ * @param string $term Raw search term
+ * @return Title[]|Status|null
+ */
+ function searchArchiveTitle ( $term ) {
+ return null;
+ }
+
+ /**
* Perform a title-only search query and return a result set.
* If title searches are not supported or disabled, return null.
* STUB
diff --git a/includes/specials/SpecialUndelete.php
b/includes/specials/SpecialUndelete.php
index 36f6b4c..55d6f99 100644
--- a/includes/specials/SpecialUndelete.php
+++ b/includes/specials/SpecialUndelete.php
@@ -74,9 +74,11 @@
* Returns result wrapper with (ar_namespace, ar_title, count) fields.
*
* @param string $prefix Title prefix
+ * @param Title[] $titles Titles suggested by SearchEngine
+ * Titles are assumed to be in the same namespace as prefix.
* @return ResultWrapper
*/
- public static function listPagesByPrefix( $prefix ) {
+ public static function listPagesByPrefix( $prefix, $titles = array() ) {
$dbr = wfGetDB( DB_SLAVE );
$title = Title::newFromText( $prefix );
@@ -89,10 +91,29 @@
$ns = 0;
}
- $conds = [
- 'ar_namespace' => $ns,
- 'ar_title' . $dbr->buildLike( $prefix,
$dbr->anyString() ),
- ];
+ if ( $titles ) {
+ $condTitles = array_map( function (Title $t) {
+ return $t->getDBkey();
+ }, $titles);
+ $conds = [
+ 'ar_namespace' => $ns,
+ $dbr->makeList( [ 'ar_title' => $condTitles ],
LIST_OR ) . " OR ar_title " . $dbr->buildLike( $prefix, $dbr->anyString() )
+ ];
+// $condTitles = array_map( function (Title $t) use($dbr) {
+// return $dbr->makeList( [ 'ar_namespace'
=> $t->getNamespace(),
+//
'ar_title' => $t->getDBkey() ],
+//
LIST_AND);
+// }, $titles);
+// $condTitles[] = $dbr->makeList( [ 'ar_namespace' =>
$ns,
+//
'ar_title' . $dbr->buildLike( $prefix, $dbr->anyString()) ],
+//
LIST_AND);
+// $conds = $dbr->makeList( $condTitles, LIST_OR );
+ } else {
+ $conds = [
+ 'ar_namespace' => $ns,
+ 'ar_title' . $dbr->buildLike( $prefix,
$dbr->anyString() ),
+ ];
+ }
return self::listPages( $dbr, $conds );
}
@@ -894,7 +915,12 @@
# List undeletable articles
if ( $this->mSearchPrefix ) {
- $result = PageArchive::listPagesByPrefix(
$this->mSearchPrefix );
+ $se = SearchEngine::create();
+ $results = $se->searchArchiveTitle(
$this->mSearchPrefix );
+ if ( !is_array( $results ) ) {
+ $results = [];
+ }
+ $result = PageArchive::listPagesByPrefix(
$this->mSearchPrefix, $results );
$this->showList( $result );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/281078
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6099fe9fbf18481068a6f0a329bbde0d218135f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits