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

Type Error for Logging #504

Closed
chiragvels opened this issue Dec 17, 2020 · 8 comments
Closed

Type Error for Logging #504

chiragvels opened this issue Dec 17, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@chiragvels
Copy link

chiragvels commented Dec 17, 2020

What versions of the client library and Google Ads API are you using?
V6

What environment are you using?
C implementation of protobuf - 3.14.0
gRPC 1.34.0
PHP 7.2.16

Actions taken
Running the GetAdgroups.php example with logging added as

$logPath = '/logs/adgroupExample.log';
        $adsLoggerFactory = new LoggerFactory();
        $logLevel = LogLevel::NOTICE;
        $logger = $adsLoggerFactory->createLogger('adgroupExample', $logPath, $logLevel);

$googleAdsClient = (new GoogleAdsClientBuilder())
                ->fromFile()
                ->withOAuth2Credential($oAuth2Credential)
                ->withLogger($logger)
                ->withLogLevel($logLevel)
                ->build();

Expected result
Adgroups List

Actual result

PHP Fatal error: Uncaught TypeError: Argument 2 passed to Google\Ads\GoogleAds\Lib\V6\GoogleAdsCallLogger::log() must be an instance of Google\Ads\GoogleAds\Lib\V6\object, instance of stdClass given, called in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsLoggingUnaryCall.php on line 55 and defined in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsCallLogger.php:77
Stack trace:
#0 /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsLoggingUnaryCall.php(55): Google\Ads\GoogleAds\Lib\V6\GoogleAdsCallLogger->log(Object(Google\Ads\GoogleAds\Lib\V6\GoogleAdsLoggingUnaryCall), Object(stdClass), Array, Object(Google\Ads\GoogleAds\V6\Services\SearchGoogleAdsResponse))
#1 /google-ads-php/vendor/google/gax/src/Transport/GrpcTransport.php(219): Google\Ads\GoogleAds\Lib\V6\GoogleAdsLoggingUnaryCall->wait()
#2 /google-ads-php/vendor/guzzlehttp/promises/src/Promise.php(248): Google\ApiCore\Transport\GrpcTransport->Google in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsCallLogger.php on line 77

Fatal error: Uncaught TypeError: Argument 2 passed to Google\Ads\GoogleAds\Lib\V6\GoogleAdsCallLogger::log() must be an instance of Google\Ads\GoogleAds\Lib\V6\object, instance of stdClass given, called in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsLoggingUnaryCall.php on line 55 and defined in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsCallLogger.php:77
Stack trace:
#0 /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsLoggingUnaryCall.php(55): Google\Ads\GoogleAds\Lib\V6\GoogleAdsCallLogger->log(Object(Google\Ads\GoogleAds\Lib\V6\GoogleAdsLoggingUnaryCall), Object(stdClass), Array, Object(Google\Ads\GoogleAds\V6\Services\SearchGoogleAdsResponse))
#1 /google-ads-php/vendor/google/gax/src/Transport/GrpcTransport.php(219): Google\Ads\GoogleAds\Lib\V6\GoogleAdsLoggingUnaryCall->wait()
#2 /google-ads-php/vendor/guzzlehttp/promises/src/Promise.php(248): Google\ApiCore\Transport\GrpcTransport->Google in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsCallLogger.php on line 77

@chiragvels chiragvels added the bug Something isn't working label Dec 17, 2020
@PierrickVoulet
Copy link
Collaborator

Hi @chiragvels,

  1. Are you using the v6.1.0 of the client lib?
  2. Do you experience this behavior with v6.0.0?

@chiragvels
Copy link
Author

Hi @PierrickVoulet ,

Yes, I was using v6.1.0 .

I have directly checked at v6.1.0, but I was not experience this on v5

Thanks

@fiboknacky
Copy link
Member

It's really strange. As you're using PHP 7.2, this version should already recognize that object means the object type, not Google\Ads\GoogleAds\Lib\V6\object .
So, it should know that stdClass is of the object type.

I wonder if you change object to \object, will it resolve the issue?

@chiragvels
Copy link
Author

Hi,

It's really strange. As you're using PHP 7.2.

I am assuming this might be issue. I am now try to add docker provided with library and see if issue with my pc only.

I wonder if you change object to \object, will it resolve the issue?
-> I have changed the

public function log(
        ForwardingCall $forwardingCall,
        \object $status,
        array $requestData,
        ?\object $response = null
    )

But still same issue.

Thanks,

@fiboknacky
Copy link
Member

You mean the error message still mentions Google\Ads\GoogleAds\Lib\V6\object?

@chiragvels
Copy link
Author

Hi,

No. Now error is like this

PHP Fatal error: Uncaught TypeError: Argument 2 passed to Google\Ads\GoogleAds\Lib\V6\GoogleAdsCallLogger::log() must be an instance of object, instance of stdClass given, called in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsLoggingUnaryCall.php on line 55 and defined in /google-ads-php/src/Google/Ads/GoogleAds/Lib/V6/GoogleAdsCallLogger.php:77

@fiboknacky
Copy link
Member

Hmm... So, your php -v returns 7.2.16?

@chiragvels
Copy link
Author

Hi,

No, It is return PHP 7.1.33 (cli). Confusion due to different version on CLI.

Sorry for the trouble it is indeed a lower PHP version then 7.2.

I am able to run my code on docker provided with library.

Thanks,

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

No branches or pull requests

3 participants