Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-41316 tool_spamcleaner: Fix sql queries

AS keyword is not allowed in sql qeries for table alias as Oracle doesn't support it
Thanks to Sara Cenni for suggesting the patch
  • Loading branch information...
commit ff8cadd271d025b0cdd823dff00aab9e8368b50a 1 parent a34073e
@ankitagarwal ankitagarwal authored samhemelryk committed
Showing with 41 additions and 7 deletions.
  1. +41 −7 admin/tool/spamcleaner/index.php
View
48 admin/tool/spamcleaner/index.php
@@ -178,13 +178,47 @@ function search_spammers($keywords) {
$conditions6 = '( '.implode(' OR ', $keywordfull6).' )';
$conditions7 = '( '.implode(' OR ', $keywordfull7).' )';
- $sql = "SELECT * FROM {user} WHERE deleted = 0 AND id <> :userid AND $conditions"; // Exclude oneself
- $sql2 = "SELECT u.*, p.summary FROM {user} AS u, {post} AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> :userid";
- $sql3 = "SELECT u.*, p.subject as postsubject FROM {user} AS u, {post} AS p WHERE $conditions3 AND u.deleted = 0 AND u.id=p.userid AND u.id <> :userid";
- $sql4 = "SELECT u.*, c.content FROM {user} AS u, {comments} AS c WHERE $conditions4 AND u.deleted = 0 AND u.id=c.userid AND u.id <> :userid";
- $sql5 = "SELECT u.*, m.fullmessage FROM {user} AS u, {message} AS m WHERE $conditions5 AND u.deleted = 0 AND u.id=m.useridfrom AND u.id <> :userid";
- $sql6 = "SELECT u.*, fp.message FROM {user} AS u, {forum_posts} AS fp WHERE $conditions6 AND u.deleted = 0 AND u.id=fp.userid AND u.id <> :userid";
- $sql7 = "SELECT u.*, fp.subject FROM {user} AS u, {forum_posts} AS fp WHERE $conditions7 AND u.deleted = 0 AND u.id=fp.userid AND u.id <> :userid";
+ $sql = "SELECT *
+ FROM {user}
+ WHERE deleted = 0
+ AND id <> :userid
+ AND $conditions"; // Exclude oneself
+ $sql2 = "SELECT u.*, p.summary
+ FROM {user} u, {post} p
+ WHERE $conditions2
+ AND u.deleted = 0
+ AND u.id=p.userid
+ AND u.id <> :userid";
+ $sql3 = "SELECT u.*, p.subject AS postsubject
+ FROM {user} u, {post} p
+ WHERE $conditions3
+ AND u.deleted = 0
+ AND u.id=p.userid
+ AND u.id <> :userid";
+ $sql4 = "SELECT u.*, c.content
+ FROM {user} u, {comments} c
+ WHERE $conditions4
+ AND u.deleted = 0
+ AND u.id=c.userid
+ AND u.id <> :userid";
+ $sql5 = "SELECT u.*, m.fullmessage
+ FROM {user} u, {message} m
+ WHERE $conditions5
+ AND u.deleted = 0
+ AND u.id=m.useridfrom
+ AND u.id <> :userid";
+ $sql6 = "SELECT u.*, fp.message
+ FROM {user} u, {forum_posts} fp
+ WHERE $conditions6
+ AND u.deleted = 0
+ AND u.id=fp.userid
+ AND u.id <> :userid";
+ $sql7 = "SELECT u.*, fp.subject
+ FROM {user} u, {forum_posts} fp
+ WHERE $conditions7
+ AND u.deleted = 0
+ AND u.id=fp.userid
+ AND u.id <> :userid";
$spamusers_desc = $DB->get_recordset_sql($sql, $params);
$spamusers_blog = $DB->get_recordset_sql($sql2, $params);
Please sign in to comment.
Something went wrong with that request. Please try again.