Page MenuHomePhabricator

PHP fatal error when override_midi is used and a Lilypond error is encountered
Closed, ResolvedPublic

Description

Author: mediazilla

Description:
In addition to bug 47536, attempting to use the "override_midi" property on a score snippet that throws a Lilypond error causes a PHP fatal error.

For instance, this:

<score override_midi="Las notas Musicales .MID">\relative c' { \cadenzaOn c1 \cadenzaOff }</score>

yields this upon attempts to save or preview the page:

PHP fatal error in /usr/local/apache/common-local/php-1.22wmf2/extensions/Score/Score.body.php line 130:
Object of class ForeignDBFile could not be converted to string

Version: unspecified
Severity: normal

Details

Reference
bz47537

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:29 AM
bzimport set Reference to bz47537.
bzimport added a subscriber: Unknown Object (MLST).

private static function throwCallException( $message, $output, $factoryDir = false ) {

		/* clean up the output a bit */
		if ( $factoryDir ) {
			$output = str_replace( $factoryDir, '...', $output );
		}
		throw new ScoreException(
			$message->rawParams(
				Html::rawElement( 'pre',
					array(),
					htmlspecialchars( $output )
				)
			)
		);

}

Line 130 is the str_replace. Though it's already dying and trying to show a message...

[23-Apr-2013 10:04:17] Catchable fatal error: Object of class ForeignDBFile could not be converted to string at /usr/local/apache/common-local/php-1.22wmf2/extensions/Score/Score.body.php on line 130
Server: mw1078
Method: POST
URL: http://en.wikipedia.org/w/index.php?title=Note&action=submit
Backtrace:
#0 /usr/local/apache/common-local/php-1.22wmf2/extensions/Score/Score.body.php(130): str_replace(Array, '...', 'Processing `/tm...')
#1 /usr/local/apache/common-local/php-1.22wmf2/extensions/Score/Score.body.php(595): Score::throwCallException(Object(Message), 'Processing `/tm...', Array)
#2 /usr/local/apache/common-local/php-1.22wmf2/extensions/Score/Score.body.php(419): Score::generatePngAndMidi('\relative c' { ...', Array)
#3 /usr/local/apache/common-local/php-1.22wmf2/extensions/Score/Score.body.php(343): Score::generateHTML(Object(Parser), '\relative c' { ...', Array)
#4 [internal function]: Score::render('\relative c' { ...', Array, Object(Parser), Object(PPFrame_DOM))
#5 /usr/local/apache/common-local/php-1.22wmf2/includes/parser/Parser.php(3918): call_user_func_array('Score::render', Array)
#6 /usr/local/apache/common-local/php-1.22wmf2/includes/parser/Preprocessor_DOM.php(1154): Parser->extensionSubstitution(Array, Object(PPFrame_DOM))
#7 /usr/local/apache/common-local/php-1.22wmf2/includes/parser/Parser.php(3075): PPFrame_DOM->expand(Object(PPNode_DOM), 0)
#8 /usr/local/apache/common-local/php-1.22wmf2/includes/parser/Parser.php(1153): Parser->replaceVariables('== Written note...')
#9 /usr/local/apache/common-local/php-1.22wmf2/includes/parser/Parser.php(383): Parser->internalParse('== Written note...')
#10 /usr/local/apache/common-local/php-1.22wmf2/includes/content/WikitextContent.php(300): Parser->parse('== Written note...', Object(Title), Object(ParserOptions), true, true, NULL)
#11 /usr/local/apache/common-local/php-1.22wmf2/includes/EditPage.php(3081): WikitextContent->getParserOutput(Object(Title), NULL, Object(ParserOptions))
#12 /usr/local/apache/common-local/php-1.22wmf2/includes/EditPage.php(2103): EditPage->getPreviewText()
#13 /usr/local/apache/common-local/php-1.22wmf2/includes/EditPage.php(441): EditPage->showEditForm()
#14 /usr/local/apache/common-local/php-1.22wmf2/includes/actions/EditAction.php(50): EditPage->edit()
#15 /usr/local/apache/common-local/php-1.22wmf2/includes/actions/EditAction.php(76): EditAction->show()
#16 /usr/local/apache/common-local/php-1.22wmf2/includes/Wiki.php(439): SubmitAction->show()
#17 /usr/local/apache/common-local/php-1.22wmf2/includes/Wiki.php(305): MediaWiki->performAction(Object(Article), Object(Title))
#18 /usr/local/apache/common-local/php-1.22wmf2/includes/Wiki.php(565): MediaWiki->performRequest()
#19 /usr/local/apache/common-local/php-1.22wmf2/includes/Wiki.php(458): MediaWiki->main()
#20 /usr/local/apache/common-local/php-1.22wmf2/index.php(59): MediaWiki->run()
#21 /usr/local/apache/common-local/w/index.php(3): require('/usr/local/apac...')
#22 {main}

Related URL: https://gerrit.wikimedia.org/r/60591 (Gerrit Change If34de5d78125eb64fbc2e1c2cf1a3a30cfc22018)

The bad error handling is now fixed

Now it is:

Processing `/tmp/MWLP.677c274f6084bc6ca2429fe3e0fbdb94/file.ly'
Parsing...
Interpreting music...
warning: cannot find or create Timing' called '
warning: cannot find or create Timing' called '
Preprocessing graphical objects...
Interpreting music...
warning: cannot find or create Timing' called '
warning: cannot find or create Timing' called '

exited with status: 139

It's not override_midi related, you seem to have invalid lilypad syntax.

On a random test:

<score raw="1" override_midi="Las notas Musicales .MID">
\header {

title =       "Boci-boci tarka"
enteredby =   "grin"

}

\version "2.14.2"

\score {
\new Staff <<
\relative c'
{

\key c \major
\time 4/4
c\mf e c e g2 g2  
c,4 e c e g2 <g e>2   
c4 b a g f2 a2 
g4 f e d c2 <c c'>2

}

\addlyrics {
Bo -- ci bo -- ci tar -- ka
Se fü -- le se far -- ka
O -- da me -- gyűnk lak -- ni
A -- hol te -- jet kap -- ni
}

\layout { }
\midi { }

}

</score>

Doesn't error about the override_midi