- function addWatch() {
- $fname = 'WatchedItem::addWatch';
- # 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(
- 'wl_user' => $this->id,
- 'wl_namespace' => ($this->ns & ~1),
+ public function addWatch() {
+ wfProfileIn( __METHOD__ );
+
+ // Use INSERT IGNORE to avoid overwriting the notification timestamp
+ // if there's already an entry for this page
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->insert( 'watchlist',
+ array(
+ 'wl_user' => $this->id,
+ 'wl_namespace' => MWNamespace::getSubject($this->ns),