getLabel is deprecated. Use isRequired or isRepeated instead.
Hello,
I have bug with using last version of the library(v26.2):
{"exception":"[object] (ErrorException(code: 0): getLabel is deprecated. Use isRequired or isRepeated instead.
at /app/vendor/googleads/google-ads-php/src/Google/Ads/GoogleAds/Util/FieldMasks.php:356)
in code it's:
/**
* @param FieldDescriptor $fieldDescriptor the field descriptor to check if it's repeated
* @return bool true if the field descriptor is repeated
*/
private static function isFieldRepeated(FieldDescriptor $fieldDescriptor)
{
return $fieldDescriptor->getLabel() === GPBLabel::REPEATED;
}
Thanks for submitting this: it will be fixed in the next release of the client library.
@Raibaz
could you say when it will be?
V20 of the Google Ads API will be released on June 6th, so we will be releasing a new version of the client library along with it.
@Raibaz
Do you plan to release a fix for this issue anytime soon?
thanks!
@Raibaz
Do you have any update on this? I just installed the latest version of the library but the fix seems to not be along with it. Im on api V18 could it be the problem?
Thank you!
@Raibaz The issue still persists. It seems that simply updating the method in the Google\Ads\GoogleAds\Util\FieldMasks class would resolve the problem. It would be great if an update could be released soon to address this. Thanks in advance!
/**
* @param FieldDescriptor $fieldDescriptor the field descriptor to check if it's repeated
* @return bool true if the field descriptor is repeated
*/
private static function isFieldRepeated(FieldDescriptor $fieldDescriptor)
{
return $fieldDescriptor->isRepeated();
}
@cbringmann
I was going to propose the same fix/hack here but you just did. Thanks!
@cbringmann
Hi!
I know the issue, you need to update google/protobuf - https://github.com/googleads/google-ads-php/blob/83134844b301e2ac15319b2c8dc0ede3bc31aa2f/composer.json#L9 to last version because isRepeated method is not available in these versions: ^3.21.5 || ^4.26
maybe releated #1083
we still see UndefinedMethod: Method Google\Protobuf\Internal\RepeatedField::offsetGet does not exist on v28
I'm taking a look at this, thank you all for your patience, I hope to have a fix pushed out by the end of next week.
perhaps also add a psalm/phpstan CI job, to catch things early with low-high deps
I updated the client library to use isRepeated in v29.0.0 (https://github.com/googleads/google-ads-php/releases/tag/v29.0.0)/.
This solved the issue for me on my local machine. Can you all confirm if this issue is resolved for you in this new version of the library?
IIUC this issue and https://github.com/googleads/google-ads-php/issues/1083 is fixed.
This issue (1084) should be fixed with the recent PHP client library release. I'm keeping this issue open for another week, just in case anyone is still running into issues, so they can post it here and I can investigate further.
As for #1083, I didn't explicitly address that with this release, so I will continue the conversation with you on that issue directly.
@ro0NL @Brothman
I've tested new version v29.0, and see the new mistake: Call to undefined method Google\Protobuf\FieldDescriptor::isRepeated() i'm sure that need to update google/protobuf to latest version
Thank you for calling that out, @urbanovich. Taking a closer look, I see the isRepeated() method was only just added in v31.0, i.e. 4.31.0.
I'll work to update the dependencies and update it in the next version of the client library (will keep this issue open until then).
I am also facing same issue when trying to update audiencelist.
Call to undefined method Google\Protobuf\FieldDescriptor::isRepeated()
On Line Number: 356 Google/Ads/GoogleAds/Util/FieldMasks.php
@chiragvels Until we get the next client library version out, can you update line 9 in composer.json to be:
google/protobuf": "4.31.0",
Then run composer update to get the newest protobuf version installed that has the method Google\Protobuf\FieldDescriptor::isRepeated().
Please let us know if you run into any errors when making this change.
I can see that under composer.lock I am already having google/protobuf (v4.31.1)
And I am still getting the error:
Type: Error Message: Call to undefined method Google\Protobuf\FieldDescriptor::isRepeated()
I did this change as a work around
From this line
$operation->setUpdateMask(FieldMasks::allSetFieldsOf($userList));
To
$fieldMask = new \Google\Protobuf\FieldMask();
$fieldMask->setPaths(['description']);
$operation->setUpdateMask($fieldMask);
Thanks,
Thank you for pointing that out, and the workaround @chiragvels.
I create Issue 1092 stating that because of dependency complications with the v29.0.0 release, we're deprecating v29.0.0, and will be releasing v30.0.0 to fix those complications so we have a working client library out of the box, no workaround needed. Then later, once those dependency complications are fixed internally, we will release another client library version.
I'll post another update here when v30.0.0 is released.
Hi, we released v30, in which we pinned the protobuf version to v4.30 to prevent this error. As such, we went back to the old getLabel method, which isn't deprecated in v4.30.
Please follow issue 1095 for updates on when we will resolve the underlying protobuf dependency conflict, at which time we will release a new client library, that uses v4.31 of protobuf onwards (alongside isRepeated).