Index: branches/robchurch/reports/maintenance/updateReports.php |
— | — | @@ -21,8 +21,13 @@ |
22 | 22 | |
23 | 23 | foreach( $reports as $report ) { |
24 | 24 | if( class_exists( $report ) ) { |
25 | | - echo( "{$report}:\n" ); |
26 | | - ReportCache::recache( new $report, $limit, 'updateReportsCallback' ); |
| 25 | + $obj = new $report; |
| 26 | + if( !$obj->isDisabled() ) { |
| 27 | + echo( "{$report}:\n" ); |
| 28 | + ReportCache::recache( $obj, $limit, 'updateReportsCallback' ); |
| 29 | + } else { |
| 30 | + echo( "{$report} is disabled\n" ); |
| 31 | + } |
27 | 32 | } else { |
28 | 33 | echo( "Unknown report '{$report}'\n" ); |
29 | 34 | } |
Index: branches/robchurch/reports/skins/monobook/main.css |
— | — | @@ -1613,6 +1613,22 @@ |
1614 | 1614 | background-color: #CC9999; |
1615 | 1615 | } |
1616 | 1616 | |
| 1617 | +/* Report cache information and disabled warnings */ |
| 1618 | +div.mw-report-cached, |
| 1619 | +div.mw-report-disabled { |
| 1620 | + font-weight: bold; |
| 1621 | + text-align: center; |
| 1622 | + padding: 2px; |
| 1623 | +} |
| 1624 | +div.mw-report-cached { |
| 1625 | + border: 1px solid #FFFF99; |
| 1626 | + background-color: #FFFFCC; |
| 1627 | +} |
| 1628 | +div.mw-report-disabled { |
| 1629 | + border: 2px solid #CC6666; |
| 1630 | + background-color: #CC9999; |
| 1631 | +} |
| 1632 | + |
1617 | 1633 | /* Recreating-deleted-page warning and log entries */ |
1618 | 1634 | div#mw-recreate-deleted-warn { |
1619 | 1635 | padding: 3px; |
Index: branches/robchurch/reports/includes/reports/Report.php |
— | — | @@ -33,6 +33,16 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
| 37 | + * Are updates for this report disabled? |
| 38 | + * |
| 39 | + * @return bool |
| 40 | + */ |
| 41 | + public function isDisabled() { |
| 42 | + global $wgDisabledReports; |
| 43 | + return in_array( $this->getName(), $wgDisabledReports ); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
37 | 47 | * Is it appropriate to allow filtering redirects? |
38 | 48 | * |
39 | 49 | * @return bool |
— | — | @@ -128,6 +138,12 @@ |
129 | 139 | public function execute( $par = false ) { |
130 | 140 | global $wgOut, $wgRequest, $wgLang; |
131 | 141 | $this->setHeaders(); |
| 142 | + $pager = $this->getPager(); |
| 143 | + if( $this->isDisabled() ) { |
| 144 | + $wgOut->addHtml( '<div class="mw-report-disabled">' . wfMsgExt( 'report-disabled', 'parse' ) . '</div>' ); |
| 145 | + } elseif( $pager instanceof CachedReportPager ) { |
| 146 | + $wgOut->addHtml( $this->getCacheInfo() ); |
| 147 | + } |
132 | 148 | # Filtering UI |
133 | 149 | $wgOut->addHtml( |
134 | 150 | $this->buildFilterUI( |
— | — | @@ -136,11 +152,7 @@ |
137 | 153 | ) |
138 | 154 | ); |
139 | 155 | # Report results |
140 | | - $pager = $this->getPager(); |
141 | | - if( $pager instanceof CachedReportPager ) |
142 | | - $wgOut->addHtml( '<div class="mw-report-cached">' . wfMsgExt( 'report-cached', 'parse' ) . '</div>' ); |
143 | 156 | if( ( $count = $pager->getNumRows() ) > 0 ) { |
144 | | - #$wgOut->addHtml( '<p>' . wfMsgHtml( 'report-num-results', $wgLang->formatNum( $count ) ) . '</p>' ); |
145 | 157 | $wgOut->addHtml( $pager->getNavigationBar() ); |
146 | 158 | $wgOut->addHtml( $pager->getBody() ); |
147 | 159 | $wgOut->addHtml( $pager->getNavigationBar() ); |
— | — | @@ -225,6 +237,24 @@ |
226 | 238 | } |
227 | 239 | |
228 | 240 | /** |
| 241 | + * Build a box containing information about when the |
| 242 | + * cache for this report was last updated |
| 243 | + * |
| 244 | + * @return string |
| 245 | + */ |
| 246 | + private function getCacheInfo() { |
| 247 | + global $wgLang; |
| 248 | + $html = '<div class="mw-report-cached">'; |
| 249 | + if( ( $ts = ReportCache::getUpdateTime( $this ) ) !== false ) { |
| 250 | + $html .= wfMsgExt( 'report-cached-timestamp', 'parse', $wgLang->timeAndDate( $ts, true ) ); |
| 251 | + } else { |
| 252 | + $html .= wfMsgExt( 'report-cached', 'parse' ); |
| 253 | + } |
| 254 | + $html .= '</div>'; |
| 255 | + return $html; |
| 256 | + } |
| 257 | + |
| 258 | + /** |
229 | 259 | * Get a list of all reports |
230 | 260 | * |
231 | 261 | * @return array |
Index: branches/robchurch/reports/includes/reports/ReportCache.php |
— | — | @@ -49,6 +49,16 @@ |
50 | 50 | ); |
51 | 51 | } |
52 | 52 | $dbr->freeResult( $res ); |
| 53 | + # Update the cache state table |
| 54 | + $dbw->replace( |
| 55 | + 'reportcache_info', |
| 56 | + array( 'rci_report' ), |
| 57 | + array( |
| 58 | + 'rci_report' => $report->getName(), |
| 59 | + 'rci_updated' => $dbw->timestamp(), |
| 60 | + ), |
| 61 | + __METHOD__ |
| 62 | + ); |
53 | 63 | # Callback? |
54 | 64 | if( is_callable( $namespaceCallback ) ) |
55 | 65 | call_user_func( $namespaceCallback, $report, $namespace, $rows ); |
— | — | @@ -74,6 +84,29 @@ |
75 | 85 | } |
76 | 86 | return $namespaces; |
77 | 87 | } |
| 88 | + |
| 89 | + /** |
| 90 | + * Get the timestamp of the last update to a cached |
| 91 | + * result set, or false if not available |
| 92 | + * |
| 93 | + * @param Report $report Report to check |
| 94 | + * @return mixed |
| 95 | + */ |
| 96 | + public static function getUpdateTime( $report ) { |
| 97 | + $dbr = wfGetDB( DB_SLAVE ); |
| 98 | + $res = $dbr->select( |
| 99 | + 'reportcache_info', |
| 100 | + '*', |
| 101 | + array( 'rci_report' => $report->getName() ), |
| 102 | + __METHOD__ |
| 103 | + ); |
| 104 | + if( $dbr->numRows( $res ) > 0 ) { |
| 105 | + $row = $dbr->fetchObject( $res ); |
| 106 | + return wfTimestamp( TS_MW, $row->rci_updated ); |
| 107 | + } else { |
| 108 | + return false; |
| 109 | + } |
| 110 | + } |
78 | 111 | |
79 | 112 | /** |
80 | 113 | * Encode a set of parameters |
Index: branches/robchurch/reports/includes/DefaultSettings.php |
— | — | @@ -1183,7 +1183,7 @@ |
1184 | 1184 | * to ensure that client-side caches don't keep obsolete copies of global |
1185 | 1185 | * styles. |
1186 | 1186 | */ |
1187 | | -$wgStyleVersion = '77'; |
| 1187 | +$wgStyleVersion = '78'; |
1188 | 1188 | |
1189 | 1189 | |
1190 | 1190 | # Server-side caching: |
— | — | @@ -2646,10 +2646,10 @@ |
2647 | 2647 | $wgBreakFrames = false; |
2648 | 2648 | |
2649 | 2649 | /** |
2650 | | - * Set this to an array of special page names to prevent |
2651 | | - * maintenance/updateSpecialPages.php from updating those pages. |
| 2650 | + * Set this to an array of report names to disable |
| 2651 | + * cache updates for those pages |
2652 | 2652 | */ |
2653 | | -$wgDisableQueryPageUpdate = false; |
| 2653 | +$wgDisabledReports = array(); |
2654 | 2654 | |
2655 | 2655 | /** |
2656 | 2656 | * Set this to false to disable cascading protection |
Index: branches/robchurch/reports/languages/messages/MessagesEn.php |
— | — | @@ -2909,7 +2909,8 @@ |
2910 | 2910 | 'report-paging-next' => 'next', |
2911 | 2911 | 'report-paging-prev' => 'previous', |
2912 | 2912 | 'report-cached' => 'This information is cached.', |
2913 | | -'report-num-results' => 'Showing $1 results:', |
| 2913 | +'report-cached-timestamp' => 'This information is cached, and was last updated $1.', |
| 2914 | +'report-disabled' => 'Updates for this report are disabled at present. Data here will not be refreshed.', |
2914 | 2915 | 'report-no-results' => 'There are no results for this report.', |
2915 | 2916 | 'report-filter-legend' => 'Filter results', |
2916 | 2917 | 'report-filter-namespace' => 'Namespace:', |