MediaWiki  master
ProtectedTitlesPager.php
Go to the documentation of this file.
1 <?php
24 
29 
33  public $mForm;
34 
38  public $mConds;
39 
41  private $level;
42 
44  private $namespace;
45 
48 
60  public function __construct(
61  $form,
62  $conds,
63  $type,
64  $level,
65  $namespace,
66  $sizetype,
67  $size,
69  ILoadBalancer $loadBalancer
70  ) {
71  // Set database before parent constructor to avoid setting it there with wfGetDB
72  $this->mDb = $loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
73  $this->mForm = $form;
74  $this->mConds = $conds;
75  $this->level = $level;
76  $this->namespace = $namespace;
77  parent::__construct( $form->getContext() );
78  $this->linkBatchFactory = $linkBatchFactory;
79  }
80 
81  protected function getStartBody() {
82  # Do a link batch query
83  $this->mResult->seek( 0 );
84  $lb = $this->linkBatchFactory->newLinkBatch();
85 
86  foreach ( $this->mResult as $row ) {
87  $lb->add( $row->pt_namespace, $row->pt_title );
88  }
89 
90  $lb->execute();
91 
92  return '';
93  }
94 
98  public function getTitle() {
99  return $this->mForm->getPageTitle();
100  }
101 
102  public function formatRow( $row ) {
103  return $this->mForm->formatRow( $row );
104  }
105 
109  public function getQueryInfo() {
110  $dbr = $this->getDatabase();
111  $conds = $this->mConds;
112  $conds[] = 'pt_expiry > ' . $dbr->addQuotes( $this->mDb->timestamp() ) .
113  ' OR pt_expiry IS NULL';
114  if ( $this->level ) {
115  $conds['pt_create_perm'] = $this->level;
116  }
117 
118  if ( $this->namespace !== null ) {
119  $conds[] = 'pt_namespace=' . $dbr->addQuotes( $this->namespace );
120  }
121 
122  return [
123  'tables' => 'protected_titles',
124  'fields' => [ 'pt_namespace', 'pt_title', 'pt_create_perm',
125  'pt_expiry', 'pt_timestamp' ],
126  'conds' => $conds
127  ];
128  }
129 
130  public function getIndexField() {
131  return 'pt_timestamp';
132  }
133 }
ProtectedTitlesPager\$linkBatchFactory
LinkBatchFactory $linkBatchFactory
Definition: ProtectedTitlesPager.php:47
ProtectedTitlesPager\getTitle
getTitle()
Definition: ProtectedTitlesPager.php:98
IndexPager\getDatabase
getDatabase()
Get the Database object in use.
Definition: IndexPager.php:244
AlphabeticPager
IndexPager with an alphabetic list and a formatted navigation bar Stable to extend.
Definition: AlphabeticPager.php:29
SpecialProtectedtitles
A special page that list protected titles from creation.
Definition: SpecialProtectedtitles.php:32
ProtectedTitlesPager\__construct
__construct( $form, $conds, $type, $level, $namespace, $sizetype, $size, LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer)
Definition: ProtectedTitlesPager.php:60
ProtectedTitlesPager\getIndexField
getIndexField()
Returns the name of the index field.
Definition: ProtectedTitlesPager.php:130
Wikimedia\Rdbms\ILoadBalancer\getConnectionRef
getConnectionRef( $i, $groups=[], $domain=false, $flags=0)
Get a live database handle reference for a real or virtual (DB_MASTER/DB_REPLICA) server index.
ProtectedTitlesPager\getStartBody
getStartBody()
Hook into getBody(), allows text to be inserted at the start.
Definition: ProtectedTitlesPager.php:81
$dbr
$dbr
Definition: testCompression.php:54
ProtectedTitlesPager\getQueryInfo
getQueryInfo()
Definition: ProtectedTitlesPager.php:109
ProtectedTitlesPager\formatRow
formatRow( $row)
Returns an HTML string representing the result row $row.
Definition: ProtectedTitlesPager.php:102
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:38
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
ProtectedTitlesPager\$namespace
int null $namespace
Definition: ProtectedTitlesPager.php:44
ProtectedTitlesPager
Definition: ProtectedTitlesPager.php:28
ProtectedTitlesPager\$level
string null $level
Definition: ProtectedTitlesPager.php:41
ProtectedTitlesPager\$mConds
array $mConds
Definition: ProtectedTitlesPager.php:38
ProtectedTitlesPager\$mForm
SpecialProtectedtitles $mForm
Definition: ProtectedTitlesPager.php:33
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
$type
$type
Definition: testCompression.php:52