Index: trunk/extensions/LilyPond/LilyPond.class.php |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | global $wgMathPath, $wgMathDirectory, $wgTmpDirectory, $wgLilypond, $wgLilypondPreMidi, |
41 | 41 | $wgLilypondPostMidi, $wgLilypondTrim, $wgLilypondBorderX, $wgLilypondBorderY; |
42 | 42 | |
| 43 | + wfProfileIn( __METHOD__ ); |
43 | 44 | $mf = wfMsg( "math_failure" ); |
44 | 45 | |
45 | 46 | $md5 = md5( $lilypond_code ); |
— | — | @@ -80,11 +81,15 @@ |
81 | 82 | $res = mkdir( $wgMathDirectory ); |
82 | 83 | wfRestoreWarnings(); |
83 | 84 | if ( !$res ) { |
| 85 | + wfDebug( 'Unable to create directory ' . $wgMathDirectory ); |
| 86 | + wfProfileOut( __METHOD__ ); |
84 | 87 | return "<b>$mf (" . wfMsg( "math_bad_output" ) . |
85 | 88 | $wgMathDirectory . ")</b>"; |
86 | 89 | } |
87 | 90 | } elseif ( !is_dir( $wgMathDirectory ) || |
88 | 91 | !is_writable( $wgMathDirectory ) ) { |
| 92 | + wfDebug( 'Unable to write to directory ' . $wgMathDirectory ); |
| 93 | + wfProfileOut( __METHOD__ ); |
89 | 94 | return "<b>$mf (" . wfMsg( "math_bad_output" ) . ")</b>"; |
90 | 95 | } |
91 | 96 | if ( !file_exists( $wgTmpDirectory ) ) { |
— | — | @@ -92,17 +97,23 @@ |
93 | 98 | $res = mkdir( $wgTmpDirectory ); |
94 | 99 | wfRestoreWarnings(); |
95 | 100 | if ( !$res ) { |
| 101 | + wfDebug( 'Unable to create temporary directory ' . $wgTmpDirectory ); |
| 102 | + wfProfileOut( __METHOD__ ); |
96 | 103 | return "<b>$mf (" . wfMsg( "math_bad_tmpdir" ) |
97 | 104 | . ")</b>"; |
98 | 105 | } |
99 | 106 | } elseif ( !is_dir( $wgTmpDirectory ) || |
100 | 107 | !is_writable( $wgTmpDirectory ) ) { |
| 108 | + wfDebug( 'Unable to write to temporary directory ' . $wgTmpDirectory ); |
| 109 | + wfProfileOut( __METHOD__ ); |
101 | 110 | return "<b>$mf (" . wfMsg( "math_bad_tmpdir" ) . ")</b>"; |
102 | 111 | } |
103 | 112 | |
104 | 113 | $lyFile = $md5 . ".ly"; |
105 | 114 | $out = fopen( $wgTmpDirectory . "/" . $lyFile, "w" ); |
106 | 115 | if ( $out === false ) { |
| 116 | + wfDebug( 'Unable to write to temporary directory ' . $wgTmpDirectory . "/" . $lyFile ); |
| 117 | + wfProfileOut( __METHOD__ ); |
107 | 118 | return "<b>$mf (" . wfMsg( "math_bad_tmpdir" ) . ")</b>"; |
108 | 119 | } |
109 | 120 | fwrite( $out, $lilypond_code ); |
— | — | @@ -119,6 +130,7 @@ |
120 | 131 | chdir( $oldcwd ); |
121 | 132 | |
122 | 133 | if ( $ret != 0 ) { |
| 134 | + wfProfileOut( __METHOD__ ); |
123 | 135 | return "<br><b>LilyPond error:</b><br><i>" |
124 | 136 | . str_replace( array( $md5, " " ), |
125 | 137 | array( "<b>your code</b>", " " ), |
— | — | @@ -130,6 +142,8 @@ |
131 | 143 | $outputFile = $wgTmpDirectory . "/" . $md5 . ".png"; |
132 | 144 | |
133 | 145 | if ( !file_exists( $outputFile ) ) { |
| 146 | + wfDebug( 'Output file doesn\'t exist ' . $outputFile ); |
| 147 | + wfProfileOut( __METHOD__ ); |
134 | 148 | return "<b>$mf (" . wfMsg( "math_image_error" ) |
135 | 149 | . ")</b>"; |
136 | 150 | } |
— | — | @@ -198,6 +212,7 @@ |
199 | 213 | self::frameImage( $imgFile, $imgFile, 0xFFFFFF, $wgLilypondBorderX, $wgLilypondBorderY ); |
200 | 214 | } |
201 | 215 | |
| 216 | + wfProfileOut( __METHOD__ ); |
202 | 217 | return $pre . $link . $post; |
203 | 218 | } |
204 | 219 | |