Skip to content

Better feedback when accidentally inputting ID 0 into a new ORM object #1

@joepie91

Description

@joepie91

When reusing a value from elsewhere by inputting it into the constructor for a CPHPDatabaseRecordClass-derived object, and that value happens to be 0, any sufficient calls to properties will result in a cryptic "check your schema" error.

Example problematic code:

$value = 0; /* pretend this came from an external source */

$sSomething = new Something($value);
echo($sSomething->sSomeProperty); /* throws schema error */

Fix: if an object is marked as 'new' (that is, not originating from the database and created with a source value of either 0 or nothing), throw a more specific exception when the code attempts to access a property, indicating that no data has been loaded into the object yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions