• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

php8 Errors on Joomla 3.10.11

ontarget

Active Member
Hi,
I started this thread as a repository of errors i may encounter into my journey into php8.1 with Fabrik 3.10 in a hope to extend the life of some of my projects.

I have just updated a backup of a site to Joomla 3.10.11, Fabrik 3.10 from git and php8.1
Most of my lists are loading ok in the backend however one shows:
An error has occurred.
0 Unsupported operand types: string + string

I have narrowed it down to a calc element which is:
PHP:
$attendance = ((int)'{aaa_maindatabase___main_total_pp}' + '{aaa_maindatabase___main_total_primary}') * (int)'{aaa_maindatabase___main_sessions}';
if($attendance >= 1)
{
return $attendance;
}
else
{
return '{aaa_maindatabase___attendance}';
}

FIX:I guess i need to cast the data correctly for php8 - this did the trick:

PHP:
$attendance = ((int)'{aaa_maindatabase___main_total_pp}' + (int)'{aaa_maindatabase___main_total_primary}') * (int)'{aaa_maindatabase___main_sessions}';
if($attendance >= 1)
{
return $attendance;
}
else
{
return '{aaa_maindatabase___attendance}';
}

Ajax Calculation:
I have the following calc element with ajax calculation = Yes
Basically the calc element just hangs with the spinner icon "Loading"
PHP:
if ('{aaa_maindatabase___main_provider}' != COMM) {
$catering = array_sum($data[(int)'aaa_maindatabase___main_catering_detail_raw']) + (int)'{aaa_maindatabase___main_other_catering}';
$totalcatering = $catering * (int)'{aaa_maindatabase___main_served}';
return $totalcatering;
}

else {
$catering = array_sum($data[(int)'aaa_maindatabase___main_catering_detail_comm_raw']) + (int)'{aaa_maindatabase___main_other_catering}';
$totalcatering = $catering * (int)'{aaa_maindatabase___main_served}';
return $totalcatering;
}
FIX: again my poor / slack coding - need to use single quotes 'COMM'
PHP:
if ('{aaa_maindatabase___main_provider}' != 'COMM') {
 
Last edited:
Hi getting lots of null to parameter errors using j3.10.11 and php8.1 and latest fabrik commit from Git - any ideas on fixes?
  • PHP Deprecated: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /libraries/vendor/joomla/string/src/phputf8/mbstring/core.php on line 24
  • PHP Deprecated: mb_substr(): Passing null to parameter #1 ($string) of type string is deprecated in /libraries/vendor/joomla/string/src/phputf8/mbstring/core.php on line 94
  • PHP Deprecated: mb_substr(): Passing null to parameter #1 ($string) of type string is deprecated in /libraries/vendor/joomla/string/src/phputf8/mbstring/core.php on line 96
  • PHP Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /components/com_fabrik/models/list.php on line 11622
  • PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /libraries/src/Uri/Uri.php on line 141
  • PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /plugins/fabrik_element/databasejoin/databasejoin.php on line 1088
  • PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /components/com_fabrik/models/listfilter.php on line 855
  • PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /plugins/fabrik_element/databasejoin/databasejoin.php on line 978
  • PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /plugins/fabrik_element/cascadingdropdown/cascadingdropdown.php on line 855
 
Last edited:
"Deprecated" are only warnings. As you can see a lot of them are coming from Joomla itself.

But if you have enabled this error level such warnings/notices will break JSON responses so popups etc. may stop working.

They will vanish if you set Joomla's error reporting to a lower level.
 
Hi can anyone help with this please:

I was getting the following blank error page with php8 on form submission due to an array_sum() calc
0
array_sum(): Argument #1 ($array) must be of type array, string given

main_catering_detail_raw is a checkbox element.

Here is the code:
PHP:
if ('{aaa_maindatabase___main_provider}' != 'COMM') {
$catering = array_sum($data[(float)'aaa_maindatabase___main_catering_detail_raw']) + (float)'{aaa_maindatabase___main_other_catering}';
$totalcatering = $catering * (int)'{aaa_maindatabase___main_served}';
return $totalcatering;
}

else {
$catering = array_sum($data[(float)'aaa_maindatabase___main_catering_detail_comm_raw']) + (float)'{aaa_maindatabase___main_other_catering}';
$totalcatering = $catering * (int)'{aaa_maindatabase___main_served}';
return $totalcatering;
}
I switched to php 7.4 - this time the form submitted but with J! errors turned on to development I could see
An error has occurred with a eval'd field - please inform the web-site owner.
Debug: Eval exception : main_total_catering (id 49)::_getV() : if ('Local' != 'COMM') { $catering = array_sum($data[(float)'aaa_maindatabase___main_catering_detail_raw']) + (float)'0.00'; $totalcatering = $catering * (int)'0'; return $totalcatering; } else { $catering = array_sum($data[(float)'aaa_maindatabase___main_catering_detail_comm_raw']) + (float)'0.00'; $totalcatering = $catering * (int)'0'; return $totalcatering; } : array_sum() expects parameter 1 to be array, null given.

So I changed the code in the calc to read:
PHP:
if ('{aaa_maindatabase___main_provider}' != 'COMM') {
  $catering = array_sum($data['aaa_maindatabase___main_catering_detail_raw']);
  $subcatering = $catering + (float)'{aaa_maindatabase___main_other_catering}';
  $totalcatering = $subcatering * (int)'{aaa_maindatabase___main_served}';
  return $totalcatering;
}

else {
  $catering = array_sum($data['aaa_maindatabase___main_catering_detail_comm_raw']);
  $subcatering = $catering+ (float)'{aaa_maindatabase___main_other_catering}';
  $totalcatering = $subcatering * (int)'{aaa_maindatabase___main_served}';
return $totalcatering;
}

The error was fixed in php7.4
So I switched back to php8 and I'm still getting:
0
array_sum(): Argument #1 ($array) must be of type array, string given
Any ideas on fixes for php8?

Thanks
 
Last edited:
Sorry didnt realise i had closed this thread.
@lousyfool had answered as below:
Hi,

Re: https://fabrikar.com/forums/index.php?threads/php8-errors-on-joomla-3-10-11.53447/

You had closed the thread, so no one will be able to respond to your latest post there.

However, in your code I guess
Code (Text):
array_sum($data['aaa_maindatabase___main_catering_detail_comm_raw'])
is indeed not an array but just some single value, and in this case it's normal that an error or at least a warning is thrown.
print_r($data['aaa_maindatabase___main_catering_detail_comm_raw']) or var_dump($data['aaa_maindatabase___main_catering_detail_comm_raw']) it followed by "exit;" and you should see.
 
@lousyfool thanks for your suggestion
I think the issue in php8 is that the checkbox data is cast as a string:
var_dump($data['aaa_maindatabase___main_catering_detail_comm_raw'])
array(1) { [0]=> string(5) "16.29" }

I used array_sum as I wanted to take whatever values that have been checked in the previous checkbox element and sum them before performing a further calc.
As php8 is much stricter on the datatype i believe that is why its failing
EDIT:
I have cast the checkbox data to float as follows and it works well:
PHP:
$options= FabrikWorker::JSONtoData($data['aaa_maindatabase___main_catering_detail_raw'],true);
$myparsedarray = array_map('floatval', $options);
$catering = array_sum($myparsedarray) + (float)'{aaa_maindatabase___main_other_catering}';
$totalcatering = $catering * (int)'{aaa_maindatabase___main_served}';
return $totalcatering;
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top