From 42748d0d6d230fc62c4b912a8f276731fabc820d Mon Sep 17 00:00:00 2001 From: Yaron Koren Date: Thu, 3 May 2018 14:52:06 +0000 Subject: [PATCH] Disable regex option for SQLite Change-Id: I83c8b38a47fc571077fef1fccabb31f5db0ac2e5 (cherry picked from commit d7db166e4f8c579f5979cc25e1bf04682633f3fd) --- src/SpecialReplaceText.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/SpecialReplaceText.php b/src/SpecialReplaceText.php index 202bbe80..b502f7df 100644 --- a/src/SpecialReplaceText.php +++ b/src/SpecialReplaceText.php @@ -423,17 +423,23 @@ class SpecialReplaceText extends SpecialPage { Xml::textarea( 'replacement', $this->replacement, 100, 5, [ 'style' => 'width: auto;' ] ) ); $out->addHTML( '' ); - $out->addHTML( Xml::tags( 'p', null, - Xml::checkLabel( - $this->msg( 'replacetext_useregex' )->text(), - 'use_regex', 'use_regex' + + // SQLite unfortunately lacks a REGEXP function or operator by + // default, so disable regex(p) searches for SQLite. + $dbr = wfGetDB( DB_REPLICA ); + if ( ! $dbr instanceof Wikimedia\Rdbms\DatabaseSqlite ) { + $out->addHTML( Xml::tags( 'p', null, + Xml::checkLabel( + $this->msg( 'replacetext_useregex' )->text(), + 'use_regex', 'use_regex' + ) + ) . "\n" . + Xml::element( 'p', + [ 'style' => 'font-style: italic' ], + $this->msg( 'replacetext_regexdocu' )->text() ) - ) . "\n" . - Xml::element( 'p', - [ 'style' => 'font-style: italic' ], - $this->msg( 'replacetext_regexdocu' )->text() - ) - ); + ); + } // The interface is heavily based on the one in Special:Search. $namespaces = SearchEngine::searchableNamespaces();