After updating Magento from 2.1.6 to 2.3.2 and PHP from 5.6.30 to 7.2.20, now running into errors on page load.
Have a module called Inquiry, which consists of forms to request things, and there is a custom table called 'inquiry_requests' that contains the things that can be requested.
Before the update, everything worked fine, but after updating getting the following error on page load for one of the forms when I run it in Developer mode. Tried clearing cache, deleting the generated folder, rerunning setup di compile multiple times, but the error continues to persist.
So it appears that it's occurring when we query for the custom table's data through the collection.
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Component\Inquiry\Model\Resource\Requests\Collection\Interceptor #1 Magento\Framework\ObjectManager\Factory\Compiled->create('Component\Inq...', array()) called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56] #2 Magento\Framework\ObjectManager\ObjectManager->create('\Component\In...', array()) called at [generated/code/Component/Inquiry/Model/Resource/Requests/CollectionFactory.php:43] #3 Component\Inquiry\Model\Resource\Requests\CollectionFactory->create() called at [app/code/Component/Inquiry/Helper/Requests.php:25] #4 Component\Inquiry\Helper\Requests->getRequestsItems(array('...')) called at [app/code/Component/Inquiry/view/frontend/templates/form/requests.phtml:104]
report.CRITICAL: Type Error occurred when creating object: Component\Inquiry\Model\Resource\Requests\Collection\Interceptor, Argument 5 passed to Component\Inquiry\Model\Resource\Requests\Collection\Interceptor::__construct() must implement interface Magento\Framework\DB\Adapter\AdapterInterface or be null, string given, called in /var/www/vhosts/MyWebsite/magento/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 116 [] [] report.ERROR: Type Error occurred when creating object: Component\Inquiry\Model\Resource\Requests\Collection\Interceptor [] []
<?php
namespace Component\Inquiry\Model\Resource\Requests;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* Define model & resource model
*/
protected function _construct()
{
$this->_init(
'Component\Inquiry\Model\Requests',
'Component\Inquiry\Model\Resource\Requests'
);
}
}
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Component\Inquiry\Model\Resource\Requests\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">inquiry_requests</argument>
<argument name="resourceModel" xsi:type="string">Component\Inquiry\Model\Resource\Requests</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="requests_list_data_source" xsi:type="string">Component\Inquiry\Model\Resource\Requests\Collection</item>
</argument>
</arguments>
</type>
</config>