From 256dcc21bb222184d5e917ea57cec334b74b96f4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 14 Oct 2024 09:34:16 +0200 Subject: New unicity policies for feeds with bad GUIDs (#4487) New set of unicity criteria options. New tolerance heuristic: > `$invalidGuidsTolerance` (default 0.05) The maximum ratio (rounded) of invalid GUIDs to tolerate before degrading the unicity criteria. > Example for 0.05 (5% rounded): tolerate 0 invalid GUIDs for up to 9 articles, 1 for 10, 2 for 30, 3 for 50, 4 for 70, 5 for 90, 6 for 110, etc. > The default value of 5% rounded was chosen to allow 1 invalid GUID for feeds of 10 articles, which is a frequently observed amount of articles. --- app/Models/Entry.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'app/Models/Entry.php') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index fe6702bcd..6e87fe5cd 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -456,7 +456,7 @@ HTML; } public function hash(): string { - if ($this->hash == '') { + if ($this->hash === '') { //Do not include $this->date because it may be automatically generated when lacking $this->hash = md5($this->link . $this->title . $this->authors(true) . $this->originalContent() . $this->tags(true)); } @@ -481,16 +481,11 @@ HTML; $this->date_added = $value; } } + public function _guid(string $value): void { - $value = trim($value); - if (empty($value)) { - $value = $this->link; - if (empty($value)) { - $value = $this->hash(); - } - } - $this->guid = $value; + $this->guid = trim($value); } + public function _title(string $value): void { $this->hash = ''; $this->title = trim($value); -- cgit v1.2.3