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

[9.4.4] API - PHP Fatal error - commondbconnexity.class.php #6462

Closed
J-C-P opened this issue Oct 11, 2019 · 5 comments · Fixed by #6636
Closed

[9.4.4] API - PHP Fatal error - commondbconnexity.class.php #6462

J-C-P opened this issue Oct 11, 2019 · 5 comments · Fixed by #6636

Comments

@J-C-P
Copy link

J-C-P commented Oct 11, 2019

Describe the bug

When using the API, I can't get rules criteria or action.
Calling /rule/[id]/rulecriteria give a ERROR 500
Calling /rulecriteria/[criteria id] works
Trying to retrieve all rulecriteria gives an ERROR 500

Page(s) URL
glpi/apirest.php/rulecriteria

To reproduce
call glpi/apirest.php/rulecriteria

Expected behavior

get all rulecriteria

Logs
Apache log of the error 500

PHP Fatal error:  Uncaught Error: Class name must be a valid object or a string in /var/www/html/glpi/inc/commondbconnexity.class.php:314
Stack trace:
#0 /var/www/html/glpi/inc/commondbchild.class.php(230): CommonDBConnexity::canConnexity('canView', 3, NULL, 'rules_id')
#1 /var/www/html/glpi/inc/commondbchild.class.php(153): CommonDBChild::canChild('canView')
#2 /var/www/html/glpi/inc/api.class.php(1134): CommonDBChild::canView()
#3 /var/www/html/glpi/inc/apirest.class.php(237): API->getItems('Ruleaction', Array, 0)
#4 /var/www/html/glpi/apirest.php(48): APIRest->call()
#5 {main}
thrown in /var/www/html/glpi/inc/commondbconnexity.class.php on line 314

Additional context

I use API a lot from Powershell module. I tried using CURL in bash, same result.
In the current situation, I can not manage rules thru the API.
The goal is to automatically create location rules based on the IP. We use a external application to manage the thousands of subnets linked to about hundred different locations.

@J-C-P
Copy link
Author

J-C-P commented Oct 11, 2019

My humble feeling is that a declaration is missing somewhere but my php competencies does not allow me to dig deep :-/

@trasher
Copy link
Contributor

trasher commented Oct 14, 2019

Please test with latest stable.

@J-C-P
Copy link
Author

J-C-P commented Oct 16, 2019

I just updated to 9.4.4.
Same issue when I try to get "rulecriteria" objects.
It works for ONE object at a time (as in the first post) but trying to get all items create this error.

[Thu Oct 17 00:42:50.677095 2019] [:error] [pid 28499] [client 148.110.18.29:52879] PHP Fatal error:  Uncaught Error: Class name must be a valid object or a string in /var/www/html/glpi/inc/commondbconnexity.class.php:314
Stack trace:
#0 /var/www/html/glpi/inc/commondbchild.class.php(230): CommonDBConnexity::canConnexity('canView', 3, NULL, 'rules_id')
#1 /var/www/html/glpi/inc/commondbchild.class.php(153): CommonDBChild::canChild('canView')
#2 /var/www/html/glpi/inc/api.class.php(1134): CommonDBChild::canView()
#3 /var/www/html/glpi/inc/apirest.class.php(237): API->getItems('Rulecriteria', Array, 0)
#4 /var/www/html/glpi/apirest.php(48): APIRest->call()
#5 {main}
 thrown in /var/www/html/glpi/inc/commondbconnexity.class.php on line 314

@J-C-P J-C-P changed the title [9.4.2] API - PHP Fatal error - commondbconnexity.class.php [9.4.4] API - PHP Fatal error - commondbconnexity.class.php Oct 21, 2019
@J-C-P
Copy link
Author

J-C-P commented Oct 29, 2019

Is there anything else I can do to help you guys get any idea of what happens?

@J-C-P
Copy link
Author

J-C-P commented Nov 25, 2019

GLPI Official support provided the solution.

Add
static public $itemtype = 'Rule';
before the line
static public $items_id = 'rules_id';
in both rulecriteria.class.php and ruleaction.class.php

Rules manipulation is now possible thru the API. I don't know if a fix has been submitted.

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

Successfully merging a pull request may close this issue.

2 participants