Quantcast

[Tiki-devel] PHP notice in MenuLib::setSelected() (RE : How to fix this PHP Notice?)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Tiki-devel] PHP notice in MenuLib::setSelected() (RE : How to fix this PHP Notice?)

Cloutier, Philippe (RESSOURCE EXTERNE)
Hi Luci,
I am not seeing such cookies on dev.tiki.org nor on my website. Do you see them? I also could not find where the code would create such cookies, although that is not an easy search.

On these websites, menu state persistence seems broken if I test with the application menu.

De : luciash [[hidden email]]
Envoyé : 15 février 2017 09:41
À : Tiki developers
Objet : [Tiki-devel] How to fix this PHP Notice?

Hi fellow devs,

I wanted to fix the notice appearing on doc.tiki.org site but cannot figure out how to do it properly. It says:

PHP (5.6.30-0+deb8u1) NOTICE (E_NOTICE):
File: lib/menubuilder/menulib.php
Line: 468
Type: Undefined index: position

It seems to be repeated for each module we have there. When I check the code on line 468 I see it is trying to get a cookie:

$ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');

I was expecting $position but this is more complex and I am unsure where to put the if (isset($option['position'])) { ... }
to get rid of the Notice.

Should it be like this?  if (isset($option['position'])) { $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu'); }

In greater context it looks like:

// set sections open/close according to cookie
                global $prefs;
                foreach ($channels['data'] as $position => &$option) {
                        if (!empty($params['menu_cookie']) && $params['menu_cookie'] == 'n') {
                                if (!empty($option['selected']) || !empty($option['selectedAscendant'])) {
                                        $option['open'] = true;
                                }
                        } else {
                                if (empty($params['id']) && !empty($params['structureId'])) {
                                        $params['id'] = $params['structureId'];
                                }
                                $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
                                if ($prefs['javascript_enabled'] === 'n') {
                                        $option['open'] = true;
                                } elseif ($ck === 'o') {
                                        $option['open'] = true;
                                } elseif ($ck === 'c') {
                                        $option['open'] = false;
                                }
                        }
                }
                return $channels;


Thanks,
luci



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Tiki-devel] PHP notice in MenuLib::setSelected() (RE : How to fix this PHP Notice?)

Jonny Bradley-4
Hi Chealer,

This cookie menu persistence only works for non-bootstrap menus, aha, there's a clue!

Hmm, seems to work as expected when bootstrap=n and css=n but i still don't get the notices. Anyway, i tried the isset fix i suggested and it seems harmless so will commit when (if) sf.net svn works again...

jb




On 19 Feb 2017, at 19:01, Cloutier, Philippe (RESSOURCE EXTERNE) <[hidden email]> wrote:

Hi Luci,
I am not seeing such cookies on dev.tiki.org nor on my website. Do you see them? I also could not find where the code would create such cookies, although that is not an easy search.

On these websites, menu state persistence seems broken if I test with the application menu.

De : luciash [[hidden email]]
Envoyé : 15 février 2017 09:41
À : Tiki developers
Objet : [Tiki-devel] How to fix this PHP Notice?

Hi fellow devs,
I wanted to fix the notice appearing on doc.tiki.org site but cannot figure out how to do it properly. It says:
PHP (5.6.30-0+deb8u1) NOTICE (E_NOTICE):
File: lib/menubuilder/menulib.php
Line: 468
Type: Undefined index: position
It seems to be repeated for each module we have there. When I check the code on line 468 I see it is trying to get a cookie:
$ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
I was expecting $position but this is more complex and I am unsure where to put the if (isset($option['position'])) { ... }
to get rid of the Notice.
Should it be like this?  if (isset($option['position'])) { $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu'); }
In greater context it looks like:
// set sections open/close according to cookie
                global $prefs;
                foreach ($channels['data'] as $position => &$option) {
                        if (!empty($params['menu_cookie']) && $params['menu_cookie'] == 'n') {
                                if (!empty($option['selected']) || !empty($option['selectedAscendant'])) {
                                        $option['open'] = true;
                                }
                        } else {
                                if (empty($params['id']) && !empty($params['structureId'])) {
                                        $params['id'] = $params['structureId'];
                                }
                                $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
                                if ($prefs['javascript_enabled'] === 'n') {
                                        $option['open'] = true;
                                } elseif ($ck === 'o') {
                                        $option['open'] = true;
                                } elseif ($ck === 'c') {
                                        $option['open'] = false;
                                }
                        }
                }
                return $channels;

Thanks,
luci

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Tiki-devel] PHP notice in MenuLib::setSelected() (RE : How to fix this PHP Notice?)

luciash d' being

Thanks jonny!

luci


On 20.2.2017 12:23, Jonny Bradley wrote:
Hi Chealer,

This cookie menu persistence only works for non-bootstrap menus, aha, there's a clue!

Hmm, seems to work as expected when bootstrap=n and css=n but i still don't get the notices. Anyway, i tried the isset fix i suggested and it seems harmless so will commit when (if) sf.net svn works again...

jb




On 19 Feb 2017, at 19:01, Cloutier, Philippe (RESSOURCE EXTERNE) <[hidden email]> wrote:

Hi Luci,
I am not seeing such cookies on dev.tiki.org nor on my website. Do you see them? I also could not find where the code would create such cookies, although that is not an easy search.

On these websites, menu state persistence seems broken if I test with the application menu.

De : luciash [[hidden email]]
Envoyé : 15 février 2017 09:41
À : Tiki developers
Objet : [Tiki-devel] How to fix this PHP Notice?

Hi fellow devs,
I wanted to fix the notice appearing on doc.tiki.org site but cannot figure out how to do it properly. It says:
PHP (5.6.30-0+deb8u1) NOTICE (E_NOTICE):
File: lib/menubuilder/menulib.php
Line: 468
Type: Undefined index: position
It seems to be repeated for each module we have there. When I check the code on line 468 I see it is trying to get a cookie:
$ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
I was expecting $position but this is more complex and I am unsure where to put the if (isset($option['position'])) { ... }
to get rid of the Notice.
Should it be like this?  if (isset($option['position'])) { $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu'); }
In greater context it looks like:
// set sections open/close according to cookie
                global $prefs;
                foreach ($channels['data'] as $position => &$option) {
                        if (!empty($params['menu_cookie']) && $params['menu_cookie'] == 'n') {
                                if (!empty($option['selected']) || !empty($option['selectedAscendant'])) {
                                        $option['open'] = true;
                                }
                        } else {
                                if (empty($params['id']) && !empty($params['structureId'])) {
                                        $params['id'] = $params['structureId'];
                                }
                                $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
                                if ($prefs['javascript_enabled'] === 'n') {
                                        $option['open'] = true;
                                } elseif ($ck === 'o') {
                                        $option['open'] = true;
                                } elseif ($ck === 'c') {
                                        $option['open'] = false;
                                }
                        }
                }
                return $channels;

Thanks,
luci

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot


_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Tiki-devel] RE : PHP notice in MenuLib::setSelected() (RE : How to fix this PHP Notice?)

Cloutier, Philippe (RESSOURCE EXTERNE)
In reply to this post by Jonny Bradley-4
Thanks Jonny.
I confirm that persistence works if I disable Bootstrap.

This line uses the "menu" cookie. Normally, the $name argument of getCookie() can take a value like menu42__27 (this is an option of the application menu). On my trunk install, every call to getCookie() has a properly constructed $name, including a position. $option['position'] is always set in setSelected().

Luci, can you reproduce this on a local website and if so, could you determine which menu triggers it?

De : Jonny Bradley [[hidden email]]
Envoyé : 20 février 2017 06:23
À : Tiki developers
Objet : Re: [Tiki-devel] PHP notice in MenuLib::setSelected() (RE : How to fix this PHP Notice?)

Hi Chealer,

This cookie menu persistence only works for non-bootstrap menus, aha, there's a clue!

Hmm, seems to work as expected when bootstrap=n and css=n but i still don't get the notices. Anyway, i tried the isset fix i suggested and it seems harmless so will commit when (if) sf.net svn works again...

jb




On 19 Feb 2017, at 19:01, Cloutier, Philippe (RESSOURCE EXTERNE) <[hidden email]> wrote:

Hi Luci,
I am not seeing such cookies on dev.tiki.org nor on my website. Do you see them? I also could not find where the code would create such cookies, although that is not an easy search.

On these websites, menu state persistence seems broken if I test with the application menu.

De : luciash [[hidden email]]
Envoyé : 15 février 2017 09:41
À : Tiki developers
Objet : [Tiki-devel] How to fix this PHP Notice?

Hi fellow devs,
I wanted to fix the notice appearing on doc.tiki.org site but cannot figure out how to do it properly. It says:
PHP (5.6.30-0+deb8u1) NOTICE (E_NOTICE):
File: lib/menubuilder/menulib.php
Line: 468
Type: Undefined index: position
It seems to be repeated for each module we have there. When I check the code on line 468 I see it is trying to get a cookie:
$ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
I was expecting $position but this is more complex and I am unsure where to put the if (isset($option['position'])) { ... }
to get rid of the Notice.
Should it be like this?  if (isset($option['position'])) { $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu'); }
In greater context it looks like:
// set sections open/close according to cookie
                global $prefs;
                foreach ($channels['data'] as $position => &$option) {
                        if (!empty($params['menu_cookie']) && $params['menu_cookie'] == 'n') {
                                if (!empty($option['selected']) || !empty($option['selectedAscendant'])) {
                                        $option['open'] = true;
                                }
                        } else {
                                if (empty($params['id']) && !empty($params['structureId'])) {
                                        $params['id'] = $params['structureId'];
                                }
                                $ck = getCookie('menu'.$params['id'].'__'.$option['position'], 'menu');
                                if ($prefs['javascript_enabled'] === 'n') {
                                        $option['open'] = true;
                                } elseif ($ck === 'o') {
                                        $option['open'] = true;
                                } elseif ($ck === 'c') {
                                        $option['open'] = false;
                                }
                        }
                }
                return $channels;

Thanks,
luci

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
Loading...