| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
namespace MediaWiki\Extension\DiscussionTools\Hooks; |
| 11 |
|
| 12 |
use LqtDispatch; |
| 13 |
use MediaWiki\Context\IContextSource; |
| 14 |
use MediaWiki\Context\RequestContext; |
| 15 |
use MediaWiki\Extension\DiscussionTools\CommentParser; |
| 16 |
use MediaWiki\Extension\DiscussionTools\CommentUtils; |
| 17 |
use MediaWiki\Extension\DiscussionTools\ContentThreadItemSet; |
| 18 |
use MediaWiki\Linker\LinkTarget; |
| 19 |
use MediaWiki\MediaWikiServices; |
| 20 |
use MediaWiki\Output\OutputPage; |
| 21 |
use MediaWiki\Page\ParserOutputAccess; |
| 22 |
use MediaWiki\Parser\ParserOptions; |
| 23 |
use MediaWiki\Registration\ExtensionRegistry; |
| 24 |
use MediaWiki\Revision\RevisionRecord; |
| 25 |
use MediaWiki\Title\Title; |
| 26 |
use MediaWiki\Title\TitleValue; |
| 27 |
use MediaWiki\User\UserIdentity; |
| 28 |
use RuntimeException; |
| 29 |
use Wikimedia\Assert\Assert; |
| 30 |
use Wikimedia\Parsoid\Core\ResourceLimitExceededException; |
| 31 |
use Wikimedia\Parsoid\Utils\DOMCompat; |
| 32 |
use Wikimedia\Parsoid\Utils\DOMUtils; |
| 33 |
use Wikimedia\Rdbms\IDBAccessObject; |
| 34 |
|
| 35 |
class HookUtils { |
| 36 |
|
| 37 |
public const REPLYTOOL = 'replytool'; |
| 38 |
public const NEWTOPICTOOL = 'newtopictool'; |
| 39 |
public const SOURCEMODETOOLBAR = 'sourcemodetoolbar'; |
| 40 |
public const TOPICSUBSCRIPTION = 'topicsubscription'; |
| 41 |
public const AUTOTOPICSUB = 'autotopicsub'; |
| 42 |
public const VISUALENHANCEMENTS = 'visualenhancements'; |
| 43 |
public const VISUALENHANCEMENTS_REPLY = 'visualenhancements_reply'; |
| 44 |
public const VISUALENHANCEMENTS_PAGEFRAME = 'visualenhancements_pageframe'; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public const FEATURES = [ |
| 52 |
|
| 53 |
self::REPLYTOOL, |
| 54 |
self::NEWTOPICTOOL, |
| 55 |
self::SOURCEMODETOOLBAR, |
| 56 |
self::TOPICSUBSCRIPTION, |
| 57 |
self::AUTOTOPICSUB, |
| 58 |
self::VISUALENHANCEMENTS, |
| 59 |
self::VISUALENHANCEMENTS_REPLY, |
| 60 |
self::VISUALENHANCEMENTS_PAGEFRAME, |
| 61 |
]; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public const CONFIGS = [ |
| 68 |
self::VISUALENHANCEMENTS, |
| 69 |
self::VISUALENHANCEMENTS_REPLY, |
| 70 |
self::VISUALENHANCEMENTS_PAGEFRAME, |
| 71 |
]; |
| 72 |
|
| 73 |
public const FEATURES_CONFLICT_WITH_GADGET = [ |
| 74 |
self::REPLYTOOL, |
| 75 |
]; |
| 76 |
|
| 77 |
private const CACHED_PAGE_PROPS = [ |
| 78 |
'newsectionlink', |
| 79 |
'nonewsectionlink', |
| 80 |
'notalk', |
| 81 |
'archivedtalk', |
| 82 |
]; |
| 83 |
private static array $propCache = []; |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public static function hasPagePropCached( Title $title, string $prop ): bool { |
| 93 |
Assert::parameter( |
| 94 |
in_array( $prop, self::CACHED_PAGE_PROPS, true ), |
| 95 |
'$prop', |
| 96 |
'must be one of the cached properties' |
| 97 |
); |
| 98 |
$id = $title->getArticleId(); |
| 99 |
if ( !isset( self::$propCache[ $id ] ) ) { |
| 100 |
$services = MediaWikiServices::getInstance(); |
| 101 |
|
| 102 |
$pagePropsPerId = $services->getPageProps()->getProperties( $title, self::CACHED_PAGE_PROPS ); |
| 103 |
if ( $pagePropsPerId ) { |
| 104 |
self::$propCache += $pagePropsPerId; |
| 105 |
} else { |
| 106 |
self::$propCache[ $id ] = []; |
| 107 |
} |
| 108 |
} |
| 109 |
return isset( self::$propCache[ $id ][ $prop ] ); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public static function parseRevisionParsoidHtml( |
| 125 |
RevisionRecord $revRecord, |
| 126 |
$updateParserCacheFor |
| 127 |
): ContentThreadItemSet { |
| 128 |
$services = MediaWikiServices::getInstance(); |
| 129 |
$mainConfig = $services->getMainConfig(); |
| 130 |
$parserOutputAccess = $services->getParserOutputAccess(); |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
$pageRecord = $services->getPageStore()->getPageById( $revRecord->getPageId() ) ?: |
| 135 |
$services->getPageStore()->getPageById( $revRecord->getPageId(), IDBAccessObject::READ_LATEST ); |
| 136 |
Assert::postcondition( $pageRecord !== null, 'Revision had no page' ); |
| 137 |
|
| 138 |
$parserOptions = ParserOptions::newFromAnon(); |
| 139 |
$parserOptions->setUseParsoid(); |
| 140 |
|
| 141 |
if ( $updateParserCacheFor ) { |
| 142 |
|
| 143 |
$parserOptions->setRenderReason( $updateParserCacheFor ); |
| 144 |
} |
| 145 |
|
| 146 |
$status = $parserOutputAccess->getParserOutput( |
| 147 |
$pageRecord, |
| 148 |
$parserOptions, |
| 149 |
$revRecord, |
| 150 |
|
| 151 |
$updateParserCacheFor ? 0 : ParserOutputAccess::OPT_NO_UPDATE_CACHE |
| 152 |
); |
| 153 |
|
| 154 |
if ( !$status->isOK() ) { |
| 155 |
[ 'message' => $key, 'params' => $params ] = $status->getErrors()[0]; |
| 156 |
|
| 157 |
|
| 158 |
if ( $status->hasMessage( 'parsoid-resource-limit-exceeded' ) ) { |
| 159 |
throw new ResourceLimitExceededException( $params[0] ?? '' ); |
| 160 |
} |
| 161 |
$message = wfMessage( $key, ...$params ); |
| 162 |
throw new RuntimeException( $message->inLanguage( 'en' )->useDatabase( false )->text() ); |
| 163 |
} |
| 164 |
|
| 165 |
$parserOutput = $status->getValue(); |
| 166 |
$html = $parserOutput->getRawText(); |
| 167 |
|
| 168 |
|
| 169 |
$doc = DOMUtils::parseHTML( $html ); |
| 170 |
$container = DOMCompat::getBody( $doc ); |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
CommentUtils::unwrapParsoidSections( $container ); |
| 175 |
|
| 176 |
|
| 177 |
$parser = $services->getService( 'DiscussionTools.CommentParser' ); |
| 178 |
$title = TitleValue::newFromPage( $revRecord->getPage() ); |
| 179 |
return $parser->parse( $container, $title ); |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
public static function featureConflictsWithGadget( UserIdentity $user, string $feature ) { |
| 188 |
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory() |
| 189 |
->makeConfig( 'discussiontools' ); |
| 190 |
$gadgetName = $dtConfig->get( 'DiscussionToolsConflictingGadgetName' ); |
| 191 |
if ( !$gadgetName ) { |
| 192 |
return false; |
| 193 |
} |
| 194 |
|
| 195 |
if ( !in_array( $feature, static::FEATURES_CONFLICT_WITH_GADGET, true ) ) { |
| 196 |
return false; |
| 197 |
} |
| 198 |
|
| 199 |
$extensionRegistry = ExtensionRegistry::getInstance(); |
| 200 |
if ( $extensionRegistry->isLoaded( 'Gadgets' ) ) { |
| 201 |
$gadgetsRepo = MediaWikiServices::getInstance()->getService( 'GadgetsRepo' ); |
| 202 |
$match = array_search( $gadgetName, $gadgetsRepo->getGadgetIds(), true ); |
| 203 |
if ( $match !== false ) { |
| 204 |
try { |
| 205 |
return $gadgetsRepo->getGadget( $gadgetName ) |
| 206 |
->isEnabled( $user ); |
| 207 |
} catch ( \InvalidArgumentException $e ) { |
| 208 |
return false; |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
return false; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
public static function isFeatureAvailableToUser( UserIdentity $user, ?string $feature = null ): bool { |
| 224 |
$services = MediaWikiServices::getInstance(); |
| 225 |
$dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' ); |
| 226 |
|
| 227 |
$userIdentityUtils = $services->getUserIdentityUtils(); |
| 228 |
if ( |
| 229 |
( $feature === static::TOPICSUBSCRIPTION || $feature === static::AUTOTOPICSUB ) && |
| 230 |
|
| 231 |
( !$user->isRegistered() || $userIdentityUtils->isTemp( $user ) || |
| 232 |
!ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) |
| 233 |
) { |
| 234 |
return false; |
| 235 |
} |
| 236 |
|
| 237 |
$optionsLookup = $services->getUserOptionsLookup(); |
| 238 |
|
| 239 |
if ( $feature ) { |
| 240 |
|
| 241 |
if ( !in_array( $feature, static::CONFIGS, true ) ) { |
| 242 |
|
| 243 |
return true; |
| 244 |
} |
| 245 |
if ( $dtConfig->get( 'DiscussionTools_' . $feature ) !== 'default' ) { |
| 246 |
|
| 247 |
return $dtConfig->get( 'DiscussionTools_' . $feature ) === 'available'; |
| 248 |
} |
| 249 |
} else { |
| 250 |
|
| 251 |
|
| 252 |
return true; |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
if ( $dtConfig->get( 'DiscussionToolsBeta' ) ) { |
| 258 |
$betaenabled = $optionsLookup->getOption( $user, 'discussiontools-betaenable', 0 ); |
| 259 |
return (bool)$betaenabled; |
| 260 |
} |
| 261 |
|
| 262 |
return true; |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
public static function isFeatureEnabledForUser( UserIdentity $user, ?string $feature = null ): bool { |
| 274 |
if ( !static::isFeatureAvailableToUser( $user, $feature ) ) { |
| 275 |
return false; |
| 276 |
} |
| 277 |
$services = MediaWikiServices::getInstance(); |
| 278 |
$optionsLookup = $services->getUserOptionsLookup(); |
| 279 |
if ( $feature ) { |
| 280 |
if ( static::featureConflictsWithGadget( $user, $feature ) ) { |
| 281 |
return false; |
| 282 |
} |
| 283 |
|
| 284 |
$enabled = $optionsLookup->getOption( $user, 'discussiontools-' . $feature ); |
| 285 |
|
| 286 |
return $enabled === null ? true : $enabled; |
| 287 |
} else { |
| 288 |
|
| 289 |
foreach ( static::FEATURES as $feat ) { |
| 290 |
if ( $optionsLookup->getOption( $user, 'discussiontools-' . $feat ) ) { |
| 291 |
return true; |
| 292 |
} |
| 293 |
} |
| 294 |
return false; |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
public static function isAvailableForTitle( Title $title, ?string $feature = null ): bool { |
| 309 |
|
| 310 |
if ( $title->getContentModel() !== CONTENT_MODEL_WIKITEXT ) { |
| 311 |
return false; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
if ( ExtensionRegistry::getInstance()->isLoaded( 'Liquid Threads' ) && LqtDispatch::isLqtPage( $title ) ) { |
| 316 |
return false; |
| 317 |
} |
| 318 |
if ( !$title->canExist() ) { |
| 319 |
return false; |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
if ( static::hasPagePropCached( $title, 'notalk' ) ) { |
| 324 |
return false; |
| 325 |
} |
| 326 |
if ( |
| 327 |
$feature === static::REPLYTOOL && |
| 328 |
static::hasPagePropCached( $title, 'archivedtalk' ) |
| 329 |
) { |
| 330 |
return false; |
| 331 |
} |
| 332 |
|
| 333 |
$services = MediaWikiServices::getInstance(); |
| 334 |
|
| 335 |
if ( $feature === static::VISUALENHANCEMENTS ) { |
| 336 |
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'discussiontools' ); |
| 337 |
|
| 338 |
return $title->isTalkPage() || ( |
| 339 |
|
| 340 |
( |
| 341 |
static::hasPagePropCached( $title, 'newsectionlink' ) || |
| 342 |
static::hasPagePropCached( $title, 'archivedtalk' ) |
| 343 |
) && |
| 344 |
|
| 345 |
( |
| 346 |
!$title->inNamespace( NS_MAIN ) || |
| 347 |
$services->getNamespaceInfo()->wantSignatures( $title->getNamespace() ) |
| 348 |
) |
| 349 |
); |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
return ( |
| 354 |
|
| 355 |
|
| 356 |
$services->getNamespaceInfo()->wantSignatures( $title->getNamespace() ) || |
| 357 |
|
| 358 |
static::hasPagePropCached( $title, 'newsectionlink' ) |
| 359 |
); |
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
public static function isFeatureEnabledForOutput( OutputPage $output, ?string $feature = null ): bool { |
| 371 |
|
| 372 |
if ( |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
$feature !== static::NEWTOPICTOOL && !( |
| 377 |
in_array( $output->getActionName(), [ 'view', 'edit', 'submit' ], true ) || |
| 378 |
|
| 379 |
( |
| 380 |
$output->getActionName() === 'history' && |
| 381 |
$feature === static::TOPICSUBSCRIPTION |
| 382 |
) |
| 383 |
) |
| 384 |
) { |
| 385 |
return false; |
| 386 |
} |
| 387 |
|
| 388 |
$title = $output->getTitle(); |
| 389 |
|
| 390 |
if ( !$title ) { |
| 391 |
return false; |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
if ( |
| 397 |
( $feature === static::TOPICSUBSCRIPTION || $feature === static::AUTOTOPICSUB ) && |
| 398 |
$title->equals( $output->getUser()->getTalkPage() ) |
| 399 |
) { |
| 400 |
return false; |
| 401 |
} |
| 402 |
|
| 403 |
|
| 404 |
if ( ( |
| 405 |
$feature === static::VISUALENHANCEMENTS_REPLY || |
| 406 |
$feature === static::VISUALENHANCEMENTS_PAGEFRAME |
| 407 |
) && !self::isFeatureEnabledForOutput( $output, static::VISUALENHANCEMENTS ) ) { |
| 408 |
return false; |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
$queryEnable = $output->getRequest()->getRawVal( 'dtenable' ) ?: |
| 413 |
|
| 414 |
RequestContext::getMain()->getRequest()->getRawVal( 'dtenable' ); |
| 415 |
|
| 416 |
if ( $queryEnable ) { |
| 417 |
return true; |
| 418 |
} |
| 419 |
|
| 420 |
if ( $queryEnable === '0' ) { |
| 421 |
|
| 422 |
return false; |
| 423 |
} |
| 424 |
|
| 425 |
if ( !static::isAvailableForTitle( $title, $feature ) ) { |
| 426 |
return false; |
| 427 |
} |
| 428 |
|
| 429 |
$isMobile = false; |
| 430 |
if ( ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) { |
| 431 |
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' ); |
| 432 |
$isMobile = $mobFrontContext->shouldDisplayMobileView(); |
| 433 |
} |
| 434 |
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'discussiontools' ); |
| 435 |
|
| 436 |
if ( $isMobile ) { |
| 437 |
return $feature === null || |
| 438 |
$feature === static::REPLYTOOL || |
| 439 |
$feature === static::NEWTOPICTOOL || |
| 440 |
$feature === static::SOURCEMODETOOLBAR || |
| 441 |
|
| 442 |
|
| 443 |
( $feature === static::TOPICSUBSCRIPTION && $output->getUser()->isNamed() ) || |
| 444 |
$feature === static::VISUALENHANCEMENTS || |
| 445 |
$feature === static::VISUALENHANCEMENTS_REPLY || |
| 446 |
$feature === static::VISUALENHANCEMENTS_PAGEFRAME; |
| 447 |
} |
| 448 |
|
| 449 |
return static::isFeatureEnabledForUser( $output->getUser(), $feature ); |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
public static function shouldShowNewSectionTab( IContextSource $context ): bool { |
| 456 |
$title = $context->getTitle(); |
| 457 |
$output = $context->getOutput(); |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
return ( |
| 465 |
!static::hasPagePropCached( $title, 'nonewsectionlink' ) && |
| 466 |
( ( $title->isTalkPage() && !$title->isRedirect() && $output->isRevisionCurrent() ) || |
| 467 |
static::hasPagePropCached( $title, 'newsectionlink' ) ) |
| 468 |
); |
| 469 |
} |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
public static function shouldOpenNewTopicTool( IContextSource $context ): bool { |
| 475 |
$req = $context->getRequest(); |
| 476 |
$out = $context->getOutput(); |
| 477 |
$hasPreload = $req->getCheck( 'editintro' ) || $req->getCheck( 'preload' ) || |
| 478 |
$req->getCheck( 'preloadparams' ) || $req->getCheck( 'preloadtitle' ) || |
| 479 |
|
| 480 |
$req->getCheck( 'wpTextbox1' ); |
| 481 |
|
| 482 |
return ( |
| 483 |
|
| 484 |
|
| 485 |
( $req->getRawVal( 'action' ) === 'edit' || $req->getRawVal( 'veaction' ) === 'editsource' ) && |
| 486 |
$req->getRawVal( 'section' ) === 'new' && |
| 487 |
|
| 488 |
( $req->getCheck( 'dtpreload' ) || !$hasPreload ) && |
| 489 |
|
| 490 |
static::isFeatureEnabledForOutput( $out, static::NEWTOPICTOOL ) |
| 491 |
); |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public static function shouldDisplayEmptyState( IContextSource $context ): bool { |
| 498 |
$req = $context->getRequest(); |
| 499 |
$out = $context->getOutput(); |
| 500 |
$user = $context->getUser(); |
| 501 |
$title = $context->getTitle(); |
| 502 |
|
| 503 |
$optionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup(); |
| 504 |
|
| 505 |
return ( |
| 506 |
( |
| 507 |
|
| 508 |
( |
| 509 |
$req->getRawVal( 'action' ) === 'edit' && $req->getRawVal( 'redlink' ) === '1' && |
| 510 |
er |
| 511 |
$optionsLookup->getOption( $user, 'discussiontools-newtopictool-createpage' ) |
| 512 |
) || |
| 513 |
|
| 514 |
static::shouldOpenNewTopicTool( $context ) || |
| 515 |
|
| 516 |
( $req->getRawVal( 'action' ) ?? 'view' ) === 'view' |
| 517 |
) && |
| 518 |
|
| 519 |
$title->isTalkPage() && |
| 520 |
|
| 521 |
static::pageSubjectExists( $title ) && |
| 522 |
|
| 523 |
|
| 524 |
$req->getIntOrNull( 'oldid' ) === null && |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
static::shouldShowNewSectionTab( $context ) && |
| 529 |
|
| 530 |
static::isFeatureEnabledForOutput( $out, static::NEWTOPICTOOL ) |
| 531 |
); |
| 532 |
} |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
private static function pageSubjectExists( LinkTarget $talkPage ): bool { |
| 539 |
$services = MediaWikiServices::getInstance(); |
| 540 |
$namespaceInfo = $services->getNamespaceInfo(); |
| 541 |
Assert::precondition( $namespaceInfo->isTalk( $talkPage->getNamespace() ), "Page is a talk page" ); |
| 542 |
|
| 543 |
if ( $talkPage->inNamespace( NS_USER_TALK ) && !str_contains( $talkPage->getText(), '/' ) ) { |
| 544 |
if ( $services->getUserNameUtils()->isIP( $talkPage->getText() ) ) { |
| 545 |
return true; |
| 546 |
} |
| 547 |
$subjectUser = $services->getUserFactory()->newFromName( $talkPage->getText() ); |
| 548 |
if ( $subjectUser && $subjectUser->isRegistered() ) { |
| 549 |
return true; |
| 550 |
} |
| 551 |
return false; |
| 552 |
} else { |
| 553 |
$subjectPage = $namespaceInfo->getSubjectPage( $talkPage ); |
| 554 |
return $services->getPageStore()->getPageForLink( $subjectPage )->exists(); |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
public static function shouldAddAutoSubscription( UserIdentity $user, Title $title ): bool { |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
if ( $title->inNamespace( NS_USER_TALK ) && $title->getText() === $user->getName() ) { |
| 569 |
return false; |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
$user = MediaWikiServices::getInstance() |
| 575 |
->getUserFactory() |
| 576 |
->newFromUserIdentity( $user ); |
| 577 |
if ( $user->isBot() ) { |
| 578 |
return false; |
| 579 |
} |
| 580 |
|
| 581 |
|
| 582 |
return static::isAvailableForTitle( $title ) && |
| 583 |
static::isFeatureEnabledForUser( $user, static::AUTOTOPICSUB ); |
| 584 |
} |
| 585 |
} |