•  » Extensions
  •  » Notice: Trying to access array offset on value of type null

#1 2021-03-08 09:52:33

diabilden
Member
2019-05-08
7

Notice: Trying to access array offset on value of type null

After update to 11.3.0 I got the following:

Notice: Trying to access array offset on value of type null in /web/se/xxx/plugins/meta/main.inc.php on line 183 and others

Meta Revision 11.0.a
Piwigo 11.3.0
Operativ system: Linux
PHP: 7.4.3

inactivate meta and no error (as expected)

Offline

 

#2 2021-03-08 13:28:25

flop25
Piwigo Team
2006-07-06
7037

Re: Notice: Trying to access array offset on value of type null

Hello

I've notified the author. While it should be fixed, that's not exactly an error : I recommand you to not display Notice messages if you are in a live production server and not debugging something.
in your piwigo local config add :
conf['show_php_errors'] = 'E_ALL & ~E_NOTICE | E_STRICT';


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2021-03-08 13:46:11

diabilden
Member
2019-05-08
7

Re: Notice: Trying to access array offset on value of type null

entering
conf['show_php_errors'] = 'E_ALL & ~E_NOTICE | E_STRICT';
gives
Fatal error: Cannot use temporary expression in write context in /web/se/xxx/plugins/LocalFilesEditor/include/functions.inc.php(45) : eval()'d code on line 5

entering
$conf['show_php_errors'] = 'E_ALL & ~E_NOTICE | E_STRICT'; works but Notice still remains

Last edited by diabilden (2021-03-08 13:51:08)

Offline

 

#4 2021-03-08 13:50:13

flop25
Piwigo Team
2006-07-06
7037

Re: Notice: Trying to access array offset on value of type null

the dollar was lost during my copy/paste

$conf['show_php_errors'] = 'E_ALL & ~E_NOTICE | E_STRICT';


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#5 2021-03-08 15:23:40

erAck
Only trying to help
2015-09-06
2196

Re: Notice: Trying to access array offset on value of type null

The single quotes around the constants are wrong, they lead to assigning a string to the config value instead of a numeric value. Oring E_STRICT onto the value is unnecessary, unless one uses dead PHP versions earlier than 5.4.0, it is included in E_ALL since then. For production sites this is sufficient

Code:

$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED & ~E_NOTICE;

which can also be expressed as
$conf['show_php_errors'] = E_ALL & ~(E_DEPRECATED | E_NOTICE);

See also https://www.php.net/manual/en/errorfunc.constants.php


Running Piwigo at https://erack.net/gallery/

Offline

 

#6 2021-03-08 15:27:30

flop25
Piwigo Team
2006-07-06
7037

Re: Notice: Trying to access array offset on value of type null

erAck wrote:

The single quotes around the constants are wrong, they lead to assigning a string to the config value instead of a numeric value.

Code:

$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED & ~E_NOTICE;

+1 !


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#7 2021-03-08 15:58:31

diabilden
Member
2019-05-08
7

Re: Notice: Trying to access array offset on value of type null

Thanks all for quick reply. Now it's working

Offline

 

#8 2025-02-04 07:26:49

sam61
Member
india
2025-02-02
1

Re: Notice: Trying to access array offset on value of type null

diabilden wrote:

entering
conf['show_php_errors'] = 'E_ALL & ~E_NOTICE | E_STRICT';
gives
Fatal error: Cannot use temporary expression in write context in /web/se/xxx/plugins/LocalFilesEditor/include/functions.inc.php(45) : eval()'d code on line 5

entering
$conf['show_php_errors'] = 'E_ALL & ~E_NOTICE | E_STRICT'; works but Notice still remains

thanks for share good information.

Offline

 

#9 Today 15:04:20

Nullbrawl
Member
2025-01-25
1

Re: Notice: Trying to access array offset on value of type null

The error message "is trying to reach the array offset at the value of the type tap" usually occurs when you are trying to reach an array element (or array -like structure) at a zero value. In the context of your Unidbgrid Checkbox column with Null's Brawl APk values, it suggests that somewhere in your code, you are trying to access or manipulate an array (or object) which is zero.

To solve this problem, you need to make sure that you are handling zero values ​​correctly before trying to access them. Here is how you can address this issue:
Steps to handle zero value:

    Check the tap before reaching the field:

    If you are trying to reach the field value or its properties, make sure that it is not zero before doing so:
if not FieldByName('YourField').IsNull then
begin
  // Proceed to access the field value
  if FieldByName('YourField').AsInteger = 1 then
    // Handle the checkbox being checked
  else
    // Handle the checkbox being unchecked
end
else
begin
  // Handle the case where the field is null
  FieldByName('YourField').AsInteger := 0;  // or some default value
end
Assign a default value when posting data:

Before posting the data, ensure that any null value in the checkbox field is converted to either 0 (unchecked) or 1 (checked) depending on your needs. For example:
if FieldByName('YourField').IsNull then
  FieldByName('YourField').AsInteger := 0;  // Treat null as unchecked
Handle the array offset issue:

If you're working with an array or collection and you expect the value to be non-null, ensure you're checking for null values before trying to access an offset. For example:
if (isset($yourArray) && $yourArray !== null && array_key_exists($key, $yourArray)) {
    // Safe to access the array offset
} else {
    // Handle the null or missing array case
}
By handling the disabled values ​​before trying to access or manipulate the data, you should be able to stop "trying to reach the array offset at the price of the type tap".

Offline

 
  •  » Extensions
  •  » Notice: Trying to access array offset on value of type null

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2025 · Contact