Last modified: 2014-07-28 11:26:04 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T19554, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 17554 - Special:Import should optionally set timestamp and summary comment
Special:Import should optionally set timestamp and summary comment
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
Export/Import (Other open bugs)
1.13.x
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-18 12:53 UTC by Dan Barrett
Modified: 2014-07-28 11:26 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Dan Barrett 2009-02-18 12:53:32 UTC
The easiest way to search-and-replace in MediaWiki is to use Special:Export, then edit the export dump file, then use Special:Import.  Unfortunately, there are two pieces missing from this method: 

- All <timestamp> fields are wrong, because the import is happening NOW, not at the time of the last revision
- All summary comments are wrong, because they don't mention the search-and-replace operation.

To achieve this right now, we have to edit the dump file to change timestamps and summary comments... but couldn't Special:Import do this for us, optionally?  (Or perhaps maintenance/importDump.php?)

I suggest adding two new fields to Special:Import:

1. A checkbox, "Set all import timestamps to NOW", defaulted to unchecked
2. A text input, "Override all summary comments", defaulted to empty

and/or modifying maintenance/importDump.php to add these features via command line.
Comment 1 Alex Z. 2009-02-21 07:57:08 UTC
This isn't really what Import was designed for. If you want to edit the contents of a page, one should really do this via a normal edit. If a lot of pages need to have an automatic search and replace done, there is an API for this. But letting people modify aspects of the page history via the import form sounds a little scary.
Comment 2 Dan Barrett 2009-02-21 13:11:53 UTC
Hmmm.  I don't see why this is "modifying aspects of the page history."  It's just importing a new, current version at the current time, not in the past.

If the MediaWiki API can do this simply, that's great. Where can I see a complete example that does search-and-replace in general?  ("In general" meaning "you don't have to write a new PHP script for every search/replace operation.")  Somehow I wonder, if it were this simple, wouldn't someone already have written a search-and-replace Special Page?

Also, I think the import solution is better than an API solution in one respect: you can see and validate your changes (in the XML file) before import.  With the API, if you get your search-and-replace patterns wrong (which is VERY easy to do), you've modified your content wrongly. I find that more "scary" than modifying an XML file you can check in advance.
Comment 3 Alex Z. 2009-02-21 18:42:17 UTC
(In reply to comment #2)
> Hmmm.  I don't see why this is "modifying aspects of the page history."  It's
> just importing a new, current version at the current time, not in the past.

Export/Import is designed for copying the history or content of a page from one wiki to another. AFAIK, Import isn't designed so that people can download the XML docuument, then re-upload it.

> If the MediaWiki API can do this simply, that's great. Where can I see a
> complete example that does search-and-replace in general?  ("In general"
> meaning "you don't have to write a new PHP script for every search/replace
> operation.")  Somehow I wonder, if it were this simple, wouldn't someone
> already have written a search-and-replace Special Page?

Something like <http://www.mediawiki.org/wiki/Extension:Replace_Text>? It doesn't support regex yet, but it does seem to be maintained at least. 
I don't know of any premade PHP scripts, but I know Pywikipedia has one and writing a simple one shouldn't be too difficult.

1. Define the search expression and replace text
2. Load the list of page to edit from a text file or something
3. Login to the site with action=login
4. Get the pagetext for each from prop=revisions
5. Perform the replacements
6. Save the pages with action=edit

> Also, I think the import solution is better than an API solution in one
> respect: you can see and validate your changes (in the XML file) before import.
>  With the API, if you get your search-and-replace patterns wrong (which is VERY
> easy to do), you've modified your content wrongly. I find that more "scary"
> than modifying an XML file you can check in advance.
> 

If this is that much of a concern, add "save the text to a file or run through action=parse and load in a browser and wait for user input" before saving in the above steps.
Comment 4 This, that and the other (TTO) 2014-07-28 11:26:04 UTC
Closing as WONTFIX per earlier comments. If you want to do a search-and-replace, use the edit API (or if keen and able, modify the database directly). Export/modify/reimport (aka rewriting history) is not something we should be supporting in MW core.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links