Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1266,6 +1266,24 @@ |
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | /** |
| 1270 | + * Get the templates used on this page |
| 1271 | + * |
| 1272 | + * @return Array (namespace => dbKey => revId) |
| 1273 | + */ |
| 1274 | + public function getTemplateIds() { |
| 1275 | + return $this->mTemplateIds; |
| 1276 | + } |
| 1277 | + |
| 1278 | + /** |
| 1279 | + * Get the files used on this page |
| 1280 | + * |
| 1281 | + * @return Array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or '')) |
| 1282 | + */ |
| 1283 | + public function getImageTimeKeys() { |
| 1284 | + return $this->mImageTimeKeys; |
| 1285 | + } |
| 1286 | + |
| 1287 | + /** |
1270 | 1288 | * Convert wikitext to HTML and add it to the buffer |
1271 | 1289 | * Default assumes that the current page title will be used. |
1272 | 1290 | * |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -1193,7 +1193,7 @@ |
1194 | 1194 | * and the page tables updated, but before LinksUpdate is called. |
1195 | 1195 | * |
1196 | 1196 | * $auto is here for revisions checked off to be reviewed. Auto-review |
1197 | | - * triggers on edit, but we don't want it to count as just automatic. |
| 1197 | + * triggers on edit, but we don't want those to count as just automatic. |
1198 | 1198 | * This also makes it so the user's name shows up in the page history. |
1199 | 1199 | * |
1200 | 1200 | * If $flags is given, then they will be the review tags. If not, the one |
— | — | @@ -1232,6 +1232,8 @@ |
1233 | 1233 | if ( self::isQuality( $flags ) ) { |
1234 | 1234 | $quality = self::isPristine( $flags ) ? 2 : 1; |
1235 | 1235 | } |
| 1236 | + # Get review property flags |
| 1237 | + $propFlags = $auto ? array( 'auto' ) : array(); |
1236 | 1238 | |
1237 | 1239 | # Rev ID is not put into parser on edit, so do the same here. |
1238 | 1240 | # Also, a second parse would be triggered otherwise. |
— | — | @@ -1256,16 +1258,16 @@ |
1257 | 1259 | 'rev_id' => $rev->getId(), |
1258 | 1260 | 'user' => $user->getId(), |
1259 | 1261 | 'timestamp' => $rev->getTimestamp(), |
1260 | | - 'comment' => "", |
1261 | 1262 | 'quality' => $quality, |
1262 | 1263 | 'tags' => FlaggedRevision::flattenRevisionTags( $flags ), |
1263 | 1264 | 'img_name' => $fileData['name'], |
1264 | 1265 | 'img_timestamp' => $fileData['timestamp'], |
1265 | 1266 | 'img_sha1' => $fileData['sha1'], |
1266 | | - 'templateVersions' => $poutput->mTemplateIds, |
1267 | | - 'fileVersions' => $poutput->mImageTimeKeys |
| 1267 | + 'templateVersions' => $poutput->getTemplateIds(), |
| 1268 | + 'fileVersions' => $poutput->getImageTimeKeys(), |
| 1269 | + 'flags' => implode( ',', $propFlags ), |
1268 | 1270 | ) ); |
1269 | | - $flaggedRevision->insertOn( $auto ); |
| 1271 | + $flaggedRevision->insertOn(); |
1270 | 1272 | # Update the article review log |
1271 | 1273 | FlaggedRevsLogs::updateReviewLog( $title, |
1272 | 1274 | $flags, array(), '', $rev->getId(), $oldSvId, true, $auto ); |
Index: trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php |
— | — | @@ -414,6 +414,7 @@ |
415 | 415 | 'img_sha1' => $fileData['sha1'], |
416 | 416 | 'templateVersions' => $tmpVersions, |
417 | 417 | 'fileVersions' => $fileVersions, |
| 418 | + 'flags' => '' |
418 | 419 | ) ); |
419 | 420 | $flaggedRevision->insertOn(); |
420 | 421 | # Update recent changes... |
— | — | @@ -544,8 +545,7 @@ |
545 | 546 | } |
546 | 547 | # Image -> timestamp -> sha1 mapping |
547 | 548 | foreach ( $imageSHA1Keys as $dbKey => $timeAndSHA1 ) { |
548 | | - $imageParams .= $dbKey . "|" . $timeAndSHA1['time']; |
549 | | - $imageParams .= "|" . $timeAndSHA1['sha1'] . "#"; |
| 549 | + $imageParams .= $dbKey . "|" . $timeAndSHA1['time'] . "|" . $timeAndSHA1['sha1'] . "#"; |
550 | 550 | } |
551 | 551 | # For image pages, note the displayed image version |
552 | 552 | if ( $article->getTitle()->getNamespace() == NS_FILE ) { |
— | — | @@ -601,7 +601,7 @@ |
602 | 602 | } |
603 | 603 | list( $dbkey, $time, $key ) = $m; |
604 | 604 | # Get the file title |
605 | | - $img_title = Title::makeTitle( NS_IMAGE, $dbkey ); // Normalize |
| 605 | + $img_title = Title::makeTitle( NS_FILE, $dbkey ); // Normalize |
606 | 606 | if ( is_null( $img_title ) ) { |
607 | 607 | continue; // Page must be valid! |
608 | 608 | } |
— | — | @@ -724,7 +724,7 @@ |
725 | 725 | $pOutput = $parserCache->get( $article, $wgOut->parserOptions() ); |
726 | 726 | } |
727 | 727 | # Otherwise (or on cache miss), parse the rev text... |
728 | | - if ( !$pOutput || !isset( $pOutput->mImageTimeKeys ) ) { |
| 728 | + if ( !$pOutput ) { |
729 | 729 | $text = $rev->getText(); |
730 | 730 | $title = $article->getTitle(); |
731 | 731 | $options = FlaggedRevs::makeParserOptions(); |
— | — | @@ -735,8 +735,8 @@ |
736 | 736 | $parserCache->save( $pOutput, $article, $options ); |
737 | 737 | } |
738 | 738 | } |
739 | | - $templateIDs = $pOutput->mTemplateIds; |
740 | | - $imageSHA1Keys = $pOutput->mImageTimeKeys; |
| 739 | + $templateIDs = $pOutput->getTemplateIds(); |
| 740 | + $imageSHA1Keys = $pOutput->getImageTimeKeys(); |
741 | 741 | } |
742 | 742 | list( $templateParams, $imageParams, $fileVersion ) = |
743 | 743 | RevisionReviewForm::getIncludeParams( $article, $templateIDs, $imageSHA1Keys ); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -36,33 +36,31 @@ |
37 | 37 | $this->mTimestamp = $row->fr_timestamp; |
38 | 38 | $this->mQuality = intval( $row->fr_quality ); |
39 | 39 | $this->mTags = self::expandRevisionTags( strval( $row->fr_tags ) ); |
| 40 | + $this->mFlags = explode( ',', $row->fr_flags ); |
| 41 | + $this->mUser = intval( $row->fr_user ); |
40 | 42 | # Image page revision relevant params |
41 | 43 | $this->mFileName = $row->fr_img_name ? $row->fr_img_name : null; |
42 | 44 | $this->mFileSha1 = $row->fr_img_sha1 ? $row->fr_img_sha1 : null; |
43 | 45 | $this->mFileTimestamp = $row->fr_img_timestamp ? |
44 | 46 | $row->fr_img_timestamp : null; |
45 | | - $this->mUser = intval( $row->fr_user ); |
46 | 47 | # Optional fields |
47 | 48 | $this->mTitle = isset( $row->page_namespace ) && isset( $row->page_title ) |
48 | 49 | ? Title::makeTitleSafe( $row->page_namespace, $row->page_title ) |
49 | 50 | : null; |
50 | | - $this->mFlags = isset( $row->fr_flags ) ? |
51 | | - explode( ',', $row->fr_flags ) : null; |
52 | 51 | } elseif ( is_array( $row ) ) { |
53 | 52 | $this->mRevId = intval( $row['rev_id'] ); |
54 | 53 | $this->mPageId = intval( $row['page_id'] ); |
55 | 54 | $this->mTimestamp = $row['timestamp']; |
56 | 55 | $this->mQuality = intval( $row['quality'] ); |
57 | 56 | $this->mTags = self::expandRevisionTags( strval( $row['tags'] ) ); |
| 57 | + $this->mFlags = explode( ',', $row['flags'] ); |
| 58 | + $this->mUser = intval( $row['user'] ); |
58 | 59 | # Image page revision relevant params |
59 | 60 | $this->mFileName = $row['img_name'] ? $row['img_name'] : null; |
60 | 61 | $this->mFileSha1 = $row['img_sha1'] ? $row['img_sha1'] : null; |
61 | 62 | $this->mFileTimestamp = $row['img_timestamp'] ? |
62 | 63 | $row['img_timestamp'] : null; |
63 | | - $this->mUser = intval( $row['user'] ); |
64 | 64 | # Optional fields |
65 | | - $this->mFlags = isset( $row['flags'] ) ? |
66 | | - explode( ',', $row['flags'] ) : null; |
67 | 65 | $this->mTemplates = isset( $row['templateVersions'] ) ? |
68 | 66 | $row['templateVersions'] : null; |
69 | 67 | $this->mFiles = isset( $row['fileVersions'] ) ? |
— | — | @@ -259,20 +257,15 @@ |
260 | 258 | /* |
261 | 259 | * Insert a FlaggedRevision object into the database |
262 | 260 | * |
263 | | - * @param array $tmpRows template version rows |
264 | | - * @param array $fileRows file version rows |
265 | | - * @param bool $auto autopatrolled |
266 | 261 | * @return bool success |
267 | 262 | */ |
268 | | - public function insertOn( $auto = false ) { |
| 263 | + public function insertOn() { |
269 | 264 | $dbw = wfGetDB( DB_MASTER ); |
270 | | - # Set any text flags |
271 | | - $textFlags = 'dynamic'; |
272 | | - if ( $auto ) $textFlags .= ',auto'; |
273 | | - $this->mFlags = explode( ',', $textFlags ); |
| 265 | + # Set any flagged revision flags |
| 266 | + $this->mFlags = array_merge( $this->mFlags, array( 'dynamic' ) ); // legacy |
274 | 267 | # Build the inclusion data chunks |
275 | 268 | $tmpInsertRows = array(); |
276 | | - foreach ( $this->getTemplateVersions() as $namespace => $titleAndID ) { |
| 269 | + foreach ( (array)$this->mTemplates as $namespace => $titleAndID ) { |
277 | 270 | foreach ( $titleAndID as $dbkey => $id ) { |
278 | 271 | $tmpInsertRows[] = array( |
279 | 272 | 'ft_rev_id' => $this->getRevId(), |
— | — | @@ -283,7 +276,7 @@ |
284 | 277 | } |
285 | 278 | } |
286 | 279 | $fileInsertRows = array(); |
287 | | - foreach ( $this->getFileVersions() as $dbkey => $timeSHA1 ) { |
| 280 | + foreach ( (array)$this->mFiles as $dbkey => $timeSHA1 ) { |
288 | 281 | $fileInsertRows[] = array( |
289 | 282 | 'fi_rev_id' => $this->getRevId(), |
290 | 283 | 'fi_name' => $dbkey, |
— | — | @@ -302,7 +295,7 @@ |
303 | 296 | 'fr_quality' => $this->getQuality(), |
304 | 297 | 'fr_tags' => self::flattenRevisionTags( $this->getTags() ), |
305 | 298 | 'fr_text' => '', # not used anymore |
306 | | - 'fr_flags' => $textFlags, |
| 299 | + 'fr_flags' => implode( ',', $this->mFlags ), |
307 | 300 | 'fr_img_name' => $this->getFileName(), |
308 | 301 | 'fr_img_timestamp' => $dbw->timestampOrNull( $this->getFileTimestamp() ), |
309 | 302 | 'fr_img_sha1' => $this->getFileSha1() |
Index: trunk/extensions/FlaggedRevs/api/ApiReview.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | $parserCache = ParserCache::singleton(); |
72 | 72 | $parserOutput = $parserCache->get( $article, $wgOut->parserOptions() ); |
73 | 73 | } |
74 | | - if ( !$parserOutput || !isset( $parserOutput->mImageTimeKeys ) ) { |
| 74 | + if ( !$parserOutput ) { |
75 | 75 | // Miss, we have to reparse the page |
76 | 76 | $text = $article->getContent(); |
77 | 77 | $options = FlaggedRevs::makeParserOptions(); |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | // Set version parameters for review submission |
82 | 82 | list( $templateParams, $imageParams, $fileVersion ) = |
83 | 83 | RevisionReviewForm::getIncludeParams( $article, |
84 | | - $parserOutput->mTemplateIds, $parserOutput->mImageTimeKeys ); |
| 84 | + $parserOutput->getTemplateIds(), $parserOutput->getImageTimeKeys() ); |
85 | 85 | $form->setTemplateParams( $templateParams ); |
86 | 86 | $form->setFileParams( $imageParams ); |
87 | 87 | $form->setFileVersion( $fileVersion ); |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -1073,12 +1073,9 @@ |
1074 | 1074 | # $wgOut may not already have the inclusion IDs, such as for diffonly=1. |
1075 | 1075 | # RevisionReviewForm will fetch them as needed however. |
1076 | 1076 | $templateIDs = $fileSHA1Keys = null; |
1077 | | - if ( $wgOut->getRevisionId() == $rev->getId() |
1078 | | - && isset( $wgOut->mTemplateIds ) |
1079 | | - && isset( $wgOut->mImageTimeKeys ) ) |
1080 | | - { |
1081 | | - $templateIDs = $wgOut->mTemplateIds; |
1082 | | - $fileSHA1Keys = $wgOut->mImageTimeKeys; |
| 1077 | + if ( $wgOut->getRevisionId() == $rev->getId() ) { |
| 1078 | + $templateIDs = $wgOut->getTemplateIds(); |
| 1079 | + $fileSHA1Keys = $wgOut->getImageTimeKeys(); |
1083 | 1080 | } |
1084 | 1081 | # Review notice box goes in top of form |
1085 | 1082 | $form = RevisionReviewForm::buildQuickReview( |