r98489 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98488‎ | r98489 | r98490 >
Date:23:29, 29 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Add some profiling and wfDebug() output
Modified paths:
  • /trunk/extensions/LilyPond/LilyPond.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LilyPond/LilyPond.class.php
@@ -39,6 +39,7 @@
4040 global $wgMathPath, $wgMathDirectory, $wgTmpDirectory, $wgLilypond, $wgLilypondPreMidi,
4141 $wgLilypondPostMidi, $wgLilypondTrim, $wgLilypondBorderX, $wgLilypondBorderY;
4242
 43+ wfProfileIn( __METHOD__ );
4344 $mf = wfMsg( "math_failure" );
4445
4546 $md5 = md5( $lilypond_code );
@@ -80,11 +81,15 @@
8182 $res = mkdir( $wgMathDirectory );
8283 wfRestoreWarnings();
8384 if ( !$res ) {
 85+ wfDebug( 'Unable to create directory ' . $wgMathDirectory );
 86+ wfProfileOut( __METHOD__ );
8487 return "<b>$mf (" . wfMsg( "math_bad_output" ) .
8588 $wgMathDirectory . ")</b>";
8689 }
8790 } elseif ( !is_dir( $wgMathDirectory ) ||
8891 !is_writable( $wgMathDirectory ) ) {
 92+ wfDebug( 'Unable to write to directory ' . $wgMathDirectory );
 93+ wfProfileOut( __METHOD__ );
8994 return "<b>$mf (" . wfMsg( "math_bad_output" ) . ")</b>";
9095 }
9196 if ( !file_exists( $wgTmpDirectory ) ) {
@@ -92,17 +97,23 @@
9398 $res = mkdir( $wgTmpDirectory );
9499 wfRestoreWarnings();
95100 if ( !$res ) {
 101+ wfDebug( 'Unable to create temporary directory ' . $wgTmpDirectory );
 102+ wfProfileOut( __METHOD__ );
96103 return "<b>$mf (" . wfMsg( "math_bad_tmpdir" )
97104 . ")</b>";
98105 }
99106 } elseif ( !is_dir( $wgTmpDirectory ) ||
100107 !is_writable( $wgTmpDirectory ) ) {
 108+ wfDebug( 'Unable to write to temporary directory ' . $wgTmpDirectory );
 109+ wfProfileOut( __METHOD__ );
101110 return "<b>$mf (" . wfMsg( "math_bad_tmpdir" ) . ")</b>";
102111 }
103112
104113 $lyFile = $md5 . ".ly";
105114 $out = fopen( $wgTmpDirectory . "/" . $lyFile, "w" );
106115 if ( $out === false ) {
 116+ wfDebug( 'Unable to write to temporary directory ' . $wgTmpDirectory . "/" . $lyFile );
 117+ wfProfileOut( __METHOD__ );
107118 return "<b>$mf (" . wfMsg( "math_bad_tmpdir" ) . ")</b>";
108119 }
109120 fwrite( $out, $lilypond_code );
@@ -119,6 +130,7 @@
120131 chdir( $oldcwd );
121132
122133 if ( $ret != 0 ) {
 134+ wfProfileOut( __METHOD__ );
123135 return "<br><b>LilyPond error:</b><br><i>"
124136 . str_replace( array( $md5, " " ),
125137 array( "<b>your code</b>", "&nbsp;" ),
@@ -130,6 +142,8 @@
131143 $outputFile = $wgTmpDirectory . "/" . $md5 . ".png";
132144
133145 if ( !file_exists( $outputFile ) ) {
 146+ wfDebug( 'Output file doesn\'t exist ' . $outputFile );
 147+ wfProfileOut( __METHOD__ );
134148 return "<b>$mf (" . wfMsg( "math_image_error" )
135149 . ")</b>";
136150 }
@@ -198,6 +212,7 @@
199213 self::frameImage( $imgFile, $imgFile, 0xFFFFFF, $wgLilypondBorderX, $wgLilypondBorderY );
200214 }
201215
 216+ wfProfileOut( __METHOD__ );
202217 return $pre . $link . $post;
203218 }
204219

Status & tagging log