Recover native MyISAM board publication without duplicate forums or groups
This commit is contained in:
parent
27bd778977
commit
bf6066335a
5 changed files with 127 additions and 85 deletions
|
|
@ -31,3 +31,5 @@ The existing `staff-parent-link` key carries a board-only overwrite scope, exact
|
|||
Isolated integration fixtures exercise real deed resolution, current key verification, lifecycle revisions, leased delivery, acknowledgement loss, source updates, native group drift, revoked/private access, temporary control and a Council without a chair. Native PHP tests validate exact payload fingerprints, revision ordering and permission-matrix coverage. With 10 existing private boards and 20 groups, updating one board touches 20 permission pairs; adding two groups additionally touches the other 9 boards, giving 38 unique pairs. This is a measured fixture work count, not a production latency claim.
|
||||
|
||||
Publication must separately record green CI, actual live source hashes, existing native mappings/content counts, native privacy checks, actual BRD receipts and comparable timing observations. Do not mark the ticket closed from catalogue entries or fixture results. Rollback disables delivery/restores reviewed native helpers while retaining keys, registry mappings and content. Never delete histories to roll back.
|
||||
|
||||
Native inventory confirmed that MyBB forums, groups, moderators and permissions use MyISAM while the mapping registry uses InnoDB. Publication therefore relies on the native advisory lock and durable per-object bindings, not a false cross-engine rollback promise. New forum/group rows contain internal HTML-comment identity markers inserted atomically with the row. An interrupted delivery adopts that exact native row before retrying its registry update; it never adopts by display name. Ambiguous markers or unexpected native privileges require review. Focused interruption tests retain the original forum/group IDs after simulated process loss.
|
||||
|
|
|
|||
|
|
@ -25,94 +25,93 @@ function dune_missing_system_boards(array $projection, array $boards): array {
|
|||
|
||||
function dune_provision_system_boards(array $input,?callable $prepare=null,?callable $review=null,?callable $beforeCommit=null): array {
|
||||
global $db,$cache,$dune_board_template;
|
||||
if (!is_array($input) || !isset($input['organisations']) || !is_array($input['organisations'])) throw new RuntimeException('Organisation snapshot required');
|
||||
foreach ($input['organisations'] as $org) {
|
||||
if (!is_array($input) || !isset($input['organisations']) || !is_array($input['organisations'])) throw new RuntimeException('Organisation snapshot required');
|
||||
foreach ($input['organisations'] as $org) {
|
||||
if (!in_array($org['kind'] ?? '', ['clan','company','politics'], true) || !preg_match('/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i', $org['id'] ?? '') || !is_string($org['name'] ?? null) || trim($org['name']) === '' || my_strlen($org['name']) > 120) throw new RuntimeException('Invalid organisation');
|
||||
}
|
||||
$lock = $db->fetch_array($db->write_query("SELECT GET_LOCK('dune_system_boards_provision',10) acquired"));
|
||||
if ((int)($lock['acquired'] ?? 0) !== 1) throw new RuntimeException('System Boards publication is busy');
|
||||
try {
|
||||
$db->write_query('CREATE TABLE IF NOT EXISTS '.TABLE_PREFIX.'dune_system_boards (kind VARCHAR(12) NOT NULL, organisation_id VARCHAR(36) NOT NULL, fid INT NOT NULL, member_gid INT NOT NULL DEFAULT 0, leader_gid INT NOT NULL DEFAULT 0, PRIMARY KEY(kind,organisation_id), UNIQUE KEY forum_id(fid)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
|
||||
}
|
||||
$lock = $db->fetch_array($db->write_query("SELECT GET_LOCK('dune_system_boards_provision',10) acquired"));
|
||||
if ((int)($lock['acquired'] ?? 0) !== 1) throw new RuntimeException('System Boards publication is busy');
|
||||
try {
|
||||
$db->write_query('CREATE TABLE IF NOT EXISTS '.TABLE_PREFIX.'dune_system_boards (kind VARCHAR(12) NOT NULL, organisation_id VARCHAR(36) NOT NULL, fid INT NOT NULL, member_gid INT NOT NULL DEFAULT 0, leader_gid INT NOT NULL DEFAULT 0, PRIMARY KEY(kind,organisation_id), UNIQUE KEY forum_id(fid)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
|
||||
if($prepare)$prepare();
|
||||
$db->write_query('START TRANSACTION');
|
||||
// MyBB core tables may be MyISAM. Keep registry bindings durable under
|
||||
// this advisory lock; per-object markers recover an interrupted insert.
|
||||
// A SQL rollback cannot undo native MyISAM rows.
|
||||
|
||||
if($review)$review($input);
|
||||
if($review&&!$input['organisations']){$db->write_query('COMMIT');return ['status'=>'unchanged','organisations'=>0,'rootForum'=>null];}
|
||||
if($review&&!$input['organisations']){return ['status'=>'unchanged','organisations'=>0,'rootForum'=>null];}
|
||||
$groups = []; $affected=[]; $added=[]; $activate=[]; $query = $db->simple_select('usergroups');
|
||||
while ($row = $db->fetch_array($query)) $groups[(int)$row['gid']] = $row;
|
||||
if (!isset($groups[2])) throw new RuntimeException('Registered group unavailable');
|
||||
$dune_board_template = $db->fetch_array($db->simple_select('forums', '*', "type='f'", ['limit'=>1]));
|
||||
if (!$dune_board_template) throw new RuntimeException('Native forum template unavailable');
|
||||
$permissionColumns = ['canview','canviewthreads','canonlyviewownthreads','candlattachments','canpostthreads','canpostreplys','canonlyreplyownthreads','canpostattachments','canratethreads','caneditposts','candeleteposts','candeletethreads','caneditattachments','canviewdeletionnotice','modposts','modthreads','mod_edit_posts','modattachments','canpostpolls','canvotepolls','cansearch'];
|
||||
$root = dune_provision_make_board('system','root','System Boards',0);
|
||||
$clans = dune_provision_make_board('system','clans','Clan Boards',(int)$root['fid']);
|
||||
$companies = dune_provision_make_board('system','companies','Company Boards',(int)$root['fid']);
|
||||
while ($row = $db->fetch_array($query)) $groups[(int)$row['gid']] = $row;
|
||||
if (!isset($groups[2])) throw new RuntimeException('Registered group unavailable');
|
||||
$dune_board_template = $db->fetch_array($db->simple_select('forums', '*', "type='f'", ['limit'=>1]));
|
||||
if (!$dune_board_template) throw new RuntimeException('Native forum template unavailable');
|
||||
$permissionColumns = ['canview','canviewthreads','canonlyviewownthreads','candlattachments','canpostthreads','canpostreplys','canonlyreplyownthreads','canpostattachments','canratethreads','caneditposts','candeleteposts','candeletethreads','caneditattachments','canviewdeletionnotice','modposts','modthreads','mod_edit_posts','modattachments','canpostpolls','canvotepolls','cansearch'];
|
||||
$root = dune_provision_make_board('system','root','System Boards',0);
|
||||
$clans = dune_provision_make_board('system','clans','Clan Boards',(int)$root['fid']);
|
||||
$companies = dune_provision_make_board('system','companies','Company Boards',(int)$root['fid']);
|
||||
$elections=dune_provision_make_board('system','elections','Election Board',(int)$root['fid'],'f');
|
||||
foreach([$root,$clans,$companies,$elections]as $system)$activate[(int)$system['fid']]=true;
|
||||
$categories=['clan'=>$clans,'company'=>$companies];
|
||||
if(array_filter($input['organisations'],fn($org)=>$org['kind']==='politics')){$categories['politics']=dune_provision_make_board('system','politics','Political Boards',(int)$root['fid']);$activate[(int)$categories['politics']['fid']]=true;}
|
||||
foreach ($input['organisations'] as $org) {
|
||||
foreach ($input['organisations'] as $org) {
|
||||
$board = dune_provision_make_board($org['kind'], $org['id'], $org['name'], (int)$categories[$org['kind']]['fid'], 'f');
|
||||
$affected[(int)$board['fid']]=true;$activate[(int)$board['fid']]=true;
|
||||
foreach (['member_gid','leader_gid'] as $field) {
|
||||
$role=$field==='leader_gid'?'leaders':'members';
|
||||
foreach (['member_gid','leader_gid'] as $field) {
|
||||
$role=$field==='leader_gid'?'leaders':'members';
|
||||
$title=my_substr((['clan'=>'Clan','company'=>'Company','politics'=>'Office'])[$org['kind']].' '.$role.' · '.$org['name'],0,45);
|
||||
if ((int)$board[$field] > 0) {
|
||||
$db->update_query('usergroups',['title'=>$db->escape_string($title)],'gid='.(int)$board[$field]);
|
||||
continue;
|
||||
}
|
||||
$group = $groups[2]; unset($group['gid']);
|
||||
$group['title'] = $title;
|
||||
$group['cancp'] = 0; $group['issupermod'] = 0; $group['canmodcp'] = $field==='leader_gid' ? 1 : 0;
|
||||
foreach ($group as $key=>$value) if (is_string($value)) $group[$key]=$db->escape_string($value);
|
||||
$gid = (int)$db->insert_query('usergroups', $group);
|
||||
$board[$field] = $gid; $groups[$gid] = $group; $added[$gid]=true;
|
||||
$db->update_query('dune_system_boards', [$field=>$gid], 'fid='.(int)$board['fid']);
|
||||
}
|
||||
$moderator = ['fid'=>(int)$board['fid'], 'id'=>(int)$board['leader_gid'], 'isgroup'=>1,
|
||||
'caneditposts'=>1,'cansoftdeleteposts'=>1,'canrestoreposts'=>1,'cansoftdeletethreads'=>1,'canrestorethreads'=>1,
|
||||
'canopenclosethreads'=>1,'canstickunstickthreads'=>1,'canapproveunapprovethreads'=>1,'canapproveunapproveposts'=>1,
|
||||
'canapproveunapproveattachs'=>1,'canmanagethreads'=>1,'canmanagepolls'=>1,'canpostclosedthreads'=>1,'canmanagereportedposts'=>1,'canviewmodlog'=>1];
|
||||
$db->delete_query('moderators', 'fid='.(int)$board['fid'].' AND id='.(int)$board['leader_gid'].' AND isgroup=1');
|
||||
$db->insert_query('moderators', $moderator);
|
||||
// Existing native Moderators retain moderation on every new board;
|
||||
// Super Moderators and Administrators already have native global power.
|
||||
$moderator['id']=6;
|
||||
$db->delete_query('moderators', 'fid='.(int)$board['fid'].' AND id=6 AND isgroup=1');
|
||||
$db->insert_query('moderators', $moderator);
|
||||
}
|
||||
if ((int)$board[$field] > 0) {
|
||||
$db->update_query('usergroups',['title'=>$db->escape_string($title)],'gid='.(int)$board[$field]);
|
||||
continue;
|
||||
}
|
||||
[$gid,$group,$created]=dune_provision_board_group($org,$field,$title,$groups[2]);
|
||||
$board[$field]=$gid;$groups[$gid]=$group;if($created)$added[$gid]=true;
|
||||
$db->update_query('dune_system_boards', [$field=>$gid], 'fid='.(int)$board['fid']);
|
||||
}
|
||||
$moderator = ['fid'=>(int)$board['fid'], 'id'=>(int)$board['leader_gid'], 'isgroup'=>1,
|
||||
'caneditposts'=>1,'cansoftdeleteposts'=>1,'canrestoreposts'=>1,'cansoftdeletethreads'=>1,'canrestorethreads'=>1,
|
||||
'canopenclosethreads'=>1,'canstickunstickthreads'=>1,'canapproveunapprovethreads'=>1,'canapproveunapproveposts'=>1,
|
||||
'canapproveunapproveattachs'=>1,'canmanagethreads'=>1,'canmanagepolls'=>1,'canpostclosedthreads'=>1,'canmanagereportedposts'=>1,'canviewmodlog'=>1];
|
||||
$db->delete_query('moderators', 'fid='.(int)$board['fid'].' AND id='.(int)$board['leader_gid'].' AND isgroup=1');
|
||||
$db->insert_query('moderators', $moderator);
|
||||
// Existing native Moderators retain moderation on every new board;
|
||||
// Super Moderators and Administrators already have native global power.
|
||||
$moderator['id']=6;
|
||||
$db->delete_query('moderators', 'fid='.(int)$board['fid'].' AND id=6 AND isgroup=1');
|
||||
$db->insert_query('moderators', $moderator);
|
||||
}
|
||||
// All affected boards are complete after every new group is known. New
|
||||
// groups are denied on unrelated private boards, without rewriting the
|
||||
// entire existing board-by-group matrix for every small change.
|
||||
$query = $db->simple_select('dune_system_boards', '*', "kind IN ('clan','company','politics')");
|
||||
$boards=[];while($board=$db->fetch_array($query))$boards[]=$board;
|
||||
foreach(dune_board_permission_targets($boards,$groups,$affected,$added)as [$board,$gid]){
|
||||
$member = in_array($gid, [(int)$board['member_gid'],(int)$board['leader_gid'],3,4,6], true);
|
||||
dune_provision_save_permissions((int)$board['fid'], (int)$gid, dune_board_private_permissions($permissionColumns, $member));
|
||||
}
|
||||
// No guest feed may publish System Boards topics.
|
||||
dune_provision_save_permissions((int)$root['fid'], 1, dune_board_private_permissions($permissionColumns, false));
|
||||
$member = in_array($gid, [(int)$board['member_gid'],(int)$board['leader_gid'],3,4,6], true);
|
||||
dune_provision_save_permissions((int)$board['fid'], (int)$gid, dune_board_private_permissions($permissionColumns, $member));
|
||||
}
|
||||
// No guest feed may publish System Boards topics.
|
||||
dune_provision_save_permissions((int)$root['fid'], 1, dune_board_private_permissions($permissionColumns, false));
|
||||
foreach($activate as $fid=>$unused)$db->update_query('forums', ['active'=>1], 'fid='.(int)$fid);
|
||||
if($beforeCommit)$beforeCommit($groups);
|
||||
$db->write_query('COMMIT');
|
||||
foreach (['usergroups','forums','forumpermissions','moderators'] as $key) { $method='update_'.$key; $cache->$method(); }
|
||||
return ['status'=>'provisioned', 'organisations'=>count($input['organisations']), 'rootForum'=>(int)$root['fid']];
|
||||
} catch (Throwable $error) {
|
||||
$db->write_query('ROLLBACK');
|
||||
throw $error;
|
||||
} finally {
|
||||
$db->write_query("SELECT RELEASE_LOCK('dune_system_boards_provision')");
|
||||
}
|
||||
|
||||
$db->write_query('COMMIT');
|
||||
foreach (['usergroups','forums','forumpermissions','moderators'] as $key) { $method='update_'.$key; $cache->$method(); }
|
||||
return ['status'=>'provisioned', 'organisations'=>count($input['organisations']), 'rootForum'=>(int)$root['fid']];
|
||||
} catch (Throwable $error) {
|
||||
$db->write_query('ROLLBACK');
|
||||
throw $error;
|
||||
} finally {
|
||||
$db->write_query("SELECT RELEASE_LOCK('dune_system_boards_provision')");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function dune_provision_board_row($kind, $id) {
|
||||
global $db;
|
||||
return $db->fetch_array($db->simple_select('dune_system_boards', '*', "kind='".$db->escape_string($kind)."' AND organisation_id='".$db->escape_string($id)."'"));
|
||||
}
|
||||
function dune_provision_board_row($kind, $id) {
|
||||
global $db;
|
||||
return $db->fetch_array($db->simple_select('dune_system_boards', '*', "kind='".$db->escape_string($kind)."' AND organisation_id='".$db->escape_string($id)."'"));
|
||||
}
|
||||
|
||||
function dune_provision_make_board($kind, $id, $name, $parent, $type = 'c') {
|
||||
global $db, $dune_board_template;
|
||||
function dune_provision_make_board($kind, $id, $name, $parent, $type = 'c') {
|
||||
global $db, $dune_board_template;
|
||||
if ($existing = dune_provision_board_row($kind, $id)) {
|
||||
$title=htmlspecialchars($name,ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8');
|
||||
$forum=$db->fetch_array($db->simple_select('forums','name','fid='.(int)$existing['fid']));
|
||||
|
|
@ -120,23 +119,45 @@ try {
|
|||
if($forum['name']!==$title)$db->update_query('forums',['name'=>$db->escape_string($title)],'fid='.(int)$existing['fid']);
|
||||
return $existing;
|
||||
}
|
||||
$row = $dune_board_template; unset($row['fid']);
|
||||
foreach (['threads','posts','lastpost','lastposteruid','unapprovedthreads','unapprovedposts','deletedthreads','deletedposts'] as $key) if (array_key_exists($key, $row)) $row[$key] = 0;
|
||||
foreach (['lastposter','lastpostsubject','linkto','password','rules','rulestitle'] as $key) if (array_key_exists($key, $row)) $row[$key] = '';
|
||||
$row = array_merge($row, ['name'=>htmlspecialchars($name, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'), 'description'=>'', 'type'=>$type, 'pid'=>$parent, 'parentlist'=>'', 'disporder'=>1000, 'active'=>0, 'open'=>1, 'allowhtml'=>0, 'allowmycode'=>1, 'allowsmilies'=>1, 'allowimgcode'=>1, 'showinjump'=>1]);
|
||||
foreach ($row as $key=>$value) if (is_string($value)) $row[$key]=$db->escape_string($value);
|
||||
$fid = (int)$db->insert_query('forums', $row);
|
||||
$parentRow = $parent ? $db->fetch_array($db->simple_select('forums','parentlist','fid='.$parent)) : null;
|
||||
$parentlist = ($parentRow ? $parentRow['parentlist'].',' : '').$fid;
|
||||
$db->update_query('forums', ['parentlist'=>$db->escape_string($parentlist)], 'fid='.$fid);
|
||||
$db->insert_query('dune_system_boards', ['kind'=>$db->escape_string($kind), 'organisation_id'=>$db->escape_string($id), 'fid'=>$fid]);
|
||||
return dune_provision_board_row($kind, $id);
|
||||
}
|
||||
$marker='<!-- dune-board:v1:'.$kind.':'.$id.' -->';
|
||||
$matches=[];$query=$db->simple_select('forums','*',"description='".$db->escape_string($marker)."'",['limit'=>2]);while($match=$db->fetch_array($query))$matches[]=$match;
|
||||
if(count($matches)>1)throw new RuntimeException('Interrupted board mapping is ambiguous');
|
||||
if($matches){
|
||||
$recovered=$matches[0];if((int)$recovered['pid']!==$parent||$recovered['type']!==$type)throw new RuntimeException('Interrupted board parent requires review');
|
||||
$parentRow=$parent?$db->fetch_array($db->simple_select('forums','parentlist','fid='.$parent)):null;
|
||||
$db->update_query('forums',['parentlist'=>$db->escape_string(($parentRow?$parentRow['parentlist'].',':'').$recovered['fid'])],'fid='.(int)$recovered['fid']);
|
||||
$db->insert_query('dune_system_boards',['kind'=>$db->escape_string($kind),'organisation_id'=>$db->escape_string($id),'fid'=>(int)$recovered['fid']]);
|
||||
return dune_provision_board_row($kind,$id);
|
||||
}
|
||||
$row = $dune_board_template; unset($row['fid']);
|
||||
foreach (['threads','posts','lastpost','lastposteruid','unapprovedthreads','unapprovedposts','deletedthreads','deletedposts'] as $key) if (array_key_exists($key, $row)) $row[$key] = 0;
|
||||
foreach (['lastposter','lastpostsubject','linkto','password','rules','rulestitle'] as $key) if (array_key_exists($key, $row)) $row[$key] = '';
|
||||
$row = array_merge($row, ['name'=>htmlspecialchars($name, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'), 'description'=>$marker, 'type'=>$type, 'pid'=>$parent, 'parentlist'=>'', 'disporder'=>1000, 'active'=>0, 'open'=>1, 'allowhtml'=>0, 'allowmycode'=>1, 'allowsmilies'=>1, 'allowimgcode'=>1, 'showinjump'=>1]);
|
||||
foreach ($row as $key=>$value) if (is_string($value)) $row[$key]=$db->escape_string($value);
|
||||
$fid = (int)$db->insert_query('forums', $row);
|
||||
$parentRow = $parent ? $db->fetch_array($db->simple_select('forums','parentlist','fid='.$parent)) : null;
|
||||
$parentlist = ($parentRow ? $parentRow['parentlist'].',' : '').$fid;
|
||||
$db->update_query('forums', ['parentlist'=>$db->escape_string($parentlist)], 'fid='.$fid);
|
||||
$db->insert_query('dune_system_boards', ['kind'=>$db->escape_string($kind), 'organisation_id'=>$db->escape_string($id), 'fid'=>$fid]);
|
||||
return dune_provision_board_row($kind, $id);
|
||||
}
|
||||
|
||||
function dune_provision_save_permissions(int $fid, int $gid, array $permissions): void {
|
||||
global $db;
|
||||
$where = 'fid='.$fid.' AND gid='.$gid;
|
||||
$existing = $db->fetch_array($db->simple_select('forumpermissions', 'pid', $where));
|
||||
if ($existing) $db->update_query('forumpermissions', $permissions, $where);
|
||||
else $db->insert_query('forumpermissions', array_merge($permissions, ['fid'=>$fid,'gid'=>$gid]));
|
||||
}
|
||||
function dune_provision_save_permissions(int $fid, int $gid, array $permissions): void {
|
||||
global $db;
|
||||
$where = 'fid='.$fid.' AND gid='.$gid;
|
||||
$existing = $db->fetch_array($db->simple_select('forumpermissions', 'pid', $where));
|
||||
if ($existing) $db->update_query('forumpermissions', $permissions, $where);
|
||||
else $db->insert_query('forumpermissions', array_merge($permissions, ['fid'=>$fid,'gid'=>$gid]));
|
||||
}
|
||||
|
||||
// A native group and its marker are one atomic MyISAM row. If the following
|
||||
// registry update was interrupted, the next delivery adopts that exact row.
|
||||
function dune_provision_board_group(array $org,string $field,string $title,array $template): array {
|
||||
global $db;$marker='<!-- dune-board-group:v1:'.$org['kind'].':'.$org['id'].':'.$field.' -->';
|
||||
$matches=[];$query=$db->simple_select('usergroups','*',"description='".$db->escape_string($marker)."'",['limit'=>2]);while($row=$db->fetch_array($query))$matches[]=$row;
|
||||
if(count($matches)>1)throw new RuntimeException('Interrupted board group is ambiguous');
|
||||
if($matches){$row=$matches[0];if(!empty($row['cancp'])||!empty($row['issupermod']))throw new RuntimeException('Interrupted board group privileges require review');$db->update_query('usergroups',['title'=>$db->escape_string($title)],'gid='.(int)$row['gid']);return [(int)$row['gid'],$row,true];}
|
||||
$group=$template;unset($group['gid']);$group['title']=$title;$group['description']=$marker;$group['cancp']=0;$group['issupermod']=0;$group['canmodcp']=$field==='leader_gid'?1:0;
|
||||
foreach($group as $key=>$value)if(is_string($value))$group[$key]=$db->escape_string($value);
|
||||
$gid=(int)$db->insert_query('usergroups',$group);return [$gid,$group,true];
|
||||
}
|
||||
|
|
|
|||
18
website/integrations/mybb/test-board-key-recovery.php
Normal file
18
website/integrations/mybb/test-board-key-recovery.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
define('IN_MYBB',1);
|
||||
function my_strlen($s){return strlen($s);}function my_substr($s,$start,$length){return substr($s,$start,$length);}
|
||||
require __DIR__.'/system-board-provision.php';
|
||||
final class RecoveryRows{public function __construct(public array $rows){}}
|
||||
final class RecoveryDB{
|
||||
public array $forums=[1=>['fid'=>1,'pid'=>0,'type'=>'c','parentlist'=>'1','name'=>'Root','description'=>'']];public array $registry=[],$groups=[];public bool $interrupt=true;
|
||||
function escape_string($s){return addslashes($s);}
|
||||
function fetch_array($q){return array_shift($q->rows);}
|
||||
function simple_select($table,$fields='*',$where='', $options=[]){$rows=$table==='forums'?$this->forums:($table==='usergroups'?$this->groups:$this->registry);return new RecoveryRows(array_values(array_filter($rows,function($r)use($where){foreach(['kind','organisation_id','description']as $k)if(preg_match("/".$k."='([^']*)'/",$where,$m)&&($r[$k]??null)!==stripslashes($m[1]))return false;if(preg_match('/fid=(\d+)/',$where,$m)&&(int)$r['fid']!==(int)$m[1])return false;return true;})));}
|
||||
function insert_query($table,$row){if($table==='dune_system_boards'){if($this->interrupt){$this->interrupt=false;throw new RuntimeException('Interrupted after native forum commit');}$row+=['member_gid'=>0,'leader_gid'=>0];$this->registry[]=$row;return 1;}if($table==='forums'){$id=count($this->forums)+1;$row['fid']=$id;$this->forums[$id]=$row;return $id;}if($table==='usergroups'){$id=count($this->groups)+14;$row['gid']=$id;$this->groups[$id]=$row;return $id;}throw new RuntimeException('Unexpected insert');}
|
||||
function update_query($table,$values,$where){if($table==='forums'&&preg_match('/fid=(\d+)/',$where,$m))$this->forums[(int)$m[1]]=array_merge($this->forums[(int)$m[1]],$values);}
|
||||
}
|
||||
$db=new RecoveryDB();$dune_board_template=$db->forums[1];$id='11111111-1111-4111-8111-111111111111';
|
||||
try{dune_provision_make_board('clan',$id,'Clan',1,'f');throw new RuntimeException('Interruption did not occur');}catch(RuntimeException $e){if($e->getMessage()!=='Interrupted after native forum commit')throw $e;}
|
||||
$board=dune_provision_make_board('clan',$id,'Clan',1,'f');if((int)$board['fid']!==2||count($db->forums)!==2||count($db->registry)!==1)throw new RuntimeException('Interrupted forum was duplicated');
|
||||
$org=['kind'=>'clan','id'=>$id];[$gid]=dune_provision_board_group($org,'member_gid','Members',['gid'=>2,'cancp'=>0,'issupermod'=>0]);[$again]=dune_provision_board_group($org,'member_gid','Renamed members',['gid'=>2]);if($gid!==$again||count($db->groups)!==1)throw new RuntimeException('Interrupted native group was duplicated');
|
||||
echo "MyISAM interruption preserves forum/group identity without a false rollback guarantee\n";
|
||||
|
|
@ -31,7 +31,7 @@ def main():
|
|||
if not (target/'global.php').is_file():raise RuntimeError('Native MyBB installation unavailable')
|
||||
planned=changes(source,target,PHASES[args.phase])
|
||||
for name in sum(PHASES.values(),[]):subprocess.run(['php','-l',str(source/name)],check=True,capture_output=True)
|
||||
for name in ['test-system-board-policy.php','test-system-board-provision.php','test-board-key-publication.php']:subprocess.run(['php',str(source/name)],check=True,capture_output=True)
|
||||
for name in ['test-system-board-policy.php','test-system-board-provision.php','test-board-key-publication.php','test-board-key-recovery.php','test-board-key-read-path.php']:subprocess.run(['php',str(source/name)],check=True,capture_output=True)
|
||||
if args.phase=='enable':
|
||||
for name in PHASES['prepare']:
|
||||
if not (target/name).is_file() or (target/name).read_bytes()!=(source/name).read_bytes():raise RuntimeError('Prepare helpers before enabling page reads')
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ test('native automatic board provisioner syntax and verified membership policy',
|
|||
}
|
||||
const result=spawnSync('php',[fileURLToPath(new URL('../integrations/mybb/test-system-board-provision.php',import.meta.url))],{encoding:'utf8'});assert.equal(result.status,0,result.stderr||result.stdout);
|
||||
const read=spawnSync('php',[fileURLToPath(new URL('../integrations/mybb/test-board-key-read-path.php',import.meta.url))],{encoding:'utf8'});assert.equal(read.status,0,read.stderr||read.stdout);
|
||||
const recovery=spawnSync('php',[fileURLToPath(new URL('../integrations/mybb/test-board-key-recovery.php',import.meta.url))],{encoding:'utf8'});assert.equal(recovery.status,0,recovery.stderr||recovery.stdout);
|
||||
const keys=spawnSync('php',[fileURLToPath(new URL('../integrations/mybb/test-board-key-publication.php',import.meta.url))],{encoding:'utf8'});assert.equal(keys.status,0,keys.stderr||keys.stdout);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff