ソースを参照

Fix memory leak when using lib_phpQuery (#3004)

* Fix memory leak when using lib_phpQuery

This library keeps documents in static class, so it requires a special
call to clean them.

* Another unload
Alexandre Alapetite 5 年 前
コミット
e1ef88d815
1 ファイル変更4 行追加1 行削除
  1. 4 1
      app/Models/Entry.php

+ 4 - 1
app/Models/Entry.php

@@ -401,6 +401,7 @@ class FreshRSS_Entry extends Minz_Model {
 						$refresh = preg_replace('/^[0-9.; ]*\s*(url\s*=)?\s*/i', '', trim($meta->getAttribute('content')));
 						$refresh = SimplePie_Misc::absolutize_url($refresh, $url);
 						if ($refresh != false && $refresh !== $url) {
+							phpQuery::unloadDocuments();
 							return self::getContentByParsing($refresh, $path, $attributes, $maxRedirs - 1);
 						}
 					}
@@ -408,7 +409,9 @@ class FreshRSS_Entry extends Minz_Model {
 			}
 
 			$content = $doc->find($path);
-			return trim(sanitizeHTML($content->__toString(), $url));
+			$html = trim(sanitizeHTML($content->__toString(), $url));
+			phpQuery::unloadDocuments();
+			return $html;
 		} else {
 			throw new Exception();
 		}