Bug 1959733: Allowing old pages with broken layout update to gridstack
This is where the column value for a block is greater than the number
of columns for that row
Change-Id: Id1c321ca13abbb771767f7a3494db2612845ff9f
Signed-off-by: Robert Lyon <robertl@catalyst.net.nz>
log_debug('Fixing up pre-gridstack layouts that have incorrect column information');
$count=0;
$limit=100;
$total=count($results);
foreach($resultsas$r){
// Because we can't tell which column they meant to put the block we will
// place it in the last column of that row
execute_sql("
UPDATE {block_instance} bi SET bi.column = ?
WHERE bi.column > ? AND bi.row = ? AND bi.view = ?",
array($r->columns,$r->columns,$r->row,$r->view)
);
// Lets sort out any order problems
$blockcolumns=get_column_sql("SELECT DISTINCT bi.column FROM {block_instance} bi WHERE bi.view = ? AND bi.row = ?",array($r->view,$r->row));
foreach($blockcolumnsas$column){
$blocks=get_column_sql("SELECT bi.id FROM {block_instance} bi WHERE bi.view = ? AND bi.row = ? AND bi.column = ? ORDER BY bi.order",array($r->view,$r->row,$column));
foreach($blocksas$k=>$blockid){
execute_sql("UPDATE {block_instance} bi SET bi.order = ? WHERE bi.id = ?",array($k+1,$blockid));