Skip to content

Commit

Permalink
MDL-24888, wiki tags' itemtype should be wiki_pages, taglib will try …
Browse files Browse the repository at this point in the history
…to query table by itemtype in cron
  • Loading branch information
Dongsheng Cai committed Oct 28, 2010
1 parent 27bfb97 commit f0f77df
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mod/wiki/backup/moodle2/backup_wiki_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function define_structure() {
JOIN {tag_instance} ti ON ti.tagid = t.id
WHERE ti.itemtype = ?
AND ti.itemid = ?', array(
backup_helper::is_sqlparam('wiki_page'),
backup_helper::is_sqlparam('wiki_pages'),
backup::VAR_PARENTID));
}

Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/backup/moodle2/restore_wiki_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function process_wiki_tag($data) {

$tag = $data->rawname;
$itemid = $this->get_new_parentid('wiki_page');
tag_set_add('wiki_page', $itemid, $tag);
tag_set_add('wiki_pages', $itemid, $tag);
}

protected function after_execute() {
Expand Down
10 changes: 10 additions & 0 deletions mod/wiki/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,17 @@ function xmldb_wiki_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2010102500, 'wiki');
}

if ($oldversion < 2010102800) {

$sql = "UPDATE {tag_instance}
SET itemtype = 'wiki_pages'
WHERE itemtype = 'wiki_page'";
$DB->execute($sql);

echo $OUTPUT->notification('Updating tags itemtype', 'notifysuccess');

upgrade_mod_savepoint(true, 2010102800, 'wiki');
}

return true;
}
4 changes: 2 additions & 2 deletions mod/wiki/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ function wiki_reset_userdata($data) {
foreach ($subwikis as $subwiki) {
if ($pages = $DB->get_records('wiki_pages', array('subwikiid' => $subwiki->id))) {
foreach ($pages as $page) {
$tags = tag_get_tags_array('wiki_page', $page->id);
$tags = tag_get_tags_array('wiki_pages', $page->id);
foreach ($tags as $tagid => $tagname) {
// Delete the related tag_instances related to the wiki page.
$errors = tag_delete_instance('wiki_page', $page->id, $tagid);
$errors = tag_delete_instance('wiki_pages', $page->id, $tagid);
$status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'wiki'), 'error' => $errors);
}
}
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ function wiki_print_page_content($page, $context, $subwikiid) {
echo $OUTPUT->box($html);

if (!empty($CFG->usetags)) {
$tags = tag_get_tags_array('wiki_page', $page->id);
$tags = tag_get_tags_array('wiki_pages', $page->id);
echo '<p class="wiki-tags"><span>Tags: </span>' . join($tags, ", ") . '</p>';
}

Expand Down
4 changes: 2 additions & 2 deletions mod/wiki/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ protected function print_edit($content = null) {
}

if (!empty($CFG->usetags)) {
$params['tags'] = tag_get_tags_csv('wiki_page', $this->page->id, TAG_RETURN_TEXT);
$params['tags'] = tag_get_tags_csv('wiki_pages', $this->page->id, TAG_RETURN_TEXT);
}

$form = new mod_wiki_edit_form($url, $params);
Expand Down Expand Up @@ -1962,7 +1962,7 @@ protected function print_save() {
$errors = $this->process_uploads($context);
}
if (!empty($CFG->usetags)) {
tag_set('wiki_page', $this->page->id, $data->tags);
tag_set('wiki_pages', $this->page->id, $data->tags);
}

$message = '<p>' . get_string('saving', 'wiki') . '</p>';
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$module->version = 2010102500; // The current module version (Date: YYYYMMDDXX)
$module->version = 2010102800; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2010080300;
$module->cron = 0; // Period for cron to check this module (secs)

0 comments on commit f0f77df

Please sign in to comment.