Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-24355 Fixed up deletion of tag correlations when deleting tags

  • Loading branch information...
commit ef7383d32aa011df6818594aa68081076a4aaf08 1 parent 3aeb4f0
Sam Hemelryk samhemelryk authored

Showing 1 changed file with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. +8 5 tag/lib.php
13 tag/lib.php
@@ -495,14 +495,14 @@ function tag_delete($tagids) {
495 495 }
496 496
497 497 $success = true;
498   - foreach( $tagids as $tagid ) {
  498 + foreach ($tagids as $tagid) {
499 499 if (is_null($tagid)) { // can happen if tag doesn't exists
500 500 continue;
501 501 }
502 502 // only delete the main entry if there were no problems deleting all the
503 503 // instances - that (and the fact we won't often delete lots of tags)
504 504 // is the reason for not using delete_records_select()
505   - if ( delete_records('tag_instance', 'tagid', $tagid) ) {
  505 + if (delete_records('tag_instance', 'tagid', $tagid) && delete_records('tag_correlation', 'tagid', $tagid)) {
506 506 $success &= (bool) delete_records('tag', 'id', $tagid);
507 507 }
508 508 }
@@ -939,9 +939,12 @@ function tag_get_correlated($tag_id, $limitnum=null) {
939 939 }
940 940
941 941 // this is (and has to) return the same fields as the query in tag_get_tags
942   - if ( !$result = get_records_sql("SELECT tg.id, tg.tagtype, tg.name, tg.rawname, tg.flag, ti.ordering ".
943   - "FROM {$CFG->prefix}tag tg INNER JOIN {$CFG->prefix}tag_instance ti ON tg.id = ti.tagid ".
944   - "WHERE tg.id IN ({$tag_correlation->correlatedtags})") ) {
  942 + $sql = "SELECT tg.id, tg.tagtype, tg.name, tg.rawname, tg.flag, ti.ordering
  943 + FROM {$CFG->prefix}tag tg
  944 + INNER JOIN {$CFG->prefix}tag_instance ti ON tg.id = ti.tagid
  945 + WHERE tg.id IN ({$tag_correlation->correlatedtags})";
  946 + $result = get_records_sql($sql);
  947 + if (!$result) {
945 948 return array();
946 949 }
947 950

0 comments on commit ef7383d

Please sign in to comment.
Something went wrong with that request. Please try again.