r40983 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40982‎ | r40983 | r40984 >
Date:14:27, 18 September 2008
Author:werdna
Status:old
Tags:
Comment:
Fix count function
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -833,6 +833,8 @@
834834 protected function funcCount( $args ) {
835835 if( count( $args ) < 1 )
836836 throw new AFPExpection( "No params passed to ".__METHOD__ );
 837+
 838+ $offset = -1;
837839
838840 if (count($args) == 1) {
839841 $count = count( explode( ",", $args[0]->toString() ) );
@@ -841,7 +843,7 @@
842844 $haystack = $args[1]->toString();
843845
844846 $count = 0;
845 - while ( ($offset = strpos( $haystack, $needle, $offset )) !== false ) {
 847+ while ( ($offset = strpos( $haystack, $needle, $offset + 1 )) !== false ) {
846848 $count++;
847849 }
848850 }