Merge branch 'MDL-69687-m39' of https://github.com/sammarshallou/moodle into MOODLE_39_STABLE

This commit is contained in:
Andrew Nicols 2020-10-20 08:02:46 +08:00
commit 565bc965b1
4 changed files with 15 additions and 3 deletions

View file

@ -2589,5 +2589,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2020061501.11); upgrade_main_savepoint(true, 2020061501.11);
} }
if ($oldversion < 2020061502.09) {
// Delete orphaned course_modules_completion rows; these were not deleted properly
// by remove_course_contents function.
$DB->delete_records_subquery('course_modules_completion', 'id', 'id',
"SELECT cmc.id
FROM {course_modules_completion} cmc
LEFT JOIN {course_modules} cm ON cm.id = cmc.coursemoduleid
WHERE cm.id IS NULL");
upgrade_main_savepoint(true, 2020061502.09);
}
return true; return true;
} }

View file

@ -2007,7 +2007,7 @@ abstract class moodle_database {
* @param string $subquery Subquery that will return values of the field to delete * @param string $subquery Subquery that will return values of the field to delete
* @param array $params Parameters for subquery * @param array $params Parameters for subquery
* @throws dml_exception If there is any error * @throws dml_exception If there is any error
* @since Moodle 3.10 * @since Moodle 3.9.3
*/ */
public function delete_records_subquery(string $table, string $field, string $alias, public function delete_records_subquery(string $table, string $field, string $alias,
string $subquery, array $params = []): void { string $subquery, array $params = []): void {

View file

@ -5293,6 +5293,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
if ($cm->id) { if ($cm->id) {
// Delete cm and its context - orphaned contexts are purged in cron in case of any race condition. // Delete cm and its context - orphaned contexts are purged in cron in case of any race condition.
context_helper::delete_instance(CONTEXT_MODULE, $cm->id); context_helper::delete_instance(CONTEXT_MODULE, $cm->id);
$DB->delete_records('course_modules_completion', ['coursemoduleid' => $cm->id]);
$DB->delete_records('course_modules', array('id' => $cm->id)); $DB->delete_records('course_modules', array('id' => $cm->id));
rebuild_course_cache($cm->course, true); rebuild_course_cache($cm->course, true);
} }

View file

@ -12,7 +12,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public Licensáe
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$version = 2020061502.08; // 20200615 = branching date YYYYMMDD - do not modify! $version = 2020061502.09; // 20200615 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches. // RR = release increments - 00 in DEV branches.
// .XX = incremental changes. // .XX = incremental changes.
$release = '3.9.2+ (Build: 20201016)'; // Human-friendly version name $release = '3.9.2+ (Build: 20201016)'; // Human-friendly version name