From 20192a1ab87d092963af732fdd8c95e5e60509a8 Mon Sep 17 00:00:00 2001 From: Liangent Date: Wed, 13 Mar 2013 18:57:41 +0800 Subject: [PATCH] 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 --- MathRenderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MathRenderer.php b/MathRenderer.php index 10676aa..e969ad9 100644 --- a/MathRenderer.php +++ b/MathRenderer.php @@ -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(