Extension talk:Replace Text

Jump to navigation Jump to search

About this board

ReplaceText just re-loads original replaceText page when I click continue

Tenbergen (talkcontribs)

On one of several wikis I run RT 1.4.1 is misbehaving: if I enter some text I want to replace, it just re-loads the initial replace text page. When I enable debugging there are no entries in the log that seem related. PHP logs are not showing anything either. MW is 1.32.1 and 7.2.11 like the others where it works so probably unrelated. Does anyone else have a problem like this?

Tenbergen (talkcontribs)

This ended up being because my domain/hosting was set up to redirect pages to www.<mydomain>; when I changed it to not redirect, it worked fine.

Reply to "ReplaceText just re-loads original replaceText page when I click continue"

Replacements file format / Regex question

Amousey (talkcontribs)

Excellent feature, and a great time saver - thank you.

--replacements option More documentation and examples would be helpful on the replacements file.

The replacements file format is described as:

The format of the replacements file is tab separated with three fields.

Any line that does not have a tab is ignored and can be considered a comment.

Fields are:

1. String to search for.
2. String to replace found text with.
3. (optional) The presence of this field indicates that the previous two are considered a regular expression.

Example: This is a comment TARGET REPL regex(p*) Count the Ps; \\1 true

Questions - Can any database including MariaDB use the regex here, including those described as unable to use regex from the interactive dialog option (MS SQL/SQLServer or SQLite)? - If not using a regular expression, do any special characters need to be avoided / escaped eg pipe |, =, {} and " ' quote marks, etc - How to active ReplaceText from the user interface using a pre-configured set of options, including a replacements file, eg for a non-technical user

Future suggestion: - a way to mark up pages not to have text replaced or ignoring pages with the DISAMBIG tag, which would allow it to be used for autocorrect - A bot using a replacements file. Is there example choose & instructions anywhere?

Reply to "Replacements file format / Regex question"

Replace double empty String

Summary by MvGulik

No reply after 30 days. Presuming resolved.

Bmrberlin (talkcontribs)

Is there a trick to replace a double empty string with text?

MvGulik (talkcontribs)

What do you mean with "empty string" ?

(technically there is no such thing as a "double empty string". Its similar to zero in counting, ie: zero + zero == zero)

MvGulik (talkcontribs)


If its "double-spaces", just use 2 spaces. Or enclose two spaces inside a RE capture group (when using RE mode)

If it "double-empty-lines", just add/type them as such in your search field (ie: [ENTER] key). (works in both Normal and RE mode)

Is it possible to replace in page titles with the Command-line script ?

Summary by MvGulik

No reply after 30 days. Presuming resolved.

Nicolas NALLET (talkcontribs)


MvGulik (talkcontribs)

Try "php replaceAll.php --help" (documented in "Command-line script: replaceAll.php" section) to see if your version contains the "--rename" option.

(Because that option is currently not listed on the extension page itself, I would make sure to test it first to see if its working correctly. Just to be save.)

ReplaceText 1.4.1 (8dd0719) breaks with Error: 22P02

SH73 (talkcontribs)

Dear Mediawiki-Community,

I'm getting this error after upgrading to Mediawiki 1.31.1:

[72b54eb34fc4319361df967a] /Spezial:ReplaceText Wikimedia\Rdbms\DBQueryError from line 1457 of /WIKI/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 FEHLER: ungültige Eingabesyntax für ganze Zahl: »edit_pages«

LINE 1: ...age_content_model FROM "page" WHERE page_id = 'edit_page...



#0 /WIKI/includes/libs/rdbms/database/Database.php(1427): Wikimedia\Rdbms\Database->makeQueryException(string, string, string, string)

#1 /WIKI/includes/libs/rdbms/database/Database.php(1200): Wikimedia\Rdbms\Database->reportQueryError(string, string, string, string, boolean)

#2 /WIKI/includes/libs/rdbms/database/Database.php(1653): Wikimedia\Rdbms\Database->query(string, string)

#3 /WIKI/includes/libs/rdbms/database/Database.php(1730): Wikimedia\Rdbms\Database->select(string, array, array, string, array, array)

#4 /WIKI/includes/Title.php(422): Wikimedia\Rdbms\Database->selectRow(string, array, array, string)

#5 /WIKI/extensions/ReplaceText/src/SpecialReplaceText.php(264): Title::newFromID(string)

#6 /WIKI/extensions/ReplaceText/src/SpecialReplaceText.php(119): SpecialReplaceText->createJobsForTextReplacements()

#7 /WIKI/extensions/ReplaceText/src/SpecialReplaceText.php(71): SpecialReplaceText->doSpecialReplaceText()

#8 /WIKI/includes/specialpage/SpecialPage.php(522): SpecialReplaceText->execute(NULL)

#9 /WIKI/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)

#10 /WIKI/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)

#11 /WIKI/includes/MediaWiki.php(861): MediaWiki->performRequest()

#12 /WIKI/includes/MediaWiki.php(524): MediaWiki->main()

#13 /WIKI/index.php(42): MediaWiki->run()

#14 {main}

The wiki runs with PostgreSQL 11 and PHP 7.0.33. I've also seen this error on Version 1.32 and above. I've already executed the script update.php without errors.

This is my Create-Table:



    page_id integer NOT NULL DEFAULT nextval('WIKI.page_page_id_seq'::regclass),

    page_namespace integer NOT NULL,

    page_title character varying(255) COLLATE pg_catalog."default" NOT NULL,

    page_restrictions text COLLATE pg_catalog."default",

    page_is_redirect smallint NOT NULL DEFAULT 0,

    page_is_new smallint NOT NULL DEFAULT 0,

    page_random real NOT NULL DEFAULT random(),

    page_touched timestamp with time zone,

    page_latest integer NOT NULL,

    page_len integer NOT NULL,

    titlevector tsvector,

    page_content_model text COLLATE pg_catalog."default",

    page_links_updated timestamp with time zone,

    page_lang text COLLATE pg_catalog."default",

    CONSTRAINT page_pkey PRIMARY KEY (page_id)





TABLESPACE pg_default;

Is there some advice?

Many thanks.

Reply to "ReplaceText 1.4.1 (8dd0719) breaks with Error: 22P02"
Krusher (talkcontribs)

Seems to use a deprecated method which no longer exists in the master:

[4ae2af512a8f9ae1b6b9e529] /wiki/Especial:ReplaceText Error from line 78 of /home/krusher/www.apocrypha.ovh/extensions/ReplaceText/src/SpecialReplaceText.php: Call to undefined method SearchEngine::searchableNamespaces()


#0 /home/krusher/www.apocrypha.ovh/extensions/ReplaceText/src/SpecialReplaceText.php(103): SpecialReplaceText->getSelectedNamespaces()

#1 /home/krusher/www.apocrypha.ovh/extensions/ReplaceText/src/SpecialReplaceText.php(71): SpecialReplaceText->doSpecialReplaceText()

#2 /home/krusher/www.apocrypha.ovh/includes/specialpage/SpecialPage.php(570): SpecialReplaceText->execute(NULL)

#3 /home/krusher/www.apocrypha.ovh/includes/specialpage/SpecialPageFactory.php(575): SpecialPage->run(NULL)

#4 /home/krusher/www.apocrypha.ovh/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)

#5 /home/krusher/www.apocrypha.ovh/includes/MediaWiki.php(865): MediaWiki->performRequest()

#6 /home/krusher/www.apocrypha.ovh/includes/MediaWiki.php(515): MediaWiki->main()

#7 /home/krusher/www.apocrypha.ovh/index.php(42): MediaWiki->run()

#8 {main}

Any workarounds? Regards.

Yaron Koren (talkcontribs)

Sorry about that. There was a change that was just merged in to fix this problem - if you get the latest code, everything should work again.

Krusher (talkcontribs)

It's me who shouldn't be playing with master branch anyway :D thanks!

There are no older topics