Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -460,6 +460,8 @@ |
461 | 461 | } else { $s=''; } |
462 | 462 | $wgOut->addHTML( $s ); |
463 | 463 | |
| 464 | + $this->img->resetHistory(); // free db resources |
| 465 | + |
464 | 466 | # Exist check because we don't want to show this on pages where an image |
465 | 467 | # doesn't exist along with the noimage message, that would suck. -ævar |
466 | 468 | if( $wgUseExternalEditor && $this->img->exists() ) { |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | parent::__construct( $title, $repo ); |
80 | 80 | $this->metadata = ''; |
81 | 81 | $this->historyLine = 0; |
| 82 | + $this->historyRes = null; |
82 | 83 | $this->dataLoaded = false; |
83 | 84 | } |
84 | 85 | |
— | — | @@ -552,9 +553,12 @@ |
553 | 554 | __METHOD__ |
554 | 555 | ); |
555 | 556 | if ( 0 == $dbr->numRows( $this->historyRes ) ) { |
| 557 | + $dbr->freeResult($this->historyRes); |
| 558 | + $this->historyRes = null; |
556 | 559 | return FALSE; |
557 | 560 | } |
558 | 561 | } else if ( $this->historyLine == 1 ) { |
| 562 | + $dbr->freeResult($this->historyRes); |
559 | 563 | $this->historyRes = $dbr->select( 'oldimage', |
560 | 564 | array( |
561 | 565 | 'oi_size AS img_size', |
— | — | @@ -582,6 +586,10 @@ |
583 | 587 | */ |
584 | 588 | function resetHistory() { |
585 | 589 | $this->historyLine = 0; |
| 590 | + if (!is_null($this->historyRes)) { |
| 591 | + $this->repo->getSlaveDB()->freeResult($this->historyRes); |
| 592 | + $this->historyRes = null; |
| 593 | + } |
586 | 594 | } |
587 | 595 | |
588 | 596 | /** getFullPath inherited */ |
Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -623,7 +623,8 @@ |
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
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 |
628 | 629 | * STUB |
629 | 630 | * Overridden in LocalFile. |
630 | 631 | */ |
— | — | @@ -829,10 +830,19 @@ |
830 | 831 | * @return bool |
831 | 832 | */ |
832 | 833 | function isLocal() { |
833 | | - return $this->repo && $this->repo->getName() == 'local'; |
| 834 | + return $this->getRepoName() == 'local'; |
834 | 835 | } |
835 | 836 | |
836 | 837 | /** |
| 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 | + /** |
837 | 847 | * Returns true if the image is an old version |
838 | 848 | * STUB |
839 | 849 | */ |