Last modified: 2014-02-12 23:45:31 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56115, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54115 - Allow to detect mobile externally without using AMF module
Allow to detect mobile externally without using AMF module
Status: RESOLVED WONTFIX
Product: MobileFrontend
Classification: Unclassified
Feature requests (Other open bugs)
unspecified
All All
: Unprioritized enhancement
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-14 09:13 UTC by yorktown
Modified: 2014-02-12 23:45 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Header and phpcode (2.42 KB, text/plain)
2013-09-14 09:13 UTC, yorktown
Details

Description yorktown 2013-09-14 09:13:14 UTC
Created attachment 13276 [details]
Header and phpcode

Currently there are two options for mobile users:
* Install AMF plugin
* Enable wgMFAutodetectMobileView

But I'd like to do this myself, e.g. set my own header and say: Hey, mobile view please.

So I looked into the code and tried:
AMF plugin sets a header AMF_DEVICE_IS_MOBILE. Idea: Set the header myself:
RequestHeader set AMF_DEVICE_IS_MOBILE true env=ismobile

But alas PHP, in it's infinite wisdom, adds HTTP_AMF_DEVICE_IS_MOBILE to $_SERVER and it doesn't work. See attached code/example for reference.

So, I see three simple solutions:
a) Add a second function similar to getAMF to MobileContext (see c) for an example)
b) Add a variable that overrides detection:

 public function isMobileDevice() {
                global $wgMFAutodetectMobileView;
                global $wgMFOverridedetectMobileView;


                return ( $wgMFAutodetectMobileView && $this->getDevice()->isMobileDevice() )
                        || $this->getAMF() || $wgMFOverridedetectMobileView;
        }


c) Make getAMF generic and allow a custom header

public function isMobileHeaderSet() {
   global $wgMFMobileHeader;
   global $wgMFTabletHeader;
   if ( isset( $_SERVER[$wgMFMobileHeader] ) &&
        $_SERVER[$wgMFMobileHeader] === "true" &&
        $_SERVER[$wgMFTabletHeader] === "false" ) {
           return true;
        }
     return false;
}

By default, $wgMFMobileHeader would be AMF_DEVICE_IS_MOBILE by default, but people using a different kind of detection algorithm/module could use it.


Not sure what's better. If b) then I could test myself in LocalSettings.php and set the variable. Btw.: I already tried to do stuff like this in LocalSettings.php, but I got problems with manually switching to desktop view and back:

if ( isset( $_SERVER['HTTP_AMF_DEVICE_IS_MOBILE'] ) && $_SERVER['HTTP_AMF_DEVICE_IS_MOBILE'] === "true" ) {
        MobileContext::singleton()->setForceMobileView( true );
}


Thanks for consideration!
Comment 1 Arthur Richards 2013-09-14 09:15:17 UTC
Prioritization and scheduling of this bug is tracked on Mingle card https://mingle.corp.wikimedia.org/projects/mobile/cards/1197
Comment 2 Max Semenik 2013-09-14 16:41:31 UTC
On  MF version for MW 1.21, there's X-Device header that is used for this, and in 1.22, there is X-WAP. Ask on IRC if you neeed help with configuring these.
Comment 3 yorktown 2013-09-14 17:04:03 UTC
That's not true.

The WAP header is only processed when $wgMobileUrlTemplate is set:

if ( $wgMobileUrlTemplate && $this->getRequest()->getHeader( 'X-WAP' ) ) {
                        return true;
                }

Why am I forced to setup a mobile subdomain? I don't need one.

Btw.: If you stand with your logic, it would be consequent to remove getAMF(). It isn't needed either.
Comment 4 yorktown 2013-09-15 18:20:43 UTC
Interesting. The version for 

The same code in MobileContext 1.21 looks this way:

public function isMobileDevice() {
                global $wgMFAutodetectMobileView;

return $this->getXDevice()
                        || $this->getAMF()
                        || ( $wgMFAutodetectMobileView && $this->getDevice()->isMobileDevice() );
}

You are right: In Mediawiki 1.21 I can set my own header. In Mediawiki 1.22 this option was basically removed.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links