Page MenuHomePhabricator

Math rendering with TeX on postgres requires use of pg_escape_bytea()
Closed, ResolvedPublic

Description

Author: ole

Description:
On a postgres-based install (UTF-8 encoding), the database barfs on binary
values for the math_inputhash and math_outputhash columns in the SQL, reporting
invalid UTF-8 chars; the byte arrays need to be escaped with pg_escape_bytea()

A database error has occurred Query: SELECT
math_outputhash,math_html_conservativeness,math_html,math_mathml FROM math WHERE
math_inputhash = '� |(�ɖ\x17�\x1ce\x06�\\�' LIMIT 1 Function: MathRenderer::_recall
Error: 1 ERROR: invalid byte sequence for encoding "UTF8": 0xce0d

Backtrace:

#0 /storage/www/htdocs/wiki/includes/Database.php(761):
DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'SELECT math_ou...',
'MathRenderer::_...', false)
#1 /storage/www/htdocs/wiki/includes/Database.php(1179): Database->query('SELECT
math_ou...', 'MathRenderer::_...')
#2 /storage/www/htdocs/wiki/includes/Database.php(1198):
Database->select('math', Array, Array, 'MathRenderer::_...', Array)
#3 /storage/www/htdocs/wiki/includes/Math.php(191): Database->selectRow('math',
Array, Array, 'MathRenderer::_...')
#4 /storage/www/htdocs/wiki/includes/Math.php(44): MathRenderer->_recall()
#5 /storage/www/htdocs/wiki/includes/Math.php(269): MathRenderer->render()
#6 /storage/www/htdocs/wiki/includes/Parser.php(590):
MathRenderer::renderMath('Insert formula ...')
#7 /storage/www/htdocs/wiki/includes/Parser.php(300): Parser->strip('This
section de...', Object(StripState))
#8 /storage/www/htdocs/wiki/includes/Article.php(2289): Parser->parse('This
section de...', Object(Title), Object(ParserOptions), true, true, 30)
#9 /storage/www/htdocs/wiki/includes/Article.php(1380):
Article->editUpdates('This section de...', '', true, '20070514154832', 30, false)
#10 /storage/www/htdocs/wiki/includes/Article.php(1205): Article->doEdit('This
section de...', '', 102)
#11 /storage/www/htdocs/wiki/includes/EditPage.php(865):
Article->updateArticle('This section de...', '', true, false, '', '')
#12 /storage/www/htdocs/wiki/includes/EditPage.php(426): EditPage->attemptSave()
#13 /storage/www/htdocs/wiki/includes/EditPage.php(279): EditPage->edit()
#14 /storage/www/htdocs/wiki/includes/Wiki.php(432): EditPage->submit()
#15 /storage/www/htdocs/wiki/includes/Wiki.php(48):
MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title),
Object(User), Object(WebRequest))
#16 /storage/www/htdocs/wiki/index.php(89): MediaWiki->initialize(Object(Title),
Object(OutputPage), Object(User), Object(WebRequest))
#17 {main}


Version: 1.10.x
Severity: normal
OS: Linux
Platform: PC

Details

Reference
bz9909

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:41 PM
bzimport set Reference to bz9909.
bzimport added a subscriber: Unknown Object (MLST).

Patch applied in r22832. Thanks for the report. Someday, we'll flip those fields back to simple text and not do all that pack() and unpack().

mf+mediawiki wrote:

Just a note for other people trying to fix this in their installations:

The patch above will *not* work for version 1.10.1 because encodeBlob returns an array in this version. In SVN trunk it only returns the encoded value.

So you need to extract the second value from the array you get from encodeBlob and then pass this on to the database functions.

  • Bug 10780 has been marked as a duplicate of this bug. ***
Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.