[Bug 39488] New: Update Koha::Object(s) to allow for polymorphic classing
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Bug ID: 39488 Summary: Update Koha::Object(s) to allow for polymorphic classing Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org This splits out the proof of concept code in bug 39190 that allows for polymorphic Koha Object classing. We update our Koha::Object(s) classes to pass back $result and propose a signature for class selection with resultsets. This allows for subclassing of an object based on a field in a shared table so one can keep methods grouped for their tasks more easily. Example use cases are (S)FTP where we want to store the basic transport details in one table and then dynamically load the right set of transport protocol specific methods based on the transport type. We might also want to update the Account Line classes to work in a similar way, where we store both debits and credits in one table and would want some shared and some specific methods based on the account line type. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |39190 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39190 [Bug 39190] Rework new (S)FTP classes to be polymorphic classes -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 179985 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=179985&action=edit Bug 39488: Add $result to Koha::Objects `object_class` calls This allows us to do dynamic polymorphic classing on calls to 'find', 'find_or_create', 'single', 'next', 'last' and 'as_list' etc. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 179986 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=179986&action=edit Bug 39488: Add template for required polymorphic class methods -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 179987 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=179987&action=edit Bug 39488: Use introspection in TestBuilder tests We update the testbuilder tests here to look for signs of a polymorphic class map and use it to test the different class options for this base class Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Hmm, I'm struggling to come up with explicit tests for these changes. The main change here is that we consistently pass the original DBIx::Class row objects into the object_class meta method so that we can query the content to ascertain which polymorphpihc subclass to use for the subsequent _new_from_dbic calls. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 180189 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=180189&action=edit Bug 39488: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Transferring Kyles SO from the bug this was split out from. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paul.derscheid@lmscloud.de -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #179985|0 |1 is obsolete| | --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 185006 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185006&action=edit Bug 39488: Add $result to Koha::Objects `object_class` calls This allows us to do dynamic polymorphic classing on calls to 'find', 'find_or_create', 'single', 'next', 'last' and 'as_list' etc. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #179986|0 |1 is obsolete| | --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 185007 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185007&action=edit Bug 39488: Add template for required polymorphic class methods -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #179987|0 |1 is obsolete| | --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 185008 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185008&action=edit Bug 39488: Use introspection in TestBuilder tests We update the testbuilder tests here to look for signs of a polymorphic class map and use it to test the different class options for this base class Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #180189|0 |1 is obsolete| | --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 185009 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185009&action=edit Bug 39488: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com QA Contact|testopia@bugs.koha-communit |tomascohen@gmail.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #185006|0 |1 is obsolete| | Attachment #185007|0 |1 is obsolete| | Attachment #185008|0 |1 is obsolete| | Attachment #185009|0 |1 is obsolete| | --- Comment #11 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 185931 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185931&action=edit Bug 39488: Add $result to Koha::Objects `object_class` calls This allows us to do dynamic polymorphic classing on calls to 'find', 'find_or_create', 'single', 'next', 'last' and 'as_list' etc. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #12 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 185932 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185932&action=edit Bug 39488: Add template for required polymorphic class methods Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #13 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 185933 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185933&action=edit Bug 39488: Use introspection in TestBuilder tests We update the testbuilder tests here to look for signs of a polymorphic class map and use it to test the different class options for this base class Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #14 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 185934 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=185934&action=edit Bug 39488: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |BLOCKED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|BLOCKED |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |25.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 --- Comment #15 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to main for 25.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |release-notes-needed --- Comment #16 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Can you please add release notes? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |Koha's object framework now release notes| |supports polymorphic | |classing, allowing | |different object subclasses | |to be instantiated based on | |field values in shared | |database tables. | | | |This enhancement updates | |`Koha::Object` and | |`Koha::Objects` classes to | |pass the original | |`DBIx::Class` result object | |to the `object_class` | |method, enabling dynamic | |class selection based on | |record content. This works | |across all standard | |retrieval methods including | |`find`, `find_or_create`, | |`single`, `next`, `last`, | |and `as_list`. | | | |**Use cases:** | | | |- Transport protocols | |(FTP/SFTP) sharing a common | |table but requiring | |protocol-specific methods | |- Account lines where | |debits and credits share a | |table but need | |type-specific behaviour | |- Any scenario where | |related object types share | |storage but require | |distinct method | |implementations | | | |**For developers:** | | | |To implement polymorphic | |classes, define a | |`_polymorphic_class_map` | |method in your | |`Koha::Objects` class that | |returns a hashref mapping | |field values to class | |names. The framework will | |automatically instantiate | |the appropriate subclass | |based on the stored data. | | | |A template for implementing | |polymorphic classes is | |included in the codebase. | |Test::Builder has also been | |updated to introspect | |polymorphic class maps for | |comprehensive testing. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|release-notes-needed | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 Laura Escamilla <Laura.escamilla@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to main |Needs documenting CC| |Laura.escamilla@bywatersolu | |tions.com --- Comment #17 from Laura Escamilla <Laura.escamilla@bywatersolutions.com> --- This is an enhancement and will not be backported to the 25.05.x branch. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39488 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED CC| |david@davidnind.com Resolution|--- |FIXED --- Comment #18 from David Nind <david@davidnind.com> --- Architecture change, no UI changes, no changes required to the manual. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org