contacts icon indicating copy to clipboard operation
contacts copied to clipboard

Avoid Undefined offset: 0 error by testing if the element exists before accessing it

Open tcitworld opened this issue 3 years ago • 2 comments

{
  "reqId": "YqVbQXz6WFiKbxaTMqzD",
  "level": 3,
  "time": "2022-07-27T08:52:24+02:00",
  "remoteAddr": "",
  "user": "--",
  "app": "PHP",
  "method": "",
  "url": "--",
  "message": "Undefined offset: 0 at /var/www/nextcloud/apps/contacts/lib/Service/SocialApiService.php#186",
  "userAgent": "--",
  "version": "24.0.3.2",
  "exception": {
    "Exception": "Error",
    "Message": "Undefined offset: 0 at /var/www/nextcloud/apps/contacts/lib/Service/SocialApiService.php#186",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/apps/contacts/lib/Service/SocialApiService.php",
        "line": 186,
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/contacts/lib/Service/SocialApiService.php",
        "line": 413,
        "function": "updateContact",
        "class": "OCA\\Contacts\\Service\\SocialApiService",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/contacts/lib/Cron/SocialUpdate.php",
        "line": 66,
        "function": "updateAddressbooks",
        "class": "OCA\\Contacts\\Service\\SocialApiService",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
        "line": 79,
        "function": "run",
        "class": "OCA\\Contacts\\Cron\\SocialUpdate",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php",
        "line": 47,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 151,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  }
}

tcitworld avatar Jul 27 '22 06:07 tcitworld

/backport to stable4.2

tcitworld avatar Jul 27 '22 06:07 tcitworld

Codecov Report

Base: 31.41% // Head: 31.45% // Increases project coverage by +0.03% :tada:

Coverage data is based on head (17f8fbd) compared to base (eb03563). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2869      +/-   ##
============================================
+ Coverage     31.41%   31.45%   +0.03%     
  Complexity      253      253              
============================================
  Files           110      110              
  Lines          1862     1863       +1     
  Branches        217      217              
============================================
+ Hits            585      586       +1     
  Misses         1162     1162              
  Partials        115      115              
Impacted Files Coverage Δ
lib/Service/SocialApiService.php 89.67% <100.00%> (+0.06%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jul 27 '22 07:07 codecov[bot]

Rebased (and fixed)

tcitworld avatar Oct 19 '22 13:10 tcitworld

/backport to stable5.0

ChristophWurst avatar Oct 19 '22 14:10 ChristophWurst