Open Metisek opened 1 month ago
Hi, thanks for your code. But when exactlt does this happen? You say "when trying to refresh calendars from WP-admin" - do you mean the "Update calendars" button on the Private Google Calendars settings page? When I click on this button, everything goes okay with the current implementation.
Yes, I mean when i click "Update calendars" while fetching multiple calendars with OAuth. I've tried now to do it using your current implementation - the same problem occurs. Every calendar I have checked in attached image below is a private one. The problem didn't occur when I had only 1 private calendar, which I found interesting. Error log is basically the same as the previous one I've sent.
I have looked into this by selecting only 2 private calendars on my site and then clicking the "Update calendars" button, and there it is working for me, so I'm not sure why you are experiencing this.
The pgc_sort_calendars
call receives the $items
parameter from the call to getCalendarList
which calls doRequest
from the PGC_GoogleClient_Request
class. This doRequest
calls json_decode
on the result it receives from the Google API (see https://developers.google.com/calendar/api/v3/reference/events/list) and this cannot return a string. So I really don't understand how pgc_sort_calendars
can receive a string in your case. All I can think of now is that another plugin interferes with this plugin, but I must admin that I don't know how.
It's not that I don't want to add your code to fix this, but I really want to first understand what is happening.
I understand that this doesn't happen when selecting just 1 private calendar. Does this also not happen when selecting 2 private calendars and also 1 or more public calendars?
The current implementation of calendar list sorting and update has been enhanced to handle cases where the input $items may be provided as either a JSON string or a delimited string, which happens in when trying to refresh calendars from WP-admin. Debug log shows this traceback:
The following code has been adjusted to to this issue and this implementation works on my WP site: