From aeab2e64a87e49235b62ab5473349e26ffe9a9f7 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 25 Apr 2005 03:30:24 +0000 Subject: [PATCH] ported live patches --- includes/Database.php | 2 ++ includes/Image.php | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 51104db682..4ed8c59f2f 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -289,6 +289,7 @@ class Database { # generalizeSQL will probably cut down the query to reasonable # logging size most of the time. The substr is really just a sanity check. $profName = 'query: ' . substr( Database::generalizeSQL( $sql ), 0, 255 ); + wfProfileIn( 'Database::query' ); wfProfileIn( $profName ); } @@ -334,6 +335,7 @@ class Database { if ( $wgProfiling ) { wfProfileOut( $profName ); + wfProfileOut( 'Database::query' ); } return $ret; } diff --git a/includes/Image.php b/includes/Image.php index 0c6f06a7ca..5ddc446520 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1518,18 +1518,21 @@ function wfGetSVGsize( $filename ) { * Is an image on the bad image list? */ function wfIsBadImage( $name ) { - global $wgLang; - - $lines = explode("\n", wfMsgForContent( 'bad_image_list' )); - foreach ( $lines as $line ) { - if ( preg_match( '/^\*\s*\[\[:(' . $wgLang->getNsText( NS_IMAGE ) . ':.*(?=]]))\]\]/', $line, $m ) ) { - $t = Title::newFromText( $m[1] ); - if ( $t->getDBkey() == $name ) { - return true; + global $wgContLang; + static $titleList = false; + if ( $titleList === false ) { + $titleList = array(); + + $lines = explode("\n", wfMsgForContent( 'bad_image_list' )); + foreach ( $lines as $line ) { + if ( preg_match( '/^\*\s*\[\[:(' . $wgContLang->getNsText( NS_IMAGE ) . ':[^\]]*)\]\]/', $line, $m ) ) { + $t = Title::newFromText( $m[1] ); + $titleList[$t->getDBkey()] = 1; } } } - return false; + + return array_key_exists( $name, $titleList ); } -- 2.20.1