From: jenkins-bot Date: Fri, 28 Nov 2014 18:52:53 +0000 (+0000) Subject: Merge "Style visited links correctly" X-Git-Tag: 1.31.0-rc.0~13140 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=650d8f7af2a18f1c0053e8aa2943c75ea049eb3f;hp=74a72eea98e34fbbc6c95a4fbfc2f2ac8887c63d;p=lhc%2Fweb%2Fwiklou.git Merge "Style visited links correctly" --- diff --git a/includes/site/SiteSQLStore.php b/includes/site/SiteSQLStore.php index fde22f1738..c1a350d854 100644 --- a/includes/site/SiteSQLStore.php +++ b/includes/site/SiteSQLStore.php @@ -51,15 +51,25 @@ class SiteSQLStore implements SiteStore { */ private $cacheTimeout = 3600; + /** + * @var BagOStuff + */ + private $cache; + /** * @since 1.21 * * @param ORMTable|null $sitesTable + * @param BagOStuff|null $cache * * @return SiteStore */ - public static function newInstance( ORMTable $sitesTable = null ) { - return new static( $sitesTable ); + public static function newInstance( ORMTable $sitesTable = null, BagOStuff $cache = null ) { + if ( $cache === null ) { + $cache = wfGetMainCache(); + } + + return new static( $cache, $sitesTable ); } /** @@ -67,13 +77,15 @@ class SiteSQLStore implements SiteStore { * * @since 1.21 * + * @param BagOStuff $cache * @param ORMTable|null $sitesTable */ - protected function __construct( ORMTable $sitesTable = null ) { + protected function __construct( BagOStuff $cache, ORMTable $sitesTable = null ) { if ( $sitesTable === null ) { $sitesTable = $this->newSitesTable(); } + $this->cache = $cache; $this->sitesTable = $sitesTable; } @@ -123,8 +135,7 @@ class SiteSQLStore implements SiteStore { if ( $source === 'cache' ) { if ( $this->sites === null ) { - $cache = wfGetMainCache(); - $sites = $cache->get( $this->getCacheKey() ); + $sites = $this->cache->get( $this->getCacheKey() ); if ( is_object( $sites ) ) { $this->sites = $sites; @@ -257,8 +268,7 @@ class SiteSQLStore implements SiteStore { } } - $cache = wfGetMainCache(); - $cache->set( $this->getCacheKey(), $this->sites, $this->cacheTimeout ); + $this->cache->set( $this->getCacheKey(), $this->sites, $this->cacheTimeout ); wfProfileOut( __METHOD__ ); } @@ -374,8 +384,7 @@ class SiteSQLStore implements SiteStore { public function reset() { wfProfileIn( __METHOD__ ); // purge cache - $cache = wfGetMainCache(); - $cache->delete( $this->getCacheKey() ); + $this->cache->delete( $this->getCacheKey() ); $this->sites = null; wfProfileOut( __METHOD__ ); diff --git a/includes/utils/IP.php b/includes/utils/IP.php index 0e2db8cc07..77f9cd11fe 100644 --- a/includes/utils/IP.php +++ b/includes/utils/IP.php @@ -628,6 +628,25 @@ class IP { strcmp( $hexIP, $end ) <= 0 ); } + /** + * Determines if an IP address is a list of CIDR a.b.c.d/n ranges. + * + * @since 1.25 + * + * @param string $ip the IP to check + * @param array $ranges the IP ranges, each element a range + * + * @return bool true if the specified adress belongs to the specified range; otherwise, false. + */ + public static function isInRanges( $ip, $ranges ) { + foreach ( $ranges as $range ) { + if ( self::isInRange( $ip, $range ) ) { + return true; + } + } + return false; + } + /** * Convert some unusual representations of IPv4 addresses to their * canonical dotted quad representation.