Merge "Swap conditions in onSpecialPageBeforeExecute"

This commit is contained in:
jenkins-bot 2023-12-07 17:32:52 +00:00 committed by Gerrit Code Review
commit a93e9cd07c

View file

@ -141,35 +141,33 @@ class Hooks implements
*/ */
public function onSpecialPageBeforeExecute( $special, $subpage ) { public function onSpecialPageBeforeExecute( $special, $subpage ) {
$name = $special->getName(); $name = $special->getName();
$out = $special->getOutput(); if ( !in_array( $name, [ 'Recentchanges', 'Userlogin', 'CreateAccount' ] ) ) {
$skin = $out->getSkin(); return;
}
$skin = $special->getSkin();
if ( !$skin instanceof SkinMinerva ) {
return;
}
$request = $special->getRequest(); $request = $special->getRequest();
if ( $name === 'Recentchanges' ) {
if ( $skin instanceof SkinMinerva ) { $isEnhancedDefaultForUser = MediaWikiServices::getInstance()
switch ( $name ) { ->getUserOptionsLookup()
case 'Recentchanges': ->getBoolOption( $special->getUser(), 'usenewrc' );
$isEnhancedDefaultForUser = MediaWikiServices::getInstance() $enhanced = $request->getBool( 'enhanced', $isEnhancedDefaultForUser );
->getUserOptionsLookup() if ( $enhanced ) {
->getBoolOption( $special->getUser(), 'usenewrc' ); $special->getOutput()->addHTML( Html::warningBox(
$enhanced = $request->getBool( 'enhanced', $isEnhancedDefaultForUser ); $special->msg( 'skin-minerva-recentchanges-warning-enhanced-not-supported' )->parse()
if ( $enhanced ) { ) );
$out->addHTML( Html::warningBox( }
$special->msg( 'skin-minerva-recentchanges-warning-enhanced-not-supported' )->parse() } else {
) ); // Add default warning message to Special:UserLogin and Special:UserCreate
} // if no warning message set.
break; if (
case 'Userlogin': !$request->getVal( 'warning' ) &&
case 'CreateAccount': !$special->getUser()->isRegistered() &&
// Add default warning message to Special:UserLogin and Special:UserCreate !$request->wasPosted()
// if no warning message set. ) {
if ( $request->setVal( 'warning', 'mobile-frontend-generic-login-new' );
!$request->getVal( 'warning' ) &&
!$special->getUser()->isRegistered() &&
!$request->wasPosted()
) {
$request->setVal( 'warning', 'mobile-frontend-generic-login-new' );
}
break;
} }
} }
} }