Index: trunk/extensions/AbuseFilter/ApiQueryAbuseFilters.php |
— | — | @@ -56,7 +56,6 @@ |
57 | 57 | $fld_private = isset($prop['private']); |
58 | 58 | |
59 | 59 | $result = $this->getResult(); |
60 | | - $data = array(); |
61 | 60 | |
62 | 61 | $this->addTables('abuse_filter'); |
63 | 62 | |
— | — | @@ -109,7 +108,7 @@ |
110 | 109 | } |
111 | 110 | $entry = array(); |
112 | 111 | if($fld_id) |
113 | | - $entry['id'] = $row->af_id; |
| 112 | + $entry['id'] = intval($row->af_id); |
114 | 113 | if($fld_desc) |
115 | 114 | $entry['description'] = $row->af_public_comments; |
116 | 115 | if($fld_pattern && (!$row->af_hidden || $showhidden)) |
— | — | @@ -117,7 +116,7 @@ |
118 | 117 | if($fld_actions) |
119 | 118 | $entry['actions'] = $row->af_actions; |
120 | 119 | if($fld_hits) |
121 | | - $entry['hits'] = $row->af_hit_count; |
| 120 | + $entry['hits'] = intval($row->af_hit_count); |
122 | 121 | if($fld_comments && (!$row->af_hidden || $showhidden)) |
123 | 122 | $entry['comments'] = $row->af_comments; |
124 | 123 | if($fld_user) |
— | — | @@ -132,11 +131,15 @@ |
133 | 132 | if($row->af_deleted) |
134 | 133 | $entry['deleted'] = ''; |
135 | 134 | } |
136 | | - if ($entry) |
137 | | - $data[] = $entry; |
| 135 | + if ($entry) { |
| 136 | + $fit = $result->addValue(array('query', $this->getModuleName()), null, $entry); |
| 137 | + if(!$fit) { |
| 138 | + $this->setContinueEnumParameter('startid', $row->af_id); |
| 139 | + break; |
| 140 | + } |
| 141 | + } |
138 | 142 | } |
139 | | - $result->setIndexedTagName($data, 'filter'); |
140 | | - $result->addValue('query', $this->getModuleName(), $data); |
| 143 | + $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'filter'); |
141 | 144 | } |
142 | 145 | |
143 | 146 | public function getAllowedParams() { |
Index: trunk/extensions/AbuseFilter/ApiQueryAbuseLog.php |
— | — | @@ -48,27 +48,21 @@ |
49 | 49 | $fld_filter = isset($prop['filter']); |
50 | 50 | $fld_user = isset($prop['user']); |
51 | 51 | $fld_ip = isset($prop['ip']); |
52 | | - if($fld_ip && !$wgUser->isAllowed('abusefilter-private')) |
53 | | - $this->dieUsage('You don\'t have permission to view IP addresses', 'permissiondenied'); |
54 | 52 | $fld_title = isset($prop['title']); |
55 | 53 | $fld_action = isset($prop['action']); |
56 | 54 | $fld_details = isset($prop['details']); |
| 55 | + $fld_result = isset($prop['result']); |
| 56 | + $fld_timestamp = isset($prop['timestamp']); |
| 57 | + |
| 58 | + if($fld_ip && !$wgUser->isAllowed('abusefilter-private')) |
| 59 | + $this->dieUsage('You don\'t have permission to view IP addresses', 'permissiondenied'); |
57 | 60 | if($fld_details && !$wgUser->isAllowed('abusefilter-log-detail')) |
58 | 61 | $this->dieUsage('You don\'t have permission to view detailed abuse log entries', 'permissiondenied'); |
59 | | - $fld_result = isset($prop['result']); |
60 | | - $fld_timestamp = isset($prop['timestamp']); |
61 | 62 | |
62 | 63 | $result = $this->getResult(); |
63 | | - $data = array(); |
64 | 64 | |
65 | 65 | $this->addTables('abuse_filter_log'); |
66 | | - if($fld_filter) { |
67 | | - $this->addTables('abuse_filter'); |
68 | | - $this->addFields('af_public_comments'); |
69 | | - $this->addJoinConds(array('abuse_filter' => |
70 | | - array('JOIN', 'afl_filter=af_id')) |
71 | | - ); |
72 | | - } |
| 66 | + $this->addFields('afl_timestamp'); |
73 | 67 | $this->addFieldsIf(array('afl_id', 'afl_filter'), $fld_ids); |
74 | 68 | $this->addFieldsIf('afl_user_text', $fld_user); |
75 | 69 | $this->addFieldsIf('afl_ip', $fld_ip); |
— | — | @@ -76,7 +70,11 @@ |
77 | 71 | $this->addFieldsIf('afl_action', $fld_action); |
78 | 72 | $this->addFieldsIf('afl_var_dump', $fld_details); |
79 | 73 | $this->addFieldsIf('afl_actions', $fld_result); |
80 | | - $this->addFields('afl_timestamp'); |
| 74 | + if($fld_filter) { |
| 75 | + $this->addTables('abuse_filter'); |
| 76 | + $this->addFields('af_public_comments'); |
| 77 | + $this->addWhere('afl_filter=af_id'); |
| 78 | + } |
81 | 79 | |
82 | 80 | $this->addOption('LIMIT', $params['limit'] + 1); |
83 | 81 | |
— | — | @@ -89,7 +87,7 @@ |
90 | 88 | if (!is_null($title)) { |
91 | 89 | $titleObj = Title :: newFromText($title); |
92 | 90 | if (is_null($titleObj)) |
93 | | - $this->dieUsage("Bad title value '$title'", 'param_title'); |
| 91 | + $this->dieUsageMsg(array('invalidtitle', $title)); |
94 | 92 | $this->addWhereFld('afl_namespace', $titleObj->getNamespace()); |
95 | 93 | $this->addWhereFld('afl_title', $titleObj->getDBkey()); |
96 | 94 | } |
— | — | @@ -106,8 +104,8 @@ |
107 | 105 | } |
108 | 106 | $entry = array(); |
109 | 107 | if($fld_ids) { |
110 | | - $entry['id'] = $row->afl_id; |
111 | | - $entry['filter_id'] = $row->afl_filter; |
| 108 | + $entry['id'] = intval($row->afl_id); |
| 109 | + $entry['filter_id'] = intval($row->afl_filter); |
112 | 110 | } |
113 | 111 | if($fld_filter) |
114 | 112 | $entry['filter'] = $row->af_public_comments; |
— | — | @@ -133,11 +131,15 @@ |
134 | 132 | $entry['details'] = array_change_key_case($vars, CASE_LOWER); |
135 | 133 | } |
136 | 134 | } |
137 | | - if ($entry) |
138 | | - $data[] = $entry; |
| 135 | + if ($entry) { |
| 136 | + $fit = $result->addValue(array('query', $this->getModuleName()), null, $entry); |
| 137 | + if(!$fit) { |
| 138 | + $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->afl_timestamp)); |
| 139 | + break; |
| 140 | + } |
| 141 | + } |
139 | 142 | } |
140 | | - $result->setIndexedTagName($data, 'item'); |
141 | | - $result->addValue('query', $this->getModuleName(), $data); |
| 143 | + $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'item'); |
142 | 144 | } |
143 | 145 | |
144 | 146 | public function getAllowedParams() { |
— | — | @@ -146,7 +148,7 @@ |
147 | 149 | ApiBase :: PARAM_TYPE => 'timestamp' |
148 | 150 | ), |
149 | 151 | 'end' => array( |
150 | | - ApiBase :: PARAM_TYPE => 'timestamp', |
| 152 | + ApiBase :: PARAM_TYPE => 'timestamp' |
151 | 153 | ), |
152 | 154 | 'dir' => array( |
153 | 155 | ApiBase :: PARAM_TYPE => array( |