LISE in UDT gives 500 error

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

LISE in UDT gives 500 error

Post by webform »

Trying to use a Smarty tag in a UDT gives almost always an 500 error.

I've tested with this UDT and a LISE Instance and get an 500 error:

Code: Select all

$smarty_data = "{LISEEmployees category='assets' xs_issued='1' template_summary='total'}";
$smarty->display('eval:'.$smarty_data);
Error log says

Code: Select all

PHP Notice: Trying to access array offset on value of type null in /lib/smarty/sysplugins/smarty_resource_recompiled.php(52) : eval()'d code on line 18\n
I've also tested with CustomGS module and it also fails but with another error when trying to save the UDT:

Code: Select all

$smarty_data = "{$CustomGS.META_Keywords}";
$smarty->display('eval:'.$smarty_data);
Error message:

Code: Select all

Invalid code entered.
syntax error, unexpected '.', expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
This is tested on:

Code: Select all

Cms Version: 2.2.21
phpversion: 7.4.33
I've also tested on an old Cms Version: 2.2.10 with phpversion: 5.6.40 and here the UDTs working. So maybe the PHP version is to blame?

So what do i have to do different to use Smarty tags in an UDT?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE in UDT gives 500 error

Post by Jo Morg »

Hard to say without access or more info, but it seems like the total template is the one giving an error. If possible post here the template.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE in UDT gives 500 error

Post by webform »

It's just a simple template I use to test with, which only contains {$totalcount}.

An error occurs regardless of whether I use the default template or any other template and regardless of which Smarty tag such as LISE, MAMS or CustomGS.

It has worked before in previous versions of CMSMS, so I thought maybe the way you call Smarty Tags in an UDT had changed?

I have previously used this guide to call a Smarty Tag in an UDT: https://cmscanbesimple.org/blog/call-a- ... from-a-udt
gusfring
New Member
New Member
Posts: 1
Joined: Mon Aug 26, 2024 8:14 am

Re: LISE in UDT gives 500 error

Post by gusfring »

webform wrote: Mon Aug 26, 2024 7:03 am It's just a simple template I use to test with, which only contains {$totalcount}.

An error occurs regardless of whether I use the default template or any other template and regardless of which Smarty tag such as LISE, MAMS or CustomGS.

It has worked before in previous versions of CMSMS, so I thought maybe the way you call Smarty Tags in an UDT had changed?

I have previously used this guide to call a Smarty Tag in an UDT: https://cmscanbesimple.org/blog/call-a- ... from-a-udt my perfect hotel
it works
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE in UDT gives 500 error

Post by webform »

It would appear that it might be a "bug" in Cms Version: 2.2.21.

I have done a clean installation of Cms Version: 2.2.21 and here the UDT fails with server error 500.
But I have also done a clean installation of Cms Version: 2.2.19 and here the UDT saves without error and I get an output.

UDT i'm testing:

Code: Select all

$smarty_data = "{MyLISEInstance}";
$smarty->display('eval:'.$smarty_data);
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1785
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE in UDT gives 500 error

Post by DIGI3 »

If you look at the error in the log, there's actually a clue:

Code: Select all

PHP Fatal error:  Uncaught  --> Smarty Compiler: Syntax error in template "eval:{MyLISEInstance}"  on line 1 "{MyLISEInstance}" unknown tag 'MyLISEInstance' <-- 
  thrown in 55d51468d3078225bb6d6ffb7a3ff94222bdf22a on line 1
Short tags to modules aren't registered in admin, so you need to use

Code: Select all

{cms_module module='MyLISEInstance'}
instead.
Not getting the answer you need? CMSMS support options
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE in UDT gives 500 error

Post by webform »

Thanks! It's working:

Code: Select all

$smarty_data = "{cms_module module='MyLISEInstance'}";
$smarty->display('eval:'.$smarty_data);
Just strange that this works in Cms version 2.2.19 but not in Cms version 2.2.21

Code: Select all

$smarty_data = "{MyLISEInstance}";
$smarty->display('eval:'.$smarty_data);
And using {CustomGS} no longer works in either Cms version 2.2.19 or Cms version 2.2.21, but works in an old Cms version 2.2.10

Code: Select all

$smarty_data = "{$CustomGS.MyTextField}";
$smarty->display('eval:'.$smarty_data);
My UDT's with the LISE API that insert data from a frontend form still work in Cms version 2.2.21, but I can no longer edit the UDT without getting errors such as:

Code: Select all

Notice: Undefined variable: params in /var/www/public_html/app/assetit/admin/editusertag.php(98) : eval()'d code on line 13
Notice: Trying to access array offset on value of type null in /var/www/public_html/app/assetit/admin/editusertag.php(98) : eval()'d code on line 13
Warning: Invalid argument supplied for foreach() in /var/www/public_html/app/assetit/admin/editusertag.php(98) : eval()'d code on line 34
And trying to save the UDT creates a blank record in the LISEInstance.
This is not happening in Cms version 2.2.19!

So I think there must be something wrong with UDT in Cms version 2.2.21 since I'm experiencing all those errors, right?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE in UDT gives 500 error

Post by Jo Morg »

There are changes to the way UDT's get parsed before being saved. Although that was not the goal, which was to parse any PHP syntax error on save, it seems that the UDT gets executed once. I'll have to revisit the code (tbh the original broken code also seemed to parse the code in a similar way without actually executing it). So it indeed seems to be a bug. If possible open a BR on CMSMS Core so that I remember to check that code out before next release. THX.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE in UDT gives 500 error

Post by webform »

Yeah! I did notice when i opened an UDT with mail handling i got sent an email from the script.

I'll file a bug report. Thanks.

p.s. I overcame some of the problem temporarily with the UDT by working with the code in the MySQL table directly, so that I didn't get error messages when I saved the UDT.

However, I have not yet found out how to use the module CustomGS in a UDT, as you could in previous CMS versions.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE in UDT gives 500 error

Post by Jo Morg »

It may be a different aspect of the same issue; as stated above by @DIGI3: "Short tags to modules aren't registered in admin", but parsing the UDT on save is done in admin, so it will trigger the error only on save. At least that's what it looks like without testing...
PS: using {cms_module .... should work with all modules though, as a workaround ...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE in UDT gives 500 error

Post by webform »

I've tried first with (which i've used in a dosen of older solutions):

Code: Select all

$smarty_data = "{$CustomGS.MyTextField}";
$smarty->display('eval:'.$smarty_data);
But get error:

Code: Select all

Invalid code entered.
syntax error, unexpected '.', expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
And then i've tried:

Code: Select all

$smarty_data = "{cms_module module='$CustomGS.MyTextField'}";
$smarty->display('eval:'.$smarty_data);
Which result in the error:

Code: Select all

.MyTextField is not a module
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE in UDT gives 500 error

Post by Jo Morg »

webform wrote: Tue Aug 27, 2024 6:39 pm

Code: Select all

$smarty_data = "{cms_module module='$CustomGS.MyTextField'}";
cms_module only work for module tags, in fact it is meant to replace them for backend module calls, so of course that won't work.
webform wrote: Tue Aug 27, 2024 6:39 pm I've tried first with (which i've used in a dosen of older solutions):

Code: Select all

$smarty_data = "{$CustomGS.MyTextField}";
$smarty->display('eval:'.$smarty_data);
But get error:

Code: Select all

Invalid code entered.
syntax error, unexpected '.', expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
This shouldn't even have worked before TBH... The PHP parser sees {$CustomGS.MyTextField} inside double quotes and evaluates it as a PHP variable so it complains about the dot in the middle. It's standard PHP syntax...
Try either:

Code: Select all

$smarty_data = '{$CustomGS.MyTextField}'; # <- single quotes here
# or
$smarty_data = "{$CustomGS.MyTextField }"; # adding a single with space may also work as the {} is what triggers PHP evaluation... didn't try though
 
$smarty->display('eval:'.$smarty_data);
HTH
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
webform
Power Poster
Power Poster
Posts: 503
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE in UDT gives 500 error

Post by webform »

It's embarrassing, but you're right! :-[

I'm a fool and remembered wrong! There are single quotes on my call of the CustomGS module when I look again in the old UDT.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE in UDT gives 500 error

Post by Jo Morg »

No worries, it happens. :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “Modules/Add-Ons”