Commit 1beacab4 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix for profile view upgrade - was broken in mysql (bug 3194)

parent 2cecadae
......@@ -846,11 +846,20 @@ function xmldb_core_upgrade($oldversion=0) {
if ($oldversion < 2009022700) {
// Get rid of all blocks with position 0 caused by 'about me' block on profile views
if (count_records('block_instance', 'order', 0) && !count_records_select('block_instance', '"order" < 0')) {
execute_sql('UPDATE {block_instance} SET "order" = -1 * "order" WHERE id IN (
SELECT i.id FROM {block_instance} i
INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
ON (z.view = i.view AND z.column = i.column))'
);
if (is_mysql()) {
$ids = get_column_sql('
SELECT i.id FROM {block_instance} i
INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
ON (z.view = i.view AND z.column = i.column)'
);
execute_sql('UPDATE {block_instance} SET "order" = -1 * "order" WHERE id IN (' . join(',', $ids) . ')');
} else {
execute_sql('UPDATE {block_instance} SET "order" = -1 * "order" WHERE id IN (
SELECT i.id FROM {block_instance} i
INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
ON (z.view = i.view AND z.column = i.column))'
);
}
execute_sql('UPDATE {block_instance} SET "order" = 1 WHERE "order" = 0');
execute_sql('UPDATE {block_instance} SET "order" = -1 * ("order" - 1) WHERE "order" < 0');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment