Skip to content

Commit

Permalink
BAP-11756: Corrupted installation on replicated mysql server (#7497)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccar authored and Krushelnitskiy committed Feb 13, 2017
1 parent 99d0c6d commit a535b45
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ protected function connectCalendars()
{
// first user is admin, often
/** @var \Oro\Bundle\UserBundle\Entity\User $admin */
$admin = $this->user->find(1);
$admin = $this->em->getRepository('OroUserBundle:User')
->createQueryBuilder('u')
->select('u')
->orderBy('u.id')
->getQuery()
->setMaxResults(1)
->getSingleResult();
/** @var Calendar $calendarAdmin */
$calendarAdmin = $this->calendar->findDefaultCalendar($admin->getId(), $admin->getOrganization()->getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ protected function initSupportingEntities(ObjectManager $manager = null)
$this->organization = $this->getReference('default_organization');

/** @var User $adminUser */
$adminUser = $this->em->getRepository('OroUserBundle:User')->find(1);
$adminUser = $this->em->getRepository('OroUserBundle:User')
->createQueryBuilder('u')
->select('u')
->orderBy('u.id')
->getQuery()
->setMaxResults(1)
->getSingleResult();
$token = new UsernamePasswordOrganizationToken(
$adminUser,
$adminUser->getUsername(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,19 @@ protected function updateUserRole(AclManager $manager)
'ROLE_MARKETING_MANAGER',
'ROLE_LEADS_DEVELOPMENT_REP',
];
$oid = $manager->getOid('entity:Oro\Bundle\EmailBundle\Entity\EmailUser');

foreach ($roles as $roleName) {
$role = $this->getRole($roleName);
if ($role) {
$sid = $manager->getSid($role);

$oid = $manager->getOid('entity:Oro\Bundle\EmailBundle\Entity\EmailUser');
$maskBuilder = $manager->getMaskBuilder($oid)
->add('VIEW_BASIC')
->add('CREATE_BASIC')
->add('EDIT_BASIC');
$manager->setPermission($sid, $oid, $maskBuilder->get());
$mask = 0;
foreach (['VIEW', 'CREATE', 'EDIT'] as $permission) {
$maskBuilder = $manager->getMaskBuilder($oid, $permission);
$maskBuilder->add($permission . '_BASIC');
$mask |= $maskBuilder->get();
}
$manager->setPermission($sid, $oid, $mask);
}
}
}
Expand Down

0 comments on commit a535b45

Please sign in to comment.