X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FRevision.php;h=458b312daad6fc69933efd8f6f76a2ea0b40b314;hb=d169a9bc8a44752ed5b1ef1348f25ae2ab6bc24c;hp=aa77bf963d399195cb0b4217d4a58806986a5ef8;hpb=edda5eca4c41be467d8fc78764ab4355bb73f766;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Revision.php b/includes/Revision.php index aa77bf963d..458b312daa 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -319,9 +319,9 @@ class Revision { $this->mSize = intval( $row->rev_len ); if( isset( $row->page_latest ) ) { - $this->mCurrent = ( $row->rev_id == $row->page_latest ); - $this->mTitle = Title::makeTitle( $row->page_namespace, - $row->page_title ); + $this->mCurrent = ( $row->rev_id == $row->page_latest ); + $this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title ); + $this->mTitle->resetArticleID( $this->mPage ); } else { $this->mCurrent = false; $this->mTitle = null; @@ -363,6 +363,7 @@ class Revision { } else { throw new MWException( 'Revision constructor passed invalid row format.' ); } + $this->mUnpatrolled = NULL; } /**#@+ @@ -536,6 +537,27 @@ class Revision { public function isMinor() { return (bool)$this->mMinorEdit; } + + /** + * @return int rcid of the unpatrolled row, zero if there isn't one + */ + public function isUnpatrolled() { + if( $this->mUnpatrolled !== NULL ) { + return $this->mUnpatrolled; + } + $dbr = wfGetDB( DB_SLAVE ); + $this->mUnpatrolled = $dbr->selectField( 'recentchanges', + 'rc_id', + array( // Add redundant user,timestamp condition so we can use the existing index + 'rc_user_text' => $this->getRawUserText(), + 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ), + 'rc_this_oldid' => $this->getId(), + 'rc_patrolled' => 0 + ), + __METHOD__ + ); + return (int)$this->mUnpatrolled; + } /** * int $field one of DELETED_* bitfield constants @@ -544,6 +566,13 @@ class Revision { public function isDeleted( $field ) { return ($this->mDeleted & $field) == $field; } + + /** + * Get the deletion bitfield of the revision + */ + public function getVisibility() { + return (int)$this->mDeleted; + } /** * Fetch revision text if it's available to the specified audience. @@ -657,7 +686,7 @@ class Revision { * $row is usually an object from wfFetchRow(), both the flags and the text * field must be included * - * @param integer $row Id of a row + * @param object $row The text data * @param string $prefix table prefix (default 'old_') * @return string $text|false the text requested */ @@ -713,9 +742,11 @@ class Revision { } global $wgLegacyEncoding; - if( $wgLegacyEncoding && !in_array( 'utf-8', $flags ) ) { + if( $wgLegacyEncoding && !in_array( 'utf-8', $flags ) && !in_array( 'utf8', $flags ) ) { # Old revisions kept around in a legacy encoding? # Upconvert on demand. + # ("utf8" checked for compatibility with some broken + # conversion scripts 2008-12-30) global $wgInputEncoding, $wgContLang; $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding, $text ); } @@ -769,10 +800,13 @@ class Revision { $flags = Revision::compressRevisionText( $data ); # Write to external storage if required - if ( $wgDefaultExternalStore ) { + if( $wgDefaultExternalStore ) { // Store and get the URL $data = ExternalStore::insertToDefault( $data ); - if ( $flags ) { + if( !$data ) { + throw new MWException( "Unable to store text to external storage" ); + } + if( $flags ) { $flags .= ','; } $flags .= 'external'; @@ -807,7 +841,8 @@ class Revision { 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ), 'rev_deleted' => $this->mDeleted, 'rev_len' => $this->mSize, - 'rev_parent_id' => $this->mParentId ? $this->mParentId : $this->getPreviousRevisionId( $dbw ) + 'rev_parent_id' => is_null($this->mParentId) ? + $this->getPreviousRevisionId( $dbw ) : $this->mParentId ), __METHOD__ ); @@ -896,7 +931,7 @@ class Revision { $current = $dbw->selectRow( array( 'page', 'revision' ), - array( 'page_latest', 'rev_text_id' ), + array( 'page_latest', 'rev_text_id', 'rev_len' ), array( 'page_id' => $pageId, 'page_latest=rev_id', @@ -909,7 +944,8 @@ class Revision { 'comment' => $summary, 'minor_edit' => $minor, 'text_id' => $current->rev_text_id, - 'parent_id' => $current->page_latest + 'parent_id' => $current->page_latest, + 'len' => $current->rev_len ) ); } else { $revision = null; @@ -943,15 +979,17 @@ class Revision { /** * Get rev_timestamp from rev_id, without loading the rest of the row + * @param Title $title * @param integer $id - * @param integer $pageid, optional */ - static function getTimestampFromId( $id, $pageId = 0 ) { + static function getTimestampFromId( $title, $id ) { $dbr = wfGetDB( DB_SLAVE ); - $conds = array( 'rev_id' => $id ); - if( $pageId ) { - $conds['rev_page'] = $pageId; + // Casting fix for DB2 + if ($id == '') { + $id = 0; } + $conds = array( 'rev_id' => $id ); + $conds['rev_page'] = $title->getArticleId(); $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ ); if ( $timestamp === false && wfGetLB()->getServerCount() > 1 ) { # Not in slave, try master