MDL-38541 Restrict calling rebuild_course_cache() from upgrade process

only plugins upgrade scripts can call rebuild_course_cache() and for clearing cache only.