OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
344 stars 139 forks source link

get_category_software with no software categories defined #349

Closed pchamo closed 2 years ago

pchamo commented 2 years ago

General informations

Operating system : CentOS 7.6.1810

Server informations

Perl version : perl-5.16.3-294 Database: mysql-community-server-5.7.35-1

OCS Inventory informations

Ocs server version : 2.9.1

Problem's description

Below lines are recorded again and again in /var/log/httpd/error_log with PerlSetEnv OCS_OPT_DBI_PRINT_ERROR 1. get_category_software function shouldn't be run when no software categories are defined.

DBD::mysql::st execute failed: Unknown column 'c.OS' in 'field list' at /usr/local/share/perl5/Apache/Ocsinventory/Interface/SoftwareCategory.pm line 59.
DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /usr/local/share/perl5/Apache/Ocsinventory/Interface/SoftwareCategory.pm line 61.
charleneauger commented 2 years ago

Hi @pchamo ,

This function determines if there are software categories. Your error leads me to think that you are missing a column from the software_categories table. Can you run this command on your mysql describe software_categories; and return me the result ?

Best regards, Charlene

pchamo commented 2 years ago

HI @charleneauger, below the result, thanks.

mysql> describe software_categories;
+---------------+--------------+------+-----+---------+----------------+
| Field         | Type         | Null | Key | Default | Extra          |
+---------------+--------------+------+-----+---------+----------------+
| ID            | int(11)      | NO   | PRI | NULL    | auto_increment |
| CATEGORY_NAME | varchar(255) | NO   |     | NULL    |                |
+---------------+--------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
charleneauger commented 2 years ago

Hi @pchamo ,

Can you run the next command in sql ?

ALTER TABLE `software_categories` ADD `OS` VARCHAR(255) default NULL;

It should fix the problem.

Best regards, Charlene Auger

pchamo commented 2 years ago

That fixed my issue, but I also had to execute three lines more according to https://github.com/OCSInventory-NG/OCSInventory-ocsreports/blob/master/files/ocsbase_new.sql because new similar errors appeared:

ALTER TABLE software_category_exp ADD SIGN_VERSION VARCHAR(255) default NULL; ALTER TABLE software_category_exp ADD VERSION VARCHAR(255) default NULL; ALTER TABLE software_category_exp ADD PUBLISHER VARCHAR(255) default NULL;

I wonder if that is an ocs bug or something wrong that I did updating ocs.

Thank you very.