FredBardin / phpMyHue

Php web interface and api to manage Philips Hue lights
http://fredbardin.github.io/phpMyHue/
MIT License
45 stars 7 forks source link

incorrect init of var $a_sname in rules.php and scenes.php #8

Closed RuudL-Carrara closed 6 years ago

RuudL-Carrara commented 6 years ago

the rules-tab did not show any rules. the same with the scenes-tab. the problem is caused by the initialisation of $a_sname as a string. it should be initialised as a Array!

FredBardin commented 6 years ago

Hello,

Thanks for your report but, as rules and scenes work correctly for me and for many downloaders, I need some additional information to understand.

This is a lazy initialization with an empty string instead of an array and it'll be corrected.

Meanwhile, with my php version and configuration, the only time it could cause a problem is when there's no data to display (which is very uncommon for rules and scenes).

Could you tell me if you have configured some strict mode for types and give me your PHP version too ?

I know that php 7 could be more strict about data type and I want to verify that the problem comes from that.

RuudL-Carrara commented 6 years ago

Hello,

your assumption about me using php 7 is correct.

To be precise i am using php 7.1.8, running on macOS Sierra with MAMP pro version 4.

After i changed the initialisation of #a_sname to an array ( like so: $a_sname=[]; ) both scenes and rules work fine (see attached screenshots; before and after change )

Let me know if you need more information. (php_error.log perhaps)

best regards,

Ruud Lagcher

On 16 Dec 2017, at 21:29, FredBardin notifications@github.com wrote:

Hello,

Thanks for your report but, as rules and scenes work correctly for me and for many downloaders, I need some additional information to understand.

This is a lazy initialization with an empty string instead of an array and it'll be corrected.

Meanwhile, with my php version and configuration, the only time it could cause a problem is when there's no data to display (which is very uncommon for rules and scenes).

Could you tell me if you have configured some strict mode for types and give me your PHP version too ?

I know that php 7 could be more strict about data type and I want to verify that the problem comes from that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FredBardin/phpMyHue/issues/8#issuecomment-352209367, or mute the thread https://github.com/notifications/unsubscribe-auth/ARgKFwnNJcXLnrcsSMNdmeBrufqC0Kl8ks5tBChFgaJpZM4Q9vSA.

FredBardin commented 6 years ago

Hello,

Thank you for you confirmation about php 7. It's a good thing to know this kind of behavior to prevent it.

The correction will be included in the next release (I hope before the end of this year). Else your fix is totally ok. I prefer explicitly "$a_name=array();" but "$a_name=[];" works too of course.