Bug 20566

Summary: Remove 'single' method from Koha::Objects
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: DatabaseAssignee: Bugs List <koha-bugs>
Status: CLOSED INVALID QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description Martin Renvoize 2018-04-11 15:38:32 UTC
We're exposing ourselves to terrible bugs which dbix::class goes to lengths to inform the developer about before they're added by circumventing the protections built into dbic here.

By hard coding a 'rows => 1' into this method instead of just using the method from DBIC we are ensuring the developer will never be informed of their stupidity if they have not added any form or ordering to their database clauses. As such, the order of the results returned and as such the result of the 'single' call is now entirely random.
Comment 1 Jonathan Druart 2018-04-11 15:40:44 UTC
Hum?

188 sub single {
189     my ($self) = @_;
190 
191     my $single = $self->_resultset()->single;
192     return unless $single;
193 
194     return $self->object_class()->_new_from_dbic($single);
195 }