From 3582a32da61f4e089eadfc84d37fdf33b7dc3046 Mon Sep 17 00:00:00 2001 From: Geoff Appleby Date: Sun, 24 Nov 2013 12:02:54 -0800 Subject: [PATCH] Store a null count if parsing XML fails, instead of killing entire run --- src/DrupalReleaseDate/DrupalIssueCount.php | 15 +++++++++++++-- src/DrupalReleaseDate/DrupalOrgParseException.php | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/DrupalReleaseDate/DrupalOrgParseException.php diff --git a/src/DrupalReleaseDate/DrupalIssueCount.php b/src/DrupalReleaseDate/DrupalIssueCount.php index 9b915c1..7ff23f2 100644 --- a/src/DrupalReleaseDate/DrupalIssueCount.php +++ b/src/DrupalReleaseDate/DrupalIssueCount.php @@ -203,7 +203,12 @@ public function getCounts($commonParameters, $fetchSet, $viewClass) { foreach ($fetchParameters as $parameterKey => $parameterValue) { $query->set($parameterKey, $parameterValue); } - $results[$fetchKey] = $this->getCount($request, $viewClass); + try { + $results[$fetchKey] = $this->getCount($request, $viewClass); + } + catch (DrupalOrgParseException $e) { + $results[$fetchKey] = null; + } } return $results; @@ -277,7 +282,13 @@ public function getXmlDocument(\Guzzle\Http\Message\Response $response) { ); $page = str_replace(array_keys($replace), array_values($replace), $page); - $document = new \SimpleXMLElement($page); + try { + $document = new \SimpleXMLElement($page); + } + catch (\Exception $e) { + // Throw a better specified Exception. + throw new DrupalOrgParseException(); + } } // Need to register name for default namespace to be able to query anything with xpath diff --git a/src/DrupalReleaseDate/DrupalOrgParseException.php b/src/DrupalReleaseDate/DrupalOrgParseException.php new file mode 100644 index 0000000..c0027d2 --- /dev/null +++ b/src/DrupalReleaseDate/DrupalOrgParseException.php @@ -0,0 +1,7 @@ +