6use Psr\Log\LoggerInterface;
11 private float|
int $denseRcSizeThreshold = 10000;
13 private ?
int $limit =
null;
14 private bool $densityThresholdReached =
true;
19 private LoggerInterface $logger,
20 private bool $miserMode,
30 $this->limit = $limit;
38 $this->densityThresholdReached = $reached;
48 $this->denseRcSizeThreshold = $threshold;
53 if ( !is_scalar( $value ) ) {
54 throw new \InvalidArgumentException(
"Change tag must be string-like" );
56 return (
string)$value;
60 public function evaluate( stdClass $row, $value ): bool {
61 if ( !$row->ts_tags ) {
64 return in_array( $value, explode(
',', $row->ts_tags ),
true );
70 'ts_tags' => $this->changeTagsStore->makeTagSummarySubquery(
'recentchanges' )
76 [ $required, $excluded ] = $this->getUniqueValues();
77 if ( $required === [] ) {
79 } elseif ( $required ) {
80 $ids = array_values( $this->changeTagsStore->getTagIdsFromNames( $required ) );
91 if ( $this->isDenseTagFilter( $dbr, $ids ) ) {
97 $query->
where( $dbr->
expr(
'changetagdisplay.ct_tag_id',
'=', $ids ) );
98 if ( count( $ids ) > 1 ) {
101 } elseif ( $excluded ) {
102 $ids = array_values( $this->changeTagsStore->getTagIdsFromNames( $excluded ) );
108 ->on( $dbr->
expr(
'changetagdisplay.ct_tag_id',
'=', $ids ) );
109 $query->
where( $dbr->
expr(
'changetagdisplay.ct_tag_id',
'=',
null ) );
127 || !$this->densityThresholdReached
138 $rcSize = $this->rcStats->getIdDelta();
139 if ( $rcSize < $this->denseRcSizeThreshold ) {
144 ->table(
'change_tag' )
146 $dbr->
expr(
'ct_rc_id',
'>=', $this->rcStats->getMinId() ),
147 'ct_tag_id' => $tagIds
149 ->caller( __METHOD__ )
150 ->estimateRowCount();
157 $isDense = $this->limit * $rcSize < $tagCount * $tagCount;
159 $this->logger->debug( __METHOD__ .
160 ": rcSize = $rcSize, tagCount = $tagCount, limit = {$this->limit} => " .
161 ( $isDense ?
'dense' :
'sparse' ) );
if(!defined('MW_SETUP_CALLBACK'))