When i actvate the module it comes : Notice: Trying to get property of non-object in user_access() etc.... And that appears whenever a user go to open an article or a node... What can i do?

Comments

danreb’s picture

I have this notice too.

    Notice: Trying to get property of non-object in user_access() (line 790 of /home/cavhostc/jsales/modules/user/user.module).
    Notice: Trying to get property of non-object in user_access() (line 802 of /home/cavhostc/jsales/modules/user/user.module).
    Notice: Trying to get property of non-object in user_access() (line 803 of /home/cavhostc/jsales/modules/user/user.module).
    Notice: Trying to get property of non-object in user_access() (line 809 of /home/cavhostc/jsales/modules/user/user.module).
    Notice: Trying to get property of non-object in user_access() (line 812 of /home/cavhostc/jsales/modules/user/user.module).
    Notice: Trying to get property of non-object in twitter_twitter_accounts() (line 257 of /home/cavhostc/jsales/sites/all/modules/twitter/twitter.module).
danreb’s picture

Title: Problem!!!! » Notice: Trying to get property of non-object in user_access() (line *

Change issue title

graemehunter’s picture

I have the same issue as danreb in comment #1, doesn't happen on the home page of the site, but that same set of errors appears when I go to an article or node on my test site.

pinguinland’s picture

Exactly the same problem...

dtone’s picture

I get the exact same notice (as in #1) when I finished setting up the OAuth (7.x-3.0-alpha2) & twitter (7.x-3.0-beta3) modules and then posting an article (which is nevertheless accepted and visible as a feed at my twitteraccount).

zoszabo’s picture

Same problem ...

steinmb’s picture

Any of these twitter accounts private?

oenie’s picture

I traced the problem back to the 'tweets' view of the twitter module.
For some reason, the view is getting called with the node id as the user-id , which, in most test-cases, isn't an existing user.
There's no check whatsoever on whether a user_load with the supposed uid yields a user, with the problems as listed in the OP's message.

Your best solution for now; disable the tweets view (added by the Twitter module) in your views section , and your problem should go away.
Mine did !

I'm looking into why the view is actually getting called, because it has a specific path associated (it could be because of the block)

to be continued

oenie’s picture

OK, as i suspected, i found the actual reason:

The tweets view, added by the Twitter module, has a block 'User tweets'.
However that block has a contextual filter that takes a UID.
In my opinion, this is not right. It was probably mistakenly added to the Block view, where it should only be on the Page-view.
So you can leave the view enabled, but be sure to either disable the block User Tweets or make sure it is only on pages without extra parameters that might be interpreted as a UID.

I think the block of the tweets view of the twitter module ought to be reviewed.

steinmb’s picture

As far as I know is the reason for picking up the uid for the block is to show tweet's from the node author. Not sure why, but this user also reported problems with uid and Views, this time in 6.x-3 #1372312: SQL errors in Views

pinguinland’s picture

Yes it worked for me!

MLSatya’s picture

Yes I am having the same issue, but I would prefer not to disable the block. I need the tweets to come in a block and appear only on the home page.

WildStar’s picture

Also having this issue.

danreb #1 who first reported the problem, and oenie #9 who homed in on the issue are spot on!!

Was trying to run tweets module with views ticker with a block display. Until fixed, how does one display with page?

I know it's beta.... but I'm anxious for a fix. :) This is a GREAT Drupal module!

Anonymous’s picture

Disabling the bock did it for me, thanks!

alberto56’s picture

StatusFileSize
new598 bytes

As oenie mentioned in comments 8 and 9, the tweets view assumes that arg(1) is the uid, when it is not necessarily: it can be anything.

For my purposes, I never need to view the tweets of a given user, only the tweets view which ignores the user argument. For me the following patch works

I am including a patch that works for these purposes, but if you want to see individual users' tweets, this might not work for you.

sfsilks63’s picture

Hi I have the same problem but I have disabled the block and it is still the same
http://www.naked-runner.com/?q=content/almeria-half-marathon

fraweg’s picture

Hi,

Hi I have the same problem but I have disabled the block and it is still the same
http://www.naked-runner.com/?q=content/almeria-half-marathon

For me the same!

The second thing is that the "http://...../user/1/tweets" shows no tweets. But when I save a forum topic it is shown in my "normal" twitter account under "https://twitter.com/#!/User"

Posted by grobot on May 9, 2011 at 12:57pm
Everybody:
* Check you're running cron.
* If you're importing a protected account, you may want to edit the view to show protected tweets.
* Have a look in the {twitter} table to see if you're getting tweets saved.

This solved the second issue!But the first still alive!

Can anyone help me?
Thanks in advanced!
Frank

webatelier’s picture

Follow this howto and it should be fine
http://drupal.org/node/1253026

especially this part is important :
Expand the "Advanced" link (in Drupal 6, it is called "Arguments") at the right and remove the contextual filter by clicking on it and hitting "Remove".

worked for me after initially having the same problem

damien_vancouver’s picture

Hello all,

I just wanted to clarify why this is happening and provide the best instructions I was able to find.

By default, the Twitter module creates a block using Views, that is intended to be displayed on User pages only. So, the reason you are seeing errors is that when you enable that block site-wide, it can't figure out which user it's supposed to display for... because it gets that user ID by expecting you are viewing a user's account page, ie. http://example.com/user/123 would look up the tweets for uid 123. So you get those PHP errors if you are at a path that doesn't have a uid as the second element.

The solution is to create a new clone of the "User Tweets" block, that is set up to display tweets from a single, fixed User ID. Then it will work on any page!

So, if you want a global block of twitter feeds from a single user, here is what to do.

  • Set up a user with a twitter feed in the user's account page. Make note of the user's uid. If you're using the Drupal administrator account, then your uid is 1.
  • Visit Structure >> Views, edit the tweets view.
  • Click the "Block" display (next to "Page"), and you are looking at the block
  • Click "Clone Block" and it will make you a new block to use for global tweets.
  • Under "Block Settings" - "Block Name", click the "User Tweets" name and rename the block to "Global Tweets".
  • Expand "Advanced" and under "Contextual Filters" click "User:Uid" to edit the filter.
  • Make sure "This block only (override)" is selected in the dropdown (VERY important) and then:
  • change "Provide default Value" dropdown to read "Fixed value" and then put the global tweet user's uid in there. To show tweets from the drupal admin user, you'd set Type = Fixed Value, Fixed value 12. To show the tweets from user 1, you'd set Type = Fixed Value, Fixed Value = 12. See the attached screenshot for how this should look when you have it set right.
  • You can also set other options here like # of results (5 is a good number), pager (mini pager is a good choice), a header or a footer (a link to the actual twitter account in the footer works well too). Remember in each case to set the dropdown to be "This block only (override), or you can accidentally change settings for all your views. I recommend only changing one thing at a time, saving, and reviewing your work before changing the next thing.
  • Choose "Save" to save your view with the new "Global Tweets" block.
  • Visit Structure >> Blocks and this new Global Tweets block will show up in the bottom list of disabled blocks. Position it in a sidebar or wherever you want.

Now you should be able to use the Global tweets block site-wide, but you can still use the User Tweets block and page for individual users.

To change which user is the global tweet user, edit the User:Uid contextual argument you set above and change the fixed value to be the new user id.

To make the global tweets block show ALL tweets from ALL users on the site, you can just remove the Contextual User:uid filter altogether. Edit the view, click the filter, and hit "remove" next to it. (remember to make sure you've chosen "This block only (override)"!!).

Other sources of these instructions are: #574556: Global account's tweets don't appear and http://drupal.org/node/1253026. If you're still confused, try reading those too!

I'm changing this issue status to be a documentation issue, as it's not actually a bug. What we are missing is clear instructions in the module's README.txt on how to accomplish this. I will work on a patch for that and post it on here.

johnpicozzi’s picture

Title: Notice: Trying to get property of non-object in user_access() (line * » Document site-wide tweet block and error: Notice: Trying to get property of non-object in user_access() (line *
Component: User interface » Documentation
Category: bug » task
Priority: Major » Normal
Status: Active » Needs work
Issue tags: +Needs documentation

I was having the same issue and I didn't want to disable the block. I removed the UID from the contextual filters section and the problem seems to have gone away. Not a fix but a way around the error if you need tweets and don't care about specific users. Another note, I am using one "Global" Twitter account.

scthomps312’s picture

I had to add another step to #19 to get this to work. When doing this action...

  • change "Provide default Value" dropdown to read "Fixed value" and then put the global tweet user's uid in there. To show tweets from the drupal admin user, you'd set Type = Fixed Value, Fixed value 12. To show the tweets from user 12, you'd set Type = Fixed Value, Fixed Value = 12. See the attached screenshot for how this should look when you have it set right.

...you still have to deal with the case where an argument is available, because the first step in the Twitter PHP is to get arg(1), which the code assumes is a user ID. My fix was to comment that out and set $uid to 7, same as the Fixed Value I set in #19's instructions.

//$uid = arg(1);
$uid = 7;

See the attached screenshot. I also commented out the if/else, as it becomes unnecessary.

I'm using a global Twitter account where the block is displayed several places on the site, which I mention because it's critical to the use case.

Donovan’s picture

I kept getting an "Ajax" error with every attempt to change uid to admin uid. In the process I noticed that the "User Tweets" block was enabled in addition to the cloned "Global Tweets" block, so I disabled the "User Tweets" block ... and Presto! problem solved!!

juampynr’s picture

Version: 7.x-3.0-beta4 » 6.x-3.x-dev

Removed inherited contextual filter uid from Views Block display.

http://drupalcode.org/project/twitter.git/commitdiff/f4e985b

Porting now to the Drupal 6 version.

juampynr’s picture

Status: Needs work » Fixed

Backported to Drupal 6.

http://drupalcode.org/project/twitter.git/commitdiff/b1aa51c

Thanks everyone for the support and info given!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

juampynr’s picture

Title: Document site-wide tweet block and error: Notice: Trying to get property of non-object in user_access() (line * » Unneded uid argument in Tweets block view generates PHP warnings

Changing title.