Page MenuHomePhabricator

[ReplaceText] Incorrect error: You must select at least one namespace.
Closed, ResolvedPublic

Description

Screenshot of the error

ReplaceText 0.9.3 incorrectly gives the error "You must select at least one namespace." when the Main namespace is select. This error appeared suddenly after using ReplaceText successfully since it was released in January 2012, even on large numbers of pages.

However, there are about 1500 pages to replace text on for the search in the screenshot, and inverting the selection and then selecting only one of them causes the bug to resolve itself. So, it seems the bug is related to the number of pages to be replaced.


Version: REL1_19-branch
Severity: critical
OS: Linux
Platform: PC
URL: http://www.issuepedia.org/Special:ReplaceText
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=43472

Attached:

2012-06-29_124109.jpg (862×1 px, 200 KB)

Details

Reference
bz38170

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:55 AM
bzimport set Reference to bz38170.
bzimport added a subscriber: Unknown Object (MLST).

woozle wrote:

I'm having this same problem, but also the "Invert selections" button isn't working for me so I can't easily confirm that the not-really-a-workaround works (hundreds of checkboxes to toggle manually).

Woozle - my guess is that there's some unrelated Javascript problem that's causing "invert selection" to not work - and maybe the other issue as well. I would recommend looking in the Javascript console in either Chrome or Firefox to see if any error messages appear.

jerryp wrote:

Have the same problem - no solution but maybe a few pointers:

MediaWiki 1.18.1
PHP 5.3.3 (apache2handler)
MySQL 5.1.61
Replace Text (Version 0.9.1)

Other installed extensions here: http://www.cookipedia.co.uk/recipes_wiki/Special:Version

Replace text was working - now fails with You must select at least one
namespaceerror on a huge replace (2000 pages)

The namespace checkbox info is not being passed by Javascript hence unchecked ns error.

This is the javascript error generated

Timestamp: 10/08/2012 17:29:40
Error: ReferenceError: mwToggleSearchCheckboxes is not defined
Source File: http://www.cookipedia.co.uk/recipes_wiki/Special:ReplaceText

From the system error log I see:

[Fri Aug 10 17:29:38 2012] [error] [client nnn.nnn.nnn.nnn] File does not exist: /home/httpd/vhosts/cookipedia.co.uk/httpdocs/wiki/skins/common/search.js, referer: http://www.cookipedia.co.uk/recipes_wiki/Special:ReplaceText

probably called from line 330 SpecialReplaceText.php :

// add javascript specific to special:search
$wgOut->addScriptFile( 'search.js' );

No search.js anywhere in my wiki dir tree
No search.js in a fresh test install of the mw repo
No search.js in the ReplaceText repo

I'm not sure where to look now?

antony.seedhouse wrote:

http://php.net/manual/en/info.configuration.php

max_input_vars 1000 PHP_INI_PERDIR Available since PHP 5.3.9.

Increase to something much higher

Also, if your PHP has suhosin,

suhosin.post.max_vars
suhosin.request.max_vars

jerryp wrote:

Hi Anthony

Thanks for your input.

From the ReplaceText page, before even running a search, if I click the 'Check: All' button, I immediately get a fatal Javascript error:

Timestamp: 30/08/2012 16:13:53
Error: ReferenceError: mwToggleSearchCheckboxes is not defined
Source File: http://www.cookipedia.co.uk/recipes_wiki/Special:ReplaceText
Line: 1

I can't see how changing the above php config var would have an effect upon Javascript. Perhaps you can enlighten me?

antony.seedhouse wrote:

Hi, sorry, my solution is for the main bug.

When checking my firefox web console I also get the ReferenceError when clicking the check all/none buttons, but they still work and nothing stops me using the page.

Have you tried in another browser and/or with all browser plugins/addons disabled?

Antony - thanks for that discovery! I bet that was the issue.

Jerry - I think your bug is totally unrelated. Actually, I think that issue is one that was fixed in the most recent version of Replace Text, 0.9.3.

Thanks to everyone for their contributions. I'm marking this bug as "invalid", since it didn't require any code changes. I added more info about the problem to the Replace Text extension page.

I changed the status of this to "WONTFIX", since the report was for an incorrect error message that is still incorrect. This could be resolved as "FIXED" if ReplaceText at least detected when large numbers of pages were being returned, and it could give a different error message that explains what is likely actually occurring with a server limitation. Then, the user could be directed to use the feature enhancement I proposed here:

https://bugzilla.wikimedia.org/show_bug.cgi?id=43472

It looks like the default value for max_input_vars is 1000, so ReplaceText could detect when there are more than 1000 search results, and automatically use that as a default limit value, and then deliver a different error message that prompts the user to proceed with that limit, or enter another limit and run the search again.

It appears that the max_input_vars parameter in PHP exists for the purpose of reducing the effectiveness of some types of DoS attacks. As such, this bug report and bug 43472 are relevant for security, so leaving a user with only a workaround that requires access to the server configuration AND compromising security, should be discouraged.

So, I'm elevating both bug reports to "critical" severity. I decided against "major" severity because the known issues section on the extension page:

https://www.mediawiki.org/wiki/Extension:Replace_Text#Known_issues

mentions the possibility that some replacements may not actually be done, which constitutes a loss of data that may or may not be recoverable after a partial replace has been done.

woozle wrote:

modifications to deal with form-size bug

Attached is a modified version of the SpecialReplaceText.php file which deals with the form-size limitation (allows user to limit how many results to display). I also added a couple of code comments as I figured out how things worked.

The modification was done on 12/1, so there may have been additional changes to the main file since then.

attachment SpecialReplaceText.php ignored as obsolete

[This bug report is resolved/closed as WONTFIX, hence adding further comments or even attachments doesn't make much sense without changing the status again.]

I think we're trying to make the case that the status should be changed to FIXED, if you know what I mean.

Created attachment 11669
A patch for Woozle's edits with minor edits by badon

I tested Woozle's modification, and they work with Replace Text 0.9.6, but there are some smaller problems.

The descriptive text was confusing, so I clarified it a little. I also found that using the exact value reported for max_input_vars did not work. In my test case, max_input_vars was 1000, but I had to reduce the maximum to 995 to get it work. The new descriptive text addresses that possibility.

Even though the limit is approximately 1000, the search results are not also limited. That means if there are millions of search results, the entire result set must be downloaded before the replace operation can proceed. So, Woozle's fix solves part of the problem, but Replace Text is still practically unusable on very large wikis.

Woozle's solution is a good starting place for working around the limitations of Replace Text, so I produced a patch for it with my edits. I will also upload the actual file. That should be sufficient for most people to resume using it until a more polished fix can be implemented.

Attached:

Created attachment 11670
The patched file, for Replace Text users that need a fix immediately

Wiki admins can use this file instead of the patch, as a matter of convenience to resume using ReplaceText immediately.

Attached:

I've run into this exact problem running the latest from gerrit + a 1.19 MediaWiki.

The problem is that edit_pages, move_pages and selected namespaces aren't passed in the pageListForm() method.

About to submit a patch to fix this.

Change 154523 had a related patch set uploaded by MarkAHershberger:
Fix “Incorrect error: You must select at least one namespace.”

https://gerrit.wikimedia.org/r/154523

Change 154523 merged by jenkins-bot:
Fix “Incorrect error: You must select at least one namespace.”

https://gerrit.wikimedia.org/r/154523

Is a backport planned for this? If not, the target milestone should be adjusted.

Good point - I just removed the "target milestone"; I don't know why it was set in the first place.

(In reply to Gerrit Notification Bot from comment #18)

Change 154523 merged by jenkins-bot:
Fix “Incorrect error: You must select at least one namespace.”

https://gerrit.wikimedia.org/r/154523

May this bug be considered fix in conjunction with change [1]? If yes it might also by time to do a new release since a couple of other fixes were done in the meantime.

[1] https://git.wikimedia.org/commit/mediawiki%2Fextensions%2FReplaceText.git/eb819cd4b07e70fbadfe2334d55205e5c9aaa959

All patches mentioned in this report were merged or abandoned - I'm resetting the ticket status.

Aklapper lowered the priority of this task from High to Medium.Apr 2 2015, 2:48 PM
Nikerabbit claimed this task.