53 $showWiki = $this->getOption(
'show-wiki' );
54 $wikiId = WikiMap::getCurrentWikiId();
55 $prefix = $this->getOption(
'prefix' );
56 $regex = $this->getArg( 0 );
57 $titleOnly = $this->hasOption(
'pages-with-matches' );
59 if ( ( $regex[0] ??
'' ) ===
'/' ) {
62 $delimRegex =
'{' . $regex .
'}';
65 foreach ( $this->
findPages( $prefix ) as $page ) {
66 $content = $page->getContent( RevisionRecord::RAW );
67 $titleText = $page->getTitle()->getPrefixedDBkey();
69 $this->error(
"Page has no content: $titleText" );
73 $this->error(
"Page has a non-text content model: $titleText" );
77 $text = $content->getText();
80 if ( preg_match( $delimRegex, $text ) ) {
82 echo
"$wikiId\t$titleText\n";
88 foreach ( StringUtils::explode(
"\n", $text ) as $lineNum => $line ) {
90 if ( preg_match( $delimRegex, $line ) ) {
92 echo
"$wikiId\t$titleText:$lineNum:$line\n";
94 echo
"$titleText:$lineNum:$line\n";
103 $dbr = $this->getReplicaDB();
105 if ( $prefixes !==
null ) {
106 foreach ( $prefixes as $prefix ) {
107 $colonPos = strpos( $prefix,
':' );
108 if ( $colonPos !==
false ) {
109 $ns = $this->contLang->getNsIndex( substr( $prefix, 0, $colonPos ) );
110 $prefixDBkey = substr( $prefix, $colonPos + 1 );
113 $prefixDBkey = $prefix;
115 $prefixExpr = $dbr->expr(
'page_namespace',
'=', $ns );
116 if ( $prefixDBkey !==
'' ) {
117 $prefixExpr = $prefixExpr->and(
120 new LikeValue( $prefixDBkey, $dbr->anyString() )
123 $orConds[] = $prefixExpr;
128 $res = $dbr->newSelectQueryBuilder()
129 ->queryInfo( WikiPage::getQueryInfo() )
130 ->where( $orConds ? $dbr->orExpr( $orConds ) : [] )
131 ->andWhere( $dbr->expr(
'page_id',
'>', $lastId ) )
133 ->caller( __METHOD__ )
135 foreach ( $res as $row ) {
136 $title = Title::newFromRow( $row );
137 yield $this->wikiPageFactory->newFromTitle( $title );
138 $lastId = $row->page_id;
140 }
while ( $res->numRows() );