Skip to content

Commit

Permalink
Free memory as soon as possible (#4381)
Browse files Browse the repository at this point in the history
  • Loading branch information
GlazerMann authored Jan 25, 2024
1 parent 53e6a61 commit b05eba7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,9 @@ public function extract_object(string $class) : array {
/** @var non-empty-string $separator */
$separator = $match[0];
$exploded = $treat_identical_separately ? explode($separator, $text, 2) : explode($separator, $text);
unset($separator, $text, $match);
$text = implode(sprintf($placeholder_text, $i++), $exploded);
unset($exploded);
$objects[] = $obj;
}
}
Expand All @@ -735,15 +737,16 @@ public function extract_object(string $class) : array {
/** @var non-empty-string $separator */
$separator = $match[0];
$exploded = $treat_identical_separately ? explode($separator, $text, 2) : explode($separator, $text);
unset($separator, $text, $match);
$text = implode(sprintf($placeholder_text, $i++), $exploded);
unset($exploded);
$objects[] = $obj;
}
// @codeCoverageIgnoreEnd
}

/** @psalm-suppress TypeDoesNotContainType */
if ($preg_ok === FALSE) { // Something went wrong. Often from bad wiki-text. Generally, preg_match() cannot return FALSE, so supress psalm
// PHP 5 segmentation faults. PHP 7.0 returns FALSE
if ($preg_ok === FALSE) { // Something went wrong. Often from bad wiki-text. Normally, preg_match() does not return FALSE, so supress psalm
// @codeCoverageIgnoreStart
$this->page_error = TRUE;
report_warning('Regular expression failure in ' . echoable($this->title) . ' when extracting ' . $class . 's');
Expand Down

0 comments on commit b05eba7

Please sign in to comment.