No Code Attached Yet
avatar beefcakefu
beefcakefu
20 Apr 2022

Steps to reproduce the issue

According to documentation, a plugin may interrupt contact form submission by returning an exception onValidateContact. While it does indeed interrupt submission, the user is redirected to the contact form URL, but without any of the contact form components or a meaningful error message.

Here is a sample code snippet that should reproduce this issue:

<?php
defined('_JEXEC') or die;

class plgContactValidation extends JPlugin {

	protected $autoloadLanguage = true;

	function onValidateContact($contact, $data) {
		return new InvalidArgumentException("Exception message is not shown.");
	}
}
?>

Expected result

User should be redirected to the contact form URL, with the form pre-filled with submitted values and the exception message explaining why the submission was rejected.
Screenshot from 2022-04-12 23-39-40

Actual result

User is redirected to the contact form URL, but without any of the contact form components or a meaningful error message.
Screenshot from 2022-04-12 23-41-00

System information (as much as possible)

This issue afflicts Joomla! 3.x and 4.x.

Additional comments

I have previously submitted a PR #37540 that resolves this issue by handling an exception onValidateContact the same way com_contact handles failures in its default validation.

avatar beefcakefu beefcakefu - open - 20 Apr 2022
avatar joomla-cms-bot joomla-cms-bot - change - 20 Apr 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 20 Apr 2022
avatar richard67 richard67 - change - 20 Apr 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-04-20 06:19:48
Closed_By richard67
avatar richard67 richard67 - close - 20 Apr 2022
avatar richard67
richard67 - comment - 20 Apr 2022

Closing as having a pull request.

@beefcakefu It doesn’t need to crate an issue when there is already a pull request to solve it.

avatar beefcakefu
beefcakefu - comment - 20 Apr 2022

Hey @richard67, sorry about that. First time contributing, not sure what the protocol is.

Could I trouble you to check if you are able to view my PR? When I first submitted it, I'd just created my GitHub account and it was "flagged" and I had a big red banner across the top of every page telling me other users would not be able to see me due to the "flagged" status. The status was eventually cleared yesterday and since there had not been any activity on the PR, I thought maybe it was a rule to also open an issue. Thank you!

avatar richard67
richard67 - comment - 20 Apr 2022

@beefcakefu Your PR is visible for me and seems to be ok.

Add a Comment

Login with GitHub to post a comment