21 lines
2 KiB
PHP
21 lines
2 KiB
PHP
<?php
|
|
// An unpublished organisation must never invoke DDL/provision/cache work on GET.
|
|
define('IN_MYBB',1);
|
|
final class ReadBoardRows {public function __construct(public array $rows){}}
|
|
final class ReadOnlyBoardDB {
|
|
public int $reads=0;
|
|
public function table_exists($name){return $name==='dune_system_boards';}
|
|
public function simple_select($table,$fields='*',$where='', $options=[]){$this->reads++;if($table==='dune_system_boards')return new ReadBoardRows([['kind'=>'clan','organisation_id'=>'11111111-1111-4111-8111-111111111111','fid'=>54,'member_gid'=>14,'leader_gid'=>15]]);if($table==='forumpermissions')return new ReadBoardRows([['fid'=>54,'policy_count'=>2]]);throw new RuntimeException('Unexpected request read: '.$table);}
|
|
public function fetch_array($rows){return array_shift($rows->rows);}
|
|
public function update_query(...$args){throw new RuntimeException('Unexpected request write');}
|
|
public function write_query(...$args){throw new RuntimeException('Request-time provisioning attempted');}
|
|
}
|
|
$db=new ReadOnlyBoardDB();$mybb=(object)['user'=>['uid'=>42,'usergroup'=>2,'additionalgroups'=>'14']];
|
|
require __DIR__.'/system-board-membership.php';
|
|
$identity=['systemBoards'=>['version'=>1,'boardKeyVersion'=>1,'inspectAll'=>false,'moderateAll'=>false,'organisations'=>[
|
|
['kind'=>'clan','id'=>'11111111-1111-4111-8111-111111111111','read'=>true,'post'=>true,'manage'=>false],
|
|
['kind'=>'company','id'=>'22222222-2222-4222-8222-222222222222','name'=>'Pending board','read'=>true,'post'=>true,'manage'=>false]]]];
|
|
$start=hrtime(true);dune_apply_system_board_membership($identity);$elapsed=(hrtime(true)-$start)/1e6;
|
|
if($db->reads!==2)throw new RuntimeException('Prepared mapping reads changed');
|
|
if(function_exists('dune_provision_system_boards'))throw new RuntimeException('Page load imported the global provisioner');
|
|
echo json_encode(['fixture'=>'unpublished organisation on GET','mappingAndPermissionReads'=>$db->reads,'writes'=>0,'globalCacheRebuilds'=>0,'milliseconds'=>$elapsed])."\n";
|

Staff