MediaWiki REL1_33
TestRecentChangesHelper.php
Go to the documentation of this file.
1<?php
2
4
11
12 public function makeEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid,
13 $timestamp, $counter, $watchingUsers
14 ) {
15 $attribs = array_merge(
16 $this->getDefaultAttributes( $titleText, $timestamp ),
17 [
18 'rc_user' => $user->getId(),
19 'rc_user_text' => $user->getName(),
20 'rc_this_oldid' => $thisid,
21 'rc_last_oldid' => $lastid,
22 'rc_cur_id' => $curid
23 ]
24 );
25
26 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
27 }
28
29 public function makeLogRecentChange(
30 $logType, $logAction, User $user, $titleText, $timestamp, $counter, $watchingUsers
31 ) {
32 $attribs = array_merge(
33 $this->getDefaultAttributes( $titleText, $timestamp ),
34 [
35 'rc_cur_id' => 0,
36 'rc_user' => $user->getId(),
37 'rc_user_text' => $user->getName(),
38 'rc_this_oldid' => 0,
39 'rc_last_oldid' => 0,
40 'rc_old_len' => null,
41 'rc_new_len' => null,
42 'rc_type' => 3,
43 'rc_logid' => 25,
44 'rc_log_type' => $logType,
45 'rc_log_action' => $logAction,
46 'rc_source' => 'mw.log'
47 ]
48 );
49
50 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
51 }
52
53 public function makeDeletedEditRecentChange( User $user, $titleText, $timestamp, $curid,
54 $thisid, $lastid, $counter, $watchingUsers
55 ) {
56 $attribs = array_merge(
57 $this->getDefaultAttributes( $titleText, $timestamp ),
58 [
59 'rc_user' => $user->getId(),
60 'rc_user_text' => $user->getName(),
61 'rc_deleted' => 5,
62 'rc_cur_id' => $curid,
63 'rc_this_oldid' => $thisid,
64 'rc_last_oldid' => $lastid
65 ]
66 );
67
68 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
69 }
70
71 public function makeNewBotEditRecentChange( User $user, $titleText, $curid, $thisid, $lastid,
72 $timestamp, $counter, $watchingUsers
73 ) {
74 $attribs = array_merge(
75 $this->getDefaultAttributes( $titleText, $timestamp ),
76 [
77 'rc_user' => $user->getId(),
78 'rc_user_text' => $user->getName(),
79 'rc_this_oldid' => $thisid,
80 'rc_last_oldid' => $lastid,
81 'rc_cur_id' => $curid,
82 'rc_type' => 1,
83 'rc_bot' => 1,
84 'rc_source' => 'mw.new'
85 ]
86 );
87
88 return $this->makeRecentChange( $attribs, $counter, $watchingUsers );
89 }
90
91 private function makeRecentChange( $attribs, $counter, $watchingUsers ) {
92 $change = new RecentChange();
93 $change->setAttribs( $attribs );
94 $change->counter = $counter;
95 $change->numberofWatchingusers = $watchingUsers;
96
97 return $change;
98 }
99
100 public function getCacheEntry( $recentChange ) {
101 $rcCacheFactory = new RCCacheEntryFactory(
102 new RequestContext(),
103 [ 'diff' => 'diff', 'cur' => 'cur', 'last' => 'last' ],
104 MediaWikiServices::getInstance()->getLinkRenderer()
105 );
106 return $rcCacheFactory->newFromRecentChange( $recentChange, false );
107 }
108
110 User $user, $titleText, $curid, $thisid, $lastid, $timestamp
111 ) {
112 $attribs = array_merge(
113 $this->getDefaultAttributes( $titleText, $timestamp ),
114 [
115 'rc_type' => RC_CATEGORIZE,
116 'rc_user' => $user->getId(),
117 'rc_user_text' => $user->getName(),
118 'rc_this_oldid' => $thisid,
119 'rc_last_oldid' => $lastid,
120 'rc_cur_id' => $curid,
121 'rc_comment' => '[[:Testpage]] added to category',
122 'rc_comment_text' => '[[:Testpage]] added to category',
123 'rc_comment_data' => null,
124 'rc_old_len' => 0,
125 'rc_new_len' => 0,
126 ]
127 );
128
129 return $this->makeRecentChange( $attribs, 0, 0 );
130 }
131
132 private function getDefaultAttributes( $titleText, $timestamp ) {
133 return [
134 'rc_id' => 545,
135 'rc_user' => 0,
136 'rc_user_text' => '127.0.0.1',
137 'rc_ip' => '127.0.0.1',
138 'rc_title' => $titleText,
139 'rc_namespace' => 0,
140 'rc_timestamp' => $timestamp,
141 'rc_old_len' => 212,
142 'rc_new_len' => 188,
143 'rc_comment' => '',
144 'rc_comment_text' => '',
145 'rc_comment_data' => null,
146 'rc_minor' => 0,
147 'rc_bot' => 0,
148 'rc_type' => 0,
149 'rc_patrolled' => 1,
150 'rc_deleted' => 0,
151 'rc_logid' => 0,
152 'rc_log_type' => null,
153 'rc_log_action' => '',
154 'rc_params' => '',
155 'rc_source' => 'mw.edit'
156 ];
157 }
158
159 public function getTestContext( User $user ) {
160 $context = new RequestContext();
161 $context->setLanguage( 'en' );
162
163 $context->setUser( $user );
164
165 $title = Title::newFromText( 'RecentChanges', NS_SPECIAL );
166 $context->setTitle( $title );
167
168 return $context;
169 }
170}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
MediaWikiServices is the service locator for the application scope of MediaWiki.
Utility class for creating new RC entries.
Group all the pieces relevant to the context of a request into one instance.
Helper for generating test recent changes entries.
makeDeletedEditRecentChange(User $user, $titleText, $timestamp, $curid, $thisid, $lastid, $counter, $watchingUsers)
makeNewBotEditRecentChange(User $user, $titleText, $curid, $thisid, $lastid, $timestamp, $counter, $watchingUsers)
makeRecentChange( $attribs, $counter, $watchingUsers)
makeCategorizationRecentChange(User $user, $titleText, $curid, $thisid, $lastid, $timestamp)
makeEditRecentChange(User $user, $titleText, $curid, $thisid, $lastid, $timestamp, $counter, $watchingUsers)
makeLogRecentChange( $logType, $logAction, User $user, $titleText, $timestamp, $counter, $watchingUsers)
getDefaultAttributes( $titleText, $timestamp)
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
const NS_SPECIAL
Definition Defines.php:62
const RC_CATEGORIZE
Definition Defines.php:155
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2848
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:955
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:2012
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37