mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-23 18:28:20 +00:00
Remove indirect calls to IDBAccessObject::READ_* constants
We are getting rid of the schema of implementing this interface and calling self::READ_* constants, it's confusing, inconsistent, prone to clashes and isn't really useful for non-ORM systems (which we are not) Bug: T354194 Change-Id: I5d7a2c91a49311a6bdf6e56053c08610d4d6d110
This commit is contained in:
parent
0342668682
commit
71c181219a
|
@ -83,12 +83,12 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
/**
|
||||
* Load the configuration page, with optional local-server caching.
|
||||
*
|
||||
* @param int $flags bit field, see self::READ_XXX
|
||||
* @param int $flags bit field, see IDBAccessObject::READ_XXX
|
||||
* @return StatusValue The content of the configuration page (as JSON
|
||||
* data in PHP-native format), or a StatusValue on error.
|
||||
*/
|
||||
public function loadConfig( int $flags = 0 ): StatusValue {
|
||||
if ( DBAccessObjectUtils::hasFlags( $flags, self::READ_LATEST ) ) {
|
||||
if ( DBAccessObjectUtils::hasFlags( $flags, IDBAccessObject::READ_LATEST ) ) {
|
||||
return $this->fetchConfig( $flags );
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
*/
|
||||
private function fetchLatestConfig(): ?array {
|
||||
$configPage = $this->getBlockedDomainPage();
|
||||
$revision = $this->revisionLookup->getRevisionByTitle( $configPage, 0, self::READ_LATEST );
|
||||
$revision = $this->revisionLookup->getRevisionByTitle( $configPage, 0, IDBAccessObject::READ_LATEST );
|
||||
if ( !$revision ) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -99,14 +99,16 @@ class FilterLookup implements IDBAccessObject {
|
|||
/**
|
||||
* @param int $filterID
|
||||
* @param bool $global
|
||||
* @param int $flags One of the self::READ_* constants
|
||||
* @param int $flags One of the IDBAccessObject::READ_* constants
|
||||
* @return ExistingFilter
|
||||
* @throws FilterNotFoundException if the filter doesn't exist
|
||||
* @throws CentralDBNotAvailableException
|
||||
*/
|
||||
public function getFilter( int $filterID, bool $global, int $flags = self::READ_NORMAL ): ExistingFilter {
|
||||
public function getFilter(
|
||||
int $filterID, bool $global, int $flags = IDBAccessObject::READ_NORMAL
|
||||
): ExistingFilter {
|
||||
$cacheKey = $this->getCacheKey( $filterID, $global );
|
||||
if ( $flags !== self::READ_NORMAL || !isset( $this->cache[$cacheKey] ) ) {
|
||||
if ( $flags !== IDBAccessObject::READ_NORMAL || !isset( $this->cache[$cacheKey] ) ) {
|
||||
[ $dbIndex, $dbOptions ] = DBAccessObjectUtils::getDBOptions( $flags );
|
||||
$dbr = $this->getDBConnection( $dbIndex, $global );
|
||||
$query = $this->getAbuseFilterQueryInfo();
|
||||
|
@ -140,9 +142,11 @@ class FilterLookup implements IDBAccessObject {
|
|||
* @return ExistingFilter[]
|
||||
* @throws CentralDBNotAvailableException
|
||||
*/
|
||||
public function getAllActiveFiltersInGroup( string $group, bool $global, int $flags = self::READ_NORMAL ): array {
|
||||
public function getAllActiveFiltersInGroup(
|
||||
string $group, bool $global, int $flags = IDBAccessObject::READ_NORMAL
|
||||
): array {
|
||||
$domainKey = $global ? 'global' : 'local';
|
||||
if ( $flags !== self::READ_NORMAL || !isset( $this->groupCache[$domainKey][$group] ) ) {
|
||||
if ( $flags !== IDBAccessObject::READ_NORMAL || !isset( $this->groupCache[$domainKey][$group] ) ) {
|
||||
if ( $global ) {
|
||||
$globalRulesKey = $this->getGlobalRulesKey( $group );
|
||||
$ret = $this->wanCache->getWithSetCallback(
|
||||
|
@ -268,9 +272,9 @@ class FilterLookup implements IDBAccessObject {
|
|||
*/
|
||||
public function getFilterVersion(
|
||||
int $version,
|
||||
int $flags = self::READ_NORMAL
|
||||
int $flags = IDBAccessObject::READ_NORMAL
|
||||
): HistoryFilter {
|
||||
if ( $flags !== self::READ_NORMAL || !isset( $this->historyCache[$version] ) ) {
|
||||
if ( $flags !== IDBAccessObject::READ_NORMAL || !isset( $this->historyCache[$version] ) ) {
|
||||
[ $dbIndex, $dbOptions ] = DBAccessObjectUtils::getDBOptions( $flags );
|
||||
$dbr = $this->loadBalancer->getConnection( $dbIndex );
|
||||
$query = $this->getAbuseFilterHistoryQueryInfo();
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace MediaWiki\Extension\AbuseFilter\View;
|
|||
|
||||
use HtmlArmor;
|
||||
use IContextSource;
|
||||
use IDBAccessObject;
|
||||
use LogicException;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager;
|
||||
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry;
|
||||
|
@ -1181,8 +1182,8 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
|
||||
$flags = $this->getRequest()->wasPosted()
|
||||
// Load from primary database to avoid unintended reversions where there's replication lag.
|
||||
? FilterLookup::READ_LATEST
|
||||
: FilterLookup::READ_NORMAL;
|
||||
? IDBAccessObject::READ_LATEST
|
||||
: IDBAccessObject::READ_NORMAL;
|
||||
|
||||
return $this->filterLookup->getFilter( $id, false, $flags );
|
||||
}
|
||||
|
|
|
@ -1600,10 +1600,10 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase {
|
|||
$this->createFilters( [ 24 ] );
|
||||
|
||||
$targetTitle = Title::makeTitle( NS_MAIN, 'TestRevIdSet' );
|
||||
$startingRevId = $targetTitle->getLatestRevID( Title::READ_LATEST );
|
||||
$startingRevId = $targetTitle->getLatestRevID( IDBAccessObject::READ_LATEST );
|
||||
|
||||
$this->doEdit( $targetTitle, 'Old text', 'New text', 'Summary' );
|
||||
$latestRevId = $targetTitle->getLatestRevID( Title::READ_LATEST );
|
||||
$latestRevId = $targetTitle->getLatestRevID( IDBAccessObject::READ_LATEST );
|
||||
|
||||
$this->assertNotSame(
|
||||
$startingRevId,
|
||||
|
|
Loading…
Reference in a new issue