- if ($wgIsMySQL) {
- $sql = "REPLACE INTO watchlist (wl_user, wl_namespace,wl_title) ".
- "VALUES ($this->id,$this->ns,'$this->eti')";
- $res = wfQuery( $sql, DB_WRITE );
- } else {
- $sql = "DELETE FROM watchlist WHERE wl_user=$this->id AND
- wl_namespace=$this->ns AND wl_title='$this->eti'";
- wfQuery( $sql, DB_WRITE);
- $sql = "INSERT INTO watchlist (wl_user, wl_namespace,wl_title) ".
- "VALUES ($this->id,$this->ns,'$this->eti')";
- $res = wfQuery( $sql, DB_WRITE );
- }
+ $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),
+ 'wl_title' => $this->ti,
+ 'wl_notificationtimestamp' => NULL
+ ), $fname );
+
+ # the following code compensates the new behaviour, introduced by the enotif patch,
+ # that every single watched page needs now to be listed in watchlist
+ # namespace:page and namespace_talk:page need separate entries: create them
+ $dbw->replace( 'watchlist', array(array('wl_user', 'wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
+ array(
+ 'wl_user' => $this->id,
+ 'wl_namespace' => ($this->ns | 1 ),
+ 'wl_title' => $this->ti,
+ 'wl_notificationtimestamp' => NULL
+ ), $fname );