Skip to content

Error when trying to create version directory structure #591

Closed
@juliusknorr

Description

This trace blocked file creation from templates where there is a second write to a file:

It looks like the path extraction logic is not working properly if the versions backend tries to create missing directory structures (when the file is written in a subdirectory).

{
  "reqId": "bOWsJWruz89BUKyg3hqR",
  "level": 3,
  "time": "2024-09-01T11:26:12+00:00",
  "remoteAddr": "95.118.78.43",
  "user": "christine",
  "app": "no app in context",
  "method": "POST",
  "url": "/ocs/v2.php/apps/files/api/v1/templates/create",
  "message": "substr(): Argument #3 ($length) must be of type ?int, bool given in file '/var/www/example.com/apps/files_accesscontrol/lib/Operation.php' line 137",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0",
  "version": "30.0.0.11",
  "exception": {
    "Exception": "Exception",
    "Message": "substr(): Argument #3 ($length) must be of type ?int, bool given in file '/var/www/example.com/apps/files_accesscontrol/lib/Operation.php' line 137",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/example.com/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/example.com/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/example.com/ocs/v1.php",
        "line": 43,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/example.com/ocs/v2.php",
        "line": 7,
        "args": [
          "/var/www/example.com/ocs/v1.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/example.com/lib/private/AppFramework/Http/Dispatcher.php",
    "Line": 146,
    "Previous": {
      "Exception": "TypeError",
      "Message": "substr(): Argument #3 ($length) must be of type ?int, bool given",
      "Code": 0,
      "Trace": [
        {
          "file": "/var/www/example.com/apps/files_accesscontrol/lib/Operation.php",
          "line": 137,
          "function": "substr"
        },
        {
          "file": "/var/www/example.com/apps/files_accesscontrol/lib/Operation.php",
          "line": 63,
          "function": "translatePath",
          "class": "OCA\\FilesAccessControl\\Operation",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/apps/files_accesscontrol/lib/StorageWrapper.php",
          "line": 43,
          "function": "checkFileAccess",
          "class": "OCA\\FilesAccessControl\\Operation",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/apps/files_accesscontrol/lib/StorageWrapper.php",
          "line": 58,
          "function": "checkFileAccess",
          "class": "OCA\\FilesAccessControl\\StorageWrapper",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/Storage/Wrapper/Wrapper.php",
          "line": 69,
          "function": "mkdir",
          "class": "OCA\\FilesAccessControl\\StorageWrapper",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/View.php",
          "line": 1136,
          "function": "mkdir",
          "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/View.php",
          "line": 208,
          "function": "basicOperation",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/apps/files_versions/lib/Storage.php",
          "line": 959,
          "function": "mkdir",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/apps/files_versions/lib/Versions/LegacyVersionsBackend.php",
          "line": 150,
          "function": "createMissingDirectories",
          "class": "OCA\\Files_Versions\\Storage",
          "type": "::",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/example.com/apps/files_versions/lib/Versions/VersionManager.php",
          "line": 81,
          "function": "createVersion",
          "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/example.com/apps/files_versions/lib/Storage.php",
          "line": 209,
          "function": "createVersion",
          "class": "OCA\\Files_Versions\\Versions\\VersionManager",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/example.com/apps/files_versions/lib/Listener/FileEventsListener.php",
          "line": 174,
          "function": "store",
          "class": "OCA\\Files_Versions\\Storage",
          "type": "::"
        },
        {
          "file": "/var/www/example.com/apps/files_versions/lib/Listener/FileEventsListener.php",
          "line": 80,
          "function": "write_hook",
          "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/EventDispatcher/ServiceEventListener.php",
          "line": 68,
          "function": "handle",
          "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 230,
          "function": "__invoke",
          "class": "OC\\EventDispatcher\\ServiceEventListener",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 59,
          "function": "callListeners",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 67,
          "function": "dispatch",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 79,
          "function": "dispatch",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/Node/HookConnector.php",
          "line": 74,
          "function": "dispatchTyped",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/legacy/OC_Hook.php",
          "line": 82,
          "function": "write",
          "class": "OC\\Files\\Node\\HookConnector",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/View.php",
          "line": 1252,
          "function": "emit",
          "class": "OC_Hook",
          "type": "::"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/View.php",
          "line": 1119,
          "function": "runHooks",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/View.php",
          "line": 644,
          "function": "basicOperation",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/Node/File.php",
          "line": 52,
          "function": "file_put_contents",
          "class": "OC\\Files\\View",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/apps/richdocuments/lib/Listener/FileCreatedFromTemplateListener.php",
          "line": 62,
          "function": "putContent",
          "class": "OC\\Files\\Node\\File",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/EventDispatcher/ServiceEventListener.php",
          "line": 68,
          "function": "handle",
          "class": "OCA\\Richdocuments\\Listener\\FileCreatedFromTemplateListener",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 230,
          "function": "__invoke",
          "class": "OC\\EventDispatcher\\ServiceEventListener",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 59,
          "function": "callListeners",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 67,
          "function": "dispatch",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 79,
          "function": "dispatch",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Files/Template/TemplateManager.php",
          "line": 162,
          "function": "dispatchTyped",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/apps/files/lib/Controller/TemplateController.php",
          "line": 69,
          "function": "createFromTemplate",
          "class": "OC\\Files\\Template\\TemplateManager",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/example.com/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 208,
          "function": "create",
          "class": "OCA\\Files\\Controller\\TemplateController",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/example.com/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 114,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/AppFramework/App.php",
          "line": 161,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/lib/private/Route/Router.php",
          "line": 302,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::"
        },
        {
          "file": "/var/www/example.com/ocs/v1.php",
          "line": 43,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->"
        },
        {
          "file": "/var/www/example.com/ocs/v2.php",
          "line": 7,
          "args": [
            "/var/www/example.com/ocs/v1.php"
          ],
          "function": "require_once"
        }
      ],
      "File": "/var/www/example.com/apps/files_accesscontrol/lib/Operation.php",
      "Line": 137
    },
    "message": "substr(): Argument #3 ($length) must be of type ?int, bool given in file '/var/www/example.com/apps/files_accesscontrol/lib/Operation.php' line 137",
    "exception": {},
    "CustomMessage": "substr(): Argument #3 ($length) must be of type ?int, bool given in file '/var/www/example.com/apps/files_accesscontrol/lib/Operation.php' line 137"
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions