Skin::getUndeleteLink performs several checks, including a
Title::userCan, which in turn checks the blocked status from master in
order to decide whether to show the link. This happens during GET
requests, and a basic calculation shows that it is responsible for
roughly 15% of the DBPerformance alerts.
This patch rearranges the IF conditions so that the permission check is
performed last, and thus will be avoided if the previous condition is
false.
Change-Id: I45a18a244a26df09beb12e198e0e91a465bd1907
*/
function getUndeleteLink() {
$action = $this->getRequest()->getVal( 'action', 'view' );
+ $title = $this->getTitle();
- if ( $this->getTitle()->userCan( 'deletedhistory', $this->getUser() ) &&
- ( !$this->getTitle()->exists() || $action == 'history' ) ) {
- $n = $this->getTitle()->isDeleted();
+ if ( ( !$title->exists() || $action == 'history' ) &&
+ $title->userCan( 'deletedhistory', $this->getUser() )
+ ) {
+ $n = $title->isDeleted();
if ( $n ) {
if ( $this->getTitle()->quickUserCan( 'undelete', $this->getUser() ) ) {