Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.90.5][9.1.1] BUG : PHP Notice: Undefined variable: nb in /var/www/glpi/inc/infocom.class.php at line 150 #1614

Closed
ladenree76000 opened this issue Jan 16, 2017 · 1 comment
Milestone

Comments

@ladenree76000
Copy link
Contributor

When "see counts in tab" is set to "no" , following message is displayed ( debug mode) when displaying assets :

PHP Notice: Undefined variable: nb in /var/www/glpi/inc/infocom.class.php at line 150

@ladenree76000
Copy link
Contributor Author

` /**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

  // Can exists on template
  if (Session::haveRight(self::$rightname, READ)) {
     $nn = 0;
     switch ($item->getType()) {
        case 'Supplier' :
           if ($_SESSION['glpishow_count_on_tabs']) {
              $nb = self::countForSupplier($item);
           }
           return self::createTabEntry(_n('Item', 'Items', Session::getPluralNumber()), $nb);

        default :
           if ($_SESSION['glpishow_count_on_tabs']) {
              $nb = countElementsInTable('glpi_infocoms',
                                         "`itemtype` = '".$item->getType()."'
                                           AND `items_id` = '".$item->getID()."'");
           }
           return self::createTabEntry(__('Management'), $nb);
     }
  }
  return '';

}

$nn variable is defined but doesn't seem to be used if "see counts in tabs" ('glpishow_count_on_tabs') is set to "no" $nb variable is not initialised and return self::createTabEntry(__('Management'), $nb);` is not correct.

i think code should be :
` /**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {

  // Can exists on template
  if (Session::haveRight(self::$rightname, READ)) {
     $nb = 0;
     switch ($item->getType()) {
        case 'Supplier' :
           if ($_SESSION['glpishow_count_on_tabs']) {
              $nb = self::countForSupplier($item);
           }
           return self::createTabEntry(_n('Item', 'Items', Session::getPluralNumber()), $nb);

        default :
           if ($_SESSION['glpishow_count_on_tabs']) {
              $nb = countElementsInTable('glpi_infocoms',
                                         "`itemtype` = '".$item->getType()."'
                                           AND `items_id` = '".$item->getID()."'");
           }
           return self::createTabEntry(__('Management'), $nb);
     }
  }
  return '';

}

`

@ladenree76000 ladenree76000 changed the title [0.90.5 BUG] PHP Notice: Undefined variable: nb in /var/www/glpi/inc/infocom.class.php at line 150 [0.90.5][9.1.1] BUG : PHP Notice: Undefined variable: nb in /var/www/glpi/inc/infocom.class.php at line 150 Jan 16, 2017
trasher added a commit that referenced this issue Jan 17, 2017
@trasher trasher added this to the 9.1.2 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants