Bug 25423 - Methods update and empty from Koha::Objects are not class methods
Summary: Methods update and empty from Koha::Objects are not class methods
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 23185
Blocks:
  Show dependency treegraph
 
Reported: 2020-05-08 11:12 UTC by Jonathan Druart
Modified: 2023-05-23 14:51 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated (2.91 KB, patch)
2020-05-08 11:47 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 25423: Unit tests (2.20 KB, patch)
2020-05-08 11:47 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated (2.91 KB, patch)
2020-05-08 13:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25423: Unit tests (2.20 KB, patch)
2020-05-08 13:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25423: (follow-up) Unit tests (1.01 KB, patch)
2020-05-08 13:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25423: Force call to update and empty with an instanciated object (1.22 KB, patch)
2020-05-08 13:18 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated (2.91 KB, patch)
2020-05-08 13:22 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 25423: Unit tests (2.20 KB, patch)
2020-05-08 13:22 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 25423: (follow-up) Unit tests (1.06 KB, patch)
2020-05-08 13:22 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 25423: Force call to update and empty with an instanciated object (1.27 KB, patch)
2020-05-08 13:23 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 25423: (follow-up) Fix wrong test (901 bytes, patch)
2020-05-08 19:46 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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