My problem is more of a nuisance, but still I’d like your help. After upgrading a project from CakePHP 1 to CakePHP 3 I get these errors in my log:
2019-12-23 19:30:03 Warning: Warning (2): var_export does not handle circular re ferences in [/[...]/vendor/cakephp/cakephp/src/Core/ObjectRegistry.php, line 147] Request URL: /cronjobs/mail Client IP: x.x.x.x Trace: Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 159 var_export - [internal], line ?? Cake\Core\ObjectRegistry::_checkDuplicate() - CORE/src/Core/ObjectRegistry.php, line 147 Cake\Core\ObjectRegistry::load() - CORE/src/Core/ObjectRegistry.php, line 86 Cake\Controller\Controller::loadComponent() - CORE/src/Controller/Controller.php, line 335 App\Controller\ErrorController::initialize() - APP/Controller/ErrorController.php, line 39 Cake\Controller\Controller::__construct() - CORE/src/Controller/Controller.php, line 273 Cake\Error\ExceptionRenderer::_getController() - CORE/src/Error/ExceptionRenderer.php, line 166 Cake\Error\ExceptionRenderer::__construct() - CORE/src/Error/ExceptionRenderer.php, line 102 Cake\Error\Middleware\ErrorHandlerMiddleware::getRenderer() - CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 173 Cake\Error\Middleware\ErrorHandlerMiddleware::handleException() - CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 114 Cake\Error\Middleware\ErrorHandlerMiddleware::__invoke() - CORE/src/Error/Middleware/ErrorHandlerMiddleware.php, line 100 Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65 Cake\Http\Runner::run() - CORE/src/Http/Runner.php, line 51 Cake\Http\Server::run() - CORE/src/Http/Server.php, line 98 [main] - ROOT/public_html/index.php, line 42
Otherwise the software runs fine; the errors are also present in my development environment. The main problem is that it happens multiple times for every call so the logs fill up fast, and it’s hard to find the real errors in between.
The one architectural change that may be related to this is that I use a plugin that acts as the base for the application. Here’s why: there are two websites with a lot of similar code. So the plugin contains all the common code, including Tables, Entities, Controllers, a Component and even some Elements. All controllers in the ‘real’ application are derived from a base controller in the plugin. Perhaps a bit weird, but I don’t see another way of doing it. Anyway, I’d like some pointers on how to tackle this problem. So far I’ve had little success in finding the circular reference, so any help would appreciated.