r59321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59320‎ | r59321 | r59322 >
Date:21:59, 21 November 2009
Author:btongminh
Status:ok
Tags:
Comment:
Rename functions to more clearer names:
* setUsage -> insertLinks
* getAllFrom -> getLinksFromPage
* deleteFrom -> deleteLinksFromPage
* deleteTo -> deleteLinksToFile
* copyFromLocal -> copyLocalImagelinks
Modified paths:
  • /trunk/extensions/GlobalUsage/GlobalUsageHooks.php (modified) (history)
  • /trunk/extensions/GlobalUsage/GlobalUsage_body.php (modified) (history)
  • /trunk/extensions/GlobalUsage/refreshGlobalimagelinks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalUsage/GlobalUsageHooks.php
@@ -18,21 +18,21 @@
1919 $gu = self::getGlobalUsage();
2020 if ( $wgUseDumbLinkUpdate ) {
2121 // Delete all entries to the page
22 - $gu->deleteFrom( $title->getArticleId( GAID_FOR_UPDATE ) );
 22+ $gu->deleteLinksFromPage( $title->getArticleId( GAID_FOR_UPDATE ) );
2323 // Re-insert new usage for the page
24 - $gu->setUsage( $title, $missingFiles );
 24+ $gu->insertLinks( $title, $missingFiles );
2525 } else {
2626 $articleId = $title->getArticleId( GAID_FOR_UPDATE );
27 - $existing = $gu->getAllFrom( $articleId );
 27+ $existing = $gu->getLinksFromPage( $articleId );
2828
2929 // Calculate changes
3030 $added = array_diff( $missingFiles, $existing );
3131 $removed = array_diff( $existing, $missingFiles );
3232
3333 // Add new usages and delete removed
34 - $gu->setUsage( $title, $added );
 34+ $gu->insertLinks( $title, $added );
3535 if ( $removed )
36 - $gu->deleteFrom( $articleId, $removed );
 36+ $gu->deleteLinksFromPage( $articleId, $removed );
3737 }
3838
3939 return true;
@@ -54,9 +54,9 @@
5555 public static function onArticleDeleteComplete( $article, $user, $reason, $id ) {
5656 $title = $article->getTitle();
5757 $gu = self::getGlobalUsage();
58 - $gu->deleteFrom( $id );
 58+ $gu->deleteLinksFromPage( $id );
5959 if ( $title->getNamespace() == NS_FILE ) {
60 - $gu->copyFromLocal( $title );
 60+ $gu->copyLocalImagelinks( $title );
6161 }
6262 return true;
6363 }
@@ -67,7 +67,7 @@
6868 */
6969 public static function onFileUndeleteComplete( $title, $versions, $user, $reason ) {
7070 $gu = self::getGlobalUsage();
71 - $gu->deleteTo( $title );
 71+ $gu->deleteLinksToFile( $title );
7272 return true;
7373 }
7474 /**
@@ -76,7 +76,7 @@
7777 */
7878 public static function onUploadComplete( $upload ) {
7979 $gu = self::getGlobalUsage();
80 - $gu->deleteTo( $upload->getTitle() );
 80+ $gu->deleteLinksToFile( $upload->getTitle() );
8181 return true;
8282 }
8383
Index: trunk/extensions/GlobalUsage/GlobalUsage_body.php
@@ -21,7 +21,7 @@
2222 * @param $title Title Title of the page
2323 * @param $images array Array of db keys of images used
2424 */
25 - public function setUsage( $title, $images, $pageIdFlags = GAID_FOR_UPDATE ) {
 25+ public function insertLinks( $title, $images, $pageIdFlags = GAID_FOR_UPDATE ) {
2626 $insert = array();
2727 foreach ( $images as $name ) {
2828 $insert[] = array(
@@ -37,7 +37,7 @@
3838 /**
3939 * Get all global images from a certain page
4040 */
41 - public function getAllFrom( $id ) {
 41+ public function getLinksFromPage( $id ) {
4242 $res = $this->db->select(
4343 'globalimagelinks',
4444 'gil_to',
@@ -59,7 +59,7 @@
6060 * @param $id int Page id of the page
6161 * @param $to mixed File name(s)
6262 */
63 - public function deleteFrom( $id, $to = null ) {
 63+ public function deleteLinksFromPage( $id, $to = null ) {
6464 $where = array(
6565 'gil_wiki' => $this->interwiki,
6666 'gil_page' => $id
@@ -74,7 +74,7 @@
7575 *
7676 * @param $title Title Title of the file
7777 */
78 - public function deleteTo( $title ) {
 78+ public function deleteLinksToFile( $title ) {
7979 $this->db->delete(
8080 'globalimagelinks',
8181 array(
@@ -90,7 +90,7 @@
9191 *
9292 * @param $title Title Title of the file to copy entries from.
9393 */
94 - public function copyFromLocal( $title ) {
 94+ public function copyLocalImagelinks( $title ) {
9595 global $wgContLang;
9696
9797 $dbr = wfGetDB( DB_SLAVE );
Index: trunk/extensions/GlobalUsage/refreshGlobalimagelinks.php
@@ -74,13 +74,13 @@
7575 # Delete all original links if this page is not a continuation
7676 # of last iteration.
7777 if ( $pageId != $lastPageId )
78 - $gu->deleteFrom( $pageId );
 78+ $gu->deleteLinksFromPage( $pageId );
7979 if ( $rows ) {
8080 $title = Title::newFromRow( reset( $rows ) );
8181 $images = array_keys( $rows );
8282 # Since we have a pretty accurate page_id, don't specify
8383 # GAID_FOR_UPDATE
84 - $gu->setUsage( $title, $images, /* $flags */ 0 );
 84+ $gu->insertLinks( $title, $images, /* $flags */ 0 );
8585 }
8686 }
8787

Status & tagging log