Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate MyRadio_Season::$timeslots caching when a timeslot is cancelled #1122

Open
markspolakovs opened this issue Jul 12, 2023 · 0 comments

Comments

@markspolakovs
Copy link
Member

This is purely hypothetical, but is the only explanation I can come up with for the phenomenon in this slack thread.

When a timeslot is cancelled, we delete the row and update the local cache:

private function deleteTimeslot()
{
$r = self::$db->query(
'DELETE FROM schedule.show_season_timeslot WHERE show_season_timeslot_id=$1',
[$this->getID()]
);
$this->updateCacheObject();
return $r;
}

However, MyRadio_Season has a local $timeslots field, which is populated at construction-time:

$this->timeslots = json_decode($result['timeslots']);

As far as I can tell, the cache for the season object doesn't get wiped when a timeslot gets deleted, which I suspect could trigger an exception like this:

Message: The MyRadio_Timeslot with instance ID #151553 does not exist.
Location:/usr/local/www/myradio/src/Classes/ServiceAPI/MyRadio_Timeslot.php:112
Trace:
#0 /usr/local/www/myradio/src/Classes/ServiceAPI/ServiceAPI.php(94): MyRadio\ServiceAPI\MyRadio_Timeslot->__construct('151553')
#1 /usr/local/www/myradio/src/Classes/ServiceAPI/ServiceAPI.php(85): MyRadio\ServiceAPI\ServiceAPI::factory('151553')
#2 /usr/local/www/myradio/src/Classes/ServiceAPI/ServiceAPI.php(141): MyRadio\ServiceAPI\ServiceAPI::getInstance('151553')
#3 /usr/local/www/myradio/src/Classes/ServiceAPI/MyRadio_Season.php(1218): MyRadio\ServiceAPI\ServiceAPI::resultSetToObjArray(Array)
#4 /usr/local/www/myradio/src/Controllers/MyRadio/timeslot.php(91): MyRadio\ServiceAPI\MyRadio_Season->getAllTimeslots()
#5 /usr/local/www/myradio/src/Controllers/root_web.php(105): require('/usr/local/www/...')
#6 /usr/local/www/myradio/src/Public/index.php(17): require('/usr/local/www/...')
#7 {main}

foreach ($shows as $show) {
foreach ($show->getAllSeasons() as $season) {
$data[$show->getMeta('title')][] = array_map(
function ($x) {
return [$x->getID(), $x->getStartTime(), $x->getEndTime()];
},
$season->getAllTimeslots()
);
}
}

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

No branches or pull requests

1 participant