Do proper pre-pack processing for $this->hash.

Output hash calcuation sometimes fails because of Texvc failure for
example, and $this->hash remains ''. At this time inserting null as
outputhash into database is improper, because that column is NOT NULL.

With this patch an empty string '' is inserted instead, and the if-check
is modified to avoid cases where ->hash exists but evaluates as null
(for example when it's '0000000000...' though it's extremely rare).

Change-Id: I852859f4b151b777c11b743faaed61dfc2c029a7
This commit is contained in:
Liangent 2013-03-13 18:57:41 +08:00
parent aa8a0eaf19
commit 20192a1ab8

View File

@ -154,10 +154,10 @@ abstract class MathRenderer {
# Now save it back to the DB:
if ( !wfReadOnly() ) {
$dbw = wfGetDB( DB_MASTER );
if ( $this->hash ) {
if ( $this->hash !== '' ) {
$outmd5_sql = $dbw->encodeBlob( pack( 'H32', $this->hash ) );
} else {
$outmd5_sql = null;
$outmd5_sql = '';
}
wfDebugLog( "Math", 'store entry for $' . $this->tex . '$ in database (hash:' . $this->getInputHash() . ')\n' );
$dbw->replace(