diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php index 7b3143e3b..c40c98694 100755 --- a/Blacklight/Binaries.php +++ b/Blacklight/Binaries.php @@ -2,6 +2,7 @@ namespace Blacklight; +use App\Models\Collection; use App\Models\Group; use App\Models\Settings; use Illuminate\Support\Carbon; @@ -787,7 +788,21 @@ class Binaries // Get the current unixtime from PHP. $now = now()->timestamp; - $xref = sprintf('xref = CONCAT(xref, "\\n"%s ),', escapeString(substr($this->header['Xref'], 2, 255))); + $collHashXref = Collection::query()->where('collectionhash', $this->header['CollectionKey'])->select(['xref'])->first(); + $xrefs = []; + if ($collHashXref !== null) { + $collXrefs = explode(' ', $collHashXref->value('xref')); + foreach ($collXrefs as $collXref) { + if (preg_match('/(^alt\.binaries\.\w+)/', $collXref, $match)) { + $xrefs[] = $match[0]; + } + } + + } + + preg_match('/(alt\.binaries\.\w+)/', $this->header['Xref'], $match2); + + $xref = ! empty($xrefs) && ! \in_array($match2[0], $xrefs, false) ? sprintf('xref = CONCAT(xref, "\\n"%s ),', escapeString(substr($this->header['Xref'], 2, 255))) : ''; $date = $this->header['Date'] > $now ? $now : $this->header['Date']; $unixtime = is_numeric($this->header['Date']) ? $date : $now; diff --git a/Changelog b/Changelog index be0a50699..b40cccd22 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-01-07 DariusIII + * Chg: Try to prevent insertion of duplicated Xref data * Chg: More File facade usage for files manipulation * Chg: Remove MenuTableSeeder as the model and table do not exist anymore * Chg: Update PreDb class and predb_import_daily_batch script