
btongminh at svn
Nov 21, 2009, 1:59 PM
Post #1 of 1
(93 views)
Permalink
|
|
SVN: [59321] trunk/extensions/GlobalUsage
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59321 Revision: 59321 Author: btongminh Date: 2009-11-21 21:59:18 +0000 (Sat, 21 Nov 2009) Log Message: ----------- Rename functions to more clearer names: * setUsage -> insertLinks * getAllFrom -> getLinksFromPage * deleteFrom -> deleteLinksFromPage * deleteTo -> deleteLinksToFile * copyFromLocal -> copyLocalImagelinks Modified Paths: -------------- trunk/extensions/GlobalUsage/GlobalUsageHooks.php trunk/extensions/GlobalUsage/GlobalUsage_body.php trunk/extensions/GlobalUsage/refreshGlobalimagelinks.php Modified: trunk/extensions/GlobalUsage/GlobalUsageHooks.php =================================================================== --- trunk/extensions/GlobalUsage/GlobalUsageHooks.php 2009-11-21 18:45:30 UTC (rev 59320) +++ trunk/extensions/GlobalUsage/GlobalUsageHooks.php 2009-11-21 21:59:18 UTC (rev 59321) @@ -18,21 +18,21 @@ $gu = self::getGlobalUsage(); if ( $wgUseDumbLinkUpdate ) { // Delete all entries to the page - $gu->deleteFrom( $title->getArticleId( GAID_FOR_UPDATE ) ); + $gu->deleteLinksFromPage( $title->getArticleId( GAID_FOR_UPDATE ) ); // Re-insert new usage for the page - $gu->setUsage( $title, $missingFiles ); + $gu->insertLinks( $title, $missingFiles ); } else { $articleId = $title->getArticleId( GAID_FOR_UPDATE ); - $existing = $gu->getAllFrom( $articleId ); + $existing = $gu->getLinksFromPage( $articleId ); // Calculate changes $added = array_diff( $missingFiles, $existing ); $removed = array_diff( $existing, $missingFiles ); // Add new usages and delete removed - $gu->setUsage( $title, $added ); + $gu->insertLinks( $title, $added ); if ( $removed ) - $gu->deleteFrom( $articleId, $removed ); + $gu->deleteLinksFromPage( $articleId, $removed ); } return true; @@ -54,9 +54,9 @@ public static function onArticleDeleteComplete( $article, $user, $reason, $id ) { $title = $article->getTitle(); $gu = self::getGlobalUsage(); - $gu->deleteFrom( $id ); + $gu->deleteLinksFromPage( $id ); if ( $title->getNamespace() == NS_FILE ) { - $gu->copyFromLocal( $title ); + $gu->copyLocalImagelinks( $title ); } return true; } @@ -67,7 +67,7 @@ */ public static function onFileUndeleteComplete( $title, $versions, $user, $reason ) { $gu = self::getGlobalUsage(); - $gu->deleteTo( $title ); + $gu->deleteLinksToFile( $title ); return true; } /** @@ -76,7 +76,7 @@ */ public static function onUploadComplete( $upload ) { $gu = self::getGlobalUsage(); - $gu->deleteTo( $upload->getTitle() ); + $gu->deleteLinksToFile( $upload->getTitle() ); return true; } Modified: trunk/extensions/GlobalUsage/GlobalUsage_body.php =================================================================== --- trunk/extensions/GlobalUsage/GlobalUsage_body.php 2009-11-21 18:45:30 UTC (rev 59320) +++ trunk/extensions/GlobalUsage/GlobalUsage_body.php 2009-11-21 21:59:18 UTC (rev 59321) @@ -21,7 +21,7 @@ * @param $title Title Title of the page * @param $images array Array of db keys of images used */ - public function setUsage( $title, $images, $pageIdFlags = GAID_FOR_UPDATE ) { + public function insertLinks( $title, $images, $pageIdFlags = GAID_FOR_UPDATE ) { $insert = array(); foreach ( $images as $name ) { $insert[] = array( @@ -37,7 +37,7 @@ /** * Get all global images from a certain page */ - public function getAllFrom( $id ) { + public function getLinksFromPage( $id ) { $res = $this->db->select( 'globalimagelinks', 'gil_to', @@ -59,7 +59,7 @@ * @param $id int Page id of the page * @param $to mixed File name(s) */ - public function deleteFrom( $id, $to = null ) { + public function deleteLinksFromPage( $id, $to = null ) { $where = array( 'gil_wiki' => $this->interwiki, 'gil_page' => $id @@ -74,7 +74,7 @@ * * @param $title Title Title of the file */ - public function deleteTo( $title ) { + public function deleteLinksToFile( $title ) { $this->db->delete( 'globalimagelinks', array( @@ -90,7 +90,7 @@ * * @param $title Title Title of the file to copy entries from. */ - public function copyFromLocal( $title ) { + public function copyLocalImagelinks( $title ) { global $wgContLang; $dbr = wfGetDB( DB_SLAVE ); Modified: trunk/extensions/GlobalUsage/refreshGlobalimagelinks.php =================================================================== --- trunk/extensions/GlobalUsage/refreshGlobalimagelinks.php 2009-11-21 18:45:30 UTC (rev 59320) +++ trunk/extensions/GlobalUsage/refreshGlobalimagelinks.php 2009-11-21 21:59:18 UTC (rev 59321) @@ -74,13 +74,13 @@ # Delete all original links if this page is not a continuation # of last iteration. if ( $pageId != $lastPageId ) - $gu->deleteFrom( $pageId ); + $gu->deleteLinksFromPage( $pageId ); if ( $rows ) { $title = Title::newFromRow( reset( $rows ) ); $images = array_keys( $rows ); # Since we have a pretty accurate page_id, don't specify # GAID_FOR_UPDATE - $gu->setUsage( $title, $images, /* $flags */ 0 ); + $gu->insertLinks( $title, $images, /* $flags */ 0 ); } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|