From b05eba76618ea0e8cb69d6e426169217840fbd38 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Thu, 25 Jan 2024 12:52:57 -0600 Subject: [PATCH] Free memory as soon as possible (#4381) --- Page.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Page.php b/Page.php index 2553e6b4f3..2a2e7ff8b4 100644 --- a/Page.php +++ b/Page.php @@ -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; } } @@ -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');