UniversityRadioYork / MyRadio

University Radio York's back-end radio management system
https://ury.org.uk/myradio
16 stars 16 forks source link

Ensure season_num is set properly on allocation #1072

Open markspolakovs opened 2 years ago

markspolakovs commented 2 years ago

We've had a few reports of two seasons on the same show both showing up as "season 1", which goes away once the cache is bopped. Here's my hunch as to what's happening:

  1. when MyRadio_Season::getInstance is called, before allocate() is called, it computes season_num through SQL:
    (
    SELECT COUNT(*) FROM schedule.show_season
    WHERE show_id=(SELECT show_id FROM schedule.show_season WHERE show_season_id=$1)
    AND show_season_id<=$1
    AND show_season_id IN (SELECT show_season_id FROM schedule.show_season_timeslot)
    ) AS season_num

    At this point, the unallocated season has a season_num of the last allocated one.

  2. MyRadio_Season->allocate() is called, which schedules timeslots, _but does not update season_num_
  3. The object is written back to the cache, with the incorrect season_num.

The fix is likely to re-compute season_num in allocate().

For #1054.