6use Wikimedia\Assert\Assert;
31 parent::__construct(
$db );
32 $this->pageStore = $pageStore;
33 $this->
table(
'page' );
34 $this->linkCache = $linkCache;
45 Assert::parameterType( [
'integer',
'array' ], $pageIds,
'$pageIds' );
48 $this->
conds( [
'page_id' => $pageIds ] );
50 $this->
conds(
'0 = 1' );
64 $this->conds( [
'page_namespace' => $namespace ] );
77 $this->whereNamespace( $namespace );
79 $this->db->expr(
'page_title', IExpression::LIKE,
new LikeValue( $prefix, $this->db->anyString() ) )
92 public function whereTitles(
int $namespace, $pageTitles ): self {
93 Assert::parameterType( [
'string',
'array' ], $pageTitles,
'$pageTitles' );
94 $this->conds( [
'page_namespace' => $namespace ] );
95 $this->conds( [
'page_title' => $pageTitles ] );
107 $this->orderBy( [
'page_namespace',
'page_title' ], $dir );
119 $this->orderBy(
'page_id', $dir );
129 $this->fields( $this->pageStore->getSelectFields() );
131 $row = $this->fetchRow();
136 $rec = $this->pageStore->newPageRecordFromRow( $row );
137 if ( $this->linkCache ) {
138 $this->linkCache->addGoodLinkObjFromRow( $rec, $row );
149 $this->fields( $this->pageStore->getSelectFields() );
151 $result = $this->fetchResultSet();
152 foreach ( $result as $row ) {
153 $rec = $this->pageStore->newPageRecordFromRow( $row );
154 if ( $this->linkCache ) {
155 $this->linkCache->addGoodLinkObjFromRow( $rec, $row );
171 foreach ( $this->fetchPageRecords() as $rec ) {
172 $recs[ $rec->getId() ] = $rec;
184 $this->field(
'page_id' );
185 return array_map(
'intval', $this->fetchFieldValues() );
Page existence and metadata cache.
whereTitlePrefix(int $namespace, string $prefix)
Find by provided prefix.
fetchPageRecords()
Fetch PageRecords for the specified query.
wherePageIds( $pageIds)
Find by provided page ids.
whereTitles(int $namespace, $pageTitles)
Find by provided page titles.
fetchPageRecord()
Fetch a single PageRecord that matches specified criteria.
orderByPageId(string $dir=self::SORT_ASC)
Order results by page id.
fetchPageIds()
Returns an array of page ids matching the query.
orderByTitle(string $dir=self::SORT_ASC)
Order results by namespace and title in $direction.
fetchPageRecordArray()
Fetch PageRecords for the specified query as an associative array, using page IDs as array keys.
__construct(IReadableDatabase $db, PageStore $pageStore, ?LinkCache $linkCache=null)
whereNamespace(int $namespace)
Find by provided namespace.