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

Unable to call to undefined method getRealContainingOneof #891

Closed
Albertopipo opened this issue Apr 12, 2023 · 11 comments
Closed

Unable to call to undefined method getRealContainingOneof #891

Albertopipo opened this issue Apr 12, 2023 · 11 comments
Assignees
Labels
bug Something isn't working triage Need triage

Comments

@Albertopipo
Copy link

While trying to update our version of the google-ads-php library to the latest version, v19, we've been facing a problem with the classes in the vendor library that we haven't been able to solve.
Basically, whenever we try to use the FieldMasks utility, more specifically its allSetFieldsOf() static function, we get the following error:

Attempted to call an undefined method named "getRealContainingOneof" of class "Google\Protobuf\FieldDescriptor".

Which is to say, it is as if the class FieldDescriptor didn't contain the getRealContainingOneof() method, except the method appears to be implemented in the class. We considered the possibility that it might be a namespace issue of the class FieldDescriptor, but as far as we can tell, the class methods that return simple types (getName and such) are functional - it's only the methods that would return a Protobuf type message that fail.

If it helps, these are the current versions of the related vendor libraries we're running:

PHP 8.0
Symfony 5.2.14
Google Ads Api V13
Google ads php 19.0.9
Google protobuf 3.22.2

@Albertopipo Albertopipo added bug Something isn't working triage Need triage labels Apr 12, 2023
@fiboknacky
Copy link
Member

Could you please tell me more what protobuf implementation (C or PHP) do you use?
Does it happen when you run a basic example like UpdateCampaign too?

@fiboknacky fiboknacky self-assigned this Apr 12, 2023
@Albertopipo
Copy link
Author

Hello,

We are currently using the PHP implementation (v3.22.2).
When we run a basic example, such as Updating or creating a campaign it works.
This is because FieldMask does not try to use the function isSettingEmptyOneOf
Instead, when we are trying to execute a 'complex' example such as creating an Asset with a SitelinkAsset inside or and AdGroupAd with an AdGroup associated it's when we get the previously mentioned error.

@fiboknacky
Copy link
Member

Could you please share your code to reproduce, then? Thanks.

@Albertopipo
Copy link
Author

Sure. In this example, we are updating an asset with a sitelinkAsset inside of it.

( The ### are the correct names, they are strings that we are using to test. )

    $assetResourceName = '#####';
    $assetToUpdate = new Asset();

    $assetToUpdate->setResourceName($assetResourceName);
    $assetToUpdate->setFinalUrls(['######']);

    $siteLink = new SitelinkAsset();
    $siteLink->setLinkText('#####');

    $assetToUpdate->setSitelinkAsset($siteLink);

    $operation = new AssetOperation();
    $operation->setUpdate($assetToUpdate);
    $operation->setUpdateMask(FieldMasks::allSetFieldsOf($assetToUpdate));

@homergleason
Copy link

  • Same problem
    Fatal error: Uncaught Error: Call to undefined method Google\Protobuf\FieldDescriptor::getRealContainingOneof() in
    protobuf - 3.20.1
    PHP Version 7.4.28

$adOperation = new AdOperation();
$adOperation->setUpdate($ad);
$adOperation->setUpdateMask(FieldMasks::allSetFieldsOf($ad));

@Albertopipo
Copy link
Author

Hello,
Is there any news regarding this issue?
Thanks

@fiboknacky
Copy link
Member

Sorry for keeping you waiting.
I tried it with protobuf 3.22.3 but couldn't reproduce your reported issue when using the code in your comment above.

Can you try upgrading to 3.22.3 first? To be 100% sure, you can remove the protobuf directories in vendor/ first. Then, after upgrading, check your composer.lock to be sure that it's 3.22.3.
If your problem still persists, could you share what the code of FieldDescriptor in your vendor/ looks like?

Apart from that, some of your other dependencies or projects may fix your protobuf to the older versions than that, or have their own protobuf versions that can silently overwrite the version you think you're using too. You may double-check if that's the case.

@homergleason
Copy link

Sorry for keeping you waiting. I tried it with protobuf 3.22.3 but couldn't reproduce your reported issue when using the code in your comment above.

Can you try upgrading to 3.22.3 first? To be 100% sure, you can remove the protobuf directories in vendor/ first. Then, after upgrading, check your composer.lock to be sure that it's 3.22.3. If your problem still persists, could you share what the code of FieldDescriptor in your vendor/ looks like?

Apart from that, some of your other dependencies or projects may fix your protobuf to the older versions than that, or have their own protobuf versions that can silently overwrite the version you think you're using too. You may double-check if that's the case.

It helped me. Thanks.

@fiboknacky
Copy link
Member

fiboknacky commented Apr 19, 2023

Hmm... Do you use any IDEs? What happens when you trace the getRealContainingOneof method? Does it link to a correct file?

Could you also check this answer too?

@Albertopipo
Copy link
Author

Hello,

After updating the Google Ad's api version it seems that we had some mix between C's and PHP's implementation and we had both 'working' at the same time. We deleted the C version completely and now it seems to work.

Thanks for your time and sorry for all the trouble.

@fiboknacky
Copy link
Member

That's what I thought that there might be a mix between implementations. Sorry that I didn't think of this early. Anyway, I'm happy that you could resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Need triage
Projects
None yet
Development

No branches or pull requests

3 participants