Index: trunk/phase3/includes/SpecialRecentchangeslinked.php |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | */ |
17 | 17 | function wfSpecialRecentchangeslinked( $par = NULL ) { |
18 | 18 | global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle, $wgScript; |
19 | | - $fname = 'wfSpecialRecentchangeslinked'; |
20 | 19 | |
21 | 20 | $days = $wgRequest->getInt( 'days' ); |
22 | 21 | $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); |
— | — | @@ -57,7 +56,7 @@ |
58 | 57 | $wgOut->setSyndicated(); |
59 | 58 | $wgOut->setFeedAppendQuery( "target=" . urlencode( $target ) ); |
60 | 59 | |
61 | | - if ( ! $days ) { |
| 60 | + if ( !$days ) { |
62 | 61 | $days = (int)$wgUser->getOption( 'rcdays', 7 ); |
63 | 62 | } |
64 | 63 | list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' ); |
— | — | @@ -83,49 +82,39 @@ |
84 | 83 | $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" ); |
85 | 84 | |
86 | 85 | $uid = $wgUser->getID(); |
87 | | - |
88 | | - $GROUPBY = " |
89 | | - GROUP BY rc_cur_id,rc_namespace,rc_title, |
| 86 | + // The fields we are selecting |
| 87 | + $fields = "rc_cur_id,rc_namespace,rc_title, |
90 | 88 | rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_log_type,rc_log_action,rc_params,rc_deleted, |
91 | | - rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len |
92 | | -" . ($uid ? ",wl_user" : "") . " |
93 | | - ORDER BY rc_timestamp DESC |
94 | | - LIMIT {$limit}"; |
| 89 | + rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len"; |
| 90 | + $fields .= $uid ? ",wl_user" : ""; |
95 | 91 | |
| 92 | + // Check if this should be a feed |
| 93 | + $feed = false; |
| 94 | + global $wgSitename, $wgFeedClasses, $wgContLanguageCode, $wgFeedLimit; |
| 95 | + $feedFormat = $wgRequest->getVal( 'feed' ); |
| 96 | + if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) { |
| 97 | + $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . |
| 98 | + ' [' . $wgContLanguageCode . ']'; |
| 99 | + $feed = new $wgFeedClasses[$feedFormat]( $feedTitle, |
| 100 | + htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() ); |
| 101 | + # Sanity check |
| 102 | + if( $limit > $wgFeedLimit ) { |
| 103 | + $limit = $wgFeedLimit; |
| 104 | + } |
| 105 | + } |
| 106 | + |
96 | 107 | // If target is a Category, use categorylinks and invert from and to |
97 | 108 | if( $nt->getNamespace() == NS_CATEGORY ) { |
98 | 109 | $catkey = $dbr->addQuotes( $nt->getDBkey() ); |
99 | | - $sql = "SELECT /* wfSpecialRecentchangeslinked */ |
100 | | - rc_id, |
101 | | - rc_cur_id, |
102 | | - rc_namespace, |
103 | | - rc_title, |
104 | | - rc_this_oldid, |
105 | | - rc_last_oldid, |
106 | | - rc_user, |
107 | | - rc_comment, |
108 | | - rc_user_text, |
109 | | - rc_timestamp, |
110 | | - rc_minor, |
111 | | - rc_bot, |
112 | | - rc_new, |
113 | | - rc_patrolled, |
114 | | - rc_type, |
115 | | - rc_old_len, |
116 | | - rc_new_len, |
117 | | - rc_log_type, |
118 | | - rc_log_action, |
119 | | - rc_params, |
120 | | - rc_deleted |
121 | | -" . ($uid ? ",wl_user" : "") . " |
122 | | - FROM $categorylinks, $recentchanges |
123 | | -" . ($uid ? "LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . " |
124 | | - WHERE rc_timestamp > '{$cutoff}' |
125 | | - {$cmq} |
126 | | - AND cl_from=rc_cur_id |
127 | | - AND cl_to=$catkey |
128 | | -$GROUPBY |
129 | | - "; |
| 110 | + # The table clauses |
| 111 | + $tables = "$categorylinks, $recentchanges"; |
| 112 | + $tables .= $uid ? "LEFT JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : ""; |
| 113 | + |
| 114 | + $sql = "SELECT /* wfSpecialRecentchangeslinked */ $fields FROM $tables |
| 115 | + WHERE rc_timestamp > '{$cutoff}' {$cmq} |
| 116 | + AND cl_from=rc_cur_id |
| 117 | + AND cl_to=$catkey |
| 118 | + GROUP BY $fields ORDER BY rc_timestamp DESC LIMIT {$limit}"; // Shitty-ass GROUP BY by for postgres apparently |
130 | 119 | } else { |
131 | 120 | if( $showlinkedto ) { |
132 | 121 | $ns = $dbr->addQuotes( $nt->getNamespace() ); |
— | — | @@ -134,41 +123,40 @@ |
135 | 124 | } else { |
136 | 125 | $joinConds = "AND pl_namespace=rc_namespace AND pl_title=rc_title AND pl_from=$id"; |
137 | 126 | } |
| 127 | + # The table clauses |
| 128 | + $tables = "$pagelinks, $recentchanges"; |
| 129 | + $tables .= $uid ? "LEFT JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : ""; |
138 | 130 | |
139 | | - $sql = |
140 | | -"SELECT /* wfSpecialRecentchangeslinked */ |
141 | | - rc_id, |
142 | | - rc_cur_id, |
143 | | - rc_namespace, |
144 | | - rc_title, |
145 | | - rc_user, |
146 | | - rc_comment, |
147 | | - rc_user_text, |
148 | | - rc_this_oldid, |
149 | | - rc_last_oldid, |
150 | | - rc_timestamp, |
151 | | - rc_minor, |
152 | | - rc_bot, |
153 | | - rc_new, |
154 | | - rc_patrolled, |
155 | | - rc_type, |
156 | | - rc_old_len, |
157 | | - rc_new_len, |
158 | | - rc_log_type, |
159 | | - rc_log_action, |
160 | | - rc_params, |
161 | | - rc_deleted |
162 | | -" . ($uid ? ",wl_user" : "") . " |
163 | | - FROM $pagelinks, $recentchanges |
164 | | -" . ($uid ? " LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . " |
165 | | - WHERE rc_timestamp > '{$cutoff}' |
166 | | - {$cmq} |
167 | | - {$joinConds} |
168 | | -$GROUPBY |
169 | | -"; |
| 131 | + $sql = "SELECT /* wfSpecialRecentchangeslinked */ $fields FROM $tables |
| 132 | + WHERE rc_timestamp > '{$cutoff}' {$cmq} |
| 133 | + {$joinConds} |
| 134 | + GROUP BY $fields ORDER BY rc_timestamp DESC LIMIT {$limit}"; // Shitty-ass GROUP BY by for postgres apparently |
170 | 135 | } |
171 | | - $res = $dbr->query( $sql, $fname ); |
172 | | - |
| 136 | + # Actually do the query |
| 137 | + $res = $dbr->query( $sql, __METHOD__ ); |
| 138 | + $count = $dbr->numRows( $res ); |
| 139 | + $rchanges = array(); |
| 140 | + # Output feeds now and be done with it! |
| 141 | + if( $feed ) { |
| 142 | + if( $count ) { |
| 143 | + $counter = 1; |
| 144 | + while ( $limit ) { |
| 145 | + if ( 0 == $count ) { break; } |
| 146 | + $obj = $dbr->fetchObject( $res ); |
| 147 | + --$count; |
| 148 | + $rc = RecentChange::newFromRow( $obj ); |
| 149 | + $rc->counter = $counter++; |
| 150 | + --$limit; |
| 151 | + $rchanges[] = $obj; |
| 152 | + } |
| 153 | + } |
| 154 | + require_once( "SpecialRecentchanges.php" ); |
| 155 | + $wgOut->disable(); |
| 156 | + rcDoOutputFeed( $rchanges, $feed ); |
| 157 | + return; |
| 158 | + } |
| 159 | + |
| 160 | + # Otherwise, carry on with regular output... |
173 | 161 | $wgOut->addHTML("< ".$sk->makeLinkObj($nt, "", "redirect=no" )."<br />\n"); |
174 | 162 | $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) ); |
175 | 163 | $wgOut->addHTML( "<hr />\n{$note}\n<br />" ); |
— | — | @@ -181,9 +169,7 @@ |
182 | 170 | |
183 | 171 | $list = ChangesList::newFromUser( $wgUser ); |
184 | 172 | $s = $list->beginRecentChangesList(); |
185 | | - $count = $dbr->numRows( $res ); |
186 | 173 | |
187 | | - $rchanges = array(); |
188 | 174 | if ( $count ) { |
189 | 175 | $counter = 1; |
190 | 176 | while ( $limit ) { |
— | — | @@ -194,7 +180,6 @@ |
195 | 181 | $rc->counter = $counter++; |
196 | 182 | $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user) ); |
197 | 183 | --$limit; |
198 | | - $rchanges[] = $obj; |
199 | 184 | } |
200 | 185 | } else { |
201 | 186 | $wgOut->addWikiMsg('recentchangeslinked-noresult'); |
— | — | @@ -203,16 +188,4 @@ |
204 | 189 | |
205 | 190 | $dbr->freeResult( $res ); |
206 | 191 | $wgOut->addHTML( $s ); |
207 | | - |
208 | | - global $wgSitename, $wgFeedClasses, $wgContLanguageCode; |
209 | | - $feedFormat = $wgRequest->getVal( 'feed' ); |
210 | | - if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) { |
211 | | - $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . ' [' . $wgContLanguageCode . ']'; |
212 | | - $feed = new $wgFeedClasses[$feedFormat]( $feedTitle, |
213 | | - htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() ); |
214 | | - |
215 | | - require_once( "SpecialRecentchanges.php" ); |
216 | | - $wgOut->disable(); |
217 | | - rcDoOutputFeed( $rchanges, $feed ); |
218 | | - } |
219 | 192 | } |
Index: trunk/phase3/includes/api/ApiFeedWatchlist.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | */ |
56 | 56 | public function execute() { |
57 | 57 | |
58 | | - global $wgFeedClasses, $wgSitename, $wgContLanguageCode; |
| 58 | + global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgContLanguageCode; |
59 | 59 | |
60 | 60 | try { |
61 | 61 | $params = $this->extractRequestParams(); |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | 'wlprop' => 'title|user|comment|timestamp', |
74 | 74 | 'wldir' => 'older', // reverse order - from newest to oldest |
75 | 75 | 'wlend' => $dbr->timestamp($endTime), // stop at this time |
76 | | - 'wllimit' => 50 |
| 76 | + 'wllimit' => (50 > $wgFeedLimit) ? $wgFeedLimit : 50 |
77 | 77 | ); |
78 | 78 | |
79 | 79 | // Check for 'allrev' parameter, and if found, show all revisions to each page on wl. |
Index: trunk/phase3/includes/SpecialNewpages.php |
— | — | @@ -289,6 +289,12 @@ |
290 | 290 | $this->title->getFullUrl() ); |
291 | 291 | |
292 | 292 | $pager = new NewPagesPager( $this, $this->opts ); |
| 293 | + $limit = $this->opts->getValue( 'limit' ); |
| 294 | + global $wgFeedLimit; |
| 295 | + if( $limit > $wgFeedLimit ) { |
| 296 | + $limit = $wgFeedLimit; |
| 297 | + } |
| 298 | + $pager->mLimit = $limit; |
293 | 299 | |
294 | 300 | $feed->outHeader(); |
295 | 301 | if( $pager->getNumRows() > 0 ) { |
Index: trunk/phase3/includes/PageHistory.php |
— | — | @@ -108,6 +108,10 @@ |
109 | 109 | */ |
110 | 110 | if ( $wgRequest->getText("go") == 'first' ) { |
111 | 111 | $limit = $wgRequest->getInt( 'limit', 50 ); |
| 112 | + global $wgFeedLimit; |
| 113 | + if( $limit > $wgFeedLimit ) { |
| 114 | + $limit = $wgFeedLimit; |
| 115 | + } |
112 | 116 | $wgOut->redirect( $wgTitle->getLocalURL( "action=history&limit={$limit}&dir=prev" ) ); |
113 | 117 | return; |
114 | 118 | } |
Index: trunk/phase3/includes/QueryPage.php |
— | — | @@ -454,6 +454,11 @@ |
455 | 455 | $wgOut->addWikiMsg( 'feed-unavailable' ); |
456 | 456 | return; |
457 | 457 | } |
| 458 | + |
| 459 | + global $wgFeedLimit; |
| 460 | + if( $limit > $wgFeedLimit ) { |
| 461 | + $limit = $wgFeedLimit; |
| 462 | + } |
458 | 463 | |
459 | 464 | if( isset($wgFeedClasses[$class]) ) { |
460 | 465 | $feed = new $wgFeedClasses[$class]( |