Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSP2 and browser_info serialization is broken with isJavaEnabled & isJavascriptEnabled #55

Closed
cyberbobjr opened this issue May 12, 2021 · 3 comments

Comments

@cyberbobjr
Copy link

cyberbobjr commented May 12, 2021

Hi,

this is a regression from the 2.8.2 package version (this bug is not present in the 2.8.0)

When i populate the BrowserInfo with these values (i masked the ipaddr) :

{
    "ipaddr": "xxx.xxx.xxx.xxx",
    "http_accept": "application\/json, text\/plain, *\/*",
    "http_user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/90.0.4430.93 Safari\/537.36",
    "java_enabled": false,
    "javascript_enabled": true,
    "language": "fr-FR",
    "color_depth": 24,
    "screen_height": 1440,
    "screen_width": 3440,
    "timezone": "-120"
}

The serialization process before the request remove the "java_enabled" and "javascript_enabled" properties :

{"ipaddr":"172.18.0.1","httpAccept":"application\/json, text\/plain, *\/*","httpUserAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/90.0.4430.93 Safari\/537.36","language":"fr-FR","colorDepth":24,"screenHeight":1440,"screenWidth":3440,"timezone":"-120"}

The main bug is inside the AbstractModel serialization function "toArray" :

        foreach ($classRef->getMethods() as $method) {
            if (substr($method->name, 0, 3) == 'get') {
                //clean key name
                $key = lcfirst(substr($method->name, 3));

                //Call getter to get the value
                $val = $method->invoke($this);
                if (is_object($val) && is_a($val, AbstractModel::class)) {
                    $array[$key] = $val->toArray();
                } elseif ($val !== null) {
                    $array[$key] = $val;
                }
            }
        }

The 2 properties for java_enabled et javascript_enabled are name with "isJavascriptEnabled" and "isJavaEnabled", so the result of these 2 functions are not parsed... and the requestOrder failed with DSP2...

So the fix must be :

  • change the isJavaEnabled & isJavascriptEnabled to getJavaEnabled & getJavascriptEnabled
  • or do a in_array with ['get','is'] for the substr
@cyberbobjr
Copy link
Author

no news ?

@cyberbobjr
Copy link
Author

so, do you want a PR ?

@pi-ecommerce
Copy link

@cyberbobjr

Sorry !
It's fixed in the last version.
Thanks for your report and sorry for the latency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants