I have a flag called feature and a flag called like, which uses dlike.
I create a new node, and then flag it with "feature".
Upon reload, an error appears:
Notice: Undefined index: like in dlike_append() (line 50 of /var/www/drupal/sites/all/modules/dlike/dlike.inc).
Then, if I "like" and reload again, it goes away.
Please help?
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | dlike-error_with_multiple_flags-1699352-18.patch | 759 bytes | dieuwe |
| #16 | dlike-multiple-flags-v3.patch | 875 bytes | sneyerst |
| #8 | dlike-multiple-flags-undefined-1699352-8-7.39.patch | 4.3 KB | ReBa |
Comments
Comment #1
DrupalDesigner-1 commented+ 1
Comment #2
mediaformat commented+ 1
Comment #3
Vlad Stratulat commented+1
The problem here is because dlike uses flag_get_counts() function from flag module. This function count for flags in specific node and it doesn't matter which type of flag was made, like, abuse or whatever.
I think it's better to clone this function into dlike module and add flag filter to it. Something like:
Here's how I handle it:
I cloned flag_get_counts() function from flag module with some changes as follows:
Then in dlike.inc file in line 51 I replaced this:
Into this
Hope this will help everyone and it will be implemented in dlike.
Cheers
Comment #4
sascher commentedYour fix works.
Thank you for the great module
Comment #5
leeotzu commentedComment #6
aalireza commentedplease make a path.
where shound put this code ?
Comment #6.0
aalireza commentedTweak
Comment #7
dankung1 commentedafter modify the dlike.inc file, the issue remains, I used the following code to created two flags at product display page. It shows undefiend index like .......
Is there a way to hide the PHP error message,
Notice: Undefined index: like in dlike_append() (line 50 of /var/www/drupal/sites/all/modules/dlike/dlike.inc).
@Vlad Stratulat
Comment #8
ReBa commentedI think this could be resolved by changing 1 line of code. Patch provided.
Comment #9
mediaformat commentedComment #10
flutterstack commented#8 is working fine for dlike 7x-2x.
Comment #11
anybodyI can confirm this problem sadly still exists for the 7.x-3.x version. Please also fix it there.
Comment #12
anybodyIn 7.x-3.x version it seems to be just an isset-check which is missing.
Comment #14
gwereg commentedTo fix it, in dlike.inc file, about line 47, just replace
if ($dlike_append_count && $dlike_append_count[$flag_name] > 0) {into this
if ($dlike_append_count && isset($dlike_append_count[$flag_name]) && $dlike_append_count[$flag_name] > 0) {Comment #15
gokulnk commentedComment #16
sneyerst commentedPatch for 7.x-3.0 attached.
Comment #17
majumdaraditya21@yahoo.in commentedPatch is not being applied . Needs reroll.
Comment #18
dieuweTry this, re-rolled against latest dev. I've removed the initial check to see if the variable exists, because isset() actually takes care of that.
Comment #20
dieuwe