Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-53823

Expression always true

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0.3
    • None
    • Navigation
    • MOODLE_30_STABLE
    • Easy

    Description

      In file moodle/lib/navigationlib.php at line 1592 there is a expression

      (($category->type != self::TYPE_CATEGORY) || ($category->type != self::TYPE_MY_CATEGORY)) 
      

      But it is always true:
      if $category->type is self::TYPE_CATEGORY then ($category->type != self::TYPE_CATEGORY) is true, so whole expression is true
      if $category->type is self::TYPE_MY_CATEGORY then ($category->type != self::TYPE_MY_CATEGORY) is true, so whole expression is true
      if $category->type is SOME_ANOTHER_TYPE then ($category->type != self::TYPE_CATEGORY) is true, so whole expression is true

      Probably, you should use "&&" operator instead of "||"

      GitHub link: https://github.com/moodle/moodle/blob/b611ade3abc7f19341db866a2d9c31f53909ba8e/lib/navigationlib.php#L1591

      The possible defect was found by static analyzer AppChecker

      Attachments

        Activity

          People

            Unassigned Unassigned
            AppChecker AppChecker
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: