Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
upon upgrading to ogx2, which uses entity references, get these errors when view the panels layout, e.g. /admin/structure/pages/nojs/operation/node_view/handlers/node_view_panel_context/content
Notice: Trying to get property of non-object in flag_entity->applies_to_content_object() (line 1391 of /www/www-staging/drupal.sandbox.sanger.ac.uk/htdocs/sites/all/modules/contrib/flag/flag.inc).
Comment | File | Size | Author |
---|---|---|---|
#11 | flag-null_entity-2135865-11.patch | 612 bytes | maximpodorov |
Comments
Comment #1
joachim CreditAttribution: joachim commentedWhat's ogx2?
Can you debug to find out why Flag doesn't get what it's expecting there?
Comment #2
StephenRobinson CreditAttribution: StephenRobinson commentedorganic groups v2
Comment #3
StephenRobinson CreditAttribution: StephenRobinson commentedtried this
and got
Comment #4
StephenRobinson CreditAttribution: StephenRobinson commentedthe new organic groups uses the project entityreference?
Comment #5
StephenRobinson CreditAttribution: StephenRobinson commentedthe this:
and got
Comment #6
StephenRobinson CreditAttribution: StephenRobinson commented$entity appears to be null...
Comment #7
StephenRobinson CreditAttribution: StephenRobinson commentedand got
Comment #8
StephenRobinson CreditAttribution: StephenRobinson commentedand got
Comment #9
StephenRobinson CreditAttribution: StephenRobinson commentedthis seems to fix it without any noticable side effects:
Comment #10
joachim CreditAttribution: joachim commented$entity should not be NULL. Can you figure out who's calling that improperly?
BTW, very good debugging!
I recommend the use of devel module, as its dpr() and dpm() functions will save you a lot of typing :)
Comment #11
maximpodorov CreditAttribution: maximpodorov commentedIt's Flag module who passes NULL object into entity hooks. This commit
http://drupalcode.org/project/flag.git/commitdiff/ed26347
unconditionally passes $flagging variable into entity_presave hooks. The patch fixes this.
Comment #13
maximpodorov CreditAttribution: maximpodorov commentedSorry, my patch was for 7.x-3.x version. Maybe it should go to e new issue.
Comment #14
joachim CreditAttribution: joachim commentedI don't think your patch is related to this issue.
Comment #15
maximpodorov CreditAttribution: maximpodorov commentedOK? I've created new issue: #2162925: Passing NULL to entity hooks.
Comment #16
joachim CreditAttribution: joachim commented#2162925: Passing NULL to entity hooks is now fixed, but it's unrelated to this issue because on 2.x flagging records are not entities.
Comment #17
hyside CreditAttribution: hyside commentedI was also running into this issue, attempting to view flagged content of all types in a custom view whenever a user attempted to view that page with no content actually flagged yet. The issue was in flag.inc around line 1391, trying to read a non-object when there were no flagged items, so I added a validity check on $entity prior to attempting to read it.
Moving from this:
To this:
Comment #18
joachim CreditAttribution: joachim commented> I was also running into this issue, attempting to view flagged content of all types in a custom view whenever a user attempted to view that page with no content actually flagged yet.
I don't quite follow your setup. Could you explain in a bit more detail please? It sounds like you're talking about a VBO -- is that the case?
Comment #19
hyside CreditAttribution: hyside commentedI was trying to create a page that showed all content that had been flagged for a given user with links to each of those pieces of flagged content using something like this to create the links
Not sure if this helps point you in the right direction?
Comment #20
joachim CreditAttribution: joachim commentedOh dear me. First off, use Views for something like that.
Second, use arg() instead of $_GET['q'].
Third, you're possibly setting $current_nid to the string 'tmp', which clearly isn't a node ID. It's not surprising that Flag chokes on that!