Arbit - project tracking

PHPillow - PHP CouchDB connector

#12: fetchById does not check the type

Issue attachments

Issue revisions

  • new by PHPGangsta at 2010-O-29 16:51
  • new by PHPGangsta at 2010-O-29 16:51
  • assigned by kore at 2011-J-05 11:19
  • closed by kore at 2011-J-05 11:23
Type bug bug
State closed closed
Priority low low
Resolution implemented implemented
Assigned to kore
Scheduled for 0.6-alpha
Affected versions 0.5-alpha
Affected components Core
Last change Wednesday 5 January 2011 11:23:22 UTC by kore

Short description

When using fetchById with an document ID which does not match the type of the class, there should be an exception thrown.

Steps to reproduce

$doc = phpillowUserDocument::createNew(); $doc->login = 'kore'; $doc->save();

$group = new phpillowGroupDocument(); $group->fetchById($doc->_id);

Expected behavior

Above code should throw an exception

Actual behavior

document is loaded "correctly"

  • PHPGangsta at Friday 29 October 2010 17:09:58 UTC

    Attached a patch with additional check for type when loading a document. Includes 2 tests.

    While fixing this I also found some other problems (static calls of non-static methods, wrong phpdoc, some trailing spaces, many spelling mistakes) which are also in this patch, hope this is no problem.

    You can also search the code for "phpillowDatabaseNotFoundErrorException". This class is used, but not defined. But I don't know how to correct that 2 lines.

  • kore at Wednesday 5 January 2011 11:23:22 UTC

    Implemented in revision #160.