mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 09:43:30 +00:00
Use expression builder instead of raw sql
Change-Id: I0cb5fa07d63bc93089a4956097eee7a41dbc99e7
This commit is contained in:
parent
a0b8933a41
commit
2a932e598c
|
@ -7,7 +7,7 @@
|
|||
"descriptionmsg": "discussiontools-desc",
|
||||
"manifest_version": 2,
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.42.0",
|
||||
"MediaWiki": ">= 1.43.0",
|
||||
"extensions": {
|
||||
"VisualEditor": "*",
|
||||
"Linter": "*"
|
||||
|
|
|
@ -87,6 +87,7 @@ class ThreadItemStore {
|
|||
return [];
|
||||
}
|
||||
|
||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||
$queryBuilder = $this->getIdsNamesBuilder()
|
||||
->caller( __METHOD__ )
|
||||
->where( [
|
||||
|
@ -94,7 +95,7 @@ class ThreadItemStore {
|
|||
// Disallow querying for headings of sections that contain no comments.
|
||||
// They all share the same name, so this would return a huge useless list on most wikis.
|
||||
// (But we still store them, as we might need this data elsewhere.)
|
||||
"it_itemname != 'h-'",
|
||||
$dbr->expr( 'it_itemname', '!=', 'h-' ),
|
||||
] );
|
||||
|
||||
if ( $limit !== null ) {
|
||||
|
@ -141,10 +142,11 @@ class ThreadItemStore {
|
|||
// It might scan a bunch of rows...
|
||||
// ->limit( 1 );
|
||||
|
||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||
$queryBuilder
|
||||
->where( [
|
||||
'it_itemname IN (' . $itemNameQueryBuilder->getSQL() . ')',
|
||||
"it_itemname != 'h-'",
|
||||
$dbr->expr( 'it_itemname', '!=', 'h-' ),
|
||||
] );
|
||||
|
||||
if ( $limit !== null ) {
|
||||
|
|
|
@ -264,7 +264,7 @@ class TopicSubscriptionsPager extends TablePager {
|
|||
],
|
||||
'conds' => [
|
||||
'sub_user' => $this->getUser()->getId(),
|
||||
'sub_state != ' . SubscriptionStore::STATE_UNSUBSCRIBED,
|
||||
$this->getDatabase()->expr( 'sub_state', '!=', SubscriptionStore::STATE_UNSUBSCRIBED ),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace MediaWiki\Extension\DiscussionTools\Maintenance;
|
|||
|
||||
use LoggedUpdateMaintenance;
|
||||
use Wikimedia\Rdbms\DBQueryError;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\IExpression;
|
||||
use Wikimedia\Rdbms\LikeValue;
|
||||
|
||||
|
@ -54,19 +53,17 @@ class FixTrailingWhitespaceIds extends LoggedUpdateMaintenance {
|
|||
->from( 'discussiontools_item_ids' )
|
||||
->field( 'itid_itemid' )
|
||||
->where(
|
||||
$dbw->makeList( [
|
||||
$dbw->orExpr( [
|
||||
$dbw->expr( 'itid_itemid', IExpression::LIKE, $like1 ),
|
||||
$dbw->expr( 'itid_itemid', IExpression::LIKE, $like2 ),
|
||||
$dbw->expr( 'itid_itemid', IExpression::LIKE, $like3 ),
|
||||
], IDatabase::LIST_OR )
|
||||
] )
|
||||
)
|
||||
->caller( __METHOD__ )
|
||||
->limit( $this->getBatchSize() );
|
||||
|
||||
if ( $skippedIds ) {
|
||||
$itemIdQueryBuilder->where(
|
||||
'itid_itemid NOT IN (' . $dbw->makeList( $skippedIds ) . ')'
|
||||
);
|
||||
$itemIdQueryBuilder->where( $dbw->expr( 'itid_itemid', '!=', $skippedIds ) );
|
||||
}
|
||||
|
||||
$itemIds = $itemIdQueryBuilder->fetchFieldValues();
|
||||
|
|
|
@ -45,7 +45,7 @@ class NewTopicOptOutActiveUsers extends Maintenance {
|
|||
'qcc_namespace' => NS_USER,
|
||||
] )
|
||||
->join( 'user', null, 'qcc_title=user_name' )
|
||||
->where( [ 'user_editcount >= 100' ] )
|
||||
->where( $this->dbw->expr( 'user_editcount', '>=', 100 ) )
|
||||
->fields( [ 'user_id', 'user_name' ] )
|
||||
->fetchResultSet();
|
||||
|
||||
|
|
Loading…
Reference in a new issue