View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
19894Bug reportsOtherpublic2025-06-18 11:33
Reportertassoman Assigned To 
PrioritynoneSeverityminor 
Status newResolutionopen 
Product Version6.6.x 
Summary19894: Calling "__tostring" method on a "SimpleXMLElement" object is not allowed
Description

While editing new theme by hands, I tried to dump(aSurveyInfo) variable.

Version is 6.8.2+241203 (missing product version in bug tracker)

Twig\Sandbox\SecurityNotAllowedMethodError

Calling "tostring" method on a "SimpleXMLElement" object is not allowed in "string_template__b85a9d86339e4b676595fbe968ac295f" at line 234.

Steps To Reproduce

Steps to reproduce

  1. create new survey theme extending fruity_twentythree
  2. enable config debug = 1
  3. add config variable 'force_xmlsettings_for_survey_rendering' => true,
  4. add {{ dump(aSurveyInfo) }} code inside global layout template

Expected result

I wanted to dump survey data

Actual result

error stacktrace, see attached image

Tagsdebug, survey, template, theme, twig
Attached Files
Bug heat4
Complete LimeSurvey version number (& build)6.8.2+241203
I will donate to the project if issue is resolvedNo
BrowserAny
Database type & versionMysql 5.7.x
Server OS (if known)
Webserver software & version (if known)
PHP Version8.2.26

Relationships

related to 19952 new Unable to use {{ dump(aSurveyInfo) }} in 

Users monitoring this issue

tassoman

Activities

tassoman

tassoman

2024-12-18 17:13

reporter   ~81659

Found this on PHP Manual (about PHP 8.x)
https://www.php.net/manual/en/language.oop5.magic.php#object.tostring

tassoman

tassoman

2024-12-18 17:51

reporter   ~81660

By removing force_xmlsettings_for_survey_rendering configuration, I got a similar error. That's because confinguration is an object.


Twig\Sandbox\SecurityNotAllowedMethodError
Calling "tostring" method on a "TemplateConfiguration" object is not allowed in "string_template__b85a9d86339e4b676595fbe968ac295f" at line 234.

To debug like this, i usually do var_export($var, true); https://www.php.net/manual/en/function.var-export.php
Maybe dump() function can ignore __toString() special method and use the var_export() function?
Also print_r($var, true); has the same behaviour https://www.php.net/manual/en/function.print-r.php

tassoman

tassoman

2025-06-18 11:33

reporter   ~82899

{{ dump() }} is something provided by Twig template engine, natively. (See: https://twig.symfony.com/doc/3.x/functions/dump.html)
By -not- declaring anything, will dump everything data available inside the template was called from.
In this situation, without passing arguments, it's able to display stringified objects, correctly.
Maybe it's time for Twig upgrade?

Issue History

Date Modified Username Field Change
2024-12-16 17:15 tassoman New Issue
2024-12-16 17:15 tassoman File Added: Screenshot 2024-12-16 at 17-08-45 Twig_Sandbox_SecurityNotAllowedMethodError.png
2024-12-16 17:17 tassoman Tag Attached: twig
2024-12-16 17:17 tassoman Tag Attached: theme
2024-12-18 17:13 tassoman Note Added: 81659
2024-12-18 17:13 tassoman Bug heat 0 => 2
2024-12-18 17:51 tassoman Note Added: 81660
2025-02-04 08:46 DenisChenu Relationship added related to 19952
2025-02-18 17:21 tassoman Issue Monitored: tassoman
2025-02-18 17:21 tassoman Bug heat 2 => 4
2025-02-18 17:23 tassoman Tag Attached: template
2025-02-18 17:23 tassoman Tag Attached: survey
2025-02-18 17:23 tassoman Tag Attached: debug
2025-06-18 11:33 tassoman Note Added: 82899