Can't use method return value in write context error in forgotpass.php

Bug #1472443 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned
15.04
Fix Released
Medium
Unassigned
15.10
Fix Released
Undecided
Unassigned

Bug Description

Reported on the mahara.org forum, as a follow-up to Bug 1460911: https://mahara.org/interaction/forum/topic.php?id=7288&offset=0&limit=10#post29295

"When we tried it on our server running php version 5.4.16 on Redhat 7.1, we get a blank page and the the error

PHP Fatal error: Can't use method return value in write context in /var/www/html/mahara/forgotpass.php on line 21, referer: http://cepd.aut.ac.nz/mahara/

Line 21 is:

if (!empty($SESSION->get('pwchangerequested'))) {

Looking into the issue I found http://stackoverflow.com/questions/1075534/cant-use-method-return-value-in-write-context/4328049#4328049 which basically says on empty() needs to access value by reference (in order to check whether that reference points to something that exists), and PHP before 5.5 didn't support references to temporary values returned from functions. Following what they suggested I changed line 21 to:

if ($SESSION->get('pwchangerequested')) {

Which if the answer in stackoverflow is correct should be the same as it was previously. After doing that no error is given and the page renders. Would this be the correct change for people that get that error?"

Summary: Need to remove the empty() check as the options for the variable 'pwchangerequested' is true/false

Robert Lyon (robertl-9)
Changed in mahara:
milestone: none → 15.10.0
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/4928

Aaron Wells (u-aaronw)
description: updated
description: updated
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4928
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/31c224836c7471a06e97b5471caa1c7583618a4b
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit 31c224836c7471a06e97b5471caa1c7583618a4b
Author: Robert Lyon <email address hidden>
Date: Wed Jul 8 12:29:48 2015 +1200

Fixing issue with forgotpass and older php versions (Bug #1472443)

Change-Id: Ifc06de12c5714b26b4705ec5d495601c4ccce437
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/4942

Aaron Wells (u-aaronw)
Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4942
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/85c334d83a8ba569fe628c19b27d85f8c805e6c4
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit 85c334d83a8ba569fe628c19b27d85f8c805e6c4
Author: Robert Lyon <email address hidden>
Date: Wed Jul 8 12:29:48 2015 +1200

Fixing issue with forgotpass and older php versions (Bug #1472443)

Change-Id: Ifc06de12c5714b26b4705ec5d495601c4ccce437
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 31c224836c7471a06e97b5471caa1c7583618a4b)

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

This patch was provided by Jawyei Wong from AUT University and accidentally not pushed under his name.

Robert Lyon (robertl-9)
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.