Have Math.php use encodeBlob and decodeBlob when accessing the binary fields math_inp...
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Fri, 8 Jun 2007 01:06:52 +0000 (01:06 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Fri, 8 Jun 2007 01:06:52 +0000 (01:06 +0000)
long-term solution is to simply store the hexadecimal as text, but converting via updaters.inc will be complex.
Fixes bug # 9909.

RELEASE-NOTES
includes/Math.php

index d946df0..ef16df3 100644 (file)
@@ -142,6 +142,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Fix maintenance/importImages.php so it doesn't barf PHP errors when no suitable
   files are found, and make the list of extensions an option (defaults to
   $wgFileExtensions)
+* (bug 9909) Ensure access to binary fields in the math table use encodeBlob() 
+  and decodeBlob.
 
 == MediaWiki API changes since 1.10 ==
 
index 88934e5..f046524 100644 (file)
@@ -157,8 +157,8 @@ class MathRenderer {
                                $dbw = wfGetDB( DB_MASTER );
                                $dbw->replace( 'math', array( 'math_inputhash' ),
                                  array(
-                                       'math_inputhash' => $md5_sql,
-                                       'math_outputhash' => $outmd5_sql,
+                                       'math_inputhash' => $dbw->encodeBlob($md5_sql),
+                                       'math_outputhash' => $dbw->encodeBlob($outmd5_sql),
                                        'math_html_conservativeness' => $this->conservativeness,
                                        'math_html' => $this->html,
                                        'math_mathml' => $this->mathml,
@@ -186,13 +186,13 @@ class MathRenderer {
                $dbr = wfGetDB( DB_SLAVE );
                $rpage = $dbr->selectRow( 'math',
                        array( 'math_outputhash','math_html_conservativeness','math_html','math_mathml' ),
-                       array( 'math_inputhash' => pack("H32", $this->md5)), # Binary packed, not hex
+                       array( 'math_inputhash' => $dbr->encodeBlob(pack("H32", $this->md5))), # Binary packed, not hex
                        $fname
                );
 
                if( $rpage !== false ) {
                        # Tailing 0x20s can get dropped by the database, add it back on if necessary:
-                       $xhash = unpack( 'H32md5', $rpage->math_outputhash . "                " );
+                       $xhash = unpack( 'H32md5', $dbr->decodeBlob($rpage->math_outputhash) . "                " );
                        $this->hash = $xhash ['md5'];
 
                        $this->conservativeness = $rpage->math_html_conservativeness;