added a comment - - edited
hmm, I spent a few hours trying to fix this and also trying to find out all potential problems.
The attached patches are incorrect - they seem to fix only one particular capability setup, it does not deal with negative capability overrides.
Major problems are:
1/ it is going to run out of memory and course major performance problems if there are a few thousand site users with the given capability
2/ if we implement support for the CAP_PREVENT override of the default frontpage role the normal role assignments on the frontpage will be eliminated by the frontpage role (thanks to the over-engineered capability evaluation in 1.9.x)
Sending new patch, I am not really sure if it is a good idea to make this change, so I have added on new config.php switch that enables the patch.
Expect big problems especially on large sites where Student role is selected as the default frontpage role.