X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FQueryPage.php;h=a904c248ce81a6b6178607ac97cae01b155fdab4;hb=d4ae43bb9fc535956b10c3ac2545e8aff1cf106d;hp=699c843c49537934a6ceee13ca4bc5de21dcbfb7;hpb=8559950ba3f8d3d22d2b1ad5f121cab53e4dc74c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 699c843c49..a904c248ce 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -30,41 +30,40 @@ */ global $wgQueryPages; // not redundant $wgQueryPages = array( -// QueryPage subclass Special page name Limit (false for none, none for the default) +// QueryPage subclass, Special page name, Limit (false for none, none for the default) // ---------------------------------------------------------------------------- - array( 'AncientPagesPage', 'Ancientpages' ), - array( 'BrokenRedirectsPage', 'BrokenRedirects' ), - array( 'DeadendPagesPage', 'Deadendpages' ), - array( 'DisambiguationsPage', 'Disambiguations' ), - array( 'DoubleRedirectsPage', 'DoubleRedirects' ), - array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ), - array( 'LinkSearchPage', 'LinkSearch' ), - array( 'ListredirectsPage', 'Listredirects' ), - array( 'LonelyPagesPage', 'Lonelypages' ), - array( 'LongPagesPage', 'Longpages' ), - array( 'MIMEsearchPage', 'MIMEsearch' ), - array( 'MostcategoriesPage', 'Mostcategories' ), - array( 'MostimagesPage', 'Mostimages' ), - array( 'MostinterwikisPage', 'Mostinterwikis' ), - array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ), - array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ), - array( 'MostlinkedPage', 'Mostlinked' ), - array( 'MostrevisionsPage', 'Mostrevisions' ), - array( 'FewestrevisionsPage', 'Fewestrevisions' ), - array( 'ShortPagesPage', 'Shortpages' ), - array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ), - array( 'UncategorizedPagesPage', 'Uncategorizedpages' ), - array( 'UncategorizedImagesPage', 'Uncategorizedimages' ), - array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ), - array( 'UnusedCategoriesPage', 'Unusedcategories' ), - array( 'UnusedimagesPage', 'Unusedimages' ), - array( 'WantedCategoriesPage', 'Wantedcategories' ), - array( 'WantedFilesPage', 'Wantedfiles' ), - array( 'WantedPagesPage', 'Wantedpages' ), - array( 'WantedTemplatesPage', 'Wantedtemplates' ), - array( 'UnwatchedPagesPage', 'Unwatchedpages' ), - array( 'UnusedtemplatesPage', 'Unusedtemplates' ), - array( 'WithoutInterwikiPage', 'Withoutinterwiki' ), + array( 'AncientPagesPage', 'Ancientpages' ), + array( 'BrokenRedirectsPage', 'BrokenRedirects' ), + array( 'DeadendPagesPage', 'Deadendpages' ), + array( 'DoubleRedirectsPage', 'DoubleRedirects' ), + array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ), + array( 'LinkSearchPage', 'LinkSearch' ), + array( 'ListredirectsPage', 'Listredirects' ), + array( 'LonelyPagesPage', 'Lonelypages' ), + array( 'LongPagesPage', 'Longpages' ), + array( 'MIMEsearchPage', 'MIMEsearch' ), + array( 'MostcategoriesPage', 'Mostcategories' ), + array( 'MostimagesPage', 'Mostimages' ), + array( 'MostinterwikisPage', 'Mostinterwikis' ), + array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ), + array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ), + array( 'MostlinkedPage', 'Mostlinked' ), + array( 'MostrevisionsPage', 'Mostrevisions' ), + array( 'FewestrevisionsPage', 'Fewestrevisions' ), + array( 'ShortPagesPage', 'Shortpages' ), + array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ), + array( 'UncategorizedPagesPage', 'Uncategorizedpages' ), + array( 'UncategorizedImagesPage', 'Uncategorizedimages' ), + array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ), + array( 'UnusedCategoriesPage', 'Unusedcategories' ), + array( 'UnusedimagesPage', 'Unusedimages' ), + array( 'WantedCategoriesPage', 'Wantedcategories' ), + array( 'WantedFilesPage', 'Wantedfiles' ), + array( 'WantedPagesPage', 'Wantedpages' ), + array( 'WantedTemplatesPage', 'Wantedtemplates' ), + array( 'UnwatchedPagesPage', 'Unwatchedpages' ), + array( 'UnusedtemplatesPage', 'Unusedtemplates' ), + array( 'WithoutInterwikiPage', 'Withoutinterwiki' ), ); wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) ); @@ -156,7 +155,8 @@ abstract class QueryPage extends SpecialPage { */ function getSQL() { /* Implement getQueryInfo() instead */ - throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor getQuery() properly" ); + throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor " + . "getQuery() properly" ); } /** @@ -295,14 +295,11 @@ abstract class QueryPage extends SpecialPage { $fname = get_class( $this ) . '::recache'; $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) ); - if ( !$dbw || !$dbr ) { + if ( !$dbw ) { return false; } try { - # Clear out any old cached data - $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname ); # Do query $res = $this->reallyDoQuery( $limit, false ); $num = false; @@ -310,7 +307,7 @@ abstract class QueryPage extends SpecialPage { $num = $res->numRows(); # Fetch results $vals = array(); - while ( $res && $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { if ( isset( $row->value ) ) { if ( $this->usesTimestamps() ) { $value = wfTimestamp( TS_UNIX, @@ -328,6 +325,9 @@ abstract class QueryPage extends SpecialPage { 'qc_value' => $value ); } + $dbw->begin( __METHOD__ ); + # Clear out any old cached data + $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname ); # Save results into the querycache table on the master if ( count( $vals ) ) { $dbw->insert( 'querycache', $vals, __METHOD__ ); @@ -337,6 +337,7 @@ abstract class QueryPage extends SpecialPage { $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname ); + $dbw->commit( __METHOD__ ); } } catch ( DBError $e ) { if ( !$ignoreErrors ) { @@ -348,6 +349,13 @@ abstract class QueryPage extends SpecialPage { return $num; } + /** + * Get a DB connection to be used for slow recache queries + */ + function getRecacheDB() { + return wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); + } + /** * Run the query and return the result * @param int|bool $limit Numerical limit or false for no limit @@ -357,7 +365,7 @@ abstract class QueryPage extends SpecialPage { */ function reallyDoQuery( $limit, $offset = false ) { $fname = get_class( $this ) . "::reallyDoQuery"; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = $this->getRecacheDB(); $query = $this->getQueryInfo(); $order = $this->getOrderFields(); @@ -513,8 +521,13 @@ abstract class QueryPage extends SpecialPage { # If updates on this page have been disabled, let the user know # that the data set won't be refreshed for now - if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) { - $out->wrapWikiMsg( "
\n$1\n
", 'querypage-no-updates' ); + if ( is_array( $wgDisableQueryPageUpdate ) + && in_array( $this->getName(), $wgDisableQueryPageUpdate ) + ) { + $out->wrapWikiMsg( + "
\n$1\n
", + 'querypage-no-updates' + ); } } }