Closed (fixed)
Project:
Entity Construction Kit (ECK)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
24 Jul 2014 at 20:21 UTC
Updated:
10 Feb 2016 at 21:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
joelpittetHere's a cleanup patch for whitespace and array_key_exists
Comment #2
func0der commentedYour patch is not appliable with git apply.
How did you create it?
Comment #3
henrijs.seso commentedRe-roll is needed. See GIT instructions for proper steps.
Comment #4
func0der commentedRe-done it. But I do not think using only "empty()" is a good practice.
Why again did u not use "isset()" and "empty()" combined? Has it been made sure that there is NO event where the used indexes are not set?
Applying a patch that fills up the watchdog with notices does not make so much sense, I think.
Comment #5
func0der commentedSince I did not use the current master, but the current dev release, I had one too many deletion.
Comment #6
joelpittet@func0der, have a look at the issue summary for the reasons for that.
empty(), has a built in isset() call in it. It's good practice when it makes sense because it's fast and concise. You'd not use it if you expect a "0", 0, 0.0, false, array(), NULL @see http://ca2.php.net/empty
It's a concise version of
!isset($var) || $var == falseWhat are you talking about notices in your watchdog?
Can you provide an interdiff on your patches there so I know what you changed? @see https://drupal.org/documentation/git/interdiff
Comment #7
joelpittetI just checked and my patch in #1 still applies against 7.x-2.x branch
Comment #8
func0der commentedOkay, where is the branch for this current downloadable version: https://www.drupal.org/node/1364484
I tried to apply your patch to that version and it did not work. That's why I made a new patch.
Your patch does apply to the branch. Mine not.
Your patch does not apply to the current released dev version, mine does.
that's strange :/
I am confused.
Comment #9
joelpittetRun the following:
Comment #11
fmizzell commented@joelpittet thank you for pointing this out. Like @func0der I was skeptical about no PHP notices or warning being generated, but it is true that using empty or isset to check and array even with a non-existent key, will not produce anything. I committed the trailing space fixes, but decided not to commit the array_key_exists changes in 2.x as there is a logical difference between array_key_exists and !empty, and as we are getting closer to a stable release, I do not want to jeopardize that.
I will change the title of the issue and move it to be applied to the 3.x branch where we will have more time to look at each array_key_exists instance and determine whether a !empty should be used, and to deal with the consequences if our analysis is incorrect.
Comment #12
joelpittet@fmizzell thanks for committing the whitespace cleanup.
It's a nice freedom to know you don't need to write both
isset() && !empty()like you used to back in the day;) At least that's how I felt when I learned the trick was possible and that they included__issetcheck in theempty()function call implicitly.As long as you can safely say you don't need
NULL, [], 0, '0', '', FALSE... which is a lot of the time, !empty() check is quicker, easier to type and understand.Comment #13
legolasboI guess this should be fixed since there is a commit. Doesn't really matter though, since 7.x-3.x is no longer supported.