Regex (big wish)

Please add regular expressions. That would help to maintain templates.--Jannis 11:27, 11 January 2010 (UTC)Reply

I also think that would be the next logical step :) Maybe a good preview (before / after) of the unparsed text would be needed here. --Subfader 18:31, 16 January 2010 (UTC)Reply
Yes, that would be lovely. --SomaticJourney 19:30, 13 March 2010 (UTC)Reply
Probably unlikely to happen, as SQL (the database language used) doesn't support RegExs. But even having simple wildcards (which SQL does support) would be a big plus! 75.119.241.73 13:45, 6 August 2010 (UTC)Reply
At least simple wildcards would be so usefull. whith this you can also use this extension as a powerfull anti-spam tool besides its other usefullness --213.196.170.72 15:33, 3 December 2010 (UTC)Reply

Search apparently not working after doing first set of replacements

I just did a search to replace "{{Template1}}" with "{{Template1-build}}" within a specific namespace. It replaced that text just fine on about 90 pages within that namespace.

I then wanted to do a similar replace in the same namespace, like this: "{{Template2}}" to "{{Template2-build}}". However, the search isn't finding the pages in that same namespace saying that no pages were found. My job to replace Template1 seems to have finished about a half hour ago, so I don't think there is any conflicting going on. Also, we have a development instance of our site, and when I try the same search on that site it does pick up all the Template2 instances. Any idea what might be happening? Thanks! --Gkullberg 18:38, 26 January 2010 (UTC)Reply

Hard to tell from here, if not impossible ;) --Subfader 20:38, 26 January 2010 (UTC)Reply
Agreed. Yet is there anything you can point me to on the server that I could look at, like processes, error / task logs, or anything where I could troubleshoot myself? --Gkullberg 21:13, 26 January 2010 (UTC)Reply
Did you try the whole thing again for Template2? If still nothing happened the Template1 case doesn't matter much here and we have the case that you searched term wasn't found at all. I can tell you what I would to. I would check if Template2 is called anywhere at all directly and in which namespace; therefor I would
  • go to [[Template:Template2]] and see "what links here", if nothing was found
  • i'd search it using this extension: replace "Template2" (without quotes and {{}}" with nothing or a temp string, just to see what it finds.If nothing was found I dunno lol.
If it was found I would check if it really is only used as {{Template2}} or if aparameter are used, e.g. {{Template2|1=foo}}. You may have tested all this, but I can't think of more.
If something was found but nothing happens it's useful to run maintenance/runJobs.php --Subfader 01:41, 27 January 2010 (UTC)Reply
What does runJobs.php do in respect to Replace Text? I'm still seeing funny behavior in that namespace from before. Ever since I did that original find/replace on that namespace it no longer finds anything I search for It works for other namespaces just fine, but not the one problem namespace. If I do a standard Wiki search in that namespace it finds the text I'm looking for, but not when I do a find from the Replace Text extension. Any ideas what might be causing this? --Gkullberg 17:02, 16 March 2010 (UTC)Reply
I can confirm this behavior. Strings are found after the first replacement and are said to be replaced, but aren't in fact. --Nakohdo 07:43, 15 April 2010 (UTC)Reply
I got the impression that the replacements indeed take place, but aren't immediately reflected in the (special) pages. I renamed a category and one hour ago there were only 4 pages in the new category on the categories special page now there are 27 ... Might be connected with cron runs and/or caching. Reloading that page shifts those numbers even as I write this. --Nakohdo 08:52, 15 April 2010 (UTC)Reply

Redirects still getting created

I did a find & replace for a bunch of page names which got moved to new names. I unchecked "Save the old titles as redirects to the new titles", yet redirects still got created. I was hoping that redirects didn't get created. Is that the intended outcome? --Gkullberg 21:12, 26 January 2010 (UTC)Reply

No it's not. I have problems with my job queue atm so I can't confirm but it looks like this is indeed a bug. --Subfader 03:45, 27 January 2010 (UTC)Reply
Ah, what do you know, it's really a bug. Well, not exactly a bug, but an issue involving the somewhat-new MediaWiki 'suppressredirect' permission. I added a note about this to the "Known issues" section. Yaron Koren 04:49, 27 January 2010 (UTC)Reply

Fieldset legends

I suggest to use legends for the fieldsets in SpecialReplaceText.php: Change

$wgOut->addHTML( "<fieldset>\n<p>$search_label</p\n>$tables\n</fieldset>" );

to

$wgOut->addHTML( "<fieldset>\n<legend>$search_label</legend>\n$tables\n</fieldset>" );

Same for the second fieldset and $optional_filters_label. --Subfader 17:31, 14 March 2010 (UTC)Reply

Useless query

IMO the info "There are XX pages that already contain the replacement string..." is quite useless. On wikis with more than 10,000 articles this query (which is a deep query, not just a mysql search) takes a lot of time and wastes the user's time and the server's ressources.

I decided to make that optional. If $wgReplaceTextSkipInfo is set to true in LocalSettings.php the info is skipped and the form jumps directly to the preview. All other checks and warnings still fully work. Add $wgReplaceTextSkipInfo to the globals of function doSpecialReplaceText() and replace

				if ( $this->replacement === '' ) {
					$message = 'replacetext_blankwarning';
				} elseif ( $this->edit_pages ) {
					$res = $this->doSearchQuery( $this->replacement, $this->selected_namespaces, $this->category, $this->prefix );
					$count = $res->numRows();
					if ( $count > 0 ) {
						$message = array( 'replacetext_warning', $wgLang->formatNum( $count ), "<code>{$this->replacement}</code>" );
					}
				} elseif ( $this->move_pages ) {
					$res = $this->getMatchingTitles( $this->replacement, $this->selected_namespaces, $this->category, $this->prefix );
					$count = $res->numRows();
					if ( $count > 0 ) {
						$message = array( 'replacetext_warning', $wgLang->formatNum( $count ), $this->replacement );
					}
				}

with

if ( $this->replacement === '' ) { $message = 'replacetext_blankwarning'; } elseif ($wgReplaceTextSkipInfo != 'true') { if ( $this->edit_pages ) { $res = $this->doSearchQuery( $this->replacement, $this->selected_namespaces, $this->category, $this->prefix ); $count = $res->numRows(); if ( $count > 0 ) { $message = array( 'replacetext_warning', $wgLang->formatNum( $count ), "<code>{$this->replacement}</code>" ); } } elseif ( $this->move_pages ) { $res = $this->getMatchingTitles( $this->replacement, $this->selected_namespaces, $this->category, $this->prefix ); $count = $res->numRows(); if ( $count > 0 ) { $message = array( 'replacetext_warning', $wgLang->formatNum( $count ), $this->replacement ); } }

}

The code may look ugly though. IMO the default behaviour should be changed so after installation the info can be enabled if really needed. --Subfader 17:56, 14 March 2010 (UTC)Reply

Hi, out of curiosity: how many string replacements do you run, that eliminating this step makes a difference? I guess a similar question could be asked for the issue below as well. Yaron Koren 16:55, 15 March 2010 (UTC)Reply
1 to 5 per day, sometimes a real session with up to 50 strings from my standard list (see archive for my automation request). I really think it's useless. You'd also find it useless if google would first show a page reading "Found 8 million results. Click here to see the search results." :D As mentioned it's not only useless but wastes time and ressources. If you have to run a replacement on a complete namespace or more without category or prefix filter on a big wiki it takes 5-10 seconds to build the info and the same AGAIN to build the preview.
I even think of removing all error messages (like empty replacements string warning) to the top of the preview (properly highlighted) so you never see the info page and always land directly on the preview page. --Subfader 02:17, 16 March 2010 (UTC)Reply
Yeah, what you're saying makes a lot of sense... I guess that page has been extraneous ever since users could specify exactly which pages they wanted to do replacement on (i.e., since version 0.2 :) ). I still think it's nice to tell people how many pages contain the replacement string already (or, even more importantly, warn about replacing with a blank string); but, as you note, those could be put at the top of the actual replacement page. Yaron Koren 04:36, 16 March 2010 (UTC)Reply
Well, I kept the query, but in the new version, 0.8, the warning now shows up at the top of the second screen, instead of in a separate "confirmation" screen. Thanks for the idea. Yaron Koren 22:04, 18 March 2010 (UTC)Reply
errorbox is fine for that. If you want a little more usability, replace tt with code tags ;) --Subfader 00:10, 19 March 2010 (UTC)Reply

Quick links to (un)tick namespace

This adds quick links to easily (un)tick defined groups of namespaces:

 

Here's the code. The javascript code is ugly but I couldn't care less since Special:ReplaceText is private and it works for me. --Subfader 19:18, 14 March 2010 (UTC)Reply

Interesting; thanks for the idea, and the code. Are you aware of the new 'Vector' skin, in MediaWiki 1.16? It has its own interface for searching by specific sets of namespaces - it's a similar concept to yours, but with different group names. I would think it makes sense to use their set of namespaces, for consistency - any thoughts? Yaron Koren 20:56, 14 March 2010 (UTC)Reply
You mean on Special:Search? Yes I switched to 1.16alpha right after it was released in August just to use that feature for the search :) Thoughts: The grouping is ok on the Search. The ones I used here are my own preference. I realized I always needed the same namespaced ticked again and again.
Somebody should create a useful master namespace selector which then should be used on all pages like special pages and it could be easily used by extensions like this. My 2 cents about namespace usabilty. The only improvemnt recently was grouping the talk namesapces after all these years, that's very poor imo. --Subfader 00:35, 15 March 2010 (UTC)Reply
Okay - well, my instinct is to always try to fit in with how MediaWiki does it. What do you mean by "the only improvement recently" - what about the other namespace groupings? Yaron Koren 02:15, 15 March 2010 (UTC)Reply
I mean the only improvement about a more useful way to select namespaces (except the new grouping for the search). There only is the fieldset or the drop down variation. Btw, I don't expect you to include this to the extension, I just wanted to post it, cos I can imagine other people who often replace text may find this useful. Better check my 2 posts above :) --Subfader 02:39, 15 March 2010 (UTC)Reply
Okay, I think I get it. Thanks also for the advice :) - I missed those other two posts entirely. Yaron Koren 02:43, 15 March 2010 (UTC)Reply
I modified the interface in version 0.8 to look more like the "Special:Search" page in MW 1.16, and to include its "check all" and "check none" buttons if MW is at version 1.16 or greater - hopefully this is a step in the right direction. Yaron Koren 22:17, 18 March 2010 (UTC)Reply
Yeah let's go for more usability. Everything that doesn't annoy me on a daily basis is cool :) --Subfader 00:06, 19 March 2010 (UTC)Reply

Apostrophe bug again?

Currently text like this is not found at all or only randomly: <div class='comment'>. Can you confirm? --Subfader 13:55, 1 May 2010 (UTC)Reply

Could be a problem with a recent $wgCompressRevisions problem tho. --Subfader 23:48, 1 May 2010 (UTC)Reply

Losing discussion after moving

If you replace text in titles (page moves) and do not tick the corresponding talk NS, you will lose all discussions since the page has a different title then. What can be done about it? E.g. if NS_MAIN and replace titles then also in NS_TALK titles. Trying some javascript for the form now. --Subfader 23:00, 2 May 2010 (UTC)Reply

That's true; but can't you just run the replace again, this time on those talk namespaces? Yaron Koren 02:09, 4 May 2010 (UTC)Reply
Yep, but to do so you have to realize the accident happened :) --Subfader 02:54, 4 May 2010 (UTC)Reply
Hm, that's true... a little Javascript "OK / Cancel" alert could be a good idea. Yaron Koren 19:19, 4 May 2010 (UTC)Reply
Yep. I'm not able to write a proper solution that would do that per php for all namespaces including custom ones. --Subfader 18:51, 5 May 2010 (UTC)Reply

Input Boxes - Number of lines

The input boxes on the specialpage are offering 3 lines for the target and the replacment text. This isn't that much. My quick solution on http://www.mobadaten.info: I changed 2 lines in the function showForm (file SpecialReplaceText.php):

$wgOut->addHTML( Xml::textarea( 'target', $this->target, 50, 2, array( 'style' => 'width: auto;' ) ) );
>>>
$wgOut->addHTML( Xml::textarea( 'target', $this->target, 50, 10, array( 'style' => 'width: auto;' ) ) );
$wgOut->addHTML( Xml::textarea( 'replacement', $this->replacement, 50, 2, array( 'style' => 'width: auto;' ) ) );
>>>
$wgOut->addHTML( Xml::textarea( 'replacement', $this->replacement, 50, 10, array( 'style' => 'width: auto;' ) ) );

It would help, if one can set up both height and width in LocalSettings.php after the 'require_once' line. Without a special configuration in LocalSettings.php the width of 50 and the height of 2 may work as default values.

…and please don't worry about my possibly funny english - I'm out of practice… :-) --Wgkderdicke 16:49, 21 May 2010 (UTC)Reply

Regular Expressions

One the goals I had installing Replace Text was to replace parameters of templates or to remove templates in their entirety that appear on a lot of pages. This could be easily accommodated with regular expressions (see xkcd) where I could specific a beginning string "{{Dummy Template" and an ending string "}}". I spoke with Yaron and he pointed out the complications arising from a lack of regular expression support in SQL (shame on you, whoever you are, who didn't make regular expressions a part of SQL!). But since template manipulation is a common requirement of this extension, and since templates are the building blocks of any sophisticate wiki, I hope someone can come by and incorporate this functionality.

MySQL actually has a REGEXP operator, so this is entirely possible (with the condition that only specific MySQL versions will be supported). And, agreed, regexp search and replace would be awesome. --The CyberShadow 22:12, 3 October 2010 (UTC)Reply

Missing Checkbox

Hi Folks, just install the new version (0.8) of this great plugin on my MediaWiki Installation 1.15.4 in german. It works just fine, the only thing that is different from the screenshot on the description page is that I don't have a "Check all" or "Uncheck all" button. Is that normal or did screw up something ? THY a lot,--Brocchinia 14:34, 23 July 2010 (UTC)Reply

Hi - yes, that's normal; those checkboxes only show up when using the Vector skin, which is only available in MediaWiki 1.16+. I just added a note to the page to explain that. Yaron Koren 15:05, 23 July 2010 (UTC)Reply

How to access Replace Text?

Once it is installed, how do I get to the page? I.e. As a normal user, how do I tell if it is already installed on a wiki I am using? Daviddoria 12:04, 13 August 2010 (UTC)Reply

It's the page "Special:ReplaceText". Yaron Koren 16:55, 13 August 2010 (UTC)Reply

No way to finish replacement process : Summary window doesn't have a confimation button

Hi, when i do a continue on the page list replacement page, i see another page with the page count that will be impacted by the replacement, a link "Return to form" and that's all... no link seems to be available to finish the replacement process.

That's strange - what versions of RT and MediaWiki are you using? Yaron Koren 18:21, 26 October 2010 (UTC)Reply
I'm having the same issue: RT 0.9.1 and Mediawiki 1.16+
I've been having this problem, too—RT 0.9.1 (also happens with 0.8.1, I tried this first then updated to 0.9.1), MediaWiki 1.17. I also have an old Referata wiki, and noticed that the same issue occurs there as well. Is there some other way to trigger the replace function we can use as a workaround in the meantime?
On my wiki it also sometimes doesn't want replace. I then run maintenance/runJobs.php --type replacetext. --Subfader 09:42, 24 July 2011 (UTC)Reply
Return to "Replace Text/Archive 2010" page.