Skip to content

imagedestroy(): Argument #1 ($image) must be of type GdImage, bool given #29990

Closed

Description

@solracsf

NC 22.2.3 with PHP 8.0.13
Cc @come-nc as you've worked on it at #29479

{
  "reqId": "m4ntpS1uGWE18wMmZMZa",
  "level": 4,
  "time": "2021-11-30T10:59:20+00:00",
  "app": "webdav",
  "method": "GET",
  "url": "/remote.php/dav/addressbooks/system/system/system/user_saml:pas.dof@ha.pl.vcf?photo&size=128",
  "message": "imagedestroy(): Argument #1 ($image) must be of type GdImage, bool given",
  "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/96.0.4664.53 Mobile/15E148 Safari/604.1",
  "version": "22.2.3.0",
  "exception": {
    "Exception": "TypeError",
    "Message": "imagedestroy(): Argument #1 ($image) must be of type GdImage, bool given",
    "Code": 0,
    "Trace": [
      {
        "file": "/lib/private/legacy/OC_Image.php",
        "line": 879,
        "function": "imagedestroy",
        "args": [
          false
        ]
      },
      {
        "file": "/apps/dav/lib/CardDAV/PhotoCache.php",
        "line": 163,
        "function": "resize",
        "class": "OC_Image",
        "type": "->",
        "args": [
          128
        ]
      },
      {
        "file": "/apps/dav/lib/CardDAV/PhotoCache.php",
        "line": 95,
        "function": "getFile",
        "class": "OCA\\DAV\\CardDAV\\PhotoCache",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\Files\\SimpleFS\\SimpleFolder"
          },
          128
        ]
      },
      {
        "file": "/apps/dav/lib/CardDAV/ImageExportPlugin.php",
        "line": 104,
        "function": "get",
        "class": "OCA\\DAV\\CardDAV\\PhotoCache",
        "type": "->",
        "args": [
          "2",
          "user_saml:pal.doft@ha.fr.vcf",
          128,
          {
            "__class__": "Sabre\\CardDAV\\Card"
          }
        ]
      },
      {
        "file": "/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpGet",
        "class": "OCA\\DAV\\CardDAV\\ImageExportPlugin",
        "type": "->",
        "args": [
          {
            "__class__": "Sabre\\HTTP\\Request"
          },
          {
            "__class__": "Sabre\\HTTP\\Response"
          }
        ]
      },
      {
        "file": "/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "method:GET",
          [
            {
              "__class__": "Sabre\\HTTP\\Request"
            },
            {
              "__class__": "Sabre\\HTTP\\Response"
            }
          ]
        ]
      },
      {
        "file": "/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          {
            "__class__": "Sabre\\HTTP\\Request"
          },
          {
            "__class__": "Sabre\\HTTP\\Response"
          }
        ]
      },
      {
        "file": "/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/apps/dav/lib/Server.php",
        "line": 333,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/apps/dav/appinfo/v2/remote.php",
        "line": 35,
        "function": "exec",
        "class": "OCA\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/remote.php",
        "line": 166,
        "args": [
          "/apps/dav/appinfo/v2/remote.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/lib/private/legacy/OC_Image.php",
    "Line": 879,
    "CustomMessage": "--"
  },
  "id": "61a658026d4c5"
}

Activity

  1. added
    0. Needs triage
    on Nov 30, 2021
  2. come-nc commented on Dec 2, 2021

    @come-nc
    Contributor

    You should have this line in the log:
    $this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
    Can you check?

    If resource is false resize cannot work. It should indeed be tested in resize and not only resizeNew.

    From what I understand, this was a warning <8, and is now a Fatal error instead. Also, «This function has no effect. Prior to PHP 8.0.0, this function was used to close the resource.».
    So we get a fatal error about giving the wrong type to a function that does nothing…

    PR incoming.

  3. self-assigned this
    on Dec 2, 2021
  4. added
    2. developing
    and removed
    0. Needs triage
    on Dec 2, 2021
  5. solracsf commented on Dec 2, 2021

    @solracsf
    MemberAuthor

    The only surrounding error is:

    {
      "exception": {
        "Exception": "Error",
        "Message": "imagecreatefromstring(): Data is not in a recognized format at /lib/private/legacy/OC_Image.php#652",
        "Code": 0,
        "Trace": [
          {
            "function": "onError",
            "class": "OC\\Log\\ErrorHandler",
            "type": "::",
            "args": [
              2,
              "imagecreatefromstring(): Data is not in a recognized format",
              "/lib/private/legacy/OC_Image.php",
              652
            ]
          },
          {
            "file": "/lib/private/legacy/OC_Image.php",
            "line": 652,
            "function": "imagecreatefromstring",
            "args": [
              "*** sensitive parameters replaced ***"
            ]
          },
          {
            "file": "/lib/private/Preview/Image.php",
            "line": 52,
            "function": "loadFromFile",
            "class": "OC_Image",
            "type": "->",
            "args": [
              "/datapool/data/Isabelle/files/Nextcloud.png"
            ]
          },
          {
            "file": "/lib/private/Preview/GeneratorHelper.php",
            "line": 62,
            "function": "getThumbnail",
            "class": "OC\\Preview\\Image",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              4096,
              4096
            ]
          },
          {
            "file": "/lib/private/Preview/Generator.php",
            "line": 245,
            "function": "getThumbnail",
            "class": "OC\\Preview\\GeneratorHelper",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Preview\\PNG"
              },
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              4096,
              4096
            ]
          },
          {
            "file": "/lib/private/Preview/Generator.php",
            "line": 140,
            "function": "getMaxPreview",
            "class": "OC\\Preview\\Generator",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Files\\SimpleFS\\SimpleFolder"
              },
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              "image/png",
              ""
            ]
          },
          {
            "file": "/lib/private/Preview/Generator.php",
            "line": 109,
            "function": "generatePreviews",
            "class": "OC\\Preview\\Generator",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              [
                {
                  "width": 375,
                  "height": 375,
                  "crop": true,
                  "mode": "fill"
                }
              ],
              "image/png"
            ]
          },
          {
            "file": "/lib/private/PreviewManager.php",
            "line": 189,
            "function": "getPreview",
            "class": "OC\\Preview\\Generator",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              375,
              375,
              true,
              "fill",
              null
            ]
          },
          {
            "file": "/core/Controller/PreviewController.php",
            "line": 169,
            "function": "getPreview",
            "class": "OC\\PreviewManager",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              375,
              375,
              true,
              "fill"
            ]
          },
          {
            "file": "/core/Controller/PreviewController.php",
            "line": 142,
            "function": "fetchPreview",
            "class": "OC\\Core\\Controller\\PreviewController",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Files\\Node\\File"
              },
              375,
              375,
              false,
              false,
              "fill"
            ]
          },
          {
            "file": "/lib/private/AppFramework/Http/Dispatcher.php",
            "line": 217,
            "function": "getPreviewByFileId",
            "class": "OC\\Core\\Controller\\PreviewController",
            "type": "->",
            "args": [
              15339322,
              375,
              375,
              false,
              false,
              "fill"
            ]
          },
          {
            "file": "/lib/private/AppFramework/Http/Dispatcher.php",
            "line": 126,
            "function": "executeController",
            "class": "OC\\AppFramework\\Http\\Dispatcher",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Core\\Controller\\PreviewController"
              },
              "getPreviewByFileId"
            ]
          },
          {
            "file": "/lib/private/AppFramework/App.php",
            "line": 156,
            "function": "dispatch",
            "class": "OC\\AppFramework\\Http\\Dispatcher",
            "type": "->",
            "args": [
              {
                "__class__": "OC\\Core\\Controller\\PreviewController"
              },
              "getPreviewByFileId"
            ]
          },
          {
            "file": "/lib/private/Route/Router.php",
            "line": 302,
            "function": "main",
            "class": "OC\\AppFramework\\App",
            "type": "::",
            "args": [
              "OC\\Core\\Controller\\PreviewController",
              "getPreviewByFileId",
              {
                "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
              },
              {
                "_route": "core.Preview.getPreviewByFileId"
              }
            ]
          },
          {
            "file": "/lib/base.php",
            "line": 1006,
            "function": "match",
            "class": "OC\\Route\\Router",
            "type": "->",
            "args": [
              "/core/preview"
            ]
          },
          {
            "file": "/index.php",
            "line": 36,
            "function": "handleRequest",
            "class": "OC",
            "type": "::",
            "args": []
          }
        ],
        "File": "/lib/private/Log/ErrorHandler.php",
        "Line": 92,
        "CustomMessage": "--"
      },
      "id": "61a8a88d95e44"
    }
    
  6. come-nc commented on Dec 2, 2021

    @come-nc
    Contributor

    @acsfer Can you test the PR?

  7. solracsf commented on Dec 2, 2021

    @solracsf
    MemberAuthor

    Will do, tomorrow.

  8. reopened this on Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

2. developingbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions