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

SocialApiService: Call to a member function supportsContact() on null #2348

Closed
juliusknorr opened this issue Jul 12, 2021 · 5 comments · Fixed by #2351
Closed

SocialApiService: Call to a member function supportsContact() on null #2348

juliusknorr opened this issue Jul 12, 2021 · 5 comments · Fixed by #2351
Labels

Comments

@juliusknorr
Copy link
Member

Describe the bug

Error on SocialUpdate background job

Error: Call to a member function supportsContact() on null

Full trace at: https://sentry.io/share/issue/836e7100013b4de9824a5bc95b31d426/

To Reproduce
Steps to reproduce the behavior:

  1. Enable update avatars from social media
  2. Let the cronjob run

Expected behavior
No errors in the logs

Actual behavior
See error log linked above

Server configuration

Operating system: Windows, Linux, MacOS...

Web server: Apache

Database: MariaDB

PHP version: 8.0

Nextcloud version: 22.0.0

Contacts version: 4.0.0

Updated from an older Nextcloud or fresh install: Updated

@call-me-matt
Copy link
Member

call-me-matt commented Jul 14, 2021

I do not see this error in my logs with same server configuration. I suppose you do have contacts in your address book?
I manually reset last_run timestamps in the jobs-table and triggered cron multiple times. saw background jobs being created correctly, but not sure if follow-ups should have been created. I expected it to run in several chunks which I did not see in my tests. (I did not follow up on this, as there are unit-tests for this)
Maybe you can help me to reproduce this error better?

@juliusknorr
Copy link
Member Author

I only had a quick look at the code but I couldn't see any handling of the any string that is passed in here:

$result = $this->social->updateAddressbooks('any', $userId, $offsetBook, $offsetContact);

To me it seems as if that is just not handled properly as it would basically result in a $allConnectors = [null]; within

$allConnectors = [$this->socialProvider->getSocialConnector($network)];
and then directly lead to the error.

The tests I looked add might not catch that though, since the provider is mocked there independent on the network:

$this->setupAddressbooks();
$result = $this->service->updateAddressbooks('any', 'mrstest');

->willReturn($provider);

If you need any additional info let me know.

@call-me-matt
Copy link
Member

ah, yes.
So should we simply check for this keyword here?
if ($network && $network != 'any') {

@juliusknorr
Copy link
Member Author

I pushed the patch i had in mind to #2351 but it showed up further errors once it passes to the actual providers

image

https://sentry.io/share/issue/d247613a85f14dff9abeddb287d1bf73/

@call-me-matt
Copy link
Member

Thank you, it looks fine. I will add some checks in the supportsContact functions to return false if no respective field is set so the error log will be clean again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants