r23818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23817‎ | r23818 | r23819 >
Date:03:04, 7 July 2007
Author:yurik
Status:old
Tags:
Comment:
filerepo: fixed mem leak for history lines and exposed repository name
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImagePage.php
@@ -460,6 +460,8 @@
461461 } else { $s=''; }
462462 $wgOut->addHTML( $s );
463463
 464+ $this->img->resetHistory(); // free db resources
 465+
464466 # Exist check because we don't want to show this on pages where an image
465467 # doesn't exist along with the noimage message, that would suck. -ævar
466468 if( $wgUseExternalEditor && $this->img->exists() ) {
Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -78,6 +78,7 @@
7979 parent::__construct( $title, $repo );
8080 $this->metadata = '';
8181 $this->historyLine = 0;
 82+ $this->historyRes = null;
8283 $this->dataLoaded = false;
8384 }
8485
@@ -552,9 +553,12 @@
553554 __METHOD__
554555 );
555556 if ( 0 == $dbr->numRows( $this->historyRes ) ) {
 557+ $dbr->freeResult($this->historyRes);
 558+ $this->historyRes = null;
556559 return FALSE;
557560 }
558561 } else if ( $this->historyLine == 1 ) {
 562+ $dbr->freeResult($this->historyRes);
559563 $this->historyRes = $dbr->select( 'oldimage',
560564 array(
561565 'oi_size AS img_size',
@@ -582,6 +586,10 @@
583587 */
584588 function resetHistory() {
585589 $this->historyLine = 0;
 590+ if (!is_null($this->historyRes)) {
 591+ $this->repo->getSlaveDB()->freeResult($this->historyRes);
 592+ $this->historyRes = null;
 593+ }
586594 }
587595
588596 /** getFullPath inherited */
Index: trunk/phase3/includes/filerepo/File.php
@@ -623,7 +623,8 @@
624624 }
625625
626626 /**
627 - * Reset the history pointer to the first element of the history
 627+ * Reset the history pointer to the first element of the history.
 628+ * Always call this function after using nextHistoryLine() to free db resources
628629 * STUB
629630 * Overridden in LocalFile.
630631 */
@@ -829,10 +830,19 @@
830831 * @return bool
831832 */
832833 function isLocal() {
833 - return $this->repo && $this->repo->getName() == 'local';
 834+ return $this->getRepoName() == 'local';
834835 }
835836
836837 /**
 838+ * Returns the name of the repository.
 839+ *
 840+ * @return string
 841+ */
 842+ function getRepoName() {
 843+ return $this->repo ? $this->repo->getName() : 'unknown';
 844+ }
 845+
 846+ /**
837847 * Returns true if the image is an old version
838848 * STUB
839849 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r23912Merged revisions 23662-23909 via svnmerge from...david18:11, 9 July 2007

Status & tagging log