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

bzimport added a project: MediaWiki-Database.Via ConduitNov 21 2014, 9:41 PM
bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz9909.
bzimport created this task.Via LegacyMay 14 2007, 3:51 PM
hashar added a comment.Via ConduitMay 17 2007, 10:48 AM

blocks bug 384

Turnstep added a comment.Via ConduitJun 8 2007, 1:07 AM

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().

bzimport added a comment.Via ConduitJul 20 2007, 3:31 PM

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.

brion added a comment.Via ConduitAug 8 2007, 5:30 PM
  • Bug 10780 has been marked as a duplicate of this bug. ***

Add Comment