Project

General

Profile

Bug #14458

Taxonomy search should search with STI base class

Added by Shlomi Zadok almost 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When searching with taxonomy scope, We are looking by model name. This may cause no results if the model is an STI child as the inner_select method adds the model.name (ArfReport) and not the base class name ("Report", which is what is saved in the taxable_taxonomies).
https://github.com/theforeman/foreman/blob/develop/app/models/concerns/taxonomix.rb#L99-L113

A possible solution: condition should change to self.base_class.name
If it is an STI it will call the parent name. If not an STI, it will call itself (current behavior).
Example: https://github.com/theforeman/foreman_openscap/pull/157/files#diff-219a837adc650cf4c4ceae3c8a76eb7dR176


Related issues

Related to OpenSCAP - Bug #14446: compliance reports from a particular org should be visible when org context is setResolved2016-04-04

Associated revisions

Revision d96297b1 (diff)
Added by Marek Hulán almost 4 years ago

Fixes #14458 - use a base class for STI taxable objects

Revision f71f5493 (diff)
Added by Marek Hulán almost 4 years ago

Fixes #14458 - use a base class for STI taxable objects

(cherry picked from commit d96297b17f55469e3c49c90979cbd004d80f461c)

History

#1 Updated by Marek Hulán almost 4 years ago

  • Tracker changed from Refactor to Bug
  • Status changed from New to Assigned
  • Assignee set to Marek Hulán

This was found in foreman_openscap plugin to get an idea you could imagine the issue with core models like this

User.current = User.first
Organization.current = Organization.first
Location.current = Location.first

# loads all libvirts associated with first org and loc
# through TaxableTaxonomy which has column taxable_type that 
# specifies object class - Foreman::Model::Libvirt in this case
Foreman::Model::Libvirt.all 

supposing you have some libvirt associated to selected orgs and locs you'll still see [] as result since it uses Foreman::Model::Libvirt for taxable_type column in SQL query. Well, in this case it actually works because Taxonomix is included in ComputeResource directly so the same name is stored in taxable_type but if you think about model that is inherited in a plugin and adds taxonomies, it does not work.

#2 Updated by The Foreman Bot almost 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3389 added

#3 Updated by Marek Hulán almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 141

#5 Updated by Marek Hulán almost 4 years ago

  • Related to Bug #14446: compliance reports from a particular org should be visible when org context is set added

Also available in: Atom PDF