Skip to content

Dynamic group or activing plugin ? #73

Closed

Description

@EC2311

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

GLPI Version

10.0.19

Plugin version

1.0.3

Bug description

When activing plugin, there is a strange error in php errors log when an inventory is raised
index 'glpiname' not found..

if i deactivate plugin database inventory : no more error

remark :
in 1.0.0 i had error with id not found
[2025-09-01 10:05:04] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "id" in D:\wamp\www\glpi\plugins\databaseinventory\inc\task.class.php at line 177

Relevant log output

[2025-09-02 13:29:03] glpiphplog.WARNING:   *** PHP Warning (2): Undefined array key "glpiname" in D:\wamp\www\glpi\src\Search.php at line 729
  Backtrace :
  ...nventory\inc\computergroupdynamic.class.php:183 Search::constructSQL()
  plugins\databaseinventory\inc\task.class.php:244   PluginDatabaseinventoryComputerGroupDynamic->isDynamicSearchMatchComputer()
  src\Plugin.php:1763                                PluginDatabaseinventoryTask::handleInventoryTask()
  src\Inventory\Request.php:420                      Plugin::doHookFunction()
  src\Inventory\Request.php:130                      Glpi\Inventory\Request->handleInventoryTask()
  src\Inventory\Request.php:340                      Glpi\Inventory\Request->handleTask()
  src\Inventory\Request.php:83                       Glpi\Inventory\Request->contact()
  src\Agent\Communication\AbstractRequest.php:359    Glpi\Inventory\Request->handleAction()
  src\Agent\Communication\AbstractRequest.php:271    Glpi\Agent\Communication\AbstractRequest->handleJSONRequest()
  front\inventory.php:100                            Glpi\Agent\Communication\AbstractRequest->handleRequest()
  plugins\glpiinventory\front\communication.php:72   include_once()
  plugins\glpiinventory\index.php:45                 include_once()

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

No response

Anything else?

No response

Activity

  1. EC2311 commented on Sep 2, 2025

    @EC2311
    Author

    If the use is well this one :
    Agent contacts glpi server to get db parameters in order to process inventory....
    in fact, As i defined 3 computers in the plugin databaseinventory, I think any other agents fails fetching databaseinventory id...
    So perhaps a "monitor" misses ?

  2. stonebuzz commented on Sep 2, 2025

    @stonebuzz
    Contributor

    @EC2311
    can you check -> #74

  3. EC2311 commented on Sep 2, 2025

    @EC2311
    Author

    I think it's ok : no error for the moment.
    but, I will wait for 'all' computer defined in the static group :
    Do you confirm that database inventory (for the case it's mysql db) must be done by the agent ?

    what do you mean by 'socket' ?
    Thanks

    Edit :
    Still same error
    [2025-09-02 14:52:04] glpiphplog.WARNING: *** PHP Warning (2): Undefined array key "glpiname" in D:\wamp\www\glpi\src\Search.php at line 729
    Backtrace :
    ...nventory\inc\computergroupdynamic.class.php:189 Search::constructSQL()
    plugins\databaseinventory\inc\task.class.php:244 PluginDatabaseinventoryComputerGroupDynamic->isDynamicSearchMatchComputer()
    src\Plugin.php:1763 PluginDatabaseinventoryTask::handleInventoryTask()
    src\Inventory\Request.php:420 Plugin::doHookFunction()
    src\Inventory\Request.php:130 Glpi\Inventory\Request->handleInventoryTask()
    src\Inventory\Request.php:340 Glpi\Inventory\Request->handleTask()
    src\Inventory\Request.php:83 Glpi\Inventory\Request->contact()
    src\Agent\Communication\AbstractRequest.php:359 Glpi\Inventory\Request->handleAction()
    src\Agent\Communication\AbstractRequest.php:271 Glpi\Agent\Communication\AbstractRequest->handleJSONRequest()
    front\inventory.php:100 Glpi\Agent\Communication\AbstractRequest->handleRequest()
    plugins\glpiinventory\front\communication.php:72 include_once()
    plugins\glpiinventory\index.php:45 include_once()

    Here are the lines updated :
    private function countDynamicItems()
    {
    $search_params = Search::manageParams('Computer', unserialize($this->fields['search']));
    $data = Search::prepareDatasForSearch('Computer', $search_params);

    	$bkp_glpi_name = $_SESSION['glpiname'];
        $_SESSION['glpiname'] = 'databaseinventory_plugin';
    	
        Search::constructSQL($data);
        Search::constructData($data);
        $count = $data['data']['totalcount'];
    	
    	$_SESSION['glpiname'] = $bkp_glpi_name;
    
        return $count;
    }
    
  4. stonebuzz commented on Sep 2, 2025

    @stonebuzz
    Contributor

    That’s unusual. Could you please try resetting the GLPI cache with the following command,

    php bin/console cache:clear

    and then restart the web server?

    Best regards,

  5. EC2311 commented on Sep 2, 2025

    @EC2311
    Author

    I cleared cache, but command is not successfull : some directory were not deleted

    Image Image Image

    I restarted services (wamp)

    same errors
    when plugin not activated -> no error

  6. stonebuzz commented on Sep 2, 2025

    @stonebuzz
    Contributor

    I’m not a WAMP expert. Could you please try deleting the contents of the glpi/files/_cache/ directory manually instead of using the command?

  7. EC2311 commented on Sep 2, 2025

    @EC2311
    Author

    in fact by debugging it fails in function isdynamicsearchmatchcomputer,
    searching for "glpiname"

    I put in comment the lines

    Image here is the contents : Image

    as soon as I remove comment of the line
    if ($dynamic_group->isDynamicSearchMatchComputer($computer))
    errors in php errors log with glpiname

  8. EC2311 commented on Sep 2, 2025

    @EC2311
    Author

    I wonder if it's not due to a record in
    glpi_plugin_databaseinventory_computergroupdynamics

    there was a record (for which I attempt to filter using name contains "glpi"

    I deleted record in it : I have no more error at all :)

    So I just re-add a dynamic group (name contains GLPI) -> 5 computers in it.

    For the moment : no error

    Was there a mismatch in the previous filter ?

  9. EC2311 commented on Sep 2, 2025

    @EC2311
    Author

    again error with dynamic group/
    -> the name of computer doesn't match the filter
    -> the agent is glpi-1.12 : name contains glpi...

    I have no error on computers with FusionInventory agent (the name of agent does'nt contains glpi...)

    I try to remove filter using

    Image -> it set ALL computers in dynamic : no filter (if we want) but a record is sett in DB and I have error then

    I delete record in the table directly : no more error

    so it's linked with the data in dynamic group

  10. stonebuzz commented on Sep 3, 2025

    @stonebuzz
    Contributor

    Sorry, I fixed the issue in the wrong place.

    I’ve updated the PR, so could you please revert your changes and apply this patch instead?

    https://patch-diff.githubusercontent.com/raw/pluginsGLPI/databaseinventory/pull/74.diff

    Best regards

  11. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    still have error with glpiname :(

    Undefined array key "glpiname" in D:\wamp\www\glpi\plugins\databaseinventory\inc\computergroupdynamic.class.php at line 182

    Image

    unless error : glpiname matchs with connected user
    and in batch, no connected user ?

  12. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    here is what I did :

    Image

    and $_Session :

    Image

    no more error, but the date inventory in the computer is not set, as if there was other thing wrong (the contact date is ok)

    as soon I delete record in group dynamic :-> all is right

    so for me the inventory with dynamic group is not "right"

  13. stonebuzz commented on Sep 3, 2025

    @stonebuzz
    Contributor

    I’ve updated the PR, so could you please revert your changes and apply this patch instead?

    https://patch-diff.githubusercontent.com/raw/pluginsGLPI/databaseinventory/pull/74.diff

  14. EC2311 commented on Sep 3, 2025

    @EC2311
    Author

    so
    no error on php logs.

    but i am not sure of good running of the program

    in fact
    in dynamic group I choose computer with name contains GLPI -> 5 computers are presents -> I save the requets

    in table computergroupdynamics :
    a:4:{s:10:"is_deleted";s:1:"0";s:6:"as_map";s:1:"0";s:8:"criteria";a:1:{i:0;a:4:{s:4:"link";s:3:"AND";s:5:"field";s:1:"1";s:10:"searchtype";s:8:"contains";s:5:"value";s:4:"glpi";}}s:12:"metacriteria";a:0:{}}

    but at agents levels
    any computers raises : ok
    but some inventorys raises (I have contact AND inventory dates updated) (the name does not contain GLPI) and are coming from FusionInventory)
    some others are not . their name doens contain GLPI too but there are from GLPI-agent (whch contain GLPI) .

    so for me there is something wrong with the check...

    When i delete ths record in the table : the inventory (of a computer which was not inventoried) raises

  15. stonebuzz commented on Sep 3, 2025

    @stonebuzz
    Contributor

    For me it's another problem, can you create a dedicated issue

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions