Opened 3 years ago
Closed 3 years ago
#55297 closed defect (bug) (fixed)
The $is_edge global returns false.
Reported by: | costdev | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | 6.0 |
Component: | General | Keywords: | good-first-bug has-testing-info has-patch commit |
Focuses: | Cc: |
Description
$is_edge
is true
when "Edge" is detected.
However, user agents for Edge have changed such that "Edg" is the only consistent substring across devices. As a result, $is_edge
returns false
.
Changing the substring to "Edg" in src/wp-includes/vars.php:68
seems to fix this.
Steps to reproduce and test the solution:
- Add this to
functions.php
:
global $is_edge;
die( var_export( $is_edge, true ) );
- Load any page.
false
should be displayed. - Change "Edge" to "Edg" in
src/wp-includes/vars.php:68
. - Reload the page.
true
should now be displayed.
Reference: Microsoft Docs - Identifiers for Microsoft Edge on various platforms
Attachments (1)
Change History (12)
#1
@
3 years ago
- Keywords has-patch added; needs-patch needs-testing removed
Hi @costdev,
Thanks for submitting the ticket with a useful guide & test information. I have created a patch & tested it locally. It looks good to me. Webpage returning true when opening in Microsoft Edge.
Best Regards,
#2
@
3 years ago
- Keywords needs-testing added
Thanks for the patch @abdullahramzan!
I'm confident that this solution works, but let's add needs-testing
so that the original issue is reproduced and the solution is tested by someone other than myself as the reporter and yourself as the patcher.
I'll post in the core-test
Slack channel to help move this ticket along more quickly.
This ticket was mentioned in Slack in #core-test by costdev. View the logs.
3 years ago
#4
@
3 years ago
Hi there!
The patch looks good to me.
The latest user agents for Edge - https://www.whatismybrowser.com/guides/the-latest-user-agent/edge
#5
@
3 years ago
- Keywords commit added; needs-testing removed
Thanks @mukesh27!
Marking for commit
consideration.
#6
@
3 years ago
This code may need to be more specific.
Via a list of user agents chosen at random, I discovered there is an old version of Ubuntu called Edgy Eft
.
It's an edge case (pun intended) but the change should probably account for the version of Firefox that include the OS name.
Maybe check for Edg/
, EdgiOS/
and EdgA/
. The annoyance here is that you'll probably need to include the previous check for edge
for older versions.
#8
@
3 years ago
Edgy Eft
uses Ubuntu-edgy
:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20060601 Firefox/2.0.0.1 (Ubuntu-edgy)
Since strpos()
is case sensitive, it returns false
: 3v4l
#9
@
3 years ago
Test Report
Env
- WordPress 5.9 with patch applied
- Edge 98.0.1108.62
- Theme: Twenty Twenty One
Steps to test
- Added the following code to functions.php:
global $is_edge; die( var_export( $is_edge, true ) );
- Visited the page using Edge
true
is displayed
Fix for 55297