Jump to content

Extension talk:Replace Text/Archive 2018

From mediawiki.org

Delete everything after certain characters

I want to delete all characters in a line after a certain word (with regular expressions enabled).
Search strings I tried were Word.*, Word(.*) and Word(.*$). The replacement string was just Word. However this didn't change anything at all.
How am I supposed to do that? --Stefahn (talk) 17:17, 17 February 2018 (UTC)Reply

Before commencing my substitution, I ensured there were no outstanding jobs in the job queue. After completing the text replacement, runJobs has a lot of work to do - refreshLinks and htmlCacheUpdate. Upon runJobs completion, I find some of my page titles have the wrong text associated with them (i.e. text which used to be associated with other titles).

My command, which is changing the markup to move from the Pubmed extension to the PubmedParser extension, looks like this:

php ./extensions/ReplaceText/replaceAll.php --nsall --yes --regex '<pubmed>\s*([0-9]+)\s*<\/pubmed>' '{{#pmid:$1}}

The markup renders as an HTML link. I am using MW REL1.30

What could cause this problem? Thanks.

Simply doesn't run

Using v1.29 of MW. Installed based on instructions. I go to the replace text page and enter find text and replace text and click continue. It simply redraws the screen without the find and replace text. 141.168.128.225 10:50, 21 February 2018 (UTC)Reply

Update. After trial and error looking at the PHP code (which I have never coded in PHP before) I have found replacing 'post' with 'get' makes the extension work. Now the question is why is 'post' not working? Please 203.166.245.180 01:58, 22 February 2018 (UTC)Reply
That's a great find. I don't know why "post" isn't working for you - I'm guessing because you have some Apache and/or PHP customizations that prevent post from working - is that possible? Yaron Koren (talk) 02:20, 23 February 2018 (UTC)Reply

How to always delay Replace Text jobs?

Until recently, no Replace Text operation would run until after I had manually executed a cronjob for runJobs.php. Suddenly, Replace Text is working without executing runJobs.php. Having grown accustomed to the old behavior, I'd like to set this extension to always defer execution. Is there a way to force the extension to do replacements only after the cronjob? My MW version is 1.29.1. Replace Text is version 1.2. --Abhidevananda (talk) 09:19, 4 April 2018 (UTC)Reply

If you don't want any jobs to run automatically, you can add "$wgJobRunRate = 0;" to LocalSettings.php... or do you already have that setting? Yaron Koren (talk) 17:22, 4 April 2018 (UTC)Reply
Thanks, Yaron. I tested that solution and it works! That line was not already contained in my LocalSettings.php. It was just how things worked up till a few days ago. Can't say why things changed, but I am happy to have them back now as they were before. --Abhidevananda (talk) 13:20, 5 April 2018 (UTC)Reply
Okay, now I get what you mean when you say "any jobs". Yes, that command resolved one problem, but it introduced an even bigger one in its place. So let me be more clear here. The only jobs I don't want to run automatically are those batch jobs generated by the Replace Text extension. Still looking for a solution to that. --Abhidevananda (talk) 09:59, 7 April 2018 (UTC)Reply
Is there any reason why you don't want Special:ReplaceText jobs to run normally, other than that you just got used to the incorrect behavior? Yaron Koren (talk) 18:00, 8 April 2018 (UTC)Reply
It's a good question and a valid one. I suppose that I have had this "incorrect behavior" for so long that I've come to think of it as an added layer of security for a tool that is very powerful. Let's say that a replace-text action mistakenly impacts hundreds of articles. Is there a quick and easy way to undo such an action? --Abhidevananda (talk) 00:00, 9 April 2018 (UTC)Reply
Okay, that makes sense. What I would recommend, then, is, instead of going to Special:ReplaceText at all, call the Replace Text command-line script, which is called replaceAll.php. It lets you do everything that Special:ReplaceText does, but you can kill the process at any time (with Ctrl+C) to see how it's working before running it on all the pages. Yaron Koren (talk) 00:51, 9 April 2018 (UTC)Reply
Hmmm... well, that might work if (1) replaceAll.php were not dependent on the ReplaceText extension (2) I (and most of my fellow admins) did not have a distinct preference for GUI (3) my own use of the ReplaceText extension were the only use that concerned me. So let's go back to my previous question. Is there a quick and easy way to undo a ReplaceText action? When all of the replacements occur over a very short span of time, it would be easier to undo all of them if they were tightly grouped. But over a longer span of time, it could be more difficult to locate all of the articles affected. In other words, the delay-and-execute-promptly option remains somewhat appealing... unless there is a simple way to undo a batch replacement. --Abhidevananda (talk) 06:40, 9 April 2018 (UTC)Reply
Sorry, I should have answered that question before. No, there's no easy way to undo a Replace Text action - other than doing another Replace Text in the opposite direction, which can only be done some of the time. And also, I don't know of any way to delay job-running only for certain job types. I still think replaceAll.php is your best bet for large-scale replacements where you're worried about the results. Yaron Koren (talk) 13:47, 9 April 2018 (UTC)Reply
Thanks for all your advice. At least I know better where things stand now. Out of curiosity, could access to ReplaceText be restricted only to bureaucrats? --Abhidevananda (talk) 16:54, 9 April 2018 (UTC)Reply
Yes - see Extension:Replace_Text#Installation. Yaron Koren (talk) 16:58, 9 April 2018 (UTC)Reply
Thanks! I'd read that section but had not realized its full ramifications. Setting $wgGroupPermissions['sysop']['replacetext'] = false; allows for a degree of precaution that I think will prove useful. At least it will help me sleep better at night. :) --Abhidevananda (talk) 17:38, 9 April 2018 (UTC)Reply

searching for ]}' and "

Hi - I often want to search for special characters (for example changing one template to another) or searching to replace straight quotes with curly quotes. But the search engine won't find strings like "isn't" and "{{template|A|B|C}}" even though I can see them there. Is there a way to fix this? ElectricRay (talk) 11:19, 30 April 2018 (UTC)Reply

Replace Wikitext in Source?

Seems this extension can't do that, right? — Preceding unsigned comment added by Johnywhy (talkcontribs)

I'll be surprised if it couldn't replace wikitext, because that's the main purpose of the whole extension. --Ciencia Al Poder (talk) 09:23, 21 June 2018 (UTC)Reply

Many pages on my wiki contained a transclude, but this extension could not find one.

{{doggy}}

I also tried with regex enabled, and

\{\{doggy\}\}

My replacement text was blank. I assume that won't affect the search.

Johnywhy (talk) 09:58, 21 June 2018 (UTC)Reply

Replace Text doesn't update category for the "file" namespace

There's no issues updating any other namespace, but updating category text for file pages don't work. Is this a configuration issue, bug or a limitation? Thanks --Skunark (talk) 16:10, 5 July 2018 (UTC)Reply

Is 250 the most replacements you can do at one time?

I've went and changed the PHP setting max_input_vars to 3000 but that didn't seem to do anything.--HausaDictionary (talk) 07:29, 18 July 2018 (UTC)Reply

It looks like it's hard coded in the RT version for MW1.31 See here. Looks like they're thinking of making it a setting. --Jeremi Plazas (talk) 17:37, 3 December 2018 (UTC)Reply
Yes, a new setting would be useful...Loman87 (talk) 11:46, 6 December 2018 (UTC)Reply
+1 vote for new setting ;-) --Alzi24 (talk) 14:25, 26 December 2018 (UTC)Reply

Error

I got this error. My Wiki's stats can be seen here.

[28948afb634085b5a9d84ef8] /Special:ReplaceText Wikimedia\Rdbms\DBQueryError from line 1457 of /var/www/ways-of-darkness.sonck.nl/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT page_namespace,page_title,page_id,page_len,page_is_redirect,page_latest,page_content_model FROM "page" WHERE page_id = 'edit_pages' LIMIT 1
Function: Title::newFromID
Error: 22P02 ERROR: invalid input syntax for integer: "edit_pages"
LINE 1: ...age_content_model FROM "page" WHERE page_id = 'edit_page...
^

Backtrace:

#0 /var/www/ways-of-darkness.sonck.nl/includes/libs/rdbms/database/Database.php(1427): Wikimedia\Rdbms\Database->makeQueryException(string, string, string, string)
#1 /var/www/ways-of-darkness.sonck.nl/includes/libs/rdbms/database/Database.php(1200): Wikimedia\Rdbms\Database->reportQueryError(string, string, string, string, boolean)
#2 /var/www/ways-of-darkness.sonck.nl/includes/libs/rdbms/database/Database.php(1653): Wikimedia\Rdbms\Database->query(string, string)
#3 /var/www/ways-of-darkness.sonck.nl/includes/libs/rdbms/database/Database.php(1730): Wikimedia\Rdbms\Database->select(string, array, array, string, array, array)
#4 /var/www/ways-of-darkness.sonck.nl/includes/Title.php(422): Wikimedia\Rdbms\Database->selectRow(string, array, array, string)
#5 /var/www/ways-of-darkness.sonck.nl/extensions/ReplaceText/src/SpecialReplaceText.php(264): Title::newFromID(string)
#6 /var/www/ways-of-darkness.sonck.nl/extensions/ReplaceText/src/SpecialReplaceText.php(119): SpecialReplaceText->createJobsForTextReplacements()
#7 /var/www/ways-of-darkness.sonck.nl/extensions/ReplaceText/src/SpecialReplaceText.php(71): SpecialReplaceText->doSpecialReplaceText()
#8 /var/www/ways-of-darkness.sonck.nl/includes/specialpage/SpecialPage.php(522): SpecialReplaceText->execute(NULL)
#9 /var/www/ways-of-darkness.sonck.nl/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)
#10 /var/www/ways-of-darkness.sonck.nl/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)
#11 /var/www/ways-of-darkness.sonck.nl/includes/MediaWiki.php(861): MediaWiki->performRequest()
#12 /var/www/ways-of-darkness.sonck.nl/includes/MediaWiki.php(524): MediaWiki->main()
#13 /var/www/ways-of-darkness.sonck.nl/index.php(42): MediaWiki->run()
#14 {main}

Can I limit the number of replacements on a page?

Is there a way to limit the number of replacements on a page?

If the word widget is an article, and I want to make it a link I can do that now:

"widget"

"[[widget]]"

But is there a way I can do this so it will only make the first instance a link and leave the rest unaffected?

If you're willing to play around enough with lookarounds in regex mode, you should be able to do that, assuming the regex engine used by the extension (I guess it's just PHP's preg_replace()?) supports lookarounds. 16:11, 28 July 2018 (UTC)

'search only' ability as separate user-right

It seems currently not possible ... but I think the Replace_Text search feature on its own is already a very useful feature (ie: without the ability to make wiki-wide changes). As such I think it would be nice if one could assign a Replace_Text 'search only' ability as user-right. --MvGulik (talk) 02:36, 13 September 2018 (UTC)Reply

Replacing text causes limit restriction

Hi Yaron,

When replacing the name for a call to a template, used in about 2.500 pages, the runJobs.php results in a max_updates_per_hour error, which the host has set to be 36.000 per hour.

It seems strange that changing one word in 2.500 pages results in more than 36.000 database updates.

The question is whether the replace text extension can further optimize it's command to MySQL, to avoid reaching such restrictions?

Pretor~nowiki (talk) 12:22, 27 September 2018 (UTC)Reply

There should only be one database update per replacement - so if there's only one replacement per page, that should be 2,500 DB updates, not 36,000. I have no idea why you're getting that error, unless there's some other process happening at the same time. If you modify a template, it probably leads to at least one DB update for every page that calls that template, so if there's a template that has tens of thousands of pages calling it, maybe that could be causing the issue. Could that be it? Yaron Koren (talk) 21:42, 27 September 2018 (UTC)Reply
Ok. The change was to the template name (and content), which is used in Cargo, so that probably caused a lot of database updates.
BTW: My opt-in to get notified when this post updates did not notify me. (I have selected to get notified for "Talk page message", "Structured Discussion" and other options, cross-wiki.) Pretor~nowiki (talk) 10:49, 28 September 2018 (UTC)Reply