Page MenuHomePhabricator

Web2Cit user script's unpatch methods may conflict with other monkey-patchers
Open, Needs TriagePublic

Description

Our monkey-patch methods keep a copy of the original unpatched function at hand to reinstate them via our unpatch methods if the user temporarily disables Web2Cit.

However, I think this unpatching may conflict with other user scripts monkey-patching the same functions. For example:

  1. our user script monkey-patches $.ajax and saves a copy of the original function at this.unpatched.ajax.
  2. some other user script monkey-patches $.ajax again; that is, our version of it. This should be OK.
  3. the user decides to temporarily disable Web2Cit, so our unpatch method reinstates the original unpatched $.ajax. Then, the monkey-patch applied by the other user script is lost.

Consider deprecating our unpatch methods and having an enabled flag that is read to decide (inside our patches) whether our custom code should be run or skipped.

Event Timeline

In addition, consider checking this enabled flag from within the credit's labelChange event handler, as it could be the case that it remained set from a previous call which did not trigger it (see T310656).