Extension talk:Replace Text/Archive 2015 to 2017

From mediawiki.org

Is there a way to search with back slashes (/) ?

For example, how would I search for the string "c:\" ? Kmacdowe (talk) 20:19, 29 January 2015 (UTC)Reply

You actually have a forward slash in your section header. Anyway, I think you can do it by just escaping it with another backslash, like "\\". Yaron Koren (talk) 00:01, 30 January 2015 (UTC)Reply

How to Use $1 replacer following by numbers?

  • What if I want to replace (\[\[|link=)2L\]\] to $12L]], with regex?
  • The extension assume $12 is the replacer, but I just want $1 to be the replacer. Boxsnake (talk) 04:01, 20 February 2015 (UTC)Reply
    • Do not mind, I found the solution on my own. Leave this thread in case others with the same problem can benefit from this
Replace
(\[\[|link=)2L\]\]
With
${1}2L]]

Is there a way to replace with \n (newline)

Is there a way to use the ReplaceText extension to replace with the \n (newline) character? I get the literal '\n' as output every time I try to replace with \n. Yes, I have 'Use regular expressions' checked. Cmjohannes (talk) 03:20, 3 September 2015 (UTC)Reply

Can't you just have a newline in the replacement string? That's why the text inputs are textareas instead of single-line inputs. Yaron Koren (talk) 12:53, 3 September 2015 (UTC)Reply
That solves it. So what regex expressions will be evaluated in the replacement string? For example, why does $1 get evaluated as a regex "variable," but not evaluated as the literal '$1' string? Cmjohannes (talk) 15:38, 4 September 2015 (UTC)Reply
I don't know - everything other than "\n", hopefully. I'm surprised that "\n" doesn't work when you check the "regex" box, but thankfully there's a backup for that one. Yaron Koren (talk) 15:59, 4 September 2015 (UTC)Reply

Is there a way to find \n or .newline.?

I would like to find \]\]\n. The ReplaceText extension can find \]\] or the ReplaceText extension can find \n, but the only way I can find \]\]\n is to search \]\] followed by pressing enter in the 'Replace Text:' box. 'Use regular expressions' is checked, so why is white space being searched for? Also, \n\n cannot be found, when I know it exists. Is there some kind of hidden character at the end of line breaks on wiki pages? Cmjohannes (talk) 05:15, 5 September 2015 (UTC)Reply

This seems like basically the same question as before - but yes, it could be that, instead of just "\n", it's "\r\n" or some such. Yaron Koren (talk) 13:12, 8 September 2015 (UTC)Reply

Parameter $wgBotJobUserID

I replaced line 56 in SpecialReplaceText.php with these lines:

global $wgBotJobUserID;
if (isset($wgBotJobUserID))
 $replacement_params['user_id'] = $wgBotJobUserID;
else
 $replacement_params['user_id'] = $this->getUser()->getId();

This way you can define a $wgBotJobUserID (number, not name) in LocalSettings.php to hide all changes of the job.

--VolkoV (talk) 12:46, 8 October 2015 (UTC)Reply

The idea makes sense, although - I assume you came up with the name "$wgBotJobUserID"? If it's specific to Replace Text, it should start with "$wgReplaceText" - "$wgReplaceTextUserID" might work. Although better yet, I would think, would be to have users set the username, not the ID, and then the code looks up the ID. Yaron Koren (talk) 14:19, 8 October 2015 (UTC)Reply
Thanks! This worked great. I used Extension:LookupUser to find the user ID of the bot I wanted to use. Just wanted to specify that the line you replaced was:
$replacement_params['user_id'] = $this->getUser()->getId();
(in case line 56 changes) --Potrod (talk) 03:38, 28 May 2016 (UTC)Reply
VolkoV - thanks for the idea, and Potrod - thanks for the reminder. I just checked in some code to handle a new global variable, $wgReplaceTextUser - it takes in a username, not an ID. If you get the latest Replace Text code, it should work. Yaron Koren (talk) 19:40, 31 May 2016 (UTC)Reply

Not here

Hi User:Yaron Koren, any particular reason why RT isn't available on this wiki? Thanks. --Elitre (WMF) (talk) 12:39, 22 February 2016 (UTC)Reply

I don't know - I have no say in what gets installed on mediawiki.org. If I did, the site would probably look different. :) Yaron Koren (talk) 14:21, 22 February 2016 (UTC)Reply

Is there any way to move pages from one NS to another?

Problem is: I need to move some bunch of pages from Namespace1:Somepagename to Namespace2:Somepagename

When I set replacement string to Namespace1 it says that no result was found, even if both NS was chosen (with or without regexp tick)

Is there any way to do such job using that extension? (btw, mediawiki 1.26.2, private $wgGroupPermissions['*']['read'] = false; if that matters) Ibutakov.smartec (talk) 12:19, 18 March 2016 (UTC)Reply

Ah, I hadn't realized (or forgot) that RT couldn't be used to modify the namespace. But that makes sense, because the "full name" of a page is not stored anywhere in the database. It would take a good amount of work to get RT to support this, unfortunately. Assuming you have a lot of pages like this, probably the easiest solution is to create a bot to do the replacement, if you know how to program. Yaron Koren (talk) 14:08, 18 March 2016 (UTC)Reply

Disable Watchlist Notifications

Is it possible to block ReplaceText from sending watchlist notifications. In order for users to continue to see major updates they would have to go into each page when they get the emails after we run this script. In our case they may have to go into hundreds of pages. Jrsovereign (talk) 19:30, 4 April 2016 (UTC)Reply

This is a tricky one - it appears to be possible to cancel the emailing for MW 1.23 and higher, thanks to a new hook in the code - but users who aren't watching hundreds or thousands of these pages may well want to be notified of Replace Text changes. If someone is watching that many pages, and gets emailed on watchlist changes, won't they be used to getting lots of emails? And if they see hundreds of new emails in a short amount of time, and they check and see that the first few are Replace Text-related, won't they be able to assume that the rest are as well? Yaron Koren (talk) 21:13, 4 April 2016 (UTC)Reply
Yes, but regardless they still have to visit all the pages once again to get any additional notifications. Jrsovereign (talk) 21:49, 4 April 2016 (UTC)Reply
Oh... now I get what you said; I didn't understand it before. Are you saying that, unless they view a page, users will stop getting emailed about changes to that page? I had no idea about that. Are you sure that that's the case? Do you know if there's any documentation about this? Yaron Koren (talk) 22:30, 4 April 2016 (UTC)Reply
Yes here: Help:Watchlist#Email_notifications: "After receiving an email notification for a page, you have to visit the page while logged in if you want to be notified of further changes to the same page." Jrsovereign (talk) 02:38, 5 April 2016 (UTC)Reply

Regex flag questions

When I was reviewing this extension for the Miraheze wiki farm, I came up with a couple of questions:

  • On this line, is there are reason why you aren't using the /U flag, or is that a bug?
  • On a very similar looking flag, /u: why isn't the Unicode flag enabled everywhere? Is there some some reason why this can't be enabled? I know that nothing we can do is going to make Mysql REGEXP aware of Unicode, but my gut feeling is that this will only produce false positives for Mediawiki to potentially make changes. And Postgres ~ is Unicode aware, so it's possible you're rejecting matches there.

Thanks for you work! --BrentLaabs (talk) 00:28, 7 August 2016 (UTC)Reply

Sorry - I wrote that code a while ago; I no longer remember any of the regex stuff. (And I never really understood SQL regex stuff all that well.) If there are bugs in the current handling, though, that should be fixed. If you don't mind, could you give an example of strings for which the current PHP and/or DB handling fails? Yaron Koren (talk) 01:21, 7 August 2016 (UTC)Reply

No problem!

~/c/mediawiki (REL1_27)> php -r '$x = "¿Ê?\n"; $y = preg_replace("/[[:alpha:]]/Uu", "a", $x); echo $y;'
Âża?
~/c/mediawiki (REL1_27)> php -r '$x = "¿Ê?\n"; $y = preg_replace("/[[:alpha:]]/U", "a", $x); echo $y;'
a�a�?
mysql> select 'Âż' REGEXP '[[:alpha:]]';
+---------------------------+
| 'Âż' REGEXP '[[:alpha:]]'  |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.02 sec)

This error is unfixable -- I know because I just ran into it at my day job 2 weeks ago. People have been complaining about lack of Unicode support in MySQL since 2004... Anyway totally not an issue in Postgres.

The solution is just to add the '/u' flag to the end, and at least PHP will get it correct when it's editing the page. Or more correct anyway -- there are mines buried everywhere when dealing with Unicode. Because the database only pulls candidate pages, it's OK for it to be a little bit wrong as long as the actual page edit in Mediawiki does the right thing.

I can submit a code patch to you if you want -- but I don't want to learn gerrit. Is emailing a git patch OK, or is there a Git(hub|lab) repo lurking around here? --BrentLaabs (talk) 02:20, 7 August 2016 (UTC)Reply

Ah, the 'Âż' character - I'm pretty sure I never tested that one! In general, I don't know if I did much, or any, testing on non-Unicode characters. Yes, feel free to email me a patch - or just paste it here, if we're just talking about a few lines. Yaron Koren (talk) 03:11, 7 August 2016 (UTC)Reply
I just want to make sure you got my email. I had an email with a patch sent to me get put into my spam folder on Gmail, so I was wondering if the same happened to you. --BrentLaabs (talk) 21:28, 10 August 2016 (UTC)Reply
Yes, I got the email - sorry, I haven't gotten around yet to merging in your patch, but I hope to do it soon. Yaron Koren (talk) 02:46, 11 August 2016 (UTC)Reply

Brilliant Extension!!!

Saved me countless hours of work.

Thank you! Yaron Koren (talk) 15:42, 9 September 2016 (UTC)Reply

how to add text if it doesn't exist in article?

i'd like to add a category to posts that don't have it or a template. so probably i need a regex to jump to end of article and checking if such text exists. how can i do that?

Working on MW 1.27?

Sometimes, when I replace some text, it returns a error page.Does anybody know if it is working with MW 1.27.1? Thanks!

What's the error message? Yaron Koren (talk) 15:41, 9 September 2016 (UTC)Reply

Ahhh, page type error again in MW 1.27.1!

This is an old bug which appeared in earlier version of MW before. When you replace text in Mediawiki:xxx.js or Mediawiki:xxx.css page. This extension will change the page type from js/css to wikitext, and resulting in js/css failure. Can someone fix this error? --Zoglun (talk) 00:19, 27 October 2016 (UTC)Reply

Oh, I never thought about the possibility of people using this to replace text in non-wikitext pages. Yaron Koren (talk) 01:15, 27 October 2016 (UTC)Reply
I just looked into this, and it's odd that you're seeing this problem - in the Replace Text code, there's a check to make sure that it's only doing replacements on pages of type "wikitext" - if the page is of another type, it doesn't run the replacement at all. That check has apparently been in place since version 0.9.6 in 2013... what version of Replace Text are you using? Yaron Koren (talk) 12:23, 31 October 2016 (UTC)Reply

Changing Pagename with command-line

Hi there,

how can I search only in pagenames, like in the gui version in the special site. I played a little bit with the replaceAll.php, but didn`t find a solution. I cant use the Gui version, because of too much Pagenames (ca. 6000 pages, php timeout).

php replaceAll.php "type:" " " --dry-run

don`t find the Sites I need. And If possible, without forwarding

It doesn't look like it's possible, unfortunately - it would require a new parameter for replaceAll.php. Yaron Koren (talk) 12:26, 31 October 2016 (UTC)Reply

I'm not getting anything MW 1.27

I have a template with query in it and when I run the replace text against the template namespace nothing returns. In the example below I want to replace servername.

{{#sparql:
PREFIX property:<http://servername/index.php/Special:URIResolver/Property-3A>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?Name ?Owner ?Publication_Status ?Start_Date ?End_Date ?Status ?Link
WHERE
What did you enter for the search and replacement strings? Yaron Koren (talk) 15:07, 1 November 2016 (UTC)Reply

batch replacing using inputfiles corresponding to pages

Im trying to replace multilined text on each Page with multilined text. But my bash knowledge is very limited. I already completed the algorithm in PHP. I tested it successfully on one page. Of course i can sort of create a shell script with PHP but that does not seem to work, i blame my lack of bash knowledge as mentioned. Is it possible to cut out the bash part? Since this is PHP anyways?

PHP code to clarify: $search = $element."


";

$replace = file_get_contents($filespath.$element); $selection = strpos($replace, "</TABLE>"); $selection += 8;

$replace = substr($replace, 0, $selection);

$cmd = '/usr/bin/php '.$scriptpath.'replaceAll.php "'.$search.'" "'.$replace.'" --yes';

I even added absolute path's everywhere

[SOLVED] Replacement won't take place :(

I'm using version 0.10.0 of the extension with mediawiki 1.23.6 and php 5.3.17 and mysql 5.5.47 I've tried to get a newer version of the extension, but I'm not able to install GIT just to get the extension updated and downloading the tarfile got me the version cited on the special:version-page. When I try to replace any kind of text, it gets found ok - the pages are listed allright, but when I click on the "replace"-button, no replacement happens. It doesn't matter whether there are a single hit to replace or nearly a hundred. I've entred the $wgRunJobsAsync = false; in LocalSettings.php and I also cleared the cache.

I'm now looking for a hint where to look for clues of what might be wrong. --Katwol (talk) 15:21, 5 December 2016 (UTC)Reply

Try just calling runJobs.php on the command line, if you can - it could be that the jobs just haven't run yet. Yaron Koren (talk) 15:55, 5 December 2016 (UTC)Reply
Thanks for the tipp! After adding the correct path for my installationphp /srv/www/htdocs/_fhbwiki/maintenance/runJobs.php suddenly the jobs scrolled through like mad... ;) Now that I know how to get the replacement to work I'm really happy again! :) --Katwol (talk) 08:41, 7 December 2016 (UTC)Reply

List of searchable namespaces incomplete under MediaWiki 1.28

I found one odd problem after upgrading to MW 1.28 (from MW 1.24). The list of namespaces available for selection under "search in namespaces" is now considerably reduced (no more than 18 in total) and does not even include the Main namespace.

  • I checked with Special:PrefixIndex to see if all namespaces are properly recognised and found no issues there.
  • Problem occurs with the latest version of RT (1.2) as well as 1.0.1 so I don't think there's a breaking change in RT to have caused this.

Cavila 11:42, 31 December 2016 (UTC)Reply

Okay, this is most likely not a RT issue, because the same layout (with many of the namespaces left out) is seen in Special:Search with advanced mode. Cavila 08:46, 1 January 2017 (UTC)Reply
Got it. It's the Lockdown extension that introduced a breaking change, which is the requirement in Localsettings.php to define $wgNamespacePermissionLockdown for all namespaces rather than just the ones that you need to 'lock down'. That's it I think. Cavila 20:01, 10 January 2017 (UTC)Reply

[RESOLVED] Missing namespaces

Has anyone experienced a total absence of namespaces in the search form? On one of my wikis, the list of namespaces is completely blank and of course, that makes the search/replace action fail with an error saying that at least one namespace needs to be selected. It looks like it may be a javascript issue on my end. I tried to disable some extensions and to switch to the vector skin, but it feels like flying blind, so I thought maybe someone already went through this issue before. If that can help, I am using the latest version of ReplaceText with Mediawiki 1.28 (but the extension does work fine with another 1.27 instance with another skin and the same version).

Are there any JavaScript errors in the browser console? Yaron Koren (talk) 14:33, 10 January 2017 (UTC)Reply
The JS error is "Error: Widget not found: searchText Error: Widget not found: searchText". I'm kind of stumped at this point. I tried rolling back to a previous version and it also shows that error. In the meantime, I will try disabling extensions one at a time but that will take a while to go through the list. --Lalquier (talk) 15:00, 10 January 2017 (UTC)Reply
(Update) I tracked the issue down the to Extension:Lockdown extension. I can't tell you if it was misconfigured or if the extension itself is a problem but disabling it brought the namespaces back in ReplaceText. --Lalquier (talk) 22:18, 11 January 2017 (UTC)Reply
Great! By coincidence, that's the same problem that Cavila had in the section above this one. Yaron Koren (talk) 19:18, 12 January 2017 (UTC)Reply

replaceText jobs won't run?

On Mediawiki 1.28.0, had an issue with old replaceText jobs piling up, so I wiped my job table and tried to run two small text changes.

showJob.php --group returns

replaceText: 0 queued; 2 claimed (2 active, 0 abandoned); 0 delayed

Running runJobs.php does not force the jobs to run. Currently have $wgRunJobsAsync = false and no revision compressing. Any idea of what to do? - Scarred Sun (talk) 19:45, 18 February 2017 (UTC)Reply

What happens when you call runJobs.php? Yaron Koren (talk) 03:07, 19 February 2017 (UTC)Reply
When calling runJobs.php --type replaceText, nothing happens. When running it without the type parameter, it just processes all other jobs. - 72.78.191.76 00:28, 20 February 2017 (UTC)Reply

I wonder if I have a related problem. It might also be related to overall problems getting all jobs to run (raised T157545 and T157716). What I am finding is that if I run a replacetext that should affect a few dozen pages, it runs on some. If I then run the same replacetext again it finds more. For one I had to run it >3 times. Just checked mw_job and there are 3 types stuck in there, 203 refreshLinks, 81 refreshLinksPrioritized and 162 replaceText. Running runJobs.php does not get rid of them. Think it's related? Or should I raise this as a separate question? Tenbergen (talk) 06:32, 21 February 2017 (UTC)Reply

That does sound related, but I have no idea. Yaron Koren (talk) 14:04, 21 February 2017 (UTC)Reply
Just a quick note that I'm also experiencing T157716 on 1.28, so you're not alone in that aspect--it's intermittent per wiki but definitely noticeable. - Scarred Sun (talk) 15:49, 21 February 2017 (UTC)Reply

Replacing text in more than 992 pages

Hi. I found a text to replace in more than 5k pages. When the confirmation page gets printed, it says that the text will be replaced in all pages (5061 to be precise). But, when I hit the confirmation button, the following pages says it will only execute the replaces in 992 pages. Is there a configuration parameter to increase that limit? Thanks. PS. I increased max_input_vars to 3500 and nothing changes. --Jurisvirtual (talk) 14:37, 21 February 2017 (UTC)JurisvirtualReply

-- Does anyone able to find any solution for this? I am facing the same issue. Thanks. -- Issue is resolved. Just required to restart the apache server after increasing max_input_vars. Thanks.

ReplaceText Not Working on MW 1.28 (but it was yesterday?)

I've been struggling with this one most of the day. I updated to the latest version of ReplaceText (1.2) on my Mediawiki installation (ver 1.28, running php 7.1.1 (cgi-fcgi), mysql 5.7.17, on Windows Server 2008 R2 Standard). It was working great yesterday while I was testing out some functionality with Semantic Mediawiki (both from the Special page and the command line replaceAll.php). However, as of this morning I cannot get it to work from either location. When I run any replacement from the command line (with $wgShowDBErrorBacktrace = true) I see the following (after about 2 minutes of waiting):

C:\Users\username>php C:\inetpub\wwwroot\mediawiki\extensions\ReplaceText\replac
eAll.php "Test Page" "Test Page"
Test Article
Replace instances on these pages? (Y/N) y
Attribute changes to the user 'Admin'? (Y/N) y
Replacing on Test Article... [14b343af975d321e4790a243] [no req]
DBConnectionError from line 748 of C:\inetpub\wwwroot\mediawiki\includes\libs\rd
bms\database\Database.php: Cannot access the database: Too many connections (loc
alhost)
Backtrace:
#0 C:\inetpub\wwwroot\mediawiki\includes\libs\rdbms\loadbalancer\LoadBalancer.ph
p(897): Database->reportConnectionError(string)
#1 C:\inetpub\wwwroot\mediawiki\includes\libs\rdbms\loadbalancer\LoadBalancer.ph
p(572): LoadBalancer->reportConnectionError()
#2 C:\inetpub\wwwroot\mediawiki\includes\GlobalFunctions.php(3075): LoadBalancer
->getConnection(integer, array, boolean)
#3 C:\inetpub\wwwroot\mediawiki\extensions\ReplaceText\ReplaceTextSearch.php(7):
 wfGetDB(integer)
#4 C:\inetpub\wwwroot\mediawiki\extensions\ReplaceText\replaceAll.php(350): Repl
aceTextSearch::doSearchQuery(string, array, NULL, NULL, NULL)
#5 C:\inetpub\wwwroot\mediawiki\maintenance\doMaintenance.php(111): ReplaceText-
>execute()
#6 C:\inetpub\wwwroot\mediawiki\extensions\ReplaceText\replaceAll.php(376): requ
ire_once(string)
#7 {main}
done.

On a separate command prompt, I have been querying the status of MySQL while this is occurring using the SHOW GLOBAL STATUS command. As the error is occurring, I see the "Threads_connected" variable slowly rising to the maximum I currently have allowed (200). Once it reaches 200, the error message spits out and the "Threads_connected" decreases once again. When the "Threads_connected" finally reaches back down to 1, the message "done." appears on the original command prompt window as the command completes (the last line of the output I pasted above).

Running "runjobs.php" does force some of the backed up jobs to run (there appears to be quite a lot created in the job queue after running replaceAll.php just once) but none of them perform any changes to the wiki pages, nor fix the issue going forward. I have attempted server restarts but it also makes no difference.

I reviewed the code in the pages of the backtrace, but nothing immediately jumps out at me as incorrect. It would probably take a lot of time combing over it to even determine how it all works, honestly.

At this point I am unsure what else to try. Maybe my troubleshooting steps will help highlight where the issue lies?

I wonder if it's related to this problem - definitely the automated creation and editing of pages seems to have become a problem in MW 1.28, which I assume is due to a MediaWiki bug. Yaron Koren (talk) 03:27, 27 February 2017 (UTC)Reply

Replace text doesn't work on Page namespace?

Hi! I have run replace text to add a Category to a number of pages within the page namespace (I did this many times in the past); from the browser everything seems ok, but if I run php runJobs.php it gives me this kind of error for each page:

2017-03-03 15:27:21 replaceText Page:EBC_1599_04_30_0034.pdf/1 user_id=5 target_str=[[Category:EBC_Not_proofread]] replacement_str=[[Category:EBC_Not_proofread]][[Category:EBC_Letters]] use_regex= edit_summary=Text replacement - "ďż˝" to "[[Category:EBC_Not_proofread]][[Category:EBC_Letters]]" create_redirect= watch_page= requestId=0e6344aa9927b8ea3e7462d5 (id=11752,timestamp=20170303152717) t=0 error=replaceText: Wiki page "Page:EBC_1599_04_30_0034.pdf/1" does not hold regular wikitext.

The only difference respesct to last time I used Replace Text in this way is that I have installed CirrusSearch with all its dependencies (ElasticSearch, Elastica): could this matter something?

Thanks for the help.
--Loman87 (talk) 15:38, 3 March 2017 (UTC)Reply

What's in the page "Page:EBC_1599_04_30_0034.pdf/1"? Is it a PDF file? Yaron Koren (talk) 16:06, 3 March 2017 (UTC)Reply
Looks like a page provided by Extension:Proofread Page --Ciencia Al Poder (talk) 10:04, 4 March 2017 (UTC)Reply
Yes, it is a page provided by the Proofread Page Extension. I can add categories manually without problems. However the images displayed are originated from a pdf. --Loman87 (talk) 08:18, 6 March 2017 (UTC)Reply
Alright - well, at the moment at least, Replace Text can only deal with pages that are defined as holding wikitext, which these Proofread Page pages don't seem to be. Yaron Koren (talk) 13:45, 6 March 2017 (UTC)Reply

Can ReplaceText be used to add text to end of a page

I'd like to add some text to the bottom of all pages within a specific category. Is there a way Replace Text can be used for this. Unfortunately the last text in the pages as they are now is }} and that is not the only occurrence of that on the page, so I don't really have anything to search for.

I don't know. I can think of two options that might work, both using regular expressions: a search string of "$" and a replacement string of "MY NEW TEXT", or a search string of "(.*)" and a replacement string of "$1 MY NEW TEXT". If you try either one, you should definitely try it first on one page as a test. Yaron Koren (talk) 23:01, 19 March 2017 (UTC)Reply

JS error on Special:ReplaceText

I'm getting the following JS error on Special:ReplaceText, but I don't see any degraded performance or missing features.

Error: Widget not found: searchText Error: Widget not found: searchText

I see the same error in the topic above "[RESOLVED] Missing namespaces", but I do not have Extension:Lockdown. In fact, I removed all extensions except ReplaceText (including Composer-installed extensions) to see if there were any conflicts. This did not resolve the issue. Upon attempting to go to Special:Search after removing the extensions (since the error is related to search) I got errors about CirrusSearch no longer being installed (since I just removed it), so I reinstalled Extension:CirrusSearch and its dependency Extension:Elastica and installed Extension:Elastica's Composer dependencies. This resolved the Special:Search issue as expected. I guess the only reason I'm stating all of this is to say that perhaps this is a conflict between CirrusSearch and ReplaceText.

This was noticed when upgrading from MW 1.25 to MW 1.27. ReplaceText and CirrusSearch were present in both cases. ReplaceText was v1.0.1 on MW1.25 and has been tested at v1.0.1, v1.2, and master (b02d10f2e13f). CirrusSearch is on the REL1_27 branch (and was REL1_25 before).

--Jamesmontalvo3 (talk) 23:14, 26 April 2017 (UTC)Reply


Left out one part: There's also an error about this that says "Exception in module-execute in module mediawiki.special.search", so perhaps there's an issue with $out->addModules( 'mediawiki.special.search' ); (see on github).
--Jamesmontalvo3 (talk) 23:27, 26 April 2017 (UTC)Reply


Grepping "searchText" on MediaWiki 1.27 gives ./includes/specials/SpecialSearch.php:1237 (amongst others), and that file has the following (see on github):
       protected function shortDialog( $term, $resultsShown, $totalNum ) {
               $searchWidget = new MediaWiki\Widget\SearchInputWidget( [
                       'id' => 'searchText',
                       'name' => 'search',
                       'autofocus' => trim( $term ) === '',
                       'value' => $term,
                       'dataLocation' => 'content',
               ] );
It looks like Extension:ReplaceText has re-implemented a lot of Special:Search methods. Perhaps this one, or some other related methods, also need to be implemented.
--Jamesmontalvo3 (talk) 23:33, 26 April 2017 (UTC)Reply
Alright. The fact that this doesn't seem to affect actual functionality makes this a low-priority issue for me, but I do hope that I or someone else can fix it. Yaron Koren (talk) 01:34, 28 April 2017 (UTC)Reply

Negated substring match?

Thanks for this great extension!

I had various instances of different markup sequences, for example:

<extension version="0.1" ZZZ>

<extension version="0.1" BLA>

I thereafter ran the following across a wiki, replacing:

<extension version="0.1" (.*)>

with:

<extension version="0.1" $1 style="width:100%;">

I now need to run the same but only affecting newly added markup, excluding those strings that already has style="width:100%;" within. So now I have various markup sequences, such as

<extension version="0.1" ZZZ style="width:100%;">

<extension version="0.1" BLA style="width:100%;">

<extension version="0.1" BBB>

<extension version="0.1" XXX>

Can someone advise what regex can be used to negate instances which includes the substring:

style="width:100%;"

In other words, running subsequent replacements, like:

<extension version="0.1" (.*)>

... but excluding instances which already has the style="width:100%;"> string at the end.

Many thanks!

--Yellowdog (talk) 21:47, 11 June 2017 (UTC)Reply

Missing list of namespaces in Special:ReplaceText

I tried with every skin, but the list of namespaces does not appear in the Repace Text input form, and obviously I get the "You must select at least one namespace" error message.
I can only see the buttons: "all" and "none" and if I choose "all" nothing happens.
Am I miss some configuration?

--Silkwood 10:56, 18 June 2017 (UTC)Reply

@Silkwood: Are you using Lockdown also ? - Mlpearc (open channel) 15:53, 18 June 2017 (UTC)Reply
What Mlpearc is alluding to is something I've made explicit over at Extension:Lockdown#Known issues.

mw 1.28.2: Works from command line, not from special page

Hello, I haven't used this extension previously, but it seems really useful when I e.g. want to move pages to another category. I have installed version 1.2(22bb5f6). Symptom: When I enter the special page, enters "FreeBSD" as the search string, enters"freespie" as replacement string and press "Continue", I am returned to the same page again – this time with blank input fields. At the same time, it seems to work as intended from the command line. Anything I could/should try? Best regards, Jon Jontheil (talk) 21:21, 18 July 2017 (UTC)Reply

Filters in replaceAll.php

A small question. It's great that the command-line version "does all the same replacements that the page Special:ReplaceText does". But how do we use the optional filters ("replace only in category", etc.)? Unless I missed something, this seems to be missing from the documentation. Cavila 13:55, 25 July 2017 (UTC)Reply

Regex to match template content

EDIT: I got it:

{{Slater\n(.*?)\n}}

I used Data transfer but I imported duplicate content. The text is like this:

{{Slater
|sltr=[here is content]
}}

So I want to delete the whole template and content from each page. I tried

\{\{Slater(.*?)\}\}

but it did not work.

Database error on regex with [^]+

Love the extension but getting a database error whenever I use this regex: [^]+ HausaDictionary (talk) 14:51, 23 August 2017 (UTC)Reply

Hi Yaron, any chance that you add support for ^? I would need to find everything until the end of my external links using this regex: ([^\]]+). When I use it I get "No results found" although I have hundreds of them. Thannks! -- Stefahn (talk) 10:33, 25 April 2018 (UTC)Reply

Filter to exclude pages with specific pattern

How about adding a selectable form field that excludes replacement on any pages that contains an XYZ string?

That's a good idea. It wouldn't need to be selectable - it could just be activated as long as it was non-blank. And it might make sense to also add a field for including only pages that do contain some string. Yaron Koren (talk) 16:53, 25 September 2017 (UTC)Reply

Replace Text does not work in MediaWiki 1.28.2

Replace text does not seem to work any more. MediaWiki 1.28.2 Replace Text 1.2 Semantic MediaWiki 2.5.4

runJobs.php does not pick anything up Sorry I noticed https://phabricator.wikimedia.org/T154425

Changing to $wgJobRunRate=0 seems to work.

Did you try adding "$wgRunJobsAsync = false;" to LocalSettings.php, as noted in "Known issues"? If not, could you try taking out that "job run rate" line, adding in this line, and doing another replacement? Unfortunately, I can't test directly in MW 1.28.2. Yaron Koren (talk) 14:57, 28 September 2017 (UTC)Reply
I just tried it and that does not work, $wgJobRunRate = 0.01; works fine anything above 0 does not work, maybe that's the way it's supposed to work. Phil
Alright. I didn't understand the numbers thing - 0.01 is above 0. Yaron Koren (talk) 19:00, 28 September 2017 (UTC)Reply

problem getting a pipe (|) written as first part of replacement string

I am trying to do some replacing around templates. When I try to use a replacement string that starts with a pipe/| then, instead of the found pages listing, I get the following error: A database query error has occurred. This may indicate a bug in the software.[We4S9q3ssAoAABZs46AAAAAJ] 2017-10-23 16:04:06: Fatal exception of type "Wikimedia\Rdbms\DBQueryError". If I put a space in front of the pipe/| it works. I tried to escape the pipe as "\|" but if I use an escape for this on the replace side it actually writes the "\" so that can't be it. I wonder if there are two problems... the first is that I am not sure whether to escape in both the find and replace window, and for which characters. The main article mentions a list but from my testing back and forth weird things happen around {, } and |. The second thing is I that there might be something buggy causing the replace string starting with a | to fail.

This clearly sounds like a bug - I'll have to look into it. Yaron Koren (talk) 05:14, 25 October 2017 (UTC)Reply
Sorry for the very long delay. I finally looked into this bug, and realized that I can't reproduce it. If you're still monitoring this page - what database type are you using? (I'm guessing it's not MySQL.) And what version of MediaWiki? Yaron Koren (talk) 04:22, 6 December 2017 (UTC)Reply
I'm getting the same issue, and I am running MySQL. MW ver. 1.28.0. Here's how to replicate. First, create a page with the following text:
| Test = 2
Then use the ReplaceText special page with the following parameters, activating 'Use Regular Expressions':
Original Text:
\| Test = (.*)
Replacement Text:
\| Test=<onlyinclude>{{#ifeq:{{{transcludesection\|Test}}}\| Test\|$1}}<\/onlyinclude>
Note that the '\' is in front of the '|' characters and any '/' characters in the replacement text. However, when you execute, you'll see that the '\' characters are inserted into the replacement text, rather than escaped out. That is, the replacement text looks literally like the above, as though regular expressions were not turned on. However, if you leave out the '\' escape characters, you get a DB error. Hope this helps. Nuada99 (talk) 19:14, 8 February 2018 (UTC)Reply
Thank you - this was very helpful. I was able to reproduce the problem with these values; it turned out to be an obvious error in the code, that I'm surprised no one encountered, or at least pointed out, until you and the other poster. (I think.) I just checked in a fix for it; if you upgrade to the latest code, hopefully the error will go away. Yaron Koren (talk) 19:25, 9 February 2018 (UTC)Reply