/** * Creates a table {prefix}{$namespace}_lock that is used as a mutex. * * @param string $namespace Allows having separate locks for separate processes * @return bool */ public function lock($namespace) { $this->assertNamespace($namespace); if (!$this->isLocked($namespace)) { // Lock it $this->db->insertData("CREATE TABLE {$this->db->getTablePrefix()}{$namespace}_lock (id INT)"); $this->logger->info("Locked mutex for {$namespace}"); return true; } $this->logger->warn("Cannot lock mutex for {$namespace}: already locked."); return false; }
/** * Get a user by GUID even if the entity is hidden or disabled * * @param int $guid User GUID. Default is logged in user * * @return ElggUser|false * @throws UserFetchFailureException * @access private */ public function getUserForPermissionsCheck($guid = 0) { if (!$guid) { return $this->session->getLoggedInUser(); } // need to ignore access and show hidden entities for potential hidden/disabled users $ia = $this->session->setIgnoreAccess(true); $show_hidden = access_show_hidden_entities(true); $user = $this->get($guid, 'user'); $this->session->setIgnoreAccess($ia); access_show_hidden_entities($show_hidden); if (!$user) { // requested to check access for a specific user_guid, but there is no user entity, so the caller // should cancel the check and return false $message = $this->translator->translate('UserFetchFailureException', array($guid)); $this->logger->warn($message); throw new UserFetchFailureException(); } return $user; }