Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#55297 closed defect (bug) (fixed)

The $is_edge global returns false.

Reported by: costdev's profile costdev Owned by: peterwilsoncc's profile 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:


$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:

  1. Add this to functions.php:
global $is_edge;
die( var_export( $is_edge, true ) );
  1. Load any page. false should be displayed.
  2. Change "Edge" to "Edg" in src/wp-includes/vars.php:68.
  3. Reload the page. true should now be displayed.

Reference: Microsoft Docs - Identifiers for Microsoft Edge on various platforms

Attachments (1)

55297-03032022.diff (652 bytes) - added by abdullahramzan 2 years ago.
Fix for 55297

Download all attachments as: .zip

Change History (12)

2 years ago

Fix for 55297

#1 @abdullahramzan
2 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 @costdev
2 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.

2 years ago

#4 @mukesh27
2 years ago

Hi there!

The patch looks good to me.

The latest user agents for Edge -

#5 @costdev
2 years ago

  • Keywords commit added; needs-testing removed

Thanks @mukesh27!

Marking for commit consideration.

#6 @peterwilsoncc
2 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.

#7 @peterwilsoncc
2 years ago

  • Keywords commit removed

#8 @costdev
2 years ago

Edgy Eft uses Ubuntu-edgy:

Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20060601 Firefox/ (Ubuntu-edgy)

Since strpos() is case sensitive, it returns false: 3v4l

#9 @Boniu91
2 years ago

Test Report


  • WordPress 5.9 with patch applied
  • Edge 98.0.1108.62
  • Theme: Twenty Twenty One

Steps to test

  1. Added the following code to functions.php:
    global $is_edge;
    die( var_export( $is_edge, true ) );
  2. Visited the page using Edge
  3. true is displayed

#10 @peterwilsoncc
2 years ago

  • Keywords commit added

Thanks @costdev and @Boniu91

Since strpos() is case sensitive, it returns false

Yes, indeed, excellent point.

#11 @peterwilsoncc
2 years ago

  • Owner set to peterwilsoncc
  • Resolution set to fixed
  • Status changed from new to closed

In 52825:

General: Improve MS Edge user-agent sniff.

Update the $is_edge global to be true if the browser's user-agent contains Edg rather than Edge. Microsoft have dropped an E from the UA string.

Refer to Microsoft's documentation on detecting edge.

Props costdev, abdullahramzan, mukesh27, Boniu91.
Fixes #55297.

Note: See TracTickets for help on using tickets.