Page MenuHomePhabricator

Provide a (reliable) way to test if a value is in a array (e.g. if a user recently edited a page)
Closed, DuplicatePublic

Description

Example

It is unreliable to test if a user edited a page recently with the code

user_name in article_recent_contributors

because this will test if the sring in the left is part of the other string (which seems to be a "\n" separated list of usernames, per bug 50107 comment 3).

E.g.: if [[user:example]] is the only one who edited a page, the code above would detect both [[user:example]] and [[user:ample]] as editors of that page. See the screenshot


Version: unspecified
Severity: enhancement

Attached:

Captura_de_tela_de_2013-07-14_13:38:01.png (1,366×768 px, 91 KB)

Details

Reference
bz51324

Event Timeline

• bzimport raised the priority of this task from to Low.Nov 22 2014, 1:54 AM
• bzimport added a project: AbuseFilter.
• bzimport set Reference to bz51324.
• bzimport added a subscriber: Unknown Object (MLST).

There seems to be a piece of dead code for this at
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FAbuseFilter.git/HEAD/AbuseFilter.parser.php#L223

public static function listContains( $value, $list ) {

		// Should use built-in PHP function somehow
		foreach ( $list->data as $item ) {
			if ( self::equals( $value, $item ) ) {
				return true;
			}
		}
		return false;

}