Skip to content

Commit

Permalink
Do not crash if not match is found
Browse files Browse the repository at this point in the history
  • Loading branch information
nitriques committed Mar 8, 2016
1 parent 40cb7bd commit 77b1cd2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fields/field.link_preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,14 @@ private function applyFormat($entryId, $format, $sectionId) {
// Extract needed schema
$element_names = array();
$element_count = preg_match_all($element_names_regexp, $format, $element_names);
if ($element_count > 0) {
if ($element_count > 0 && !empty($element_names[1])) {
$element_names = array_map(function ($element) {
return current(explode(':', $element));
}, $element_names[1]); // index 1 are captures
}
else {
$element_names = array();
}

// Get all the data for this entry
$entryData = EntryManager::fetch($entryId, null, 1, 0, null, null, false, true, $element_names, false);
Expand Down

0 comments on commit 77b1cd2

Please sign in to comment.