WPClubManager / wp-club-manager

Create and manage a sports club or league website quickly and easily using WordPress.
https://wpclubmanager.com
Other
33 stars 13 forks source link

Update class-wpcm-meta-box-match-players.php #34

Closed DaveyJake closed 3 years ago

DaveyJake commented 3 years ago

When importing matches with roster information from an external JSON API, I found the wpcm_players meta value (for any wpcm_match post type) is automatically serialized.

When viewing the wp-admin side of any match, I'm seeing an issue where no players are appearing but the serialized data for that match is in the database.

The error log shows the following message:

PHP Warning: unserialize() expects parameter 1 to be string, array given in /wp-club-manager/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-players.php on line 287

This is because the imported data was only serialized once and not twice.

Using the WordPress function maybe_unserialize() instead of PHP's unserialize() resolves this issue as it will check the data prior to unserializing and will only unserialize if it absolutely needs to.

roofdog commented 3 years ago

I've merged that fix into the dev branch now.

Thanks for all your help Davey :)

DaveyJake commented 3 years ago

Glad to help anyway I can, mate!