Fixes: CORE-1964
This reverts commit 72d558f095
this restores the commit (aka, reverts that ^ revert) that was causing
us bugs on caturday. the root cause of the bug was that
["active_record_types", [], self].cache_key
and
["active_record_types", nil, self].cache_key
return the same string.
how to replay the buggy scenerio:
(as a student, in a course with annnouncements):
* right after having "touched" the course (so there's nothing cached),
* have one person go to /courses/:course_id/assignments/syllabus
* in the controller action for that, it will do:
`return unless tab_enabled?(@context.class::TAB_SYLLABUS)`
that will call Course::uncached_tabs_available(only_check: @context.class::TAB_SYLLABUS)
which would have called @course.active_record_types(only_check: [])
(because @context.class::TAB_SYLLABUS is not one of the `tabs_that_can_be_marked_hidden_unused`)
which woud have written `{}` to redis at ['active_record_types', [], self].cache_key
* now, as a different student, go to /courses/:course_id/annnouncements
it will call `tab_enabled?(@context.class::TAB_ANNOUNCEMENTS)`
that will call Course::uncached_tabs_available(only_check: @context.class::TAB_ANNOUNCEMENTS)
which will call @course.active_record_types(only_check: [:announcements])
it will do a cache read for ['active_record_types', [:announcements], self].cache_key
since it it a fresh cach, that will not be found
then it would have done a cache read for the "everything" cache at
['active_record_types', nil, self].cache_key
THAT WOULD HAVE RETURNED THE CACHED `{}` SINCE `nil.cache_key` and `[].cache_key` ARE THE SAME!
* the user would be told the announcement page is not enabled for that course
the fix is to explicitly not allow Context::active_record_types to ever
be called with `only_check: []`
and for good measure, we don't allow the implicit conversion of
nil.cache_key to "" and instead use "everything" for the cache cache_key
I added specs to spefically catch this bug so that it doesn't happen again.
To see the difference, compare the latest patchset of this commit against
patchset 1. patchset 1 is the original version of this code without this
fix.
Change-Id: I513104b90dd94227a04c151ee02a22f4a4ac2832
Reviewed-on: https://gerrit.instructure.com/167400
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Canvas is a modern, open-source LMS
developed and maintained by Instructure Inc. It is released under the
AGPLv3 license for use by anyone interested in learning more about or using
learning management systems.