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

USAGOV-1925: USAGOV-1925 - When the body is empty generating FAQs fails #1977

Merged
merged 4 commits into from
Oct 2, 2024
Merged
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
6 changes: 6 additions & 0 deletions web/themes/custom/usagov/usagov.theme
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ function usagov_preprocess_html(&$variables) {
function generate_faq(&$node) {
$faq = [];

// While a node may have its FAQ-Page checked, this does not guarantee the body field is not empty.
// When it is empty, there is nothing we can do here. We will bail to prevent errors (see USAGOV-1925).
if (empty($node->get('body')) || empty($node->get('body')[0]) || empty($node->get('body')[0]->value)) {
return;
}

// Set up a DOMDocument with the node's body content
$node_body = $node->get('body')[0]->value;
$dom = new DOMDocument();
Expand Down
Loading