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

Bug #885588 reported by Juan Segarra Montesinos
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
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.

Revision history for this message
Juan Segarra Montesinos (juan-segarra) wrote :
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

Hello Juan, thanks for your patch can you please push it to gerrit for revision, see https://wiki.mahara.org/index.php/Developer_Area/Contributing_Code for details. Thanks!

Revision history for this message
Juan Segarra Montesinos (juan-segarra) wrote :

Ops... sorry ;) Done ;)

Revision history for this message
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.

Revision history for this message
Juan Segarra Montesinos (juan-segarra) wrote :

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 :/

Revision history for this message
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
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :
Changed in mahara:
milestone: none → 1.4.2
status: Confirmed → In Progress
importance: Low → Medium
assignee: nobody → Juan Segarra Montesinos (juan-segarra)
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/828
Committed: http://gitorious.org/mahara/mahara/commit/edffa944101f1e8918f0aa7a4e08aca2c07742e4
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
Revision history for this message
Ruslan Kabalin (rkabalin) wrote :

Thanks Juan again, well-spotted issue ;)

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.