Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Dear KK Sir,

Hope you are doing good and have recovered well!

I encountered the following error:
Fatal error: Uncaught TypeError: addslashes(): Argument #1 ($string) must be of type string, array given in D:\wamp64\www\CTO\jadhaogin.in2.0\couch\functions.php on line 188


To replicate:
1. WAMP (I am using)
2. Apache: 2.4.54.2
3. MySQL: 8.1.0
4. PHP: 8.3.9
5. Code that triggered the error:
Code: Select all
<cms:editable name="display_tech_specs" label="Display Technical Specifications?" type="checkbox" opt_values="Yes" opt_selected="" group="tech_specs" order="1" />
        <cms:func _into='cond_display_tech_specs' display_tech_specs=''>
            <cms:if display_tech_specs='Yes'>
                show
            <cms:else />
                hide
            </cms:if>
        </cms:func>
        <cms:editable name="tech_specs_title" label="Technical Specifications Table - Title" desc="If empty then 'Technical Specs' will be displayed" type="text" group="tech_specs" not_active=cond_display_tech_specs order="2" />


The error occurred when I added the <cms:func> block.

Regards,
Aashish
GXCPL
Image
where innovation meets technology
Hi Aashish,

I am well, thank you :)

Thanks for the heads-up on the error too.
While the immediate reason for that error is that you are using a wrong construct in your func -
Code: Select all
<cms:if display_tech_specs='Yes'>

The field being checked is a checkbox and hence the correct way to test its value should be this (because a checkbox can potentially have multiple values) -
Code: Select all
<cms:if "<cms:is 'Yes' in=display_tech_specs />">

That said, the expected behaviour for this mistake in PHP versions prior to 8 would be that the check would simply fail.
PHP 8 chooses to throw a fatal error instead (https://php.watch/versions/8.0/internal ... exceptions) and going by this change I suspect we'll come across more such corner cases going forward :(

Anyway, to fix this particular problem and to align the behaviour of PHP 8 with previous versions, I have pushed a commit to GitHub. You may get it from there, if you like.

Hope this helps.
Good Mornig KK Sir!
Good to know you are doing well!

I saw my mistake, actually i only had a single value in the checkbox so i didnt use the <cms:is> tag. But got it and have corrected it. Thanks a lot.

Sir another thing I wanted to know was the string+string error in the cms:add tag and other tags for mathematical operations. Could you please see that once. This is the link to the issue.

Thanks again.

Regards,
Aashish
GXCPL
Image
where innovation meets technology
Nice one, I guess this type fix solves the Fatal error with conditional inside Mosaic #197 https://github.com/CouchCMS/CouchCMS/issues/197 as it is based on the similar concept.
Edit: and this one as well? Arrays not handled #201 https://github.com/CouchCMS/CouchCMS/issues/201
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@genxcoders, I'll try and fix the cms:add issue shortly.
@trendoman, yes, indeed! This seems to be the same problem as those two reported by you much earlier.
5 posts Page 1 of 1