PHP 7.4 support for substitutions ?

1 year 6 months ago - 1 year 6 months ago #330824 by activha
PHP 7.4 support for substitutions ? was created by activha
Hello
I am on PHP 8.1 on the dev website and there is no issues to get [var1_params_activ] display ACTIV'H.A saved in a cb activity params.
However on PHP 7.4 for the production website, this seems to issue an error due to the quote in the name not being escaped.

The display is correct on HTML code, but fails on PHP code
I noticed this since the last build of CB.
Is it intended ? can you check this ?
Thanks for your return

Please Log in to join the conversation.

1 year 6 months ago #330825 by krileon
Replied by krileon on topic PHP 7.4 support for substitutions ?

However on PHP 7.4 for the production website, this seems to issue an error due to the quote in the name not being escaped.

Enable debug mode and maximum error reporting then retry and provide the full error with callstack. PHP 7.4 is still supported. Substitutions should always be treated as strings so be sure your substitution is inside of a string. Example as follows.

Correct
$test = '[cb_myfield]';

Incorrect
$test = [cb_myfield];


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

1 year 6 months ago #330838 by activha
Replied by activha on topic PHP 7.4 support for substitutions ?
There are no errors, on 7.4 I have to use 
$title =htmlspecialchars("[var1_params_activ]");
instead of using only '[var1_params_activ]' as this fails when there are quotes in the params.

On 8.1, '[var1_params_activ]'  works fine.

I have also noticed that it's not possible to add php use in an outside file on PHP 7.4 with CB
An external file starting with :
use AcyMailing\Helpers\MailerHelper;
use AcyMailing\Classes\UserClass;
use AcyMailing\Classes\QueueClass;
use AcyMailing\Classes\MailClass;
...

works perfectly well with PHP 8.1 when called by the autoaction, and exactly the same file fails on 7.4 with  Error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)

I have spent the day on this without success.... :-(

Do you have a idea of what goes wrong with 7.4 and CB ??
 

Please Log in to join the conversation.

1 year 6 months ago #330840 by krileon
Replied by krileon on topic PHP 7.4 support for substitutions ?
Substitutions do not escape quotes for you. That's for you to do. They simply output whatever is assigned to that substitution. The same goes for sanitization. So for example do not substitute directly into a query user content without sanitizing with parser functions (for Query conditions/actions CB Auto Actions will escape quotes though so this is an exception, but this is not going to be applied to your own PHP code). In short nothing is going wrong and it's doing what it's supposed to.

works perfectly well with PHP 8.1 when called by the autoaction, and exactly the same file fails on 7.4 with Error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)

That has nothing to do with CB. You've a syntax error in your PHP. Probably using PHP 8.1 syntax of some kind that is not valid on PHP 7.4.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

1 year 6 months ago - 1 year 6 months ago #330841 by activha
Replied by activha on topic PHP 7.4 support for substitutions ?
Oupsss you where right that was :
$ownerlist = $eventowner->getField( 'cb_comactiv_liste', null, 'csv', 'none', 'list' ) != null ? eventowner->getField( 'cb_comactiv_liste', null, 'csv', 'none', 'list' ) : 3847; 

Thanks a lot for your help :-)
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.239 seconds

Facebook Twitter LinkedIn