From cde37acb4bd4e439d0afc6c2c37763d67dcb6693 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 9 Dec 2016 04:15:44 -0800 Subject: [PATCH] When a custom logo is configured but has a restrictive visibility policy, fall back to the default logo Summary: Fixes T11982. Currently, configuring a custom logo and then setting the policy restrictively locks off the whole install. Test Plan: - Configured `ui.logo`. - Searched for the file PHID in global search to find the underlying file. - Set the policy to something restrictive ("only me"). - Purged cache (`bin/cache purge --purge-all`). - Restarted webserver to nuke APC. - Loaded a page as a different user. - Before change: policy exception while trying to load the logo. - After change: fallback to default logo. - Loaded page as user who can see the logo, got custom logo. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11982 Differential Revision: https://secure.phabricator.com/D17011 --- src/view/page/menu/PhabricatorMainMenuView.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/view/page/menu/PhabricatorMainMenuView.php b/src/view/page/menu/PhabricatorMainMenuView.php index 4bd09992e4..a28e38db06 100644 --- a/src/view/page/menu/PhabricatorMainMenuView.php +++ b/src/view/page/menu/PhabricatorMainMenuView.php @@ -317,19 +317,26 @@ final class PhabricatorMainMenuView extends AphrontView { $logo_uri = $cache->getKey($cache_key_logo); if (!$logo_uri) { - $file = id(new PhabricatorFileQuery()) + // NOTE: If the file policy has been changed to be restrictive, we'll + // miss here and just show the default logo. The cache will fill later + // when someone who can see the file loads the page. This might be a + // little spooky, see T11982. + $files = id(new PhabricatorFileQuery()) ->setViewer($this->getViewer()) ->withPHIDs(array($custom_header)) - ->executeOne(); + ->execute(); + $file = head($files); if ($file) { $logo_uri = $file->getViewURI(); $cache->setKey($cache_key_logo, $logo_uri); } } - $logo_style[] = 'background-size: 40px 40px;'; - $logo_style[] = 'background-position: 0 0;'; - $logo_style[] = 'background-image: url('.$logo_uri.')'; + if ($logo_uri) { + $logo_style[] = 'background-size: 40px 40px;'; + $logo_style[] = 'background-position: 0 0;'; + $logo_style[] = 'background-image: url('.$logo_uri.')'; + } } $logo_node = phutil_tag(