Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -333,7 +333,8 @@ |
334 | 334 | /** |
335 | 335 | * Get all the revisions that meet the requirments |
336 | 336 | * per the $wgFlaggedRevTags variable |
337 | | - * This can become expensive |
| 337 | + * This can become expensive, use it if you changed |
| 338 | + * your quality criteria |
338 | 339 | * @param database $db |
339 | 340 | * @param int $page_id |
340 | 341 | * @param int $limit |
— | — | @@ -784,10 +785,11 @@ |
785 | 786 | $dbr = wfGetDB( DB_SLAVE ); |
786 | 787 | // Skip deleted revisions |
787 | 788 | $result = $dbr->select( |
788 | | - array('flaggedpages', 'flaggedrevs', 'revision'), |
| 789 | + array('flaggedrevs', 'revision'), |
789 | 790 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
790 | | - array('fp_page_id' => $article->getId(), 'fp_latest_q = fr_rev_id', 'fp_latest_q=rev_id', 'rev_deleted=0'), |
791 | | - __METHOD__ ); |
| 791 | + array('fr_page_id' => $article->getId(), 'fr_rev_id = rev_id', 'fr_quality=1', 'rev_deleted=0'), |
| 792 | + __METHOD__, |
| 793 | + array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
792 | 794 | // Do we have one? |
793 | 795 | if ( $row = $dbr->fetchObject($result) ) { |
794 | 796 | $this->stablefound = true; |
— | — | @@ -822,10 +824,11 @@ |
823 | 825 | $dbr = wfGetDB( DB_SLAVE ); |
824 | 826 | // Skip deleted revisions |
825 | 827 | $result = $dbr->select( |
826 | | - array('flaggedpages', 'flaggedrevs', 'revision'), |
| 828 | + array('flaggedrevs', 'revision'), |
827 | 829 | array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'), |
828 | | - array('fp_page_id' => $article->getId(), 'fp_latest = fr_rev_id', 'fp_latest=rev_id', 'rev_deleted=0'), |
829 | | - __METHOD__ ); |
| 830 | + array('fr_page_id' => $article->getId(), 'fr_rev_id = rev_id', 'rev_deleted=0'), |
| 831 | + __METHOD__, |
| 832 | + array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) ); |
830 | 833 | // Do we have one? |
831 | 834 | if ( $row = $dbr->fetchObject($result) ) { |
832 | 835 | $this->latestfound = true; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -12,10 +12,11 @@ |
13 | 13 | fr_rev_id int(10) NOT NULL, |
14 | 14 | fr_user int(5) NOT NULL, |
15 | 15 | fr_timestamp char(14) NOT NULL, |
16 | | - fr_comment mediumblob default NULL, |
| 16 | + fr_comment mediumblob NOT NULL default '', |
17 | 17 | -- Store the text with all transclusions resolved |
18 | 18 | -- This will trade space for more speed and reliability |
19 | | - fr_text mediumblob default NULL, |
| 19 | + fr_text mediumblob NOT NULL default '', |
| 20 | + fr_quality tinyint(1) default 0, |
20 | 21 | |
21 | 22 | PRIMARY KEY fr_rev_id (fr_rev_id), |
22 | 23 | UNIQUE KEY (fr_id), |
— | — | @@ -34,15 +35,13 @@ |
35 | 36 | INDEX frt_page_rev_val (frt_page_id,frt_rev_id,frt_dimension,frt_value) |
36 | 37 | ) TYPE=InnoDB; |
37 | 38 | |
| 39 | +-- For future restrictons |
38 | 40 | CREATE TABLE /*$wgDBprefix*/flaggedpages ( |
39 | 41 | fp_page_id int(10) NOT NULL, |
40 | | - -- What are the latest reviewed and "quality" revisions |
41 | | - fp_latest int(10) NOT NULL, |
42 | | - fp_latest_q int(10) NOT NULL, |
43 | | - -- minimum quality levels for some pages, csv |
44 | | - fp_restrictions tinyblob NOT NULL, |
| 42 | + -- The tag type |
| 43 | + pr_dimension varchar(255) NOT NULL, |
| 44 | + -- The protection level (Sysop, autoconfirmed, etc) |
| 45 | + pr_level varchar(255) NOT NULL, |
45 | 46 | |
46 | 47 | PRIMARY KEY fp_page_id (fp_page_id), |
47 | | - INDEX fp_page_latest (fp_page_id,fp_latest,fp_latest_q) |
48 | 48 | ) TYPE=InnoDB; |
\ No newline at end of file |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php |
— | — | @@ -254,6 +254,12 @@ |
255 | 255 | // Parse the text into HTML |
256 | 256 | $parserOutput = FlaggedRevs::parseStableText( $rev->getTitle(), $fulltext, $rev->getID(), new ParserOptions, $timestamp ); |
257 | 257 | |
| 258 | + $quality = 0; |
| 259 | + if ( FlaggedRevs::isPristine($this->dims) ) |
| 260 | + $quality = 2; |
| 261 | + else if ( FlaggedRevs::isQuality($this->dims) ) |
| 262 | + $quality = 1; |
| 263 | + |
258 | 264 | $dbw = wfGetDB( DB_MASTER ); |
259 | 265 | // Our review entry |
260 | 266 | $revset = array( |
— | — | @@ -262,7 +268,8 @@ |
263 | 269 | 'fr_user' => $wgUser->getId(), |
264 | 270 | 'fr_timestamp' => $timestamp, |
265 | 271 | 'fr_comment' => $notes, |
266 | | - 'fr_text' => $fulltext // Store expanded text for good-measure |
| 272 | + 'fr_text' => $fulltext, // Store expanded text for good-measure |
| 273 | + 'fr_quality' => $quality |
267 | 274 | ); |
268 | 275 | // Our flags |
269 | 276 | $flagset = array(); |
— | — | @@ -278,26 +285,7 @@ |
279 | 286 | $dbw->replace( 'flaggedrevs', array( array('fr_page_id','fr_rev_id') ), $revset, __METHOD__ ); |
280 | 287 | // Set all of our flags |
281 | 288 | $dbw->replace( 'flaggedrevtags', array( array('frt_rev_id','frt_dimension') ), $flagset, __METHOD__ ); |
282 | | - // Update our flagged page table if needed |
283 | | - $res = $dbw->select( 'flaggedpages', array('fp_page_id'), array('fp_page_id' => $rev->getPage() ), __METHOD__ ); |
284 | | - if ( $dbw->numrows($res) ) { |
285 | | - # This page has an entry, update it... |
286 | | - $dbw->update( 'flaggedpages', |
287 | | - array( 'fp_latest' => $rev->getId() ), |
288 | | - array( 'fp_page_id' => $rev->getPage(), "fp_latest < ".$rev->getId() ), |
289 | | - __METHOD__ ); |
290 | | - } else { |
291 | | - # Insert our new rows... |
292 | | - $dbw->insert( 'flaggedpages', |
293 | | - array( 'fp_page_id' => $rev->getPage(), 'fp_latest' => $rev->getId(), 'fp_latest_q' => 0 ), |
294 | | - __METHOD__ ); |
295 | | - } |
296 | | - if ( FlaggedRevs::isQuality($this->dims) ) { |
297 | | - $dbw->update( 'flaggedpages', |
298 | | - array( 'fp_latest_q' => $rev->getId() ), |
299 | | - array( 'fp_page_id' => $rev->getPage(), "fp_latest_q < ".$rev->getId() ), |
300 | | - __METHOD__ ); |
301 | | - } |
| 289 | + |
302 | 290 | // Update the article review log |
303 | 291 | $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, true ); |
304 | 292 | |
— | — | @@ -327,24 +315,7 @@ |
328 | 316 | $dbw->delete( 'flaggedrevs', array( 'fr_rev_id' => $row->fr_rev_id ) ); |
329 | 317 | // And the flags... |
330 | 318 | $dbw->delete( 'flaggedrevtags', array( 'frt_rev_id' => $row->fr_rev_id ) ); |
331 | | - // Update our page table, what is the new top flagged rev? |
332 | | - // Read from the master to get up to date values |
333 | | - // Check for top remaining rev... |
334 | | - list($lrev) = FlaggedRevs::getStableRevisions( $dbw, $row->fr_page_id, 1 ); |
335 | | - $dbw->update( 'flaggedpages', |
336 | | - array( 'fp_latest' => $lrev ? $lrev->fr_rev_id : 0 ), |
337 | | - array( 'fp_page_id' => $row->fr_page_id ), |
338 | | - __METHOD__ ); |
339 | | - // Check for top remaining quality rev |
340 | | - $lqrev = false; |
341 | | - if ( $lrev ) { |
342 | | - list($lqrev) = FlaggedRevs::getQualityRevisions( $dbw, $row->fr_page_id, 1 ); |
343 | | - } |
344 | | - // Fallback to the newest remaining one |
345 | | - $dbw->update( 'flaggedpages', |
346 | | - array( 'fp_latest_q' => $lqrev ? $lrev->fr_rev_id : 0), |
347 | | - array( 'fp_page_id' => $row->fr_page_id ), |
348 | | - __METHOD__ ); |
| 319 | + |
349 | 320 | // Update the article review log |
350 | 321 | $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, false ); |
351 | 322 | |
— | — | @@ -653,20 +624,21 @@ |
654 | 625 | function getSQLText( &$dbr, $namespace, $nonquality = false ) { |
655 | 626 | global $wgContentNamespaces; |
656 | 627 | |
657 | | - list( $page, $flaggedpages ) = $dbr->tableNamesN( 'page', 'flaggedpages' ); |
| 628 | + list( $page, $flaggedrevs ) = $dbr->tableNamesN( 'page', 'flaggedrevs' ); |
658 | 629 | |
659 | 630 | $ns = ($namespace !== null) ? "page_namespace=$namespace" : '1 = 1'; |
660 | | - $where = $nonquality ? 'fp_latest IS NULL OR fp_latest=0' : 'fp_latest_q IS NULL OR fp_latest_q=0'; |
| 631 | + $where = $nonquality ? '1 = 1' : 'fr_rev_id IS NULL'; |
661 | 632 | $content = array(); |
662 | 633 | foreach( $wgContentNamespaces as $cns ) { |
663 | 634 | $content[] = "page_namespace=$cns"; |
664 | 635 | } |
665 | 636 | $content = implode(' OR ',$content); |
666 | 637 | $sql = |
667 | | - "SELECT page_namespace AS namespace,page_title AS title,page_len AS size |
| 638 | + "SELECT page_namespace,page_title,page_len AS size, MAX(fr_quality) as quality, COUNT(*) as num |
668 | 639 | FROM $page |
669 | | - LEFT JOIN $flaggedpages ON page_id = fp_page_id |
670 | | - WHERE page_is_redirect=0 AND $ns AND ($where) AND ($content) "; |
| 640 | + LEFT JOIN $flaggedrevs ON page_id=fr_page_id |
| 641 | + WHERE page_is_redirect=0 AND $ns AND ($where) AND ($content) |
| 642 | + GROUP BY page_id "; |
671 | 643 | return $sql; |
672 | 644 | } |
673 | 645 | |
— | — | @@ -681,9 +653,13 @@ |
682 | 654 | |
683 | 655 | function formatResult( $skin, $result ) { |
684 | 656 | global $wgLang; |
685 | | - |
| 657 | + |
| 658 | + // If the best revision of the page is quality |
| 659 | + // then skip it... |
| 660 | + if ( $this->nonquality && $result->quality >= 1 ) |
| 661 | + return false; |
686 | 662 | $fname = 'UnreviewedPagesPage::formatResult'; |
687 | | - $title = Title::makeTitle( $result->namespace, $result->title ); |
| 663 | + $title = Title::makeTitle( $result->page_namespace, $result->page_title ); |
688 | 664 | $link = $skin->makeKnownLinkObj( $title ); |
689 | 665 | $stxt = ''; |
690 | 666 | if (!is_null($size = $result->size)) { |