Problem/Motivation
There is code that doesn't check for the existence of an array key before using it which causes a PHP warning when the key is missing. The code was added as part of this issue.
Steps to reproduce
Run drupal on a server which doesn't allow $_SERVER['HTTP_REFERER']. Open an entity browser with an iframe display.
You'll get this error message in the modal, but everything will work:
Warning: Undefined array key "HTTP_REFERER" in Drupal\entity_browser\Plugin\EntityBrowser\Display\IFrame->displayEntityBrowser() (line 101 of modules/contrib/entity_browser/src/Plugin/EntityBrowser/Display/IFrame.php).
Proposed resolution
Check for the existence of the array key before using it.
Issue fork entity_browser-3553412
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
very_random_man commentedComment #4
benstallings commentedClaude Code says:
Assessment — Correct but minimal:
1. Fixes the bug correctly. The old code assigned $_SERVER['HTTP_REFERER'] to $referer unconditionally, triggering the warning. The new code gates access behind !empty(). Simple and right.
2. Pre-existing concern (not this patch's fault): Direct access to $_SERVER['HTTP_REFERER'] is a Drupal anti-pattern. The request object is already available via the $this->request property (or could be injected). The idiomatic approach would be $this->request->server->get('HTTP_REFERER') or $this->request->headers->get('referer'), which return NULL gracefully without needing the !empty() check at all. But that's a separate cleanup, not a reason to block this fix.
3. Net reduction of one line — cleaner than the original.
This is a straightforward, safe fix. Good to merge.
Comment #5
anybody