cconard96 / jamf

JAMF Plugin for GLPI
GNU General Public License v2.0
6 stars 5 forks source link

Trying to access array offset on value of type null #67

Closed amabri04 closed 3 years ago

amabri04 commented 3 years ago

After adding the plugin to GLPI, I cannot retrieve the devices due to a weird error coming from PHP. This error happen on the configuration page as well as on the JSS Account Link. By having such an error it seems that the connection with JSS is not even initiated as I cannot see any user connection request in the Jamf Server logs.

I have tried to reinstall the plugin several times and even try an older version but no luck. We have other plugins running on our instance and do not have this issue with any of them. Screen Shot 2021-01-08 at 5 07 12 PM

Screen Shot 2021-01-08 at 4 47 40 PM

[08-Jan-2021 12:13:09 Canada/Eastern] PHP Notice: Trying to access array offset on value of type null in \plugins\jamf\inc\user_jssaccount.class.php on line 200 [08-Jan-2021 12:13:09 Canada/Eastern] PHP Stack trace: [08-Jan-2021 12:13:09 Canada/Eastern] PHP 1. {main}() \ajax\common.tabs.php:0 [08-Jan-2021 12:13:09 Canada/Eastern] PHP 2. CommonGLPI::displayStandardTab() \ajax\common.tabs.php:92 [08-Jan-2021 12:13:09 Canada/Eastern] PHP 3. PluginJamfUser_JSSAccount::displayTabContentForItem() \inc\commonglpi.class.php:637 [08-Jan-2021 12:13:09 Canada/Eastern] PHP 4. PluginJamfUser_JSSAccount::showForUser() \plugins\jamf\inc\user_jssaccount.class.php:62 [08-Jan-2021 12:13:09 Canada/Eastern] PHP Warning: Invalid argument supplied for foreach() in \plugins\jamf\inc\user_jssaccount.class.php on line 202 [08-Jan-2021 12:13:09 Canada/Eastern] PHP Stack trace: [08-Jan-2021 12:13:09 Canada/Eastern] PHP 1. {main}() \ajax\common.tabs.php:0 [08-Jan-2021 12:13:09 Canada/Eastern] PHP 2. CommonGLPI::displayStandardTab() \ajax\common.tabs.php:92 [08-Jan-2021 12:13:09 Canada/Eastern] PHP 3. PluginJamfUser_JSSAccount::displayTabContentForItem() \inc\commonglpi.class.php:637 [08-Jan-2021 12:13:09 Canada/Eastern] PHP 4. PluginJamfUser_JSSAccount::showForUser() \plugins\jamf\inc\user_jssaccount.class.php:62

System Specifications

Thanks for the help!

cconard96 commented 3 years ago

Do you have any errors in files/_log/php-errors.log or files/_log/sql-errors.log around the time you tried installing the plugin initially? Do you have any of the Jamf plugin config records in your glpi_configs table?

To check the configs: SELECT name FROM glpi_configs WHERE context="plugin:Jamf";

amabri04 commented 3 years ago

Hi, The errors from files/_log/php-errors.log are the one in the previous post. I do not have any error in sql-errors. Here is the screenshot of configs after using the sql request: Screen Shot 2021-01-11 at 8 22 28 AM

amabri04 commented 3 years ago

I tried a new full install and now I am getting the following error from sql-errors.log. We are running a MariaDB and not MySQL.

[2021-01-11 15:42:37] glpisqllog.ERROR: DBmysql::query() in \inc\dbmysql.class.php line 306 MySQL query error: SQL: SELECT itemtype, items_id FROM glpi_plugin_jamf_mobiledevices WHERE sync_date < NOW() - INTERVAL 15 MINUTE Error: Champ 'itemtype' inconnu dans field list Backtrace : inc\dbmysqliterator.class.php:95 inc\dbmysql.class.php:858 DBmysqlIterator->execute() plugins\jamf\inc\devicesync.class.php:185 DBmysql->request() plugins\jamf\inc\cron.class.php:42 PluginJamfDeviceSync::syncAll() inc\crontask.class.php:848 PluginJamfCron::cronSyncJamf() front\cron.php:61 CronTask::launch() {"user":"6@SRV-GLPI"} [2021-01-11 15:42:37] glpisqllog.ERROR: DBmysql::query() in \inc\dbmysql.class.php line 306 MySQL query error: SQL: SELECT itemtype, items_id FROM glpi_plugin_jamf_computers WHERE sync_date < NOW() - INTERVAL 15 MINUTE Error: Champ 'itemtype' inconnu dans field list Backtrace : inc\dbmysqliterator.class.php:95 inc\dbmysql.class.php:858 DBmysqlIterator->execute() plugins\jamf\inc\devicesync.class.php:185 DBmysql->request() plugins\jamf\inc\cron.class.php:42 PluginJamfDeviceSync::syncAll() inc\crontask.class.php:848 PluginJamfCron::cronSyncJamf() front\cron.php:61 CronTask::launch() {"user":"6@SRV-GLPI","mem_usage":"0.021\", 3.95Mio)"}

cconard96 commented 3 years ago

This issue was fixed in version 2.1.3 and the table name in the query for both cases was changed to glpi_plugin_jamf_devices. I don't know why you are getting that with the latest release 2.1.3).

amabri04 commented 3 years ago

Corrected when I tried following #68 Thanks! And sorry for not answering in the past few days.