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

avoid importing disks with empty serial #2322

Merged
merged 1 commit into from Oct 24, 2017

Conversation

Projects
None yet
3 participants
@orthagh
Contributor

orthagh commented Oct 23, 2017

Actually, the missing serial in $arraydb causes a lot of log in php_errors.log
Ex on 0.85 (already seen in recent versions):

*** PHP Notice(8): Undefined index: serial
  Backtrace :
  ...nventory/inc/inventorycomputerlib.class.php:347
  ...ry/inc/inventorycomputerinventory.class.php:566 PluginFusioninventoryInventoryComputerLib->updateComputer()
  ...inventory/inc/inventoryruleimport.class.php:719 PluginFusioninventoryInventoryComputerInventory->rulepassed()
  inc/rule.class.php:1402                            PluginFusioninventoryInventoryRuleImport->executeActions()
  inc/rulecollection.class.php:1455                  Rule->process()
  ...ry/inc/inventorycomputerinventory.class.php:369 RuleCollection->processAllRules()
  ...ry/inc/inventorycomputerinventory.class.php:108 PluginFusioninventoryInventoryComputerInventory->sendCriteria()
  ...fusioninventory/inc/communication.class.php:222 PluginFusioninventoryInventoryComputerInventory->import()
  ...fusioninventory/inc/communication.class.php:452 PluginFusioninventoryCommunication->import()
  plugins/fusioninventory/front/communication.php:88 PluginFusioninventoryCommunication->handleOCSCommunication()
  plugins/fusioninventory/index.php:51               include_once()

I think we have 2 solutions,

  • don't import disks with non-set serials (i choose this one)
  • force serial to empty string when it doesn't exists.

I fear the second solution may causes some data overwriting when we have multiple disks with no serials

@orthagh orthagh added the bug label Oct 23, 2017

@orthagh orthagh requested review from trasher and ddurieux Oct 23, 2017

@@ -459,7 +459,8 @@ function updateComputer($a_computerinventory, $computers_id, $no_history, $setdy
foreach ($a_computerinventory['harddrive'] as $key => $arrays) {
$arrayslower = array_map('strtolower', $arrays);
foreach ($db_harddrives as $keydb => $arraydb) {
if ($arrayslower['serial'] == $arraydb['serial']) {
if (!isset($arraydb['serial'])

This comment has been minimized.

@trasher

trasher Oct 24, 2017

Collaborator

Is not condition inverted? I guess we would update item only if serial is defined; am I wrong?

This comment has been minimized.

@orthagh

orthagh Oct 24, 2017

Contributor

in fact no, but i'll do more readable

@orthagh orthagh merged commit 7dce8b0 into fusioninventory:glpi9.2 Oct 24, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ddurieux ddurieux added this to the 9.2+2.0 milestone May 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment