Skip to content

Rearchitect the Files Module, part 2: storage abstraction (Phase 1) #394

Description

@caseysoftware

Intent: introduce a storage abstraction built on Flysystem, with the local disk as the only backend, without changing behavior or the on-disk layout.

Before starting: folder fixes #405, #406, #407, #408, #409, #410, #411.

Steps

  • Set the PHP baseline: add "php": ">=8.2" to composer.json.
  • Add league/flysystem 3.x and its local adapter.
  • Add w2p_Storage_Driver, _Registry, _Service, _Factory and w2p_Storage_Exception, with local (rooted at W2P_BASE_DIR/files, not configurable) and in-memory drivers.
  • Migration: files.file_backend (default local), file_storage_key, file_etag.
  • Move $_FILES, move_uploaded_file, $AppUI->setMsg() and die() out of the backend into the controllers; read returns a stream.
  • Replace CFile::getFileSystem() with getStorage(); keep w2p_FileSystem_Local and the deprecated CFile methods as shims for one release.
  • Enforce __nonce on every Files and Folders handler (do_file_aed, do_folder_aed, do_files_bulk_aed).
  • Replace files/.htaccess and files/temp/.htaccess with Apache 2.4 deny rules (Require all denied, 2.2 fallback), and add an nginx example that denies /files/.
  • Contract test suite, run against both drivers.

The Category, Project and Owner list filters from the original issue are already on master.

Goal: local storage runs through the new layer with an identical on-disk layout, the contract tests pass, and /files/... returns 403 on Apache 2.4 and nginx.

Spec: Pluggable File Backend proposal (#404).

Original scope

Extend the Files Module:

  • refactor to a "local" storage backend
  • add filters on the list view for Category, Project, and Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions