Hey everyone!
With the holiday season upon us, we want to share our upcoming working hours:
- New Year: Our team will be off on January 1st and 2nd. We’ll be back on Friday, January 3rd, to respond to any messages received during this time.
- Weekend: As usual, we don’t work on weekends, so January 4th and 5th will also be non-working days.
- Orthodox Christmas: Our office will be closed on Monday and Tuesday, January 6th and 7th for the holiday.
After that, we’ll return to our regular schedule and assist you as quickly as possible.
In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find tons of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel), which might just have the answers you need while we’re away.
Thanks a bunch for your understanding and support!
Warm regards and happy holidays!
TMS
In attempt to render the "Avg" of a specific column in a wpdatatable, the webpage returns a
Warning: Division by zero in /var/www/html/wp-content/plugins/wpdatatables/source/class.wpdatatable.php on line 1459
This is the entire block of code in the pointed plugin file:
public function calcColumnFunction($columnKey, $function) {
$result = null;
if ($function == 'sum' || $function == 'avg') {
foreach ($this->getDataRows() as $wdtRowDataArr) {
$result += $wdtRowDataArr[$columnKey];
}
if ($function == 'avg') {
$result = $result / count($this->getDataRows()); (this is line 1459)
require_once(WDT_ROOT_PATH . 'source/class.float.wpdatacolumn.php');
$floatCol = new FloatWDTColumn();
$floatCol->setParentTable($this);
return $floatCol->prepareCellOutput($result);
}
} else if ($function == 'min') {
foreach ($this->getDataRows() as $wdtRowDataArr) {
if (!isset($result) || $wdtRowDataArr[$columnKey] < $result) {
$result = $wdtRowDataArr[$columnKey];
}
}
} else if ($function == 'max') {
foreach ($this->getDataRows() as $wdtRowDataArr) {
if (!isset($result) || $wdtRowDataArr[$columnKey] > $result) {
$result = $wdtRowDataArr[$columnKey];
}
}
}
return $this->returnCellValue($result, $columnKey);
}
Hi Brian
Thank you for reaching out to us.
Please provide me a temporary WP-admin (administrator) user for your site where this happens and the table ID, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue.
We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course, we do not provide login data to third parties.
You can write credentials here just check PRIVATE Reply so nobody can see them except us.
Hi Brian
You are right, the warning does appear because there is no data in the table when the new user accesses the table, but this warning doesn't affect the plugin.
You see it because you have debugging turned on in your wp-config.php file:
define( 'WP_DEBUG', true );
This should be turned on only when actual debugging is being conducted on the site, otherwise it should be:
define( 'WP_DEBUG', false );
Please turn that off, and the warnings will disappear.
This config is also showing you a warning on your log-in page. Just visit the page, and take a screenshot of that warning in the upper left corner, and show it to him
Once you disable debugging, it will be fine.
Hi Blazenka,
Thanks for the update - I will take a look at the wp-config.php file and make the adjustments you suggested. Please leave this ticket open until it's confirmed the issue has been resolved.
Appreciate your assistance on this.
Thanks
- Brian
You are most welcome
The ticket will automatically close after 7 days of inactivity. But even after that if there is anything else we can assist you with please don't hesitate to open a new ticket.
Have a wonderful day!
Hi Blazenka,
Thank you for your patience - I went ahead and did as you suggested disabling the debugging line item in the wp-config file but it didn't really resolve the main issue which gets me thinking if this is a plugin bug?
Reason why I say this is because for the function "SUM" for the same line-items in the wpdatatable (no entries), the return value is 0 as it should be. But on the "AVG" function, it returned that Warning as screen-shotted initially in this case. After disabling the debugging code in wp-config file, it now returns "nan" on the front end; it used to return 0.
Can we further investigate this? Flagging incase this may affect other users of this plugin.
ps. The debugging enabled actually may be necessary to help identify issues on the site - this is what pointed me towards the right direction to resolve the PHP XML issue and lead me to submit this support ticket with you guys.
Thanks
-Brian
Hi Brain
Let me forward this to our Level 2 support to investigate further.
We appreciate your time and patience.
Hey Brian
This is not the default behavior of the plugin, and I'm sure you won't be able to replicate it on our sandbox site:
The warning you saw is being displayed if WP_DEBUG is enabled, but that is normal, since the formula that's used for AVG function does error out due to dividing the sum with the number of rows (which is 0). As long as the debugging mode is enabled, and the formula tries to divide by a zero, it will display that warning.
As Blazenka mentioned - having the debugging mode on at all times is not a good practice. It's OK to turn it on once in a while to see if there are any errors on the site, but WordPress already has this function built-in, so if there are any errors, you will receive an email about them.
I tried replicating your query structure on our sandbox, to include table.`column`, and the VAR1 placeholder, but no matter what I do, I get Avg=0.
On what front-end page is this table?
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables