Skip to content

[Bug] Syncing speakers from an Eventyay JSON:API URL empties the imported schedule #299

Description

@arpan7sarkar

Bug Description

Sync Speakers from Eventyay replaces an event's imported schedule with an empty table when the event's Eventyay API URL returns a JSON:API document, for example https://api.eventyay.com/v1/events/<slug>/sessions.
The sync still reports success ("Synced 2 speaker(s) from 2 Eventyay session(s).") and logs PHP Warning: Undefined array key "sessions".

Steps to Reproduce

  1. Open an Eventyay-linked event (one with an Eventyay slug) in the editor and click Sync Speakers from Eventyay in the Eventyay Speaker Sync box.
    With no saved API URL the sync uses the organizer REST speakers endpoint, and Event Schedule Sessions now lists the imported sessions.
  2. Set the event's saved Eventyay API URL to a JSON:API sessions URL, e.g. https://api.eventyay.com/v1/events/<slug>/sessions.
    The sync handler accepts it as eventyay_api_url, saves it for later syncs and appends include=speakers,track itself.
  3. Click Sync Speakers from Eventyay again and reload the editor.

Measured on main @ 5d08094 (WordPress 7.1, PHP 8.3), driving the editor with Playwright, with the Eventyay responses stubbed locally:

step 1, organizer REST speakers URL:  "Synced 2 speaker(s) from 2 Eventyay session(s)."
                                       Event Schedule Sessions: Opening keynote, Closing talk
step 3, JSON:API sessions URL:         "Synced 2 speaker(s) from 2 Eventyay session(s)."  schedule_rows: 0
                                       Event Schedule Sessions: (empty)
schedule-<event id>.json:              header row only, "sessions": []
debug.log:                             PHP Warning:  Undefined array key "sessions" in
                                       .../admin/class-wpfaevent-eventyay-ajax-sync.php on line 119

Expected Behavior

A sync only rewrites the schedule when the Eventyay response actually carries a session list.
A JSON:API response, for which the plugin builds no session list, leaves the imported schedule as it is, and no Undefined array key warning is raised.

Actual Behavior

The imported schedule is overwritten with a header-only table while the sync reports success.
Every later click keeps it empty, because the JSON:API URL stays saved for the event.

Screenshots

issue.webm

Additional Context

Root cause: Wpfaevent_JSONAPI_Parser::normalize_eventyay_payload() returns only speakers and session_count for a JSON:API document (includes/eventyay-importer/class-wpfaevent-jsonapi-parser.php:1699-1702).
REST responses are unaffected, because normalize_eventyay_rest_speakers_payload() always returns a sessions list.
Wpfaevent_Eventyay_Ajax_Sync::ajax_sync_eventyay() and ::sync_speakers_for_event() still pass $import['sessions'] to write_eventyay_schedule_table() unconditionally (admin/class-wpfaevent-eventyay-ajax-sync.php:119 and :1108).
The missing key arrives as null, line 1256 turns it into array(), and because the existing schedule's source is eventyay (line 1267) it is replaced.
Manually created schedules are not affected, since that same source check protects them.

sync_speakers_for_event(), used by the import flows, takes the JSON:API path when the import settings have no organizer slug, and loses the schedule the same way (reproduced separately).
The unconditional reads date back to #134 (75dac81).

Building schedule rows from JSON:API session resources would be a separate enhancement; that path has never written schedule rows.


Contribution Checklist

  • I have searched existing issues to ensure this bug hasn't been reported
  • I have provided clear reproduction steps
  • I have included relevant environment details
  • I have described both expected and actual behavior

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions