PHP 7.4 : Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated.

Pyros9

Member
May 24, 2020
35
12
8
I'm getting this error on every page since I uploaded website to php 7.4, with Pinpoint booking system (free version, but I guess also with paid). Tried to ask for help in the support forum, but I don't have any hope, as help there just sucks.

Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in / domain /wp-content/plugins/booking-system/includes/calendars/class-backend-calendar-schedule.php on line 621


Line 620 (and 621) are:


PHP:
                if(!empty($selectedHours)){
                    $hours_length = count($selectedHours)-(!$settings_calendar->hours_multiple_select == 'true' ? true:($settings_calendar->hours_add_last_hour_to_total_price == 'true' && $settings_calendar->hours_interval_enabled == 'false' ? true:false) || ($settings_calendar->hours_multiple_select == 'false' ? false:($settings_calendar->hours_interval_enabled == 'true' ? true:false)) && ($settings_calendar->hours_multiple_select == 'true' ? true:false) ? 1:0);





Any php master who can help me with this? :)
 
Last edited:
  • Wow
Reactions: OnlyJesusSaves

OnlyJesusSaves

Well-known member
Null Master
Trusted Uploader
Feb 26, 2020
341
1,043
100
Hi!

You can try this and let me know if it works. I ran it in a quick PHP test and the error is gone. It looks like in PHP 7.4, the conditional true or false code, just needs wrapped in some enclosures: "(...)"


PHP:
$hours_length = count($selectedHours)-(!$settings_calendar->hours_multiple_select == 'true' ? true:(($settings_calendar->hours_add_last_hour_to_total_price == 'true' && $settings_calendar->hours_interval_enabled == 'false' ? true:false) || ($settings_calendar->hours_multiple_select == 'false' ? false:($settings_calendar->hours_interval_enabled == 'true' ? true:false)) && ($settings_calendar->hours_multiple_select == 'true' ? true:false) ? 1:0));

ONLY replace the $hours_length line, NOT the if(!empty($selectedHours)){ line.
 

Pyros9

Member
May 24, 2020
35
12
8
Hi!

You can try this and let me know if it works. I ran it in a quick PHP test and the error is gone. It looks like in PHP 7.4, the conditional true or false code, just needs wrapped in some enclosures: "(...)"


PHP:
$hours_length = count($selectedHours)-(!$settings_calendar->hours_multiple_select == 'true' ? true:(($settings_calendar->hours_add_last_hour_to_total_price == 'true' && $settings_calendar->hours_interval_enabled == 'false' ? true:false) || ($settings_calendar->hours_multiple_select == 'false' ? false:($settings_calendar->hours_interval_enabled == 'true' ? true:false)) && ($settings_calendar->hours_multiple_select == 'true' ? true:false) ? 1:0));

ONLY replace the $hours_length line, NOT the if(!empty($selectedHours)){ line.


Nope, it didn't work:


Code:
Parse error: syntax error, unexpected 'if' (T_IF) in / domain /wp-content/plugins/booking-system/includes/calendars/class-backend-calendar-schedule.php on line 620
Critical error
 

OnlyJesusSaves

Well-known member
Null Master
Trusted Uploader
Feb 26, 2020
341
1,043
100
Nope, it didn't work:

Code:
Parse error: syntax error, unexpected 'if' (T_IF) in / domain /wp-content/plugins/booking-system/includes/calendars/class-backend-calendar-schedule.php on line 620
Critical error

Hi. It should work, it looks like when you replaced the code you replaced it incorrectly. :)

There is no "if" statement in the code I gave you. The parse error is from previous line.

But try this... I edited it locally and tested it, I think it should get rid of the depreciated error on PHP 7.4.

However, this "depreciated" error is a not a major concern, it's just depreciated- as long as you suppress the errors of such from those who don't need to see that error, it's fine, so the dev can have time to update accordingly for PHP 7.4+. Also, there are other normal errors that the dev needs to look into, at least one that I know of. See @ https://monosnap.com/file/g9B0lIocNIn1ijS0bFacAnWI73pYuN

You can download the edited version I edited and try it @ https://monosnap.com/file/BsNE4L1jycmvM4PYl06wNZEdREIYMI
 
  • Like
Reactions: Pyros9

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu