Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -128,6 +128,7 @@ |
129 | 129 | * (bug 26020) Setting $wgEmailConfirmToEdit to true no longer removes diffs |
130 | 130 | from recent changes feeds |
131 | 131 | * (bug 30232) add current time to message wlnote on Special:Watchlist |
| 132 | +* (bug 29110) $wgFeedDiffCutoff did not affect new pages |
132 | 133 | |
133 | 134 | === API changes in 1.19 === |
134 | 135 | * (bug 19838) siprop=interwikimap can now use the interwiki cache. |
Index: trunk/phase3/includes/FeedUtils.php |
— | — | @@ -102,7 +102,7 @@ |
103 | 103 | $anon = new User(); |
104 | 104 | $accErrors = $title->getUserPermissionsErrors( 'read', $anon, true ); |
105 | 105 | |
106 | | - # Early exist when the page is not an article, on errors and now newid to |
| 106 | + # Early exist when the page is not an article, on errors and no newid to |
107 | 107 | # compare. |
108 | 108 | if( $title->getNamespace() < 0 || $accErrors || !$newid ) { |
109 | 109 | wfProfileOut( __METHOD__ ); |
— | — | @@ -131,14 +131,7 @@ |
132 | 132 | |
133 | 133 | if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) { |
134 | 134 | // Omit large diffs |
135 | | - $diffLink = $title->escapeFullUrl( |
136 | | - 'diff=' . $newid . |
137 | | - '&oldid=' . $oldid ); |
138 | | - $diffText = '<a href="' . |
139 | | - $diffLink . |
140 | | - '">' . |
141 | | - htmlspecialchars( wfMsgForContent( 'showdiff' ) ) . |
142 | | - '</a>'; |
| 135 | + $diffText = self::getDiffText( $title, $newid, $oldid); |
143 | 136 | } elseif ( $diffText === false ) { |
144 | 137 | // Error in diff engine, probably a missing revision |
145 | 138 | $diffText = "<p>Can't load revision $newid</p>"; |
— | — | @@ -150,13 +143,18 @@ |
151 | 144 | wfProfileOut( __METHOD__."-dodiff" ); |
152 | 145 | } else { |
153 | 146 | $rev = Revision::newFromId( $newid ); |
154 | | - if( is_null( $rev ) ) { |
| 147 | + if( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) { |
155 | 148 | $newtext = ''; |
156 | 149 | } else { |
157 | 150 | $newtext = $rev->getText(); |
158 | 151 | } |
159 | | - $diffText = '<p><b>' . wfMsg( 'newpage' ) . '</b></p>' . |
160 | | - '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>'; |
| 152 | + if ( $wgFeedDiffCutoff <= 0 || strlen( $newtext ) > $wgFeedDiffCutoff ) { |
| 153 | + // Omit large new page diffs, bug 29110 |
| 154 | + $diffText = self::getDiffText( $title, $newid ); |
| 155 | + } else { |
| 156 | + $diffText = '<p><b>' . wfMsg( 'newpage' ) . '</b></p>' . |
| 157 | + '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>'; |
| 158 | + } |
161 | 159 | } |
162 | 160 | $completeText .= $diffText; |
163 | 161 | |
— | — | @@ -165,6 +163,27 @@ |
166 | 164 | } |
167 | 165 | |
168 | 166 | /** |
| 167 | + * Generates a diff link. Used when the full diff is not wanted for example |
| 168 | + * when $wgFeedDiffCutoff is 0. |
| 169 | + * |
| 170 | + * @param $title Title object: used to generate the diff URL |
| 171 | + * @param $newid Integer newid for this diff |
| 172 | + * @param $oldid Integer|null oldid for the diff. Null means it is a new article |
| 173 | + */ |
| 174 | + protected static function getDiffText( Title $title, $newid, $oldid = null ) { |
| 175 | + $queryParameters = ($oldid == null) |
| 176 | + ? "diff={$newid}" |
| 177 | + : "diff={$newid}&oldid={$oldid}" ; |
| 178 | + $diffLink = $title->escapeFullUrl( $queryParameters ); |
| 179 | + |
| 180 | + $diffText = Html::RawElement( 'a', array( 'href' => $diffLink ), |
| 181 | + htmlspecialchars( wfMsgForContent( 'showdiff' ) ) |
| 182 | + ); |
| 183 | + |
| 184 | + return $diffText; |
| 185 | + } |
| 186 | + |
| 187 | + /** |
169 | 188 | * Hacky application of diff styles for the feeds. |
170 | 189 | * Might be 'cleaner' to use DOM or XSLT or something, |
171 | 190 | * but *gack* it's a pain in the ass. |