Umherirrender has submitted this change and it was merged.
Change subject: PostgreSQL: Fix text search on moved pages
......................................................................
PostgreSQL: Fix text search on moved pages
When a page is updated under PostgreSQL, there is code to
de-index all but the most recent version of the page. But
when a page is moved, it was accidentally de-indexing the
most recent version as well, because rev_text_id is not
incremented in that case. A simple tweak to the SQL
fixes that.
I added code to the update script to find pages
previously corrupted by this problem and reindex them.
Bug: 66650
Change-Id: I52e1bbbd8592be5e7c7383c225e6b4c19bbe5b9e
---
M RELEASE-NOTES-1.24
M includes/installer/PostgresUpdater.php
M includes/search/SearchPostgres.php
A maintenance/postgres/archives/patch-textsearch_bug66650.sql
M maintenance/postgres/update-keys.sql
5 files changed, 23 insertions(+), 1 deletion(-)
Approvals:
Umherirrender: Verified; Looks good to me, approved
EBernhardson: Looks good to me, approved
diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index 5d2df36..64705e4 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -4,6 +4,8 @@
== Changes since 1.24.3 ==
* (T91653) Minimal PSR-3 debug logger to support backports from 1.25+.
+* (T68650) Fix indexing of moved pages with PostgreSQL. Requires running
+ update.php to fix.
== MediaWiki 1.24.3 ==
diff --git a/includes/installer/PostgresUpdater.php
b/includes/installer/PostgresUpdater.php
index df2f0e3..c04e901 100644
--- a/includes/installer/PostgresUpdater.php
+++ b/includes/installer/PostgresUpdater.php
@@ -407,6 +407,8 @@
array( 'addPgField', 'mwuser', 'user_password_expires',
'TIMESTAMPTZ NULL' ),
array( 'changeFieldPurgeTable', 'l10n_cache',
'lc_value', 'bytea',
"replace(lc_value,'\','\\\\')::bytea" ),
+ // 1.23.9
+ array( 'rebuildTextSearch'),
// 1.24
array( 'addPgField', 'page_props', 'pp_sortkey', 'float
NULL' ),
@@ -945,4 +947,12 @@
$this->applyPatch( 'patch-tsearch2funcs.sql', false,
"Rewriting tsearch2 triggers" );
}
}
+
+ protected function rebuildTextSearch() {
+ if ( $this->updateRowExists( 'patch-textsearch_bug66650.sql' )
) {
+ $this->output( "...bug 66650 already fixed or not
applicable.\n" );
+ return true;
+ };
+ $this->applyPatch( 'patch-textsearch_bug66650.sql', false,
"Rebuilding text search for bug 66650" );
+ }
}
diff --git a/includes/search/SearchPostgres.php
b/includes/search/SearchPostgres.php
index 59b0c31..bd2484f 100644
--- a/includes/search/SearchPostgres.php
+++ b/includes/search/SearchPostgres.php
@@ -186,7 +186,7 @@
function update( $pageid, $title, $text ) {
## We don't want to index older revisions
$sql = "UPDATE pagecontent SET textvector = NULL WHERE
textvector IS NOT NULL and old_id IN " .
- "(SELECT rev_text_id FROM revision WHERE
rev_page = " . intval( $pageid ) .
+ "(SELECT DISTINCT rev_text_id FROM revision
WHERE rev_page = " . intval( $pageid ) .
" ORDER BY rev_text_id DESC OFFSET 1)";
$this->db->query( $sql );
return true;
diff --git a/maintenance/postgres/archives/patch-textsearch_bug66650.sql
b/maintenance/postgres/archives/patch-textsearch_bug66650.sql
new file mode 100644
index 0000000..e4f5681
--- /dev/null
+++ b/maintenance/postgres/archives/patch-textsearch_bug66650.sql
@@ -0,0 +1,5 @@
+UPDATE /*_*/pagecontent SET textvector=to_tsvector(old_text)
+WHERE textvector IS NULL AND old_id IN
+(SELECT max(rev_text_id) FROM revision GROUP BY rev_page);
+
+INSERT INTO /*_*/updatelog(ul_key) VALUES ('patch-textsearch_bug66650.sql');
diff --git a/maintenance/postgres/update-keys.sql
b/maintenance/postgres/update-keys.sql
index 7761d0c..b858551 100644
--- a/maintenance/postgres/update-keys.sql
+++ b/maintenance/postgres/update-keys.sql
@@ -27,3 +27,8 @@
VALUES(
'user_former_groups-ufg_group-patch-ufg_group-length-increase-255.sql', null );
INSERT INTO /*_*/updatelog (ul_key, ul_value)
VALUES( 'user_properties-up_property-patch-up_property.sql', null );
+
+-- PostgreSQL-specific patches.
+
+INSERT INTO /*_*/updatelog (ul_key, ul_value)
+ VALUES( 'patch-textsearch_bug66650.sql', null );
--
To view, visit https://gerrit.wikimedia.org/r/191245
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I52e1bbbd8592be5e7c7383c225e6b4c19bbe5b9e
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_24
Gerrit-Owner: Jjanes <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Springle <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits