} else { $s=''; }
$wgOut->addHTML( $s );
+ $this->img->resetHistory(); // free db resources
+
# Exist check because we don't want to show this on pages where an image
# doesn't exist along with the noimage message, that would suck. -ævar
if( $wgUseExternalEditor && $this->img->exists() ) {
}
/**
- * Reset the history pointer to the first element of the history
+ * Reset the history pointer to the first element of the history.
+ * Always call this function after using nextHistoryLine() to free db resources
* STUB
* Overridden in LocalFile.
*/
* @return bool
*/
function isLocal() {
- return $this->repo && $this->repo->getName() == 'local';
+ return $this->getRepoName() == 'local';
+ }
+
+ /**
+ * Returns the name of the repository.
+ *
+ * @return string
+ */
+ function getRepoName() {
+ return $this->repo ? $this->repo->getName() : 'unknown';
}
/**
parent::__construct( $title, $repo );
$this->metadata = '';
$this->historyLine = 0;
+ $this->historyRes = null;
$this->dataLoaded = false;
}
__METHOD__
);
if ( 0 == $dbr->numRows( $this->historyRes ) ) {
+ $dbr->freeResult($this->historyRes);
+ $this->historyRes = null;
return FALSE;
}
} else if ( $this->historyLine == 1 ) {
+ $dbr->freeResult($this->historyRes);
$this->historyRes = $dbr->select( 'oldimage',
array(
'oi_size AS img_size',
*/
function resetHistory() {
$this->historyLine = 0;
+ if (!is_null($this->historyRes)) {
+ $this->repo->getSlaveDB()->freeResult($this->historyRes);
+ $this->historyRes = null;
+ }
}
/** getFullPath inherited */