-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try Catch for embeded media #9424
Changes from 1 commit
d1e3dfe
f88dbe6
94b73b4
006151c
d6e3465
d8415ee
1edc15e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -89,7 +89,24 @@ public static function handle_shortcode($arguments, $content, $parser, $shortcod | |||||||||||||
} | ||||||||||||||
|
||||||||||||||
// Process embed | ||||||||||||||
$embed = $embed->getEmbed(); | ||||||||||||||
try { | ||||||||||||||
$embed = $embed->getEmbed(); | ||||||||||||||
} | ||||||||||||||
catch(\Embed\Exceptions\InvalidUrlException $e) { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 95 | ERROR | [x] Expected 1 space(s) after CATCH keyword; 0 found
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you change this to |
||||||||||||||
$attr = array( | ||||||||||||||
'class' => 'ss-media-exception embed' | ||||||||||||||
); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
if (Director::isDev()) { | ||||||||||||||
$result = HTML::createTag('div', $attr, $e->getMessage()); | ||||||||||||||
return $result; | ||||||||||||||
} | ||||||||||||||
$result = HTML::createTag( | ||||||||||||||
'div', | ||||||||||||||
$attr, | ||||||||||||||
HTML::createTag('p', array(), 'There was a problem loading the media.') | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If changing to the [] format from array() in @ScopeyNZ s suggestion, then probably should do the same here.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the text be translateable?
Suggested change
@ScopeyNZ - can you advise what the namespace & entity should be? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Normally the namespace is related to the class (and namespace) - the "entity" indicates the content of the message. Maybe something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EmbedShortcodeProvider.INVALID_URL works for me : ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be |
||||||||||||||
); | ||||||||||||||
emteknetnz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
return $result; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// Convert embed object into HTML | ||||||||||||||
if ($embed && $embed instanceof Adapter) { | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
travis is failing because:
94 | ERROR | [x] Expected 1 space after closing brace; newline found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think the style is supposed to be:
https://www.php-fig.org/psr/psr-2/#56-try-catch