Fatal error on Pods Admin list screen
-
Hey guys!
I’m hitting a fatal error that takes down the entire Pods admin list screen
(wp-admin/admin.php?page=pods) in Pods 3.3.8.Note: The crash occured with custom code and so i ran evaluation with Cladue Code because i couldn’t work around the bug without hard coding the pods plugin which is not idea.
ERROR:
PHP Fatal error: Uncaught TypeError: number_format(): Argument #1 ($num)
must be of type int|float, array given
in wp-includes/functions.php:428#0 wp-includes/functions.php(428): number_format()
#1 wp-content/plugins/pods/classes/PodsAdmin.php(1228): number_format_i18n()
#2 PodsAdmin->admin_setup()CAUSE (as far as I can tell):
In src/Pods/Whatsit.php, count_groups() looks like it has a copy/paste
omission compared to count_fields().count_fields() (correct) returns:
return count( $this->_fields );count_groups() (around line 1390) returns the array itself instead of its count:
if ( null !== $this->_groups && ! $has_custom_args ) { return $this->_groups; // returns the array, not count() }PodsAdmin::admin_setup() then passes that array straight into
number_format_i18n(), which fatals.REPRODUCTION:
It triggers on any pod that has one or more groups once _groups is populated
on the cached object. In my case a pod with a single group is enough to crash
the list screen.SUGGESTED FIX:
Mirror count_fields():
if ( null !== $this->_groups && ! $has_custom_args ) { return count( $this->_groups ); }I’ve confirmed locally that this one-line change resolves the crash and the
admin list renders correctly.ENVIRONMENT:
- Pods: 3.3.8
- WordPress: 6.9.4
- PHP: 8.3.6
- Multisite: yes
Thanks for the great plugin and I am happy to provide more detail if useful. ☺️😀
You must be logged in to reply to this topic.