MediaWiki  master
DeprecatedHooks.php
Go to the documentation of this file.
1 <?php
24 
25 use InvalidArgumentException;
26 
28 
36  private $deprecatedHooks = [
37  'AddNewAccount' => [ 'deprecatedVersion' => '1.27', 'silent' => true ],
38  'BaseTemplateAfterPortlet' => [ 'deprecatedVersion' => '1.35' ],
39  'BeforeParserFetchTemplateAndtitle' => [ 'deprecatedVersion' => '1.36' ],
40  'BeforeParserrenderImageGallery' => [ 'deprecatedVersion' => '1.35' ],
41  'EditPageBeforeEditToolbar' => [ 'deprecatedVersion' => '1.36' ],
42  'InternalParseBeforeSanitize' => [ 'deprecatedVersion' => '1.35' ],
43  'LocalFile::getHistory' => [ 'deprecatedVersion' => '1.37' ],
44  'MagicWordwgVariableIDs' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
45  'PageContentSave' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
46  'ParserGetVariableValueVarCache' => [ 'deprecatedVersion' => '1.35' ],
47  'ParserSectionCreate' => [ 'deprecatedVersion' => '1.35' ],
48  'ParserTestTables' => [ 'deprecatedVersion' => '1.36', 'silent' => true ],
49  'PrefixSearchBackend' => [ 'deprecatedVersion' => '1.27', 'silent' => true ],
50  'ProtectionForm::buildForm' => [ 'deprecatedVersion' => '1.36', 'silent' => true ],
51  'ResourceLoaderTestModules' => [ 'deprecatedVersion' => '1.33' ],
52  'RollbackComplete' => [ 'deprecatedVersion' => '1.36', 'silent' => true ],
53  'SkinGetPoweredBy' => [ 'deprecatedVersion' => '1.37' ],
54  'SpecialMuteSubmit' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
55  'UserLoadFromDatabase' => [ 'deprecatedVersion' => '1.37' ],
56  'UserSetCookies' => [ 'deprecatedVersion' => '1.27' ],
57  'WikiPageDeletionUpdates' => [ 'deprecatedVersion' => '1.32', 'silent' => true ],
58  'userCan' => [ 'deprecatedVersion' => '1.37' ],
59  'ArticleDelete' => [ 'deprecatedVersion' => '1.37', 'silent' => true ],
60  'ArticleDeleteComplete' => [ 'deprecatedVersion' => '1.37', 'silent' => true ],
61  ];
62 
71  public function __construct( array $deprecatedHooks = [] ) {
72  foreach ( $deprecatedHooks as $hook => $info ) {
73  $this->markDeprecated(
74  $hook,
75  $info['deprecatedVersion'],
76  $info['component'] ?? false,
77  $info['silent'] ?? false
78  );
79  }
80  }
81 
94  public function markDeprecated( string $hook, string $version,
95  ?string $component = null, bool $silent = false
96  ): void {
97  if ( isset( $this->deprecatedHooks[$hook] ) ) {
98  throw new InvalidArgumentException(
99  "Cannot mark hook '$hook' deprecated with version $version. " .
100  "It is already marked deprecated with version " .
101  $this->deprecatedHooks[$hook]['deprecatedVersion']
102  );
103  }
104  $hookInfo = [
105  'deprecatedVersion' => $version,
106  'silent' => $silent
107  ];
108  if ( $component ) {
109  $hookInfo['component'] = $component;
110  }
111  $this->deprecatedHooks[$hook] = $hookInfo;
112  }
113 
119  public function isHookDeprecated( string $hook ): bool {
120  return isset( $this->deprecatedHooks[$hook] );
121  }
122 
128  public function getDeprecationInfo( ?string $hook = null ): ?array {
129  if ( !$hook ) {
130  return $this->deprecatedHooks;
131  }
132  return $this->deprecatedHooks[$hook] ?? null;
133  }
134 }
true
return true
Definition: router.php:90
MediaWiki\HookContainer\DeprecatedHooks\__construct
__construct(array $deprecatedHooks=[])
Definition: DeprecatedHooks.php:71
MediaWiki\HookContainer\DeprecatedHooks
Definition: DeprecatedHooks.php:27
MediaWiki\HookContainer
Definition: DeprecatedHooks.php:23
MediaWiki\HookContainer\DeprecatedHooks\markDeprecated
markDeprecated(string $hook, string $version, ?string $component=null, bool $silent=false)
For use by extensions, to add to list of deprecated hooks.
Definition: DeprecatedHooks.php:94
MediaWiki\HookContainer\DeprecatedHooks\getDeprecationInfo
getDeprecationInfo(?string $hook=null)
Gets deprecation info for a specific hook or all hooks if hook not specified.
Definition: DeprecatedHooks.php:128
MediaWiki\HookContainer\DeprecatedHooks\$deprecatedHooks
array[] $deprecatedHooks
List of deprecated hooks.
Definition: DeprecatedHooks.php:36
MediaWiki\HookContainer\DeprecatedHooks\isHookDeprecated
isHookDeprecated(string $hook)
Checks whether hook is marked deprecated.
Definition: DeprecatedHooks.php:119