From 73969d74cd005659768526cdde4521c9de6cafdc Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Sun, 6 Mar 2016 00:07:06 +0000 Subject: [PATCH] Simplify showtabdialog logic a little bit Don't unnecessarily nest if statements, don't check tabs preference twice Change-Id: I788d978b2e13030104be7ea295137a09abc032a8 --- VisualEditor.hooks.php | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index 94bbf67636..77466e236d 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -234,32 +234,28 @@ class VisualEditorHooks { return true; } + $dbr = wfGetDB( DB_SLAVE ); if ( $config->get( 'VisualEditorUseSingleEditTab' ) && - $user->getOption( 'visualeditor-tabs' ) !== 'multi-tab' + !$user->isAnon() && + !$user->getOption( 'visualeditor-autodisable' ) && + !$user->getOption( 'visualeditor-betatempdisable' ) && + !$user->getOption( 'visualeditor-hidetabdialog' ) && + $user->getOption( 'visualeditor-tabs' ) === 'remember-last' && + $dbr->select( + 'revision', + '1', + [ + 'rev_user' => $user->getId(), + 'rev_timestamp < ' . $dbr->addQuotes( + $config->get( 'VisualEditorSingleEditTabSwitchTime' ) + ) + ], + __METHOD__, + [ 'LIMIT' => 1 ] + )->numRows() === 1 ) { - $dbr = wfGetDB( DB_SLAVE ); - if ( - !$user->isAnon() && - !$user->getOption( 'visualeditor-autodisable' ) && - !$user->getOption( 'visualeditor-betatempdisable' ) && - !$user->getOption( 'visualeditor-hidetabdialog' ) && - $user->getOption( 'visualeditor-tabs' ) === 'remember-last' && - $dbr->select( - 'revision', - '1', - [ - 'rev_user' => $user->getId(), - 'rev_timestamp < ' . $dbr->addQuotes( - $config->get( 'VisualEditorSingleEditTabSwitchTime' ) - ) - ], - __METHOD__, - [ 'LIMIT' => 1 ] - )->numRows() === 1 - ) { - $links['views']['edit']['class'] .= ' visualeditor-showtabdialog'; - } + $links['views']['edit']['class'] .= ' visualeditor-showtabdialog'; } // Exit if the user doesn't have VE enabled