user/view.php PHP Fatal error in non-auth access

Bug #885588 reported by Juan Segarra Montesinos on 2011-11-03
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Juan Segarra Montesinos

Bug Description

This is Mahara 1.4.0:

Each 4 minutes or so, I was getting the following error on PHP error log:

PHP Fatal error: Call to a member function get() on a non-object in [MAHARA_DIRROOT]/user/view.php on line 67

To reproduce just access /user/view.php without being authenticated. The access log shows GoogleBot trying to access user's profile page.

Ruslan Kabalin (rkabalin) wrote :

Hello Juan, thanks for your patch can you please push it to gerrit for revision, see for details. Thanks!

Ops... sorry ;) Done ;)

Ruslan Kabalin (rkabalin) wrote :

Hello Juan, I can't reproduce it for some reason. $view object always exist, does not matter if you are authenticated or not (lines 58-65). And if you try accessing non-existing user it will throw the exception earlier.

I've realised that the error isn't raised with all users, just those without a profile view. You can try with any of these:

   select id from usr where id not in ( select distinct owner from view where type='profile' );

Take one id and access /user/view.php?id={one of the preovious id}

Maybe is not a general problem... just a problem with the way we are creating our users... mmmm... is it possible to have a user created without a profile view?

Look at get_view_by_type() method. If profile view doesn't exists and you're not logged in, null is returned. That's what I'm getting here :/

Ruslan Kabalin (rkabalin) wrote :

That is true, attempt to access user that has been created but does not have profile will cause fatal error.

Regarding your question, yes, it is possible to have the user without profile. The profile view is created on the first user login, see auth/user.php, load_views() call from authenticate().

Changed in mahara:
status: New → Confirmed
importance: Undecided → Low
Changed in mahara:
milestone: none → 1.4.2
status: Confirmed → In Progress
importance: Low → Medium
assignee: nobody → Juan Segarra Montesinos (juan-segarra)

Submitter: Richard Mansfield (<email address hidden>)
Branch: 1.4_STABLE

commit edffa944101f1e8918f0aa7a4e08aca2c07742e4
Author: Juan Segarra Montesinos <email address hidden>
Date: Thu Nov 3 09:45:04 2011 +0100

    Fix PHP Fatal Error in user/view.php

    Reported in Bug #885588

    Change-Id: I10e2277e3b0d0e83ae2348ea3212c711e42ca353
    Signed-off-by: Juan Segarra Montesinos <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
Ruslan Kabalin (rkabalin) wrote :

Thanks Juan again, well-spotted issue ;)

Melissa Draper (melissa) on 2012-03-06
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers