7use Wikimedia\Assert\Assert;
30 parent::__construct(
$db );
32 $this->
table(
'page' );
44 Assert::parameterType(
'integer|array', $pageIds,
'$pageIds' );
47 $this->
conds( [
'page_id' => $pageIds ] );
49 $this->
conds(
'0 = 1' );
63 $this->conds( [
'page_namespace' => $namespace ] );
76 $this->whereNamespace( $namespace );
77 $this->conds(
'page_title ' . $this->db->buildLike( $prefix, $this->db->anyString() ) );
89 public function whereTitles(
int $namespace, $pageTitles ): self {
90 Assert::parameterType(
'string|array', $pageTitles,
'$pageTitles' );
91 $this->conds( [
'page_namespace' => $namespace ] );
92 $this->conds( [
'page_title' => $pageTitles ] );
104 $this->orderBy( [
'page_namespace',
'page_title' ], $dir );
116 $this->orderBy(
'page_id', $dir );
126 $this->fields( $this->pageStore->getSelectFields() );
128 $row = $this->fetchRow();
133 $rec = $this->pageStore->newPageRecordFromRow( $row );
134 if ( $this->linkCache ) {
135 $this->linkCache->addGoodLinkObjFromRow( $rec, $row );
146 $this->fields( $this->pageStore->getSelectFields() );
148 return call_user_func(
function () {
149 $result = $this->fetchResultSet();
150 foreach ( $result as $row ) {
151 $rec = $this->pageStore->newPageRecordFromRow( $row );
152 if ( $this->linkCache ) {
153 $this->linkCache->addGoodLinkObjFromRow( $rec, $row );
170 foreach ( $this->fetchPageRecords() as $rec ) {
171 $recs[ $rec->getId() ] = $rec;
183 $this->field(
'page_id' );
184 return array_map(
'intval', $this->fetchFieldValues() );
Cache for article titles (prefixed DB keys) and ids linked from one source.
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.
__construct(IDatabase $db, PageStore $pageStore, ?LinkCache $linkCache=null)
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.
LinkCache null $linkCache
fetchPageRecordArray()
Fetch PageRecords for the specified query as an associative array, using page IDs as array keys.
whereNamespace(int $namespace)
Find by provided namespace.