From 7b8efba71bb04820d0b09db4d0ee459e192053be Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Fri, 11 Jun 2004 15:54:29 +0000 Subject: [PATCH] de-mysql: remove REPLACE INTO and DELETE .. LIMIT for nonmysql --- includes/WatchedItem.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index 74371be4bf..23ad2804e1 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -36,10 +36,22 @@ class WatchedItem { function addWatch() { + global $wgIsMySQL; # REPLACE instead of INSERT because occasionally someone # accidentally reloads a watch-add operation. - $sql = "REPLACE INTO watchlist (wl_user, wl_namespace,wl_title) VALUES ($this->id,$this->ns,'$this->eti')"; - $res = wfQuery( $sql, DB_WRITE ); + 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 ); + } + if( $res === false ) return false; global $wgMemc; @@ -49,7 +61,7 @@ class WatchedItem { function removeWatch() { - $sql = "DELETE FROM watchlist WHERE wl_user=$this->id AND wl_namespace=$this->ns AND wl_title='$this->eti' LIMIT 1"; + $sql = "DELETE FROM watchlist WHERE wl_user=$this->id AND wl_namespace=$this->ns AND wl_title='$this->eti'"; $res = wfQuery( $sql, DB_WRITE ); if( $res === false ) return false; -- 2.20.1