Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save imbushuo/392228551052d7bdf72a252fd30b4234 to your computer and use it in GitHub Desktop.
Save imbushuo/392228551052d7bdf72a252fd30b4234 to your computer and use it in GitHub Desktop.
Moegirlpedia HotCat Extension Bug Investigation 17/03/29

Moegirlpedia HotCat Extension Bug Investigation 17/03/29

Condition set

  1. Widget Hotcat is enabled in Gadget settings
  2. In Special:UploadFile page
  3. File validation is enabled and loaded. It seems that not all interface languages have this feature on. Update: It seems that file validation depends on some RL module that takes long time to load.

Reproduce steps

  1. Select a random file and wait for file validation
  2. Select another file

Expected result

  1. Function setup_upload, which is responsible for presenting category controls in upload page, should not be fired multiple times.

Bug behavior

  1. Hotcat was re-loaded with unexpected additional category edit control, regardless of its previous state.

Next step

  1. Check callstack.

Bug details

If file validation is enabled, MediaWiki will send a XHR request to server. A callback is fired when such request finishes. Leveraging DOM operation, the client is able to display preview, present a warning or do something else according to server's response.

MediaWiki client-side JavaScript framework contains a hook that provides the ability to monitor page content changes. Hotcat relies on this hook for initialization. When the hook is triggered, Hotcat clears existing initialization flag and kicks off DOM operations.

So in this case, when file validation finished, the upload form was changed to reflect validation status (file deduplication, preview, etc.). Then the content hook was fired. Finally, Hotcat was constantly reloaded, regardless of its previous status.

Fix

Use a global variable (which acts as a lock) instead of a local variable to determine the eligibility of a full initialization.

A patched version is available at here.

File information

Fast publish - Reversion 10 (2017/3/29)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment