From: Aaron Schulz Date: Fri, 12 Aug 2011 17:29:57 +0000 (+0000) Subject: * Added Revision::getSha1 function X-Git-Tag: 1.31.0-rc.0~28311 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=86c799210070b3bff0669b4b4d1cf08a075af0da;p=lhc%2Fweb%2Fwiklou.git * Added Revision::getSha1 function * Try to populate mSha1 when a Revision is made from an array (as rev_len does) --- diff --git a/includes/Revision.php b/includes/Revision.php index 89599bfb3f..996f7ef541 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -405,9 +405,14 @@ class Revision { $this->mTitle = null; # Load on demand if needed $this->mCurrent = false; - # If we still have no len_size, see it we have the text to figure it out - if ( !$this->mSize ) - $this->mSize = is_null( $this->mText ) ? null : strlen( $this->mText ); + # If we still have no length, see it we have the text to figure it out + if ( !$this->mSize ) { + $this->mSize = is_null( $this->mText ) ? null : strlen( $this->mText ); + } + # Same for sha1 + if ( $this->mSha1 === null ) { + $this->mSha1 = is_null( $this->mText ) ? null : self::base36Sha1( $this->mText ); + } } else { throw new MWException( 'Revision constructor passed invalid row format.' ); } @@ -450,6 +455,15 @@ class Revision { return $this->mSize; } + /** + * Returns the base36 sha1 of the text in this revision, or null if unknown. + * + * @return String + */ + public function getSha1() { + return $this->mSha1; + } + /** * Returns the title of the page associated with this entry. *