98 parent::__construct( $context, $linkRenderer );
99 $this->commentStore = $commentStore;
100 $this->linkBatchFactory = $linkBatchFactory;
101 $this->rowCommentFormatter = $rowCommentFormatter;
102 $this->userCache = $userCache;
103 $this->mConds = $conds;
104 $this->type = $type ?:
'edit';
105 $this->level = $level;
106 $this->
namespace = $namespace;
107 $this->sizetype = $sizetype;
108 $this->size = intval( $size );
109 $this->indefonly = (bool)$indefonly;
110 $this->cascadeonly = (bool)$cascadeonly;
111 $this->noredirect = (bool)$noredirect;
115 # Do a link batch query
116 $lb = $this->linkBatchFactory->newLinkBatch();
119 foreach ( $result as $row ) {
120 $lb->add( $row->page_namespace, $row->page_title );
121 if ( $row->actor_user !==
null ) {
122 $userids[] = $row->actor_user;
127 if ( count( $userids ) ) {
128 $this->userCache->doQuery( $userids, [], __METHOD__ );
129 foreach ( $userids as $userid ) {
130 $name = $this->userCache->getProp( $userid,
'name' );
131 if ( $name !==
false ) {
141 $this->formattedComments = $this->rowCommentFormatter->formatRows( $result,
'log_comment' );
176 case 'log_timestamp':
178 if ( $value ===
null ) {
179 $formatted = Html::rawElement(
181 [
'class' =>
'mw-protectedpages-unknown' ],
182 $this->
msg(
'protectedpages-unknown-timestamp' )->escaped()
185 $formatted = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
191 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
193 $formatted = Html::element(
195 [
'class' =>
'mw-invalidtitle' ],
196 Linker::getInvalidTitleDescription(
198 $row->page_namespace,
203 $formatted = $linkRenderer->makeLink( $title );
205 if ( $row->page_len !==
null ) {
207 ' ' . Html::rawElement(
209 [
'class' =>
'mw-protectedpages-length' ],
210 Linker::formatRevisionSize( $row->page_len )
216 $formatted = htmlspecialchars( $this->
getLanguage()->formatExpiry(
217 $value,
true,
'infinity', $this->
getUser() ) );
218 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
219 if ( $title && $this->
getAuthority()->isAllowed(
'protect' ) ) {
220 $changeProtection = $linkRenderer->makeKnownLink(
222 $this->
msg(
'protect_change' )->text(),
224 [
'action' =>
'unprotect' ]
226 $formatted .=
' ' . Html::rawElement(
228 [
'class' =>
'mw-protectedpages-actions' ],
229 $this->
msg(
'parentheses' )->rawParams( $changeProtection )->escaped()
236 if ( $row->log_timestamp ===
null ) {
237 $formatted = Html::rawElement(
239 [
'class' =>
'mw-protectedpages-unknown' ],
240 $this->
msg(
'protectedpages-unknown-performer' )->escaped()
243 $username = $row->actor_name;
244 if ( LogEventsList::userCanBitfield(
246 LogPage::DELETED_USER,
247 $this->getAuthority()
249 $formatted = Linker::userLink( (
int)$value, $username )
250 . Linker::userToolLinks( (
int)$value, $username );
252 $formatted = $this->
msg(
'rev-deleted-user' )->escaped();
254 if ( LogEventsList::isDeleted( $row, LogPage::DELETED_USER ) ) {
255 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
263 $params[] = $this->
msg(
'restriction-level-' . $row->pr_level )->escaped();
264 if ( $row->pr_cascade ) {
265 $params[] = $this->
msg(
'protect-summary-cascade' )->escaped();
267 $formatted = $this->
getLanguage()->commaList( $params );
272 if ( $row->log_timestamp ===
null ) {
273 $formatted = Html::rawElement(
275 [
'class' =>
'mw-protectedpages-unknown' ],
276 $this->
msg(
'protectedpages-unknown-reason' )->escaped()
279 if ( LogEventsList::userCanBitfield(
281 LogPage::DELETED_COMMENT,
282 $this->getAuthority()
286 $formatted = $this->
msg(
'rev-deleted-comment' )->escaped();
288 if ( LogEventsList::isDeleted( $row, LogPage::DELETED_COMMENT ) ) {
289 $formatted =
'<span class="history-deleted">' . $formatted .
'</span>';
304 $conds[] =
'pr_expiry > ' . $dbr->addQuotes( $dbr->timestamp() ) .
305 ' OR pr_expiry IS NULL';
306 $conds[] =
'page_id=pr_page';
307 $conds[] =
'pr_type=' . $dbr->addQuotes( $this->type );
309 if ( $this->sizetype ==
'min' ) {
310 $conds[] =
'page_len>=' . $this->size;
311 } elseif ( $this->sizetype ==
'max' ) {
312 $conds[] =
'page_len<=' . $this->size;
315 if ( $this->indefonly ) {
316 $conds[
'pr_expiry'] = [ $dbr->getInfinity(), null ];
318 if ( $this->cascadeonly ) {
319 $conds[] =
'pr_cascade = 1';
321 if ( $this->noredirect ) {
322 $conds[] =
'page_is_redirect = 0';
325 if ( $this->level ) {
326 $conds[] =
'pr_level=' . $dbr->addQuotes( $this->level );
328 if ( $this->
namespace !==
null ) {
329 $conds[] =
'page_namespace=' . $dbr->addQuotes( $this->
namespace );
332 $commentQuery = $this->commentStore->getJoin(
'log_comment' );
336 'page',
'page_restrictions',
'log_search',
337 'logparen' => [
'logging',
'actor' ] + $commentQuery[
'tables'],
352 ] + $commentQuery[
'fields'],
357 'ls_field' =>
'pr_id',
'ls_value = ' . $dbr->buildStringCast(
'pr_id' )
370 ] + $commentQuery[
'joins']