New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array to String conversion notice #106
base: master
Are you sure you want to change the base?
Conversation
Maybe I'm missing something, but shouldn't this be comparing values instead of keys? Or at least in addition to? |
You are right. I changed it instead of pseudo intersecting to a recursive diff function. |
Just seems that it would be good to compare values when checking for duplicate jobs. I can have two jobs with the same keys but wildly different values, and I'd hate those to be treated as the same job. Just saw the new commit. Seems good, though I have to wonder why you use |
To be honest I copied this from the PHP Bug Report where people provided a recursive function. I think it uses isset() and array_key_exists() in order check in one scenario only if a key is present and the other case prevents it from being NULL. |
Odd. We probably care about NULLs in both cases, here... |
If NULL values should be compared we need to use array_key_exists which is used in the second case. In the first case isset is used because it doesn't matter we have checked before if it is an array. Which is good, in a case that we have in one array an empty array and in the other under the same key just a NULL value this would be treated as difference. But this is probably a VERY rare edge case. |
Noting that Probably be good to check coding standards compliance, though. Not sure why people are so fond of |
I am flexible with the coding standard. I use whatever my IDE is doing to my code. Do I need to adapt anything in order to get this merged? |
I don't know if it's related but I've been debugging a problem with php-resque-scheduler, I had a problem in this line of php-resque-scheduler, there was a problem with zrangebyscore. https://github.com/chrisboulton/php-resque-scheduler/blob/master/lib/ResqueScheduler.php#L228 $items = Resque::redis()->zrangebyscore('delayed_queue_schedule', '-inf', $at, array('limit' => array(0, 1))); Removing the array('limit'...) solve all my issues, It seems that's not working, It also solved my problem with array string conversion. $items = Resque::redis()->zrangebyscore('delayed_queue_schedule', '-inf', $at); |
@javaguirre - If you search the issues for Scheduler, you'll find references to a difference in how Credis handles @KeKs0r - Indentation should be consistent with the rest of the file (spaces versus tabs and that kind of thing), |
@KeKs0r Please reformat the code to this and test it: /**
* Intersect of recursive arrays
* needed for enqueueOnce
*
* @param array $array1
* @param array $array2
* @return array
*/
protected static function array_diff_assoc_recursive($array1, $array2)
{
$difference = array();
foreach($array1 as $key => $value) {
if(is_array($value)) {
if(!isset($array2[$key]) || !is_array($array2[$key])) {
$difference[$key] = $value;
} else {
$new_diff = self::array_diff_assoc_recursive($value, $array2[$key]);
if(!empty($new_diff)) {
$difference[$key] = $new_diff;
}
}
} else {
if(!array_key_exists($key, $array2) || $array2[$key] !== $value) {
$difference[$key] = $value;
}
}
}
return $difference;
} |
@danhunsaker Thank you, I'll do that. :-) |
@KeKs0r Any news on this? |
Having the same problem with enqueueOnce. For me it is "caused" by setting auto_retry strategy for a job which is then part of "args" and fails in enqueueOnce |
BTW I don't think array_diff_assoc_recursive is doing the right job because it does not enqueue job with different values of args. |
Hi there, as it's clear that this bundle is no longer being maintained I've published a fork at https://github.com/mpclarkson/resque-bundle where I have already incorporated a bundle of changes and improvements. Your contributions would be appreciated. This is still a bug. |
This pull request adresses issue #101