public static function update($existing, $data) {
        global $DB;
        $data = array_intersect_key((array)$data,
                array('enabled' => 1, 'tagcollid' => 1,
                    'callback' => 1, 'callbackfile' => 1, 'showstandard' => 1,
                    'multiplecontexts' => 1));
        foreach ($data as $key => $value) {
            if ($existing->$key == $value) {
                unset($data[$key]);
            }
        }
        if (!$data) {
            return;
        }

        if (!empty($data['tagcollid'])) {
            self::move_tags($existing->component, $existing->itemtype, $data['tagcollid']);
        }

        $data['id'] = $existing->id;
        $DB->update_record('tag_area', $data);

        // Reset cache.
        cache::make('core', 'tags')->delete('tag_area');
    }