r106481 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106480‎ | r106481 | r106482 >
Date:21:35, 16 December 2011
Author:mah
Status:ok
Tags:
Comment:
followup r106459, Use wfMkdirParents(), add a missing message.
Modified paths:
  • /trunk/extensions/Score/Score.body.php (modified) (history)
  • /trunk/extensions/Score/Score.i18n.php (modified) (history)
  • /trunk/extensions/Score/Score.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Score/Score.i18n.php
@@ -40,6 +40,8 @@
4141 'score-compilererr' => 'Unable to compile LilyPond input file:',
4242 'score-desc' => 'MediaWiki tag extension for rendering musical scores with LilyPond',
4343 'score-getcwderr' => 'Unable to obtain current working directory',
 44+ 'score-nooutput' => 'Failed to create LilyPond image dir',
 45+ 'score-nofactory' => 'Failed to create LilyPond factory dir',
4446 'score-noinput' => 'Failed to create LilyPond input file',
4547 'score-page' => 'Page',
4648 'score-renameerr' => 'Error moving score files to upload directory',
@@ -58,5 +60,3 @@
5961 'score-renameerr' => 'Displayed if moving the resultant files from the working environment to the upload directory fails.',
6062 'score-trimerr' => 'Displayed if the extension failed to trim an output image.',
6163 );
62 -
63 -?>
Index: trunk/extensions/Score/Score.php
@@ -91,5 +91,3 @@
9292
9393 return true;
9494 }
95 -
96 -?>
Index: trunk/extensions/Score/Score.body.php
@@ -119,7 +119,8 @@
120120 $factoryImageTrimmed = $factoryDirectory . "/file-trimmed.png";
121121 $factoryMultiFormat = $factoryDirectory . "/file-%d.png"; // for multi-page scores
122122 $factoryMultiTrimmedFormat = $factoryDirectory . "/file-%d-trimmed.png";
123 - $rel = 'lilypond/' . md5( $lilypondCode ); // FIXME: Too many files in one directory?
 123+ $lilypondDir = "lilypond";
 124+ $rel = $lilypondDir . "/" . md5( $lilypondCode ); // FIXME: Too many files in one directory?
124125 $filePrefix = "$wgUploadDirectory/$rel";
125126 $pathPrefix = "$wgUploadPath/$rel";
126127 $midi = "$filePrefix.midi";
@@ -162,7 +163,15 @@
163164 }
164165
165166 /* create working environment */
166 - $rc = mkdir( $factoryDirectory, 0700, true );
 167+ if ( !file_exists( "$wgUploadDirectory/$lilypondDir" ) ) {
 168+ $rc = wfMkdirParents( "$wgUploadDirectory/$lilypondDir", null, __METHOD__ );
 169+ if ( !$rc ) {
 170+ throw new ScoreException( 'score-nooutput' );
 171+ }
 172+ }
 173+
 174+ /* create working environment */
 175+ $rc = wfMkdirParents( $factoryDirectory, 0700, __METHOD__ );
167176 if ( !$rc ) {
168177 throw new ScoreException( 'score-nofactory' );
169178 }
@@ -222,7 +231,7 @@
223232 if ( file_exists( $factoryMidi ) ) {
224233 $rc = $rc && rename( $factoryMidi, $midi );
225234 }
226 - if ( file_exists( $factoryImage ) ) {
 235+ if ( file_exists( $factoryImageTrimmed ) ) {
227236 $rc = $rc && rename( $factoryImageTrimmed, $image );
228237 }
229238 for ( $i = 1; file_exists( $f = sprintf( $factoryMultiTrimmedFormat, $i ) ); ++$i ) {
@@ -319,5 +328,3 @@
320329 }
321330
322331 }
323 -
324 -?>

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106459Commit Lilypond replacement from https://github.com/TheCount/score...mah18:47, 16 December 2011

Status & tagging log