Skip to content

Make db-credentials and db-backup compatible with ConfigReadShell #32

Description

@beporter

Our new approach to defining DB connection settings is to put them in Configure and have DATABASE_CONFIG::__construct() extract them into class properties. This has the side effect of breaking the db-credentials and db-backup "shell" scripts (which are actually implemented in PHP) since they both try to include('Config/database.php') in order to extract the connection values from the ::$default property.

This no longer works in a command line context because the DATABASE_CONFIG class now depends on the Configure class and a host of other associated Cake core libs. These classes are not available without the Cake bootstrapping process, so it's no longer possible to directly instantiate DATABASE_CONFIG. There are two alternatives:

  1. Define our own very crude Configure class that has no other dependencies and use it to extract the values we need from Config/core.php.
  2. Detect the presence of the Loadsys/ConfigReadShell plugin, and use bin/cake config_read.config_read Database.default to obtain the DB connection values we need. (This approach has already been implemented in the EducationUnlimited legacy app, which has its own static copies of db-credentials and db-backup.)

Ideally, both approaches should be used so that the db-* scripts remain as versatile and "unspecialized" as possible.

Activity

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

Metadata

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