// Find all tags that are related to the tags being moved and make sure they are present in the target tagcoll.
// This query is a little complicated because Oracle does not allow to run SELECT DISTINCT on CLOB fields.
- $sql = "SELECT name, rawname, description, descriptionformat, userid, isstandard, flag ".
+ $sql = "SELECT name, rawname, description, descriptionformat, userid, isstandard, flag, timemodified ".
"FROM {tag} WHERE id IN ".
"(SELECT r.id ".
"FROM {tag_instance} ti ". // Instances that need moving.
// Find all tags that are used for this itemtype/component and are not present in the target tag collection.
// This query is a little complicated because Oracle does not allow to run SELECT DISTINCT on CLOB fields.
- $sql = "SELECT id, name, rawname, description, descriptionformat, userid, isstandard, flag
+ $sql = "SELECT id, name, rawname, description, descriptionformat, userid, isstandard, flag, timemodified
FROM {tag} WHERE id IN
(SELECT t.id
FROM {tag_instance} ti
$tagarea = $DB->get_record('tag_area', array('itemtype' => 'user', 'component' => 'core'));
core_tag_area::update($tagarea, array('tagcollid' => $collid2));
+ $tagsaftermove = $DB->get_records('tag');
+ foreach ($tagsaftermove as $tag) {
+ // Confirm that the time modified has not been unset.
+ $this->assertNotEmpty($tag->timemodified);
+ }
+
$this->assertEquals(array('Tag4'),
$DB->get_fieldset_select('tag', 'rawname', 'tagcollid = ? ORDER BY name', array($collid1)));
$this->assertEquals(array('Tag1', 'Tag2', 'Tag3', 'Tag5'),
$tagareauser = $DB->get_record('tag_area', array('itemtype' => 'user', 'component' => 'core'));
core_tag_area::update($tagareauser, array('tagcollid' => $collid2));
+ $tagsaftermove = $DB->get_records('tag');
+ foreach ($tagsaftermove as $tag) {
+ // Confirm that the time modified has not been unset.
+ $this->assertNotEmpty($tag->timemodified);
+ }
+
$this->assertEquals(array('Tag1', 'Tag3', 'Tag4'),
$DB->get_fieldset_select('tag', 'rawname', 'tagcollid = ? ORDER BY name', array($collid1)));
$this->assertEquals(array('Tag1', 'Tag2', 'Tag3', 'Tag5'),
$tagareauser = $DB->get_record('tag_area', array('itemtype' => 'user', 'component' => 'core'));
core_tag_area::update($tagareauser, array('tagcollid' => $collid2));
+ $tagsaftermove = $DB->get_records('tag');
+ foreach ($tagsaftermove as $tag) {
+ // Confirm that the time modified has not been unset.
+ $this->assertNotEmpty($tag->timemodified);
+ }
+
$this->assertEquals(array('Tag4'),
$DB->get_fieldset_select('tag', 'rawname', 'tagcollid = ? ORDER BY name', array($collid1)));
$this->assertEquals(array('TAG1', 'Tag2', 'Tag3', 'Tag5'),
$tagarea = $DB->get_record('tag_area', array('itemtype' => 'user', 'component' => 'core'));
core_tag_area::update($tagarea, array('tagcollid' => $collid2));
+ $tagsaftermove = $DB->get_records('tag');
+ foreach ($tagsaftermove as $tag) {
+ // Confirm that the time modified has not been unset.
+ $this->assertNotEmpty($tag->timemodified);
+ }
+
$this->assertEquals(array('Tag1', 'Tag2', 'Tag4'),
$DB->get_fieldset_select('tag', 'rawname', 'tagcollid = ? ORDER BY name', array($collid1)));
$this->assertEquals(array('TAG1', 'Tag2', 'Tag3', 'Tag4', 'Tag5'),
$tagarea = $DB->get_record('tag_area', array('itemtype' => 'user', 'component' => 'core'));
core_tag_area::update($tagarea, array('tagcollid' => $collid2));
+ $tagsaftermove = $DB->get_records('tag');
+ foreach ($tagsaftermove as $tag) {
+ // Confirm that the time modified has not been unset.
+ $this->assertNotEmpty($tag->timemodified);
+ }
+
// Now all tags are correctly moved to the new collection and both tags 'Tag1' were merged.
$user1tags = array_values(core_tag_tag::get_item_tags('core', 'user', $user1->id));
$user2tags = array_values(core_tag_tag::get_item_tags('core', 'user', $user2->id));