JeroenDeDauw / ParamProcessor

Declarative parameter processing library
https://entropywins.wtf
Other
20 stars 4 forks source link

Invalid argument supplied for foreach in `ParamDefinition.php` on line 522 #16

Closed mwjames closed 8 years ago

mwjames commented 8 years ago

Just run into it while researching something else.

$ php maintenance/refreshLinks.php
Refreshing redirects table.
Starting from page_id 1 of 590.
100
200
300
400
500
Refreshing links tables.
Starting from page_id 1 of 590.

Warning: Invalid argument supplied for foreach() in ...\vendor\param-processor\param-processor\src\ParamDefinition.php on line 522

param-processor/param-processor 1.2.2

JeroenDeDauw commented 8 years ago

Do you know if this issue occurs with the latest version of this library? Bugfixes where made since 1.2.2

mwjames commented 8 years ago

Do you know if this issue occurs with the latest version of this library? Bugfixes where made since 1.2.2

Lines are different [0], code is the same $values = $param->getValue();. I'm guessing getValue doesn't return an expected array and that is why foreach ( $values as &$value ) complains about it.

No other stack trace, no hint as the where and by what it is caused, it just appeared during the refreshLinks.php run.

[0] https://github.com/JeroenDeDauw/ParamProcessor/blob/master/src/ParamDefinition.php#L482-L486

mwjames commented 8 years ago

According to [0] $param->getValue(); returns a mixed type, so no guarantee for an array.

[0] https://github.com/JeroenDeDauw/ParamProcessor/blob/master/src/Param.php#L462-L469

JeroenDeDauw commented 8 years ago

Yeah sure, no guarantee, though if isList returns true, it really ought to be. Probably null or something. Will investigate.

JeroenDeDauw commented 8 years ago

I looked at this for 20 minutes and did not find the source. It is very possible the error is coming from code using ParamProcessor and simply not caught until this point. Hard to tell, very high code complexity and little encapsulation

JeroenDeDauw commented 8 years ago

Error also observed with 1.2.5 at http://sandbox.semantic-mediawiki.org/w/index.php?title=Sp%C3%A9cial%3AAsk&q=%5B%5BHas+coordinates%3A%3A%2B%5D%5D&po=%3FHas+coordinates%0D%0A&eq=yes&p%5Bformat%5D=googlemaps3&sort_num=&order_num=ASC&p%5Bsource%5D=&p%5Blimit%5D=&p%5Boffset%5D=&p%5Blink%5D=all&p%5Bsort%5D=&p%5Bheaders%5D=show&p%5Bmainlabel%5D=&p%5Bintro%5D=&p%5Boutro%5D=&p%5Bsearchlabel%5D=%26hellip%3B+autres+r%C3%A9sultats&p%5Bdefault%5D=&p%5Bgeoservice%5D=geonames&p%5Bwidth%5D=auto&p%5Bheight%5D=350&p%5Bcentre%5D=&p%5Bzoom%5D=14&p%5Btype%5D=roadmap&p%5Bzoomstyle%5D=default&p%5Btypestyle%5D=default&p%5Bpoi%5D=1&p%5Btilt%5D=0&p%5Bimageoverlays%5D=&p%5Bkml%5D=&p%5Bgkml%5D=&p%5Bfusiontables%5D=&p%5Bsearchmarkers%5D=&p%5Bstaticlocations%5D=&p%5Bshowtitle%5D=1&p%5Btemplate%5D=&p%5Buserparam%5D=&p%5Bactiveicon%5D=&p%5Btitle%5D=&p%5Blabel%5D=&p%5Bicon%5D=&p%5Bvisitedicon%5D=&p%5Blines%5D=&p%5Bpolygons%5D=&p%5Bcircles%5D=&p%5Brectangles%5D=&p%5Bwmsoverlay%5D=&p%5Bmaxzoom%5D=&p%5Bminzoom%5D=&eq=yes