Bug 25423

Summary: Methods update and empty from Koha::Objects are not class methods
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: 1joynelson, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 23185    
Bug Blocks:    
Attachments: Bug 25423: Add Koha::Exceptions::Object::NotInstantiated
Bug 25423: Unit tests
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated
Bug 25423: Unit tests
Bug 25423: (follow-up) Unit tests
Bug 25423: Force call to update and empty with an instanciated object
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated
Bug 25423: Unit tests
Bug 25423: (follow-up) Unit tests
Bug 25423: Force call to update and empty with an instanciated object
Bug 25423: (follow-up) Fix wrong test

Description Jonathan Druart 2020-05-08 11:12:40 UTC
They should be called with an instance of the class, not directly as class methods:

  Koha::Object->new->empty
vs
  Koha::Object->empty

A trick has been done earlier to accept the second form, but as we notice the same need/problem for another method it seems better to enforce a rule and forbid such calls.

An exception will be raised if the methods are called without an instantiated object.

See also
  commit 4805b9b9dd0a95d79faf450ed1aaaec62d544ec6
  Bug 25296: Make ->empty work for uninstantiated calls
Comment 1 Tomás Cohen Arazi (tcohen) 2020-05-08 11:47:47 UTC
Created attachment 104587 [details] [review]
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 Tomás Cohen Arazi (tcohen) 2020-05-08 11:47:51 UTC
Created attachment 104588 [details] [review]
Bug 25423: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 3 Jonathan Druart 2020-05-08 13:18:22 UTC
Created attachment 104589 [details] [review]
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 4 Jonathan Druart 2020-05-08 13:18:25 UTC
Created attachment 104590 [details] [review]
Bug 25423: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 5 Jonathan Druart 2020-05-08 13:18:28 UTC
Created attachment 104591 [details] [review]
Bug 25423: (follow-up) Unit tests
Comment 6 Jonathan Druart 2020-05-08 13:18:31 UTC
Created attachment 104592 [details] [review]
Bug 25423: Force call to update and empty with an instanciated object
Comment 7 Tomás Cohen Arazi (tcohen) 2020-05-08 13:22:50 UTC
Created attachment 104593 [details] [review]
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 8 Tomás Cohen Arazi (tcohen) 2020-05-08 13:22:55 UTC
Created attachment 104594 [details] [review]
Bug 25423: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 9 Tomás Cohen Arazi (tcohen) 2020-05-08 13:22:59 UTC
Created attachment 104595 [details] [review]
Bug 25423: (follow-up) Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Tomás Cohen Arazi (tcohen) 2020-05-08 13:23:04 UTC
Created attachment 104596 [details] [review]
Bug 25423: Force call to update and empty with an instanciated object

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 11 Jonathan Druart 2020-05-08 13:43:49 UTC
Taking on Martin to push this one for 20.05
Comment 12 Tomás Cohen Arazi (tcohen) 2020-05-08 19:46:54 UTC
Created attachment 104618 [details] [review]
Bug 25423: (follow-up) Fix wrong test

This is confusing: why does it pass on all OSs but Debian 8?

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Joy Nelson 2020-05-11 21:22:56 UTC
not backported to 19.11.x