Page MenuHomePhabricator

CodeMirror V6's search field can conflict with MediaWiki's legacy search behaviour
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Add the following to LocalSettings.php:
wfLoadExtension( 'CodeMirror' );
$wgCodeMirrorV6 = true;
$wgMainPageIsDomainRoot = true; // as this is not set on WMF wikis, it probably only affects third-party wikis
  • Open the source editor for the main page of the wiki
  • CTRL + F to open the CodeMirror search box
  • Type something into the search box
  • Click "Save Changes" with the search box still open

What happens?:

The page redirects to the search results page for the term you entered into CodeMirror's search box. This is because the search box in CodeMirror is an <input> with name="search", so when the page is POSTed, some legacy code in MediaWiki core sees the search parameter and tries to search the wiki, aborting the page save.

A possible solution is changing the name of CodeMirror's parameter, but this would require modifying the upstream CodeMirror V6 library. I think that a wiser change to fix this is to modify ActionEntrypoint.php in core to only perform this legacy search functionality if the request was not POSTed.

What should have happened instead?:

The edit should have been saved, and the user should be redirected to the page that they just edited.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

1.45

Other information (browser name/version, screenshots, etc.):

Event Timeline

Change #1238392 had a related patch set uploaded (by Jayden Bailey; author: Jayden Bailey):

[mediawiki/core@master] ActionEntryPoint: Only do legacy search redirect if not POSTed

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

Change #1248076 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeMirror@master] CodeMirrorSearch: use a 'name' attr different than Core's search field

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

A possible solution is changing the name of CodeMirror's parameter, but this would require modifying the upstream CodeMirror V6 library.

We actually re-implement our own search functionality, so the name can be changed easily. The above patch does that. It seems quite sensible to not have two [name=search]s on the same page!

I'm a bit nervous about touching ActionEntryPoint, but that's not to say that patch isn't an improvement. I'd just rather someone more familiar with that code review it.

MusikAnimal changed the task status from Open to In Progress.Mar 4 2026, 6:43 PM

Change #1248076 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirrorSearch: use a 'name' attr different than Core's search field

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

MusikAnimal claimed this task.
MusikAnimal moved this task from Bugs to Done on the MediaWiki-extensions-CodeMirror board.

Resolved on the CodeMirror side. I don't know whether the change to ActionEntryPoint is still worthwhile or not, but if so it should perhaps be a different task. Thanks nonetheless for contributing!

Change #1238392 abandoned by Jayden Bailey:

[mediawiki/core@master] ActionEntryPoint: Only do legacy search redirect if not POSTed

Reason:

Resolved in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CodeMirror/+/1248076 instead

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