-
Notifications
You must be signed in to change notification settings - Fork 769
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
Unsetting properties? #426
Comments
Would not touching advertiser ID at all have the same effect? Knack |
@fiboknacky that is correct if you're creating objects from scratch. But in our case, we are duplicating (copying) various objects. Till this update, creative(s) duplicating was as easy as querying from API, unsetting ID, and calling |
As a temporary workaround, we'll use this approach: /** @var \Google\AdsApi\Dfp\v201705\Creative $creative */
$reflectionClass = new \ReflectionClass( get_class($creative) );
$idProperty = $reflectionClass->getProperty('id');
$idProperty->setAccessible( true );
$idProperty->setValue( $creative, null );
$idProperty->setAccessible( false ); But ideally, I'd suggest changing API and checking for value integrity: /**
* @param int $id
* @return \Google\AdsApi\Dfp\v201705\Creative
*/
public function setId($id)
{
$this->id = ($id && PHP_INT_SIZE === 4)
? floatval($id) : $id;
return $this;
} Or using your colleague's approach: |
This is a great feedback. Unfortunately, this is not a high priority issue for us. And we will have to close it as Not Fixed for now. Please reopen this issue if it becomes high priority for you. Otherwise, we will revisit it later this year. |
It looks like there are 2 aspects of this issue:
For (1), we can fix it as a bug in the next release. For (2), we will continue to investigate the use case and work on it later. |
Thanks @thangduo for the feedback. |
Classes are now generated to support setting null in v33.0.0. |
Thank you! |
Despite the fact that I hate your decision to close properties as protected - and leave communication through getters and setters - can you please shed the light for me, how can we unset certain properties?
E.g. I want to set advertiser ID for creative to
null
(as obviously,unset( $creative->advertiserId )
won't work).But instead of unsetting or setting to null, it sets to zero - because:
https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/Dfp/v201705/Creative.php#L95
And then SOAP call fails.
And yes,
PHP_INT_SIZE
is 4 on my environment.Help!
The text was updated successfully, but these errors were encountered: