-
Notifications
You must be signed in to change notification settings - Fork 767
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
Soap call problem with >32bit ids #254
Comments
Also, some criteria across examples etc. Knack, we may need to grep across lib for "intval(" and make sure the value range may not exceed int32. PHP documentation around Integer makes me depressed. |
Hello JC, Thanks for reporting this! I'm afraid that doing anything (like casting values) in AdsSoapClient is not possible, as it's too deep and we don't know the structure of an object passed there. In fact, the As an example, CampaignService's mutate() accepts You can cast the value of I'll document this properly so other users won't face this problem too. Best, |
Thanks for the suggestions. I am developing my app using Windows and Mac and deploying to Linux. Only Window's PHP is limited to 32 bits. So casting it myself is also just for a single machine. I have no problems with casting it, but why can't the library cast it at the service classes'
Can you explain why? |
Hello JC, Provided that I have a public function setId($id) {
$this->id = (PHP_INT_SIZE === 4) ? floatval($id) : $id;
return $this;
} And given that you pass a variable exceeding 2147483647 like 2147485000, to this function: // Case 1
$a = 2147485000; // would work
$campaign->setId($a);
// Case 2
$a = "2147485000"; // would work
$campaign->setId($a);
// Case 3
$a = intval(2147485000); // not work
$campaign->setId($a); My point is that it still depends on the values that you pass to the method. For case 3, it wouldn't work because 2147485000 will be maxed out as 2147483647 before passed to the method, and casting it to float just produces floatval of 2147483647, not of 2147485000. Best, |
And the reason why I agreed that we should fix #236 is because we explicitly did |
Maybe there's a misunderstanding, I didn't intval(). The argument to soap call reflects the correct integer. Only after soapCall the XML became 32bits. |
Hi, So, do you mean the XMLs produced by SOAP toolkit (before sending to the servers) are not correct? Knack |
Yes. I printed out the argument and the XML to do a comparison. The XML is wrong. See similar issue here: http://stackoverflow.com/questions/19228213/php-soapclient-soap-request-with-long-integer And |
Hi JC, Thanks for information. Then it's a PHP SOAP toolkit bug itself. For example, if we have: $a = 21474850000;
$b = flotval(21474850000); Using Knack |
I've been researching a bit yesterday. Not sure if it's the case, but seems like no one is going to fix it: https://bugs.php.net/bug.php?id=48717 For your example, here's how it actually executed on my system.
|
Yup, that's what I think. After converting to XML, there are no differences between int and string and this should work fine on the API servers too. |
Ok, just did further investigation. In my database I am storing the id as bigint(20). Querying using PHP gets it default as a string of the correct value i.e. Sorry for the confusion. So string does not work. I can't cast it to integer either, as you said. So the only solution for me is to cast it to float and this works. The issue still lies with SOAP toolkit. And the question is still who should do the casting?
|
Hello JC, As mentioned in previously, I'm still concerned that providing casting in the setter doesn't help all cases. Let me consider pros and cons more carefully. Best, |
To be honest, I rather not cast this on my end as the only case where it's necessary is this issue. To change this, I'll need to either target the columns manually or change things on the framework level, both which adds to more maintenance down the line. I'll wait for your decision on this. In the mean time, I'll ignore it on this development machine :D Thanks for your help! |
Hi Knack, Just encountered this issue again. This time it's not related to database. In my app I make a DELETE request like this: http://app.dev/feeds/45250724/feed_items/11688017155 The URL parameters are automatically cast to string by the routing system. So unless I manually cast it to float, the issue will occur. It'll be inconvenient to cast it to float manually every time. So I hope that you'll add this into the library. Thanks! |
Hi JC, Could you please add more details like SOAP logs? I can't access your link. :) Best, |
Hi Knack, The URL is for an AJAX request within my app. The routing system is part of the framework I am using. So a URL like As discussed few days ago, when strings are over 32bits the SOAP toolkit will output it as It's not part of the library. But my point earlier: Unless I go to every controller method or route and cast it to float manually, the issue will occur. It's inconvenient to do so. If it's cast on the library itself, then I don't have to handle this. The ideal solution, I think, is to run the Hope that is clearer. Let me know if you need more information. Thanks! JC |
Hello JC,
I understand your case for passing values to AdWords API server, but in this case, it looks like you mean your system also has an issue with the results returned from the API? Moreover,
I don't think this would be easy to implement. It looks like we have to deeply traverse to all members of all objects stored as
Unfortunately, this doesn't solve all the problems. People can still run into problems if they pass 32-bit integer into setters of AdWords integer values (like campaign's ID). That's why I'm still reluctant to do this. My thought is like "garbage in, garbage out". You have a choice to pass the right values to the system and the library shouldn't change your value unnecessarily. :) Note that, I don't turn this proposal down completely. I know that it at least helps your case. Best, |
Hi Knack,
No, my example deals with deleting a feed item by doing a DELETE request through AJAX. I do already have the ids. As the routing system interprets the URL, it reads the params like so
While that's true, we can skip traversing if system is not 32 bits. Also, we can add a config option that switches off this feature if the developer chooses to cast it. It's not elegant but it works.
This is only true if the developer manually casts to integer with
Yes. However to pass the right value in this case, I'll have to cast float at every instance. While I can do that, it's inconvenient and easy to miss. I imagine the developer would expect the string value id to work. The only way to discover this problem is to do __getLastRequest() on SOAP. It's not urgent as this is only a problem on Windows. I just need to make sure you get my points clearly to make the decision. And of course if SOAP toolkit can fix that issue, then all these goes away :D Thanks! |
Hi JC, Thanks for more thoughts.
Yes. The ideal way is to have SOAP toolkit fix this.
As for this, if I do casting values, I'd go for this way, do the casting in the setters, rather than in
Sorry for this too but still doesn't follow you here. :( In other words, it seems you don't pass Cheers, |
Hi,
It's related because throughout the application the ids if placed into the URL are cast as strings (when received in PHP) -- and strings must be cast to float to avoid the issue. Compared to our discussion earlier where I thought it's only when queried by the database that I get strings, this is more widespread. Therefore now I must cast to float on a wider scale.
I do. Using the example in my reply, the request is received in PHP as strings. Then the operations constructed and sent to the API. In other words, |
Hi JC, So,
Are you saying that you get the URL in forms of the above, which is filled with Just wonder if you're also affected by this issue in other libraries too? Cheers, |
Hi Knack, That's what I mean. So with that example, I must go through every route and cast them to float. I haven't yet work with an API that requires 64 bits integers other than AdWords. Or at least not that I know of - because I've been working on Mac (64bit PHP) with no issues. JC |
Classes are generated with default floatval() for 32-bit in v28.0.0. |
Seems like the issue is not isolated to just BatchJobs. SoapCall is also affected.
The Keyword id
289674651551
became2147483647
.Error message:
[EntityNotFound.INVALID_ID @ operations[0].operand.criterion.id; trigger:'CriterionId{id=2147483647}']
Output from soap call from AdsSoapClient Line 115
Guess you'll have to cast id to float in the argument.
The text was updated successfully, but these errors were encountered: