Nonfunctional beginnings of a patch
Article::doRollback is very messy right now, with several problems:
- It provides no way for scripts to override permissions checks.
- It uses nonstandard permissions checks and inadequate error return codes, which a) duplicate code in Title::getPermissionsErrors (probably, in some respect, incorrectly), and b) force Article::rollback to check permissions anyway using Title::getPermissionsErrors so it can display a proper error. Combined, this code duplication probably results in more than one scenario in which you can rollback through the API but not the standard UI, and vice versa.
- Break into two functions, doRollback() and commitRollback() (or whatever -- name suggested by BrokenArrow). doRollback() should perform all permissions checks and then call commitRollback() to do the actual work. commitRollback() should only ensure that the database is not read-only.
- Remove the pass-by-reference $resultDetails (this isn't C(++) here), and change the return value to an array of errors, like some of the editing logic already does.
The very beginnings of a (not yet functional) patch are attached.