Skip to content

CI4: Problem in Module model #3349

Closed
Closed

Description

@objecttothis

Background information

  • Reporting an issue of an unmodified OSPOS installation
  • Checked open and closed issues and no similar issue was already reported (please make sure you searched!)
  • Read README, WHATS_NEW, INSTALL.md and UPGRADE
  • Read the FAQ for any known install and/or upgrade gotchas (in specific PHP extensions installed)
  • Read the wiki
  • Executed any database upgrade scripts if an upgrade pre 3.0.0 (e.g. database/2.4_to_3.0.sql)
  • Aware the installation code is in bintray (see README), and GitHub master is for developers only and therefore not complete nor stable

Installation information

  • OSPOS version is: 3.3.5

Issue / Bug / Question / New Feature

The Following code appears at the end of the Module model and I need to properly convert it to the CI4 equivalent. The problem is that the query doesn't make sense to me. This code was added about four years ago in code that @daN4cat and @SteveIreland worked on to add the office menu.

	/**
	 * This method is used to show the office navigation icon on the home page
	 * which happens when the sort value is greater than zero
	 */
	public function get_show_office_group()
	{
		$this->db->select('sort');
		$this->db->from('grants');
		$this->db->where('module_id', 'office');
		$this->db->from('modules');
		return $this->db->get()->row()->sort;
	}

The function seems to be returning the value of sort (int) from the modules table. Both the sort and module_id fields appear in the modules table. The question is: what is the intention with the $this->db->from('grants'); line? Was it meant to be a JOIN modules ON grants.menu_group = modules.module_id?

I may be mistaken, but I've never seen multiple from calls in the same QueryBuilder calls in the same way that you can do multiple where() or join(). Can anyone shed some light on this one for me?

Activity

  1. linked a pull request that will close this issueUpgrade CI to 4.1.3 (Old) #3271on Nov 2, 2021
  2. daN4cat commented on Nov 2, 2021

    @daN4cat
    Collaborator

    My mind is blank on this story I'm afraid.

  3. jekkos commented on Nov 16, 2021

    @jekkos
    Member

    Not sure how this query looks like, can you print a this->db->last_query() after to see how it looks like?

  4. stale commented on Dec 16, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  5. SteveIreland commented on Dec 20, 2021

    @SteveIreland
    Collaborator

    Looks like a copy and paste that went bad. I believe that the intent was to replace grants with modules. It wasn't caught in testing because apparently the generated SQL does enough that it passed the limited testing that was done on it.

  6. objecttothis commented on Dec 20, 2021

    @objecttothis
    MemberAuthor

    Looks like a copy and paste that went bad. I believe that the intent was to replace grants with modules. It wasn't caught in testing because apparently the generated SQL does enough that it passed the limited testing that was done on it.

    Thank you @SteveIreland. If I understand correctly, the code should look like this?

    /**
    	 * This method is used to show the office navigation icon on the home page
    	 * which happens when the sort value is greater than zero
    	 */
    	public function get_show_office_group()
    	{
    		$this->db->select('sort');
    		$this->db->where('module_id', 'office');
    		$this->db->from('modules');
    
    		return $this->db->get()->row()->sort;
    	}
    

    This makes sense because the grants table do not have a columns called sort or module_id. We should probably test that change outside of my change from CI3 to CI4. God knows that the CI3->CI4 change is going to need to be heavily regression tested.

  7. SteveIreland commented on Dec 20, 2021

    @SteveIreland
    Collaborator

    That should work.

  8. mrsarith commented on Jan 20, 2022

    @mrsarith

    Hello,

    May you help me,please? I have one issue relate missing title on Modal form. I dont know I touch sth where else. That why, all title got blank.

    here is my screenshot.

    https://docs.google.com/document/d/1mSDYP13qqObWKmM7xpc55W_YmVk7Nn6T9-CJq0nO8pE/edit?usp=sharing

    ]
    Sarith

  9. daN4cat commented on Jan 21, 2022

    @daN4cat
    Collaborator

    @mrsarith , is that from a modified OSPOS?

  10. changed the title [-]Problem in Module model[/-] [+]CI4: Problem in Module model[/+] on Apr 1, 2022
  11. objecttothis commented on Apr 12, 2022

    @objecttothis
    MemberAuthor

    Fixed in #3271

  12. added this to the 3.4.0 milestone on Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions