From: Brion Vibber Date: Wed, 24 Nov 2004 09:57:03 +0000 (+0000) Subject: Add profiling points, and disable output instead of abrupt exit (so things like the... X-Git-Tag: 1.5.0alpha1~1258 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=42f9badced68036bd422c830a3ad114f9b47754c;p=lhc%2Fweb%2Fwiklou.git Add profiling points, and disable output instead of abrupt exit (so things like the profiling actually work!) --- diff --git a/includes/SpecialExport.php b/includes/SpecialExport.php index 2c6a2c5659..78ce26f275 100644 --- a/includes/SpecialExport.php +++ b/includes/SpecialExport.php @@ -38,11 +38,12 @@ function wfSpecialExport( $page = '' ) { } if( $page != '' ) { + $wgOut->disable(); header( "Content-type: application/xml; charset=utf-8" ); $pages = explode( "\n", $page ); $xml = pages2xml( $pages, $curonly ); echo $xml; - wfAbruptExit(); + return; } $wgOut->addWikiText( wfMsg( "exporttext" ) ); @@ -60,6 +61,9 @@ function wfSpecialExport( $page = '' ) { } function pages2xml( $pages, $curonly = false ) { + $fname = 'pages2xml'; + wfProfileIn( $fname ); + global $wgContLanguageCode, $wgInputEncoding, $wgContLang; $xml = "<" . "?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n" . "\n"; @@ -69,15 +73,21 @@ function pages2xml( $pages, $curonly = false ) { $xml .= "\n"; if($wgInputEncoding != "utf-8") $xml = $wgContLang->iconv( $wgInputEncoding, "utf-8", $xml ); + + wfProfileOut( $fname ); return $xml; } function page2xml( $page, $curonly, $full = false ) { global $wgLang; $fname = 'page2xml'; + wfProfileIn( $fname ); $title = Title::NewFromText( $page ); - if( !$title ) return ""; + if( !$title ) { + wfProfileOut( $fname ); + return ""; + } $dbr =& wfGetDB( DB_SLAVE ); $s = $dbr->selectRow( 'cur', array( 'cur_id as id','cur_timestamp as timestamp','cur_user as user', @@ -106,13 +116,18 @@ function page2xml( $page, $curonly, $full = false ) { } $xml .= revision2xml( $s, $full, true ); $xml .= " \n"; + wfProfileOut( $fname ); return $xml; } else { + wfProfileOut( $fname ); return ""; } } function revision2xml( $s, $full, $cur ) { + $fname = 'revision2xml'; + wfProfileIn( $fname ); + $ts = wfTimestamp2ISO8601( $s->timestamp ); $xml = " \n"; if($full && !$cur) @@ -136,6 +151,7 @@ function revision2xml( $s, $full, $cur ) { $t = xmlsafe( Article::getRevisionText( $s, "" ) ); $xml .= " $t\n"; $xml .= " \n"; + wfProfileOut( $fname ); return $xml; } @@ -145,14 +161,28 @@ function wfTimestamp2ISO8601( $ts ) { } function xmlsafe( $string ) { - # May contain old data which has not been properly normalized. + $fname = 'xmlsafe'; + wfProfileIn( $fname ); + + /** + * The page may contain old data which has not been properly normalized. + * Invalid UTF-8 sequences or forbidden control characters will make our + * XML output invalid, so be sure to strip them out. + */ global $wgUseLatin1; if( $wgUseLatin1 ) { + /** + * We know the UTF-8 is valid since we converted outselves. + * Just check for forbidden controls... + */ $string = preg_replace( '/[\x00-\x08\x0b-\x1f]/', '', $string ); } else { $string = UtfNormal::cleanUp( $string ); } - return htmlspecialchars( $string ); + + $string = htmlspecialchars( $string ); + wfProfileOut( $fname ); + return $string; } ?>