# if we have a content object, use it to set the model and type
if ( !empty( $row['content'] ) ) {
- //@todo: when is that set? test with external store setup! check out insertOn() [dk]
+ // @todo when is that set? test with external store setup! check out insertOn() [dk]
if ( !empty( $row['text_id'] ) ) {
throw new MWException( "Text already stored in external store (id {$row['text_id']}), " .
"can't serialize content object" );
}
/**
- * @return Integer rcid of the unpatrolled row, zero if there isn't one
+ * @return integer rcid of the unpatrolled row, zero if there isn't one
*/
public function isUnpatrolled() {
if ( $this->mUnpatrolled !== null ) {
return $this->mUnpatrolled;
}
+ $rc = $this->getRecentChange();
+ if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == 0 ) {
+ $this->mUnpatrolled = $rc->getAttribute( 'rc_id' );
+ } else {
+ $this->mUnpatrolled = 0;
+ }
+ return $this->mUnpatrolled;
+ }
+
+ /**
+ * Get the RC object belonging to the current revision, if there's one
+ *
+ * @since 1.22
+ * @return RecentChange|null
+ */
+ public function getRecentChange() {
$dbr = wfGetDB( DB_SLAVE );
- $this->mUnpatrolled = $dbr->selectField( 'recentchanges',
- 'rc_id',
- array( // Add redundant user,timestamp condition so we can use the existing index
+ return RecentChange::newFromConds(
+ array(
'rc_user_text' => $this->getRawUserText(),
'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
- 'rc_this_oldid' => $this->getId(),
- 'rc_patrolled' => 0
+ 'rc_this_oldid' => $this->getId()
),
__METHOD__
);
- return (int)$this->mUnpatrolled;
}
/**
* to the $audience parameter
*
* @deprecated in 1.21, use getContent() instead
- * @todo: replace usage in core
+ * @todo Replace usage in core
* @return String
*/
public function getText( $audience = self::FOR_PUBLIC, User $user = null ) {