r107215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107214‎ | r107215 | r107216 >
Date:18:18, 24 December 2011
Author:grafzahl
Status:ok
Tags:
Comment:
Monopolise our globals and set them unconditionally.
This fixes a register globals issue, see r107162#c28479.
Modified paths:
  • /trunk/extensions/Score/Score.body.php (modified) (history)
  • /trunk/extensions/Score/Score.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Score/Score.php
@@ -46,20 +46,14 @@
4747 * Default is $wgUseImageMagick and set in efScoreExtension */
4848 $wgScoreTrim = null;
4949
50 -/* Path of lilypond executable */
51 -if ( !isset( $wgLilyPond ) ) {
52 - $wgLilyPond = '/usr/bin/lilypond';
53 -}
 50+/* Path to LilyPond executable */
 51+$wgScoreLilyPond = '/usr/bin/lilypond';
5452
5553 /* Path to converter from ABC */
56 -if ( !isset( $wgAbc2Ly ) ) {
57 - $wgAbc2Ly = '/usr/bin/abc2ly';
58 -}
 54+$wgScoreAbc2Ly = '/usr/bin/abc2ly';
5955
6056 /* Path to TiMidity++ */
61 -if ( !isset( $wgTimidity ) ) {
62 - $wgTimidity = '/usr/bin/timidity';
63 -}
 57+$wgScoreTimidity = '/usr/bin/timidity';
6458
6559 /*
6660 * Extension credits
Index: trunk/extensions/Score/Score.body.php
@@ -108,13 +108,13 @@
109109 * @throws ScoreException if LilyPond could not be executed properly.
110110 */
111111 private static function getLilypondVersion() {
112 - global $wgLilyPond;
 112+ global $wgScoreLilyPond;
113113
114 - if ( !is_executable( $wgLilyPond ) ) {
115 - throw new ScoreException( wfMessage( 'score-notexecutable', $wgLilyPond ) );
 114+ if ( !is_executable( $wgScoreLilyPond ) ) {
 115+ throw new ScoreException( wfMessage( 'score-notexecutable', $wgScoreLilyPond ) );
116116 }
117117
118 - $cmd = wfEscapeShellArg( $wgLilyPond ) . ' --version 2>&1';
 118+ $cmd = wfEscapeShellArg( $wgScoreLilyPond ) . ' --version 2>&1';
119119 $output = wfShellExec( $cmd, $rc );
120120 if ( $rc != 0 ) {
121121 self::throwCallException( wfMessage( 'score-versionerr' ), $output );
@@ -310,7 +310,7 @@
311311 * @throws ScoreException on error.
312312 */
313313 private static function generatePngAndMidi( $code, $options, $filePrefix, $factoryDirectory ) {
314 - global $wgLilyPond, $wgScoreTrim;
 314+ global $wgScoreLilyPond, $wgScoreTrim;
315315
316316 wfProfileIn( __METHOD__ );
317317
@@ -377,10 +377,10 @@
378378 if ( !$rc ) {
379379 throw new ScoreException( wfMessage( 'score-chdirerr', $factoryDirectory ) );
380380 }
381 - if ( !is_executable( $wgLilyPond ) ) {
382 - throw new ScoreException( wfMessage( 'score-notexecutable', $wgLilyPond ) );
 381+ if ( !is_executable( $wgScoreLilyPond ) ) {
 382+ throw new ScoreException( wfMessage( 'score-notexecutable', $wgScoreLilyPond ) );
383383 }
384 - $cmd = wfEscapeShellArg( $wgLilyPond )
 384+ $cmd = wfEscapeShellArg( $wgScoreLilyPond )
385385 . ' -dsafe='
386386 . wfEscapeShellArg( '#t' )
387387 . ' -dbackend=eps --png --header=texidoc '
@@ -478,7 +478,7 @@
479479 * @throws ScoreException if an error occurs.
480480 */
481481 private static function generateOgg( $options, $filePrefix, $factoryDirectory ) {
482 - global $wgTimidity;
 482+ global $wgScoreTimidity;
483483
484484 wfProfileIn( __METHOD__ );
485485
@@ -490,10 +490,10 @@
491491 $ogg = "$filePrefix.ogg";
492492
493493 /* Run timidity */
494 - if ( !is_executable( $wgTimidity ) ) {
495 - throw new ScoreException( wfMessage( 'score-timiditynotexecutable', $wgTimidity ) );
 494+ if ( !is_executable( $wgScoreTimidity ) ) {
 495+ throw new ScoreException( wfMessage( 'score-timiditynotexecutable', $wgScoreTimidity ) );
496496 }
497 - $cmd = wfEscapeShellArg( $wgTimidity )
 497+ $cmd = wfEscapeShellArg( $wgScoreTimidity )
498498 . ' -Ov' // Vorbis output
499499 . ' --output-file=' . wfEscapeShellArg( $factoryOgg )
500500 . ' ' . wfEscapeShellArg( $midi )
@@ -563,7 +563,7 @@
564564 * @throws ScoreException if the conversion fails.
565565 */
566566 private function generateLilypondFromAbc( $code, $factoryDirectory ) {
567 - global $wgAbc2Ly;
 567+ global $wgScoreAbc2Ly;
568568
569569 $factoryAbc = "$factoryDirectory/file.abc";
570570 $factoryLy = "$factoryDirectory/file.ly";
@@ -575,11 +575,11 @@
576576 }
577577
578578 /* Convert to LilyPond file */
579 - if ( !is_executable( $wgAbc2Ly ) ) {
580 - throw new ScoreException( wfMessage( 'score-abc2lynotexecutable', $wgAbc2Ly ) );
 579+ if ( !is_executable( $wgScoreAbc2Ly ) ) {
 580+ throw new ScoreException( wfMessage( 'score-abc2lynotexecutable', $wgScoreAbc2Ly ) );
581581 }
582582
583 - $cmd = wfEscapeShellArg( $wgAbc2Ly )
 583+ $cmd = wfEscapeShellArg( $wgScoreAbc2Ly )
584584 . ' -s'
585585 . ' --output=' . wfEscapeShellArg( $factoryLy )
586586 . ' ' . wfEscapeShellArg( $factoryAbc )

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107162Do not unconditionally set global variables that might be used by other exten...grafzahl16:41, 23 December 2011

Status & tagging log