Skip to content

Commit

Permalink
fix: Handle all exceptions in OembedService to prevent edge case errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
reganlawton committed Dec 6, 2023
1 parent fc8957e commit 6ed493d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# oEmbed Changelog

## 2.3.2 - 2023-12-07

### Update
- Handle all exceptions in OembedService to prevent edge case errors. Reported by @holiday-jan in issue #141. Thanks @holiday-jan

## 2.3.1 - 2023-10-11

### Update
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wrav/oembed",
"description": "A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.",
"type": "craft-plugin",
"version": "2.3.0",
"version": "2.3.2",
"keywords": [
"craft",
"cms",
Expand Down
5 changes: 4 additions & 1 deletion src/services/OembedService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ public function embed($url, array $options = [], array $cacheProps = [])

/** @var Adapter $media */
$media = Embed::create($url, $options, $dispatcher);
} catch (InvalidUrlException $e) {
} catch (\Exception $e) {
// Trigger notification
if (Oembed::getInstance()->getSettings()->enableNotifications) {
Oembed::getInstance()->trigger(Oembed::EVENT_BROKEN_URL_DETECTED, new BrokenUrlEvent([
'url' => $url,
]));
}

// Log
Craft::info($e->getMessage(), 'oembed');

// Create fallback
$media = new FallbackAdapter(
$e->getResponse(),
Expand Down

0 comments on commit 6ed493d

Please sign in to comment.