Skip to content
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

Miscellaneous error fixing in json_form_widget and metastore.theme.inc #3968

Merged
merged 4 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/json_form_widget/src/Element/UploadOrLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st
$element = static::unsetFilesWhenRemoving($form_state->getTriggeringElement(), $element);

$file_url_remote = isset($element['#value']['file_url_remote']) ? $element['#value']['file_url_remote'] : $element['#uri'];
$file_url_remote_is_valid = UrlHelper::isValid($file_url_remote, TRUE);
$file_url_remote_is_valid = isset($file_url_remote) && UrlHelper::isValid($file_url_remote, TRUE);
$is_remote = $file_url_remote_is_valid && $file_url_type == static::TYPE_REMOTE;
if ($is_remote) {
$element = static::loadRemoteFile($element, $file_url_remote);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
$default_data = [];
// Get default data.
foreach ($items as $item) {
$default_data = json_decode($item->value);
if ($item->value) {
$default_data = json_decode($item->value);
}
}
$type = $this->getSchemaId($form_state);
// Copy the item type to the entity.
Expand Down
2 changes: 1 addition & 1 deletion modules/json_form_widget/src/ValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handleStringValues($formValues, $property) {
if (isset($formValues[$property]['select'])) {
return isset($formValues[$property][0]) ? $formValues[$property][0] : NULL;
}
return !empty($formValues[$property]) ? $this->cleanSelectId($formValues[$property]) : FALSE;
return !empty($formValues[$property]) && is_string($formValues[$property]) ? $this->cleanSelectId($formValues[$property]) : FALSE;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions modules/metastore/metastore.theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ function metastore_preprocess_node__data(&$variables) {
];
}
}
// Fallback to display file path for link title.
if ($rows['downloadURL'] && !property_exists($d, 'title')) {
$rows['title'] = $rows['downloadURL'];
}
$variables['dataset']['distributions'][] = $rows;
$variables['dataset']['distributions_tables'][] = [
'#type' => 'table',
'#caption' => $d->title,
'#header' => [t("Key"), t("Value")],
'#rows' => $rows,
];
}
}
}
Expand Down