Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/70140
Change subject: (bug 46867) skip bad search keys and report them.
......................................................................
(bug 46867) skip bad search keys and report them.
rebuildTermsSearchKey.php now returns terms for which no search key
could be calculated, and skips them.
Change-Id: Iedd9cc3b56c0db2e5ed6c02a398d7c35b1c96a1b
---
M repo/includes/store/sql/TermSearchKeyBuilder.php
1 file changed, 19 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/40/70140/1
diff --git a/repo/includes/store/sql/TermSearchKeyBuilder.php
b/repo/includes/store/sql/TermSearchKeyBuilder.php
index f8fa085..d2fc77e 100644
--- a/repo/includes/store/sql/TermSearchKeyBuilder.php
+++ b/repo/includes/store/sql/TermSearchKeyBuilder.php
@@ -173,16 +173,24 @@
);
$c = 0;
+ $cError = 0;
foreach ( $terms as $row ) {
- $this->updateSearchKey( $dbw,
$row->term_row_id, $row->term_text, $row->term_language );
+ $key = $this->updateSearchKey( $dbw,
$row->term_row_id, $row->term_text, $row->term_language );
+
+ if ( $key === false ) {
+ $this->report( "Unable to calculate
search key for " . $row->term_text );
+ $cError += 1;
+ } else {
+ $c+= 1;
+ }
+
$rowId = $row->term_row_id;
- $c+= 1;
}
$dbw->commit();
- $this->report( "Updated $c search keys, up to row
$rowId." );
+ $this->report( "Updated $c search keys (skipped
$cError), up to row $rowId." );
$total += $c;
if ( $c < $this->batchSize ) {
@@ -230,11 +238,18 @@
* @param string $text the term's text
* @param string $lang the term's language
*
- * @return string the search key
+ * @return string|bool the search key, or false if no search key could
be calculated.
*/
protected function updateSearchKey( \DatabaseBase $dbw, $rowId, $text,
$lang ) {
$key = Term::normalizeText( $text, $lang );
+ if ( $key === '' ) {
+ wfDebugLog( __CLASS__, __FUNCTION__ . ": failed to
normalized term: $text" );
+ return false;
+ }
+
+ wfDebugLog( __CLASS__, __FUNCTION__ . ": row_id = $rowId,
search_key = `$key`" );
+
$dbw->update(
$this->table->getTableName(),
array(
--
To view, visit https://gerrit.wikimedia.org/r/70140
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iedd9cc3b56c0db2e5ed6c02a398d7c35b1c96a1b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits