From: Niklas Laxström Date: Thu, 8 Jul 2010 08:11:14 +0000 (+0000) Subject: Little debugging help for LinkBatch X-Git-Tag: 1.31.0-rc.0~36217 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=0b9f22078fe8839244c71a0a792382332e390d35;p=lhc%2Fweb%2Fwiklou.git Little debugging help for LinkBatch --- diff --git a/includes/LinkBatch.php b/includes/LinkBatch.php index 7df39e2496..75ec2dfdc9 100644 --- a/includes/LinkBatch.php +++ b/includes/LinkBatch.php @@ -12,12 +12,26 @@ class LinkBatch { */ var $data = array(); + /** + * For debugging which method is using this class. + */ + protected $caller; + function __construct( $arr = array() ) { foreach( $arr as $item ) { $this->addObj( $item ); } } + /** + * Use ->setCaller( __METHOD__ ) to indicate which code is using this + * class. Only used in debugging output. + * @since 1.17 + */ + public function setCaller( $caller ) { + $this->caller = $caller; + } + public function addObj( $title ) { if ( is_object( $title ) ) { $this->add( $title->getNamespace(), $title->getDBkey() ); @@ -134,7 +148,8 @@ class LinkBatch { $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, page_latest FROM $page WHERE $set"; // Do query - $res = $dbr->query( $sql, __METHOD__ ); + $caller = $this->caller ? __METHOD__ . " (for {$this->caller})" : __METHOD__; + $res = $dbr->query( $sql, $caller ); wfProfileOut( __METHOD__ ); return $res; }