After an upgrade to PHP 5.2.3, Apache 2.2.4, APC 3.0.14 and Drupal 4.7.6, we started seeing hundreds of these nag notes in the watchdog: "Attempt to assign property of non-object in /web/blufftontoday.com/htdocs/modules/profile.module on line 498." Buddylist and /profile views seem to trigger the error.

Adding a quick check for a null UID at the top of profile_load_profile makes the problem go away:

if(!$user->uid) return;

This seems benign but I am baffled as to the root cause. AFAIK this function has not been changed in any recent versions.

Comments

haus’s picture

Priority: Normal » Critical

I have the same Problem:

- it happens if someone uses a link an the profile page which is supposed to show a list of users with the same profile item
- The page is correctly displayed but watchdog fills up with error message:

Typ PHP
...
...
Adresse profile/profile_allg_userkat/Hannover.
Referrer ...
Nachricht ‚Attempt to assign property of non-object‘ in ‚.../modules/profile.module‘ in Zeile 499.

- It happens if in profile settings a profile field's page title is set to "%value" as suggested.
- But the error did not appear until today - it might be connected to deleting a user?

I added this hack (which I don't like): "if(!$user->uid) return;" to the function profile_load_profile() and it works.

But it would be very nice to get an advice how to fix this bug correctly

haus’s picture

Priority: Critical » Normal
Status: Active » Fixed

Finally I found my beginners error (actually I found it somewhere else in a snippet):

function profile_load_profile($user) waits for $user - objekt, not for $user->uid which I used.

After I corrected this in a custom profile_listing.tpl.php it works correctly.

Sorry for this.

Anonymous’s picture

Status: Fixed » Closed (fixed)
sudhii9999’s picture

Version: 4.7.6 » 5.2
Status: Closed (fixed) » Active

I am not able to display the profile field information as i am used to with 5.1 version using the following code.please help me out


global $user;


profile_load_profile($user->uid); 

echo "hi";
echo $user->profile_Fname;
echo "</br>";
echo $user->profile_Lname;
echo "</br>";
echo $user->profile_Cname;
echo "</br>";
echo $user->profile_Pnumber;
echo "</br>";
echo $user->mail;
echo "</br>";
echo $user->uid;
echo "</br>";
echo $user->name;
echo "</br>";

the above script used to work in the desired way but its now not working with the 5.2 version please help me out as soon as possible.

yelvington’s picture

Status: Active » Closed (fixed)

As noted above, this is not a Drupal bug, but rather an error in your code. The profile_load_profile function takes a user object as an arg, not a UID, so remove the "->uid" part of the argument in your example.

Closing.