Steps to reproduce the issue
Create a contact.
Create a single Contact menu item to display this contact.
Modify the Contact Publishing parameters.
For example:
Set it to Unpublished
Or, set it to Published and modify publish up or down so as to not display the contact when the menu item is clicked to therefore obtain a 404.
Expected result
404 Contact not found
Actual result
Argument 1 passed to Joomla\Registry\Registry::merge() must be an instance of Joomla\Registry\Registry, null given, called in /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/Model/ContactModel.php on line 132
Trying to solve the issue
Modifying ContactModel.php line 132 to use registry
From
$temp->merge($contact->params);
$contact->params = $temp;
to
$registry = new Registry($contact->params);
$temp->merge($registry);
$contact->params = $temp;
We now get
Argument 1 passed to Joomla\Registry\Registry::merge() must be an instance of Joomla\Registry\Registry, null given, called in /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/View/Contact/HtmlView.php on line 147
Modifying Contact/HtmlView.php
Adding use Joomla\Registry\Registry;
Then change line 147 from
$temp->merge($item->params);
$item->params = $temp;
to
$registry = new Registry($item->params);
$temp->merge($registry);
$item->params = $temp;
Result:
500 Exception: Contact not found in /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/Model/ContactModel.php:249 Stack trace: #0 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/MVC/View/AbstractView.php(146): Joomla\Component\Contact\Site\Model\ContactModel->getItem() #1 /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/View/Contact/HtmlView.php(118): Joomla\CMS\MVC\View\AbstractView->get('Item') #2 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/MVC/Controller/BaseController.php(691): Joomla\Component\Contact\Site\View\Contact\HtmlView->display() #3 /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/Controller/DisplayController.php(81): Joomla\CMS\MVC\Controller\BaseController->display(false, Array) #4 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/MVC/Controller/BaseController.php(729): Joomla\Component\Contact\Site\Controller\DisplayController->display() #5 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/Dispatcher/ComponentDispatcher.php(146): Joomla\CMS\MVC\Controller\BaseController->execute('display') #6 /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/Dispatcher/Dispatcher.php(45): Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() #7 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/Component/ComponentHelper.php(389): Joomla\Component\Contact\Site\Dispatcher\Dispatcher->dispatch() #8 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/Application/SiteApplication.php(206): Joomla\CMS\Component\ComponentHelper::renderComponent('com_contact') #9 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/Application/SiteApplication.php(245): Joomla\CMS\Application\SiteApplication->dispatch() #10 /Applications/MAMP/htdocs/newfolder/joomla40/libraries/src/Application/CMSApplication.php(231): Joomla\CMS\Application\SiteApplication->doExecute() #11 /Applications/MAMP/htdocs/newfolder/joomla40/includes/app.php(63): Joomla\CMS\Application\CMSApplication->execute() #12 /Applications/MAMP/htdocs/newfolder/joomla40/index.php(36): require_once('/Applications/M...') #13 {main}
I.e. instead of getting a 404 from the ContactModel
if (empty($data))
{
throw new \Exception(Text::_('COM_CONTACT_ERROR_CONTACT_NOT_FOUND'), 404);
}
we get the result from the HtmlView.php code
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
Note:
- There may be other places where Registry should be used
- The same (or very similar) code for article uses the 404 from the ArticleModel. No registry error.
Steps to reproduce the issue
Create a contact.
Create a single Contact menu item to display this contact.
Modify the Contact Publishing parameters.
For example:
Set it to Unpublished
Or, set it to Published and modify publish up or down so as to not display the contact when the menu item is clicked to therefore obtain a 404.
Expected result
404 Contact not found
Actual result
Argument 1 passed to Joomla\Registry\Registry::merge() must be an instance of Joomla\Registry\Registry, null given, called in /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/Model/ContactModel.php on line 132Trying to solve the issue
Modifying
ContactModel.phpline 132 to use registryFrom
to
We now get
Argument 1 passed to Joomla\Registry\Registry::merge() must be an instance of Joomla\Registry\Registry, null given, called in /Applications/MAMP/htdocs/newfolder/joomla40/components/com_contact/src/View/Contact/HtmlView.php on line 147Modifying
Contact/HtmlView.phpAdding
use Joomla\Registry\Registry;Then change line 147 from
to
Result:
I.e. instead of getting a 404 from the ContactModel
we get the result from the
HtmlView.phpcodeNote: