In function mobile_detect_check_type() $rules variable has keyed array for devices and array('Mobile', 'Tablet', 'Handheld'). So, in_array() function finds only this three items ('Mobile', 'Tablet', 'Handheld'). I propose check key and value in array.

Comments

goodboy created an issue. See original summary.

goodboy’s picture

goodboy’s picture

StatusFileSize
new865 bytes
göran’s picture

Thank's this patch solved my problem: Mobile Detect missed iphone, did not recognize.

mpdonadio’s picture

Status: Active » Needs work
+++ b/mobile_detect.module
@@ -99,7 +99,7 @@ function mobile_detect_check_type($type) {
   $rules = array('Mobile', 'Tablet', 'Handheld') + $detect->getRules();
   $name = preg_replace('/^is/', '', $type);
 
-  if (!in_array($name, $rules)) {
+  if (!in_array($name, $rules) && !array_key_exists($name, $rules)) {

I'd rather change the $rules array to match what $detect->getRules() returns than have two types of checks.

Also curious if this is a change in the way Mobile_Detect.php works, or a bug that has always existed.

goodboy’s picture

I put second patch to replace previous one.

goodboy’s picture

Status: Needs work » Needs review
göran’s picture

#goodboy - is #7 patch a new patch instead of #3 or the second patch in a chain of two?

goodboy’s picture

@Göran, the last patch is a new patch instead of #3 . You do not need to install it if you have installed the patch #3.

izmeez’s picture

Clearly the patch in #3 and #6 are different. It appears that the new patch in #6 is the one to test against.

nonom’s picture

Actually we cannot test 7.x in the Drupal.org CI . But I can test it myself.

nonom’s picture

Category: Bug report » Task
nonom’s picture

Assigned: goodboy » nonom
Category: Task » Feature request
Status: Needs review » Closed (won't fix)
izmeez’s picture

Patch in comment #6 still applies to latest version.

nonom’s picture

Status: Closed (won't fix) » Needs work

Thanks if you see any other patch pending to commit let me know to review it.

  • nonom committed a8d507d on 7.x-1.x authored by goodboy
    Issue #2782183 by goodboy, Göran, izmeez, mpdonadio:...
nonom’s picture

Status: Needs work » Fixed

Added to the 7.1-x-dev branch and going to be released.

Thanks for the contribution!

nonom’s picture

Status: Fixed » Closed (fixed)