var_export() does not handle circular references [#3267110] | Drupal.org
Skip to search
Can we use first and third party cookies and web beacons to
understand our audience, and to tailor promotions you see
var_export() does not handle circular references
Closed (fixed)
Project:
Examples for Developers
Version:
4.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
jmohino
Created:
1 Mar 2022 at 10:48 UTC
Updated:
21 Apr 2026 at 10:35 UTC
Jump to comment:
Most recent
Problem/Motivation
I have a Drupal 9.3 site with php 7.3. After enabling the render-example module I try to go to the link "Demonstration of render array usage." and I receive an error "502 Proxy Error", in the log messages I have many warnings with the following content:
Warning: var_export does not handle circular references en Drupal\Component\Utility\Variable::export() (línea 88 de /var/www/html/my-site/web/core/lib/Drupal/Component/Utility/Variable.php)
#0 /var/www/html/my-site/web/core/includes/bootstrap.inc(346): _drupal_error_handler_real(2, 'var_export does...', '/var/www/html/m...', 88)
#1 [internal function]: _drupal_error_handler(2, 'var_export does...', '/var/www/html/m...', 88, Array)
#2 /var/www/html/my-site/web/core/lib/Drupal/Component/Utility/Variable.php(88): var_export(Object(Drupal\Core\StringTranslation\TranslatableMarkup), true)
#3 /var/www/html/my-site/web/core/lib/Drupal/Component/Utility/Variable.php(60): Drupal\Component\Utility\Variable::export(Object(Drupal\Core\StringTranslation\TranslatableMarkup), ' ', false)
#4 /var/www/html/my-site/web/modules/contrib/examples/modules/render_example/src/Controller/RenderExampleController.php(407): Drupal\Component\Utility\Variable::export(Array)
#5 [internal function]: Drupal\render_example\Controller\RenderExampleController->arrays()
#6 /var/www/html/my-site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#7 /var/www/html/my-site/web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 /var/www/html/my-site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#9 /var/www/html/my-site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#10 /var/www/html/my-site/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /var/www/html/my-site/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#12 /var/www/html/my-site/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /var/www/html/my-site/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/my-site/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/my-site/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/my-site/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/my-site/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/my-site/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/my-site/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/my-site/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#21 {main}
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork
examples-3267110
Show commands
Start within a Git clone of the project using the
version control instructions
Add & fetch this issue fork’s repository
Or,
if you do not have
SSH keys set up on git.drupalcode.org
Add & fetch this issue fork’s repository
3267110-fix-the-code-to-export-variables
plain diff
MR
!44
Check out this branch for the first time
Check out existing branch, if you already have it locally
About issue forks
Comments
Comment
#1
1 March 2022 at 10:48
jmohino
created an issue. See
original summary
or
to post comments
Comment
#2
jmohino
commented
11 March 2022 at 11:43
I don't know much about this, but after changing line 407 of the RenderExampleController.php file in the render_example/src/Controller folder it worked and I can see the output. Also for the 'unrendered'
Change:
'#markup' => htmlentities(Variable::export($build[$key])),
by:
'#markup' => htmlentities(json_encode($build[$key])),
or
to post comments
Comment
#3
jmohino
commented
11 March 2022 at 13:03
Issue summary:
View changes
or
to post comments
Comment
#4
jungle
He/Him
Chongqing, China
commented
19 February 2023 at 05:23
Version:
3.0.3
» 4.0.x-dev
Status:
Active
» Postponed (maintainer needs more info)
You can always use
dpm()
with the Devel module installed for debugging.
Would you try it with the latest dev branch 4.0.x (for Drupal core 9.4+) or the latest release 4.0.0 to see if the bug still exists?
Thanks!
or
to post comments
Comment
#5
optlai
commented
23 April 2024 at 07:38
yes bug still exist.
Drupal 10.2.5 + version 4.0.2
I have Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 534777856 bytes) in /app/web/core/lib/Drupal/Component/Utility/Variable.php on line 88
with '#markup' => htmlentities(json_encode($build[$key])), no problem
or
to post comments
Comment
#6
avpaderno
he/him
Italian
Brescia, 🇮🇹 🇪🇺
commented
27 June 2024 at 19:41
I think that what described here explains why adding
\Drupal\render_example\Controller\RenderExampleController::preRender()
as pre-render callback causes two tests to fails.
In fact, one of the tests expects to get a 200 status back, but it gets a 500 status. Usually, that is caused by some errors on PHP side, like the one described here.
or
to post comments
Comment
#7
avpaderno
he/him
Italian
Brescia, 🇮🇹 🇪🇺
commented
27 June 2024 at 19:47
Title:
render-example var_export does not handle circular references
» var_export() does not handle circular references
or
to post comments
Comment
#8
27 June 2024 at 19:51
apaderno
opened
merge request !44
or
to post comments
Comment
#9
avpaderno
he/him
Italian
Brescia, 🇮🇹 🇪🇺
commented
27 June 2024 at 19:51
Status:
Postponed (maintainer needs more info)
» Needs review
or
to post comments
Comment
#10
avpaderno
he/him
Italian
Brescia, 🇮🇹 🇪🇺
commented
2 October 2025 at 09:28
Component:
Render Example
» Code
or
to post comments
Comment
#11
7 April 2026 at 10:32
avpaderno
committed
7da2ba3d
on
4.0.x
Issue #3267110: var_export() does not handle circular references
or
to post comments
Comment
#12
avpaderno
he/him
Italian
Brescia, 🇮🇹 🇪🇺
commented
7 April 2026 at 10:33
Status:
Needs review
» Fixed
or
to post comments
Comment
#13
7 April 2026 at 10:33
Now that this issue is closed,
review the
contribution record
As a contributor, attribute any organization that helped you, or if you volunteered your own time.
Maintainers, credit people who helped resolve this issue.
or
to post comments
Comment
#14
21 April 2026 at 10:35
Status:
Fixed
» Closed (fixed)
Automatically closed - issue fixed for 2 weeks with no activity.
or
to post comments
Contribution record
Add child issue
clone issue
Referenced by
#2986435: Fix the code in \Drupal\render_example\Controller\RenderExampleController::preRender()
Infrastructure management for Drupal.org provided by
Need a Drupal 7 extended support partner? Consider Tag1.
News items
News
Planet Drupal
Social media
Sign up for Drupal news
Security advisories
Jobs
Our community
Community
Services
Training
Hosting
Contributor guide
Groups & meetups
DrupalCon
Code of conduct
Documentation
Documentation
Drupal Guide
Drupal User Guide
Developer docs
API.Drupal.org
Drupal code base
Download & Extend
Drupal core
Modules
Themes
Distributions
Governance of community
About
Web accessibility
Drupal Association
About Drupal.org
Drupal is a
registered trademark
of
Dries Buytaert
US