From 521a23421f52e70532a662b9bc2c6de599f34109 Mon Sep 17 00:00:00 2001 From: Nathan Boiron Date: Sun, 3 Mar 2024 19:28:18 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20v=C3=A9rification=20de=20type?= =?UTF-8?q?=20d'un=20node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La méthode `query` retourne une liste de `\DOMNode`, classe qui ne possède pas de méthode `getAttribute` comme la classe `\DOMElement`. --- sources/AppBundle/Indexation/Meetups/MeetupScraper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/AppBundle/Indexation/Meetups/MeetupScraper.php b/sources/AppBundle/Indexation/Meetups/MeetupScraper.php index 8127f4a40..4f6ef1324 100644 --- a/sources/AppBundle/Indexation/Meetups/MeetupScraper.php +++ b/sources/AppBundle/Indexation/Meetups/MeetupScraper.php @@ -37,6 +37,10 @@ public function getEvents() $events = $xpath->query("//*[contains(@id, 'event-card')]"); foreach ($events as $event) { try { + if (!$event instanceof \DOMElement) { + throw new \Exception('Élement DOM de type invalide'); + } + $eventUrl = $event->getAttribute('href'); if (preg_match('/\/(\d+)\/$/', $eventUrl, $matches)) { $id = (int) $matches[1];