Download & Extend

Parameters passed by value instead of reference

Project:Secure Pages
Version:6.x-1.8
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

PHP 5.3.0 revealed that some functions in extension modules require references as parameters, but get values instead. It produces a bunch of warnings.

For example, securepages_link_alter() called using call_user_func_array() at includes/common.inc:2830 gets its second (and unused) parameter by value, although its declaration expects references. Fortunately, this parameter is neither assigned nor modified in any way, so this doesn't change the semantics.

AFAIK,

  1. Modules shouldn't get direct references to shared data structures so that they can't modify them. (There's probably nothing like a 'constant reference' in PHP.)
  2. PHP uses the CoW (Copy on Write) approach when parameters are passed by "value", so there should be no performance penalty compared to passing by "reference", provided that they are not assigned or modified.

If I'm not mistaken, this issue could be resolved by simply removing the &.

Comments

#1

Priority:minor» normal
Status:active» needs review

Attached is a patch that resolves this. Given that php 5.3 is now standard on the latest LTS release from ubuntu, this notice will start appearing with increasing frequency.

AttachmentSize
securepages.600106.patch 432 bytes

#2

Status:needs review» fixed

Thanks, committed

#3

Status:fixed» closed (fixed)

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