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

present friendlier error message if petition cannot be displayed. #26446

Merged
merged 1 commit into from
Jun 5, 2023

Conversation

jmcclelland
Copy link
Contributor

@jmcclelland jmcclelland commented Jun 5, 2023

Overview

This is a replacement PR for #25915

Provide a friendlier error message if a petition cannot be displayed for some reason.

Before

If a user clicks on a link to a petition that either doesn't exist, is disabled, or the link doesn't have a sid parameter - the user is redirected to the home page with an error message.

However, the home page may not be accessible to a non-logged in user, so instead of seeing the error, they simply get a forbidden message. Also, depending on how the theme is configured, they may get a page with a different theme than the petition page should display.

After

Instead of redirecting the user, display the petition page but without any of the petition elements. If the user has access to sign a petition, then they will stay on the page and get the friendly error message displayed.

Technical Details

The old code uses the CRM_Core_Error::statusBounce() call. That is replaced with a smarty assign to tell the template to display a message and not show the form fields.

@civibot
Copy link

civibot bot commented Jun 5, 2023

(Standard links)

@demeritcowboy
Copy link
Contributor

I just updated the description to remove the part about setStatus().

And there's been a trend against this type of construct but not a blocker:

    if ($this->petition['is_active'] == 0) {
      $this->assign('isActive', FALSE);
    }
    else {
      $this->assign('isActive', TRUE);
    }

could just be

$this->assign('isActive', (bool) $this->petition['is_active']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants