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  'ArticleEditUpdates' => [ 'deprecatedVersion' => '1.35' ],
39  'ArticleEditUpdatesDeleteFromRecentchanges' => [ 'deprecatedVersion' => '1.35' ],
40  'ArticleRevisionUndeleted' => [ 'deprecatedVersion' => '1.35' ],
41  'ArticleRollbackComplete' => [ 'deprecatedVersion' => '1.35' ],
42  'BaseTemplateAfterPortlet' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
43  'BaseTemplateToolbox' => [ 'deprecatedVersion' => '1.35' ],
44  'BeforeHttpsRedirect' => [ 'deprecatedVersion' => '1.35' ],
45  'BeforeParserrenderImageGallery' => [ 'deprecatedVersion' => '1.35' ],
46  'CanIPUseHTTPS' => [ 'deprecatedVersion' => '1.35' ],
47  'DiffRevisionTools' => [ 'deprecatedVersion => 1.35' ],
48  'DiffViewHeader' => [ 'deprecatedVersion' => '1.35' ],
49  'HistoryRevisionTools' => [ 'deprecatedVersion => 1.35' ],
50  'InternalParseBeforeSanitize' => [ 'deprecatedVersion' => '1.35' ],
51  'MagicWordwgVariableIDs' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
52  'NewRevisionFromEditComplete' => [ 'deprecatedVersion' => '1.35' ],
53  'PageContentInsertComplete' => [ 'deprecatedVersion' => '1.35' ],
54  'PageContentSave' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
55  'PageContentSaveComplete' => [ 'deprecatedVersion' => '1.35' ],
56  'ParserFetchTemplate' => [ 'deprecatedVersion' => '1.35' ],
57  'ParserGetVariableValueVarCache' => [ 'deprecatedVersion' => '1.35' ],
58  'ParserSectionCreate' => [ 'deprecatedVersion' => '1.35' ],
59  'PrefixSearchBackend' => [ 'deprecatedVersion' => '1.27', 'silent' => true ],
60  'ResourceLoaderTestModules' => [ 'deprecatedVersion' => '1.33' ],
61  'RevisionInsertComplete' => [ 'deprecatedVersion' => '1.31' ],
62  'RollbackComplete' => [ 'deprecatedVersion' => '1.36', 'silent' => true ],
63  'SecondaryDataUpdates' => [ 'deprecatedVersion' => '1.32', 'silent' => true ],
64  'SpecialMuteSubmit' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
65  'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' => [ 'deprecatedVersion' => '1.35' ],
66  'SkinTemplateOutputPageBeforeExec' => [ 'deprecatedVersion' => '1.35' ],
67  'SkinTemplatePreventOtherActiveTabs' => [ 'deprecatedVersion' => '1.35' ],
68  'SkinTemplateTabAction' => [ 'deprecatedVersion' => '1.35' ],
69  'SkinTemplateToolboxEnd' => [ 'deprecatedVersion' => '1.35' ],
70  'TitleMoveComplete' => [ 'deprecatedVersion' => '1.35' ],
71  'TitleMoveCompleting' => [ 'deprecatedVersion' => '1.35' ],
72  'UndeleteShowRevision' => [ 'deprecatedVersion' => '1.35' ],
73  'UserRequiresHTTPS' => [ 'deprecatedVersion' => '1.35' ],
74  'UserRetrieveNewTalks' => [ 'deprecatedVersion' => '1.35' ],
75  'UserSetCookies' => [ 'deprecatedVersion' => '1.27' ],
76  'WikiPageDeletionUpdates' => [ 'deprecatedVersion' => '1.32', 'silent' => true ],
77  ];
78 
87  public function __construct( array $deprecatedHooks = [] ) {
88  foreach ( $deprecatedHooks as $hook => $info ) {
89  $this->markDeprecated(
90  $hook,
91  $info['deprecatedVersion'],
92  $info['component'] ?? false,
93  $info['silent'] ?? false
94  );
95  }
96  }
97 
110  public function markDeprecated( string $hook, string $version,
111  ?string $component = null, bool $silent = false
112  ) : void {
113  if ( isset( $this->deprecatedHooks[$hook] ) ) {
114  throw new InvalidArgumentException(
115  "Cannot mark hook '$hook' deprecated with version $version. " .
116  "It is already marked deprecated with version " .
117  $this->deprecatedHooks[$hook]['deprecatedVersion']
118  );
119  }
120  $hookInfo = [
121  'deprecatedVersion' => $version,
122  'silent' => $silent
123  ];
124  if ( $component ) {
125  $hookInfo['component'] = $component;
126  }
127  $this->deprecatedHooks[$hook] = $hookInfo;
128  }
129 
135  public function isHookDeprecated( string $hook ) : bool {
136  return isset( $this->deprecatedHooks[$hook] );
137  }
138 
144  public function getDeprecationInfo( ?string $hook = null ) : ?array {
145  if ( !$hook ) {
146  return $this->deprecatedHooks;
147  }
148  return $this->deprecatedHooks[$hook] ?? null;
149  }
150 }
true
return true
Definition: router.php:90
MediaWiki\HookContainer\DeprecatedHooks\__construct
__construct(array $deprecatedHooks=[])
Definition: DeprecatedHooks.php:87
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:110
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:144
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:135