From: Max Semenik Date: Thu, 17 Dec 2009 15:39:11 +0000 (+0000) Subject: Fixup for r57989: removed artifacts of the previous version of my patch, improved... X-Git-Tag: 1.31.0-rc.0~38515 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=eb8b230abce92a0f0dce6e8e835683de40b6df68;p=lhc%2Fweb%2Fwiklou.git Fixup for r57989: removed artifacts of the previous version of my patch, improved code reuse. --- diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index af90a9bf20..27641858f3 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -53,63 +53,18 @@ class LinkFilter { */ public static function makeLike( $filterEntry , $prot = 'http://' ) { wfDeprecated( __METHOD__ ); - $db = wfGetDB( DB_MASTER ); - if ( substr( $filterEntry, 0, 2 ) == '*.' ) { - $subdomains = true; - $filterEntry = substr( $filterEntry, 2 ); - if ( $filterEntry == '' ) { - // We don't want to make a clause that will match everything, - // that could be dangerous - return false; - } - } else { - $subdomains = false; - } - // No stray asterisks, that could cause confusion - // It's not simple or efficient to handle it properly so we don't - // handle it at all. - if ( strpos( $filterEntry, '*' ) !== false ) { + + $like = self::makeLikeArray( $filterEntry , $prot ); + if ( !$like ) { return false; } - $slash = strpos( $filterEntry, '/' ); - if ( $slash !== false ) { - $path = substr( $filterEntry, $slash ); - $host = substr( $filterEntry, 0, $slash ); - } else { - $path = '/'; - $host = $filterEntry; - } - // Reverse the labels in the hostname, convert to lower case - // For emails reverse domainpart only - if ( $prot == 'mailto:' && strpos($host, '@') ) { - // complete email adress - $mailparts = explode( '@', $host ); - $domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) ); - $host = $domainpart . '@' . $mailparts[0]; - $like = $db->escapeLike( "$prot$host" ) . "%"; - } elseif ( $prot == 'mailto:' ) { - // domainpart of email adress only. do not add '.' - $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) ); - $like = $db->escapeLike( "$prot$host" ) . "%"; - } else { - $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) ); - if ( substr( $host, -1, 1 ) !== '.' ) { - $host .= '.'; - } - $like = $db->escapeLike( "$prot$host" ); + $dbw = wfGetDB( DB_MASTER ); - if ( $subdomains ) { - $like .= '%'; - } - if ( !$subdomains || $path !== '/' ) { - $like .= $db->escapeLike( $path ) . '%'; - } - } - return $like; + return $dbw->buildLike( $like ); } /** - * Make an array to be used for calls to Database::like(), which will match the specified + * Make an array to be used for calls to Database::buildLike(), which will match the specified * string. There are several kinds of filter entry: * *.domain.com - Produces http://com.domain.%, matches domain.com * and www.domain.com diff --git a/maintenance/storage/compressOld.inc b/maintenance/storage/compressOld.inc index 60096ff75c..981cfda547 100644 --- a/maintenance/storage/compressOld.inc +++ b/maintenance/storage/compressOld.inc @@ -105,8 +105,8 @@ function compressWithConcat( $startId, $maxChunkSize, $beginDate, # overwriting bulk storage concat rows. Don't compress external references, because # the script doesn't yet delete rows from external storage. $conds = array( - 'old_flags NOT ' . $dbr->buildLike( MATCH_STRING, 'object', MATCH_STRING ) . ' AND old_flags NOT ' - . $dbr->buildLike( MATCH_STRING, 'external', MATCH_STRING ) ); + 'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString() ) . ' AND old_flags NOT ' + . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) ); if ( $beginDate ) { if ( !preg_match( '/^\d{14}$/', $beginDate ) ) {