r98436 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98435‎ | r98436 | r98437 >
Date:19:41, 29 September 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix usages of @

Swap $parser to &$parser in ParserFirstCallInit hook

Comment blocks
Modified paths:
  • /trunk/extensions/LilyPond/LilyPond.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LilyPond/LilyPond.php
@@ -72,16 +72,25 @@
7373 /**
7474 * @param $parser Parser
7575 */
76 -function wfLilyPondExtension( $parser ) {
 76+function wfLilyPondExtension( &$parser ) {
7777 $parser->setHook( "lilypond", "renderLilyPondFragment" );
7878 $parser->setHook( "lilymidi", "renderLilyPondMidiFragment" );
7979 $parser->setHook( "lilybook", "renderLilyPond" );
8080 }
8181
 82+/**
 83+ * @param $lilypond_code string
 84+ * @return string
 85+ */
8286 function renderLilyPondMidiFragment( $lilypond_code ) {
8387 return renderLilyPondFragment( $lilypond_code, true );
8488 }
8589
 90+/**
 91+ * @param $lilypond_code string
 92+ * @param $midi bool
 93+ * @return string
 94+ */
8695 function renderLilyPondFragment( $lilypond_code, $midi = false ) {
8796 return renderLilyPond( "\\header {\n"
8897 . "\ttagline = ##f\n"
@@ -98,11 +107,16 @@
99108 . "}\n", $lilypond_code );
100109 }
101110
 111+/**
 112+ * @param $lilypond_code
 113+ * @param $short_code bool
 114+ * @return string
 115+ */
102116 function renderLilyPond( $lilypond_code, $short_code = false ) {
103117 global $wgMathPath, $wgMathDirectory, $wgTmpDirectory, $wgLilypond, $wgLilypondPreMidi,
104118 $wgLilypondPostMidi, $wgLilypondTrim, $wgLilypondBorderX, $wgLilypondBorderY;
105119
106 - $mf = wfMsg( "math_failure" );
 120+ $mf = wfMsg( "math_failure" );
107121
108122 $md5 = md5( $lilypond_code );
109123
@@ -139,7 +153,10 @@
140154
141155 # Ensure that the temp and output dirs are available before continuing.
142156 if ( !file_exists( $wgMathDirectory ) ) {
143 - if ( !@mkdir( $wgMathDirectory ) ) {
 157+ wfSuppressWarnings();
 158+ $res = mkdir( $wgMathDirectory );
 159+ wfRestoreWarnings();
 160+ if ( !$res ) {
144161 return "<b>$mf (" . wfMsg( "math_bad_output" ) .
145162 $wgMathDirectory . ")</b>";
146163 }
@@ -148,7 +165,10 @@
149166 return "<b>$mf (" . wfMsg( "math_bad_output" ) . ")</b>";
150167 }
151168 if ( !file_exists( $wgTmpDirectory ) ) {
152 - if ( !@mkdir( $wgTmpDirectory ) ) {
 169+ wfSuppressWarnings();
 170+ $res = mkdir( $wgTmpDirectory );
 171+ wfRestoreWarnings();
 172+ if ( !$res ) {
153173 return "<b>$mf (" . wfMsg( "math_bad_tmpdir" )
154174 . ")</b>";
155175 }
@@ -258,6 +278,11 @@
259279 return $pre . $link . $post;
260280 }
261281
 282+/**
 283+ * @param $source
 284+ * @param $dest
 285+ * @param $bgColour
 286+ */
262287 function trimImage( $source, $dest, $bgColour ) {
263288 $srcImage = imagecreatefrompng( $source );
264289 $width = imagesx( $srcImage );
@@ -319,6 +344,13 @@
320345 imagepng( $dstImage, $dest );
321346 }
322347
 348+/**
 349+ * @param $source
 350+ * @param $dest
 351+ * @param $bgColour
 352+ * @param $borderWidth
 353+ * @param $borderHeight
 354+ */
323355 function frameImage( $source, $dest, $bgColour, $borderWidth, $borderHeight ) {
324356 $srcImage = imagecreatefrompng( $source );
325357 $width = imagesx( $srcImage );

Status & tagging log