global $wgDBname;
return "$wgDBname:watchlist:user:$this->id:page:$this->ns:$this->ti";
}
-
+
/**
* Is mTitle being watched by mUser?
*/
$key = $this->watchKey();
$iswatched = $wgMemc->get( $key );
if( is_integer( $iswatched ) ) return $iswatched;
-
+
$dbr =& wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'watchlist', 1, array( 'wl_user' => $this->id, 'wl_namespace' => $this->ns,
+ $res = $dbr->select( 'watchlist', 1, array( 'wl_user' => $this->id, 'wl_namespace' => $this->ns,
'wl_title' => $this->ti ), $fname );
$iswatched = ($dbr->numRows( $res ) > 0) ? 1 : 0;
$wgMemc->set( $key, $iswatched );
*/
function addWatch() {
$fname = 'WatchedItem::addWatch';
+ wfProfileIn( $fname );
# REPLACE instead of INSERT because occasionally someone
# accidentally reloads a watch-add operation.
$dbw =& wfGetDB( DB_MASTER );
$dbw->replace( 'watchlist', array(array('wl_user', 'wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
- array(
+ array(
'wl_user' => $this->id,
'wl_namespace' => ($this->ns & ~1),
'wl_title' => $this->ti,
- 'wl_notificationtimestamp' => '0'
+ 'wl_notificationtimestamp' => NULL
), $fname );
# the following code compensates the new behaviour, introduced by the enotif patch,
'wl_user' => $this->id,
'wl_namespace' => ($this->ns | 1 ),
'wl_title' => $this->ti,
- 'wl_notificationtimestamp' => '0'
+ 'wl_notificationtimestamp' => NULL
), $fname );
global $wgMemc;
$wgMemc->set( $this->watchkey(), 1 );
+ wfProfileOut( $fname );
return true;
}
function removeWatch() {
+ global $wgMemc;
$fname = 'WatchedItem::removeWatch';
+ $success = false;
$dbw =& wfGetDB( DB_MASTER );
- $dbw->delete( 'watchlist',
- array(
- 'wl_user' => $this->id,
+ $dbw->delete( 'watchlist',
+ array(
+ 'wl_user' => $this->id,
'wl_namespace' => ($this->ns & ~1),
'wl_title' => $this->ti
), $fname
);
+ if ( $dbw->affectedRows() ) {
+ $success = true;
+ }
# the following code compensates the new behaviour, introduced by the
# enotif patch, that every single watched page needs now to be listed
'wl_title' => $this->ti
), $fname
);
-
+
if ( $dbw->affectedRows() ) {
- global $wgMemc;
+ $success = true;
+ }
+ if ( $success ) {
$wgMemc->set( $this->watchkey(), 0 );
- return true;
- } else {
- return false;
}
+ return $success;
}
/**
$dbw =& wfGetDB( DB_MASTER );
$watchlist = $dbw->tableName( 'watchlist' );
-
- $res = $dbw->select( 'watchlist', 'wl_user',
+
+ $res = $dbw->select( 'watchlist', 'wl_user',
array( 'wl_namespace' => $oldnamespace, 'wl_title' => $oldtitle ),
$fname, 'FOR UPDATE'
);