From 86c799210070b3bff0669b4b4d1cf08a075af0da Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 12 Aug 2011 17:29:57 +0000 Subject: [PATCH] * Added Revision::getSha1 function * Try to populate mSha1 when a Revision is made from an array (as rev_len does) --- includes/Revision.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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. * -- 2.20.1