magento2 – Call to a member function getField() on string

I’m trying to connect external accountant software to Magento 2 using the API. However, I can’t seem to get the whole lot to synchronise properly.

In the process of looking for the issue, I noticed a repeating error in the error log. The error seem to be coming back every 10 minutes, which is similar to how often the accountant software is supposed to synchronise. Therefore I’m thinking these errors are somehow being triggered by the synchronisation-attempts. I’m not hundred percent sure though.

Does anybody know what might be going on? I can’t seem to figure out, and all I’m seeing is Magento vendor files.

Error:

(2021-03-04 10:18:34) main.CRITICAL: Error: Call to a member function getField() on string in /path/to/magento/vendor/magento/framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php:76
Stack trace:
#0 /path/to/magento/vendor/magento/framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php(48): MagentoFrameworkApiSearchCriteriaCollectionProcessorSortingProcessor->applyOrders(Array, Object(MagentoSalesModelResourceModelOrderCollectionInterceptor))
#1 /path/to/magento/vendor/magento/framework/Api/SearchCriteria/CollectionProcessor.php(38): MagentoFrameworkApiSearchCriteriaCollectionProcessorSortingProcessor->process(Object(MagentoFrameworkApiSearchCriteriaInterceptor), Object(MagentoSalesModelResourceModelOrderCollectionInterceptor))
#2 /path/to/magento/vendor/magento/module-sales/Model/OrderRepository.php(213): MagentoFrameworkApiSearchCriteriaCollectionProcessor->process(Object(MagentoFrameworkApiSearchCriteriaInterceptor), Object(MagentoSalesModelResourceModelOrderCollectionInterceptor))
#3 /path/to/magento/vendor/magento/framework/Interception/Interceptor.php(58): MagentoSalesModelOrderRepository->getList(Object(MagentoFrameworkApiSearchCriteriaInterceptor))
#4 /path/to/magento/vendor/magento/framework/Interception/Interceptor.php(138): MagentoSalesModelOrderRepositoryInterceptor->___callParent('getList', Array)
#5 /path/to/magento/vendor/magento/framework/Interception/Interceptor.php(153): MagentoSalesModelOrderRepositoryInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkApiSearchCriteriaInterceptor))
#6 /path/to/magento/generated/code/Magento/Sales/Model/OrderRepository/Interceptor.php(32): MagentoSalesModelOrderRepositoryInterceptor->___callPlugins('getList', Array, Array)
#7 (internal function): MagentoSalesModelOrderRepositoryInterceptor->getList(Object(MagentoFrameworkApiSearchCriteriaInterceptor))
#8 /path/to/magento/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)
#9 /path/to/magento/vendor/magento/module-webapi/Controller/Rest.php(188): MagentoWebapiControllerRestSynchronousRequestProcessor->process(Object(MagentoFrameworkWebapiRestRequestProxy))
#10 /path/to/magento/vendor/magento/framework/Interception/Interceptor.php(58): MagentoWebapiControllerRest->dispatch(Object(MagentoFrameworkAppRequestHttp))
#11 /path/to/magento/vendor/magento/framework/Interception/Interceptor.php(138): MagentoWebapiControllerRestInterceptor->___callParent('dispatch', Array)
#12 /path/to/magento/vendor/magento/framework/Interception/Interceptor.php(153): MagentoWebapiControllerRestInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#13 /path/to/magento/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): MagentoWebapiControllerRestInterceptor->___callPlugins('dispatch', Array, Array)
#14 /path/to/magento/vendor/magento/framework/App/Http.php(116): MagentoWebapiControllerRestInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#15 /path/to/magento/generated/code/Magento/Framework/App/Http/Interceptor.php(23): MagentoFrameworkAppHttp->launch()
#16 /path/to/magento/vendor/magento/framework/App/Bootstrap.php(263): MagentoFrameworkAppHttpInterceptor->launch()
#17 /path/to/magento/index.php(43): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#18 {main} () ()

Line 76 of SortingProcessor.php is part of the function ‘applyOrders()’:

$field = $this->getFieldMapping($sortOrder->getField());

The function applyOrders is called earlier in SortingProcessor.php, through this function:

public function process(SearchCriteriaInterface $searchCriteria, AbstractDb $collection)
{
    if ($searchCriteria->getSortOrders()) {
        $this->applyOrders($searchCriteria->getSortOrders(), $collection);
    } elseif ($this->defaultOrders) {
        $this->applyDefaultOrders($collection);
    }
}

System:

  • CentOS 7 WHM/cPanel
  • PHP 7.3.27
  • PHP Handler SuPHP
  • Magento 2.4.1
  • Webserver: Apache (behind Varnish)