Skip to content

Commit

Permalink
Fixed postgres real good this time
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed May 2, 2019
1 parent f6c3dff commit 401ed6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/Dev/FixFolderPermissionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ class FixFolderPermissionsHelper
*/
public function run()
{
SQLUpdate::create(
'"' . File::singleton()->baseTable() . '"',
['CanViewType' => 'Inherit'],
['ISNULL("CanViewType")', 'ClassName' => Folder::class]
)->execute();
SQLUpdate::create()
->setTable('"' . File::singleton()->baseTable() . '"')
->setAssignments(['"CanViewType"' => 'Inherit'])
->setWhere([
'"CanViewType" IS NULL',
'"ClassName"' => Folder::class
])
->execute();

// This part won't work if run from the CLI, because Apache and the CLI don't share the same cache.
InheritedPermissionFlusher::flush();
Expand Down
6 changes: 3 additions & 3 deletions tests/php/Dev/Tasks/FixFolderPermissionsHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function testTask()
$task = new FixFolderPermissionsHelper();
$updated = $task->run();

$this->assertEquals('Inherit', Folder::get()->where(['Name' => 'ParentFolder'])->first()->CanViewType);
$this->assertEquals('Anyone', Folder::get()->where(['Name' => 'SubFolder'])->first()->CanViewType);
$this->assertEquals('Inherit', Folder::get()->where(['Name' => 'AnotherFolder'])->first()->CanViewType);
$this->assertEquals('Inherit', Folder::get()->filter('Name', 'ParentFolder')->first()->CanViewType);
$this->assertEquals('Anyone', Folder::get()->filter('Name', 'SubFolder')->first()->CanViewType);
$this->assertEquals('Inherit', Folder::get()->filter('Name', 'AnotherFolder')->first()->CanViewType);
$this->assertEquals(2, $updated);
}
}

0 comments on commit 401ed6f

Please sign in to comment.