Skip to content

Conversation

@agaubertAlteca
Copy link

@agaubertAlteca agaubertAlteca commented Jun 22, 2021

Notice: Trying to access array offset on value of type null in L:\inetpub\wwwroot\glpi\plugins\fields\inc\container.class.php on line 921
if $found is empty, $first_found is null and so $first_found['right'] does not exist

Reproduce: Load page /front/helpdesk.public.php

Notice: Trying to access array offset on value of type null in L:\inetpub\wwwroot\glpi\plugins\fields\inc\container.class.php on line 921
if $found is empty, $first_found is null and so  $first_found['right'] does not exist
Copy link
Contributor

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain how to reproduce this issue in the description ?

'right' => ['>=', READ]]);
$first_found = array_shift($found);
if ($first_found['right'] == null || $first_found['right'] == 0) {
if (isset($first_found['right']) && ($first_found['right'] == null || $first_found['right'] == 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array_shift will return null if array is empty. Checking for null value is more appropriate.

Suggested change
if (isset($first_found['right']) && ($first_found['right'] == null || $first_found['right'] == 0)) {
if ($first_found !== null && ($first_found['right'] == null || $first_found['right'] == 0)) {

@agaubertAlteca
Copy link
Author

Hello,
sorry, just load the page /front/helpdesk.public.php
regards

@cedric-anne
Copy link
Contributor

Fixed in #447.

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 this pull request may close these issues.

2 participants