The current version of upload_form_alter() has incorrect arguments. It is currently:

function upload_form_alter(&$form, $form_state, $form_id) {

whereas according to the D6 API it should be:

function upload_form_alter(&$form, &$form_state, $form_id) {

Comments

damienmckenna’s picture

FYI the bug was identified by AyumuKasuga: #1200982: nodewords_form_alter() and php 5.3

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new528 bytes

Here's a quick patch to change the second argument of hook_form_alter() for the upload module to a reference.

damienmckenna’s picture

Title: upload_form_alter()'s second argument should be by reference » hook_form_alter()'s second argument should be by reference

Reviewing the full D6 codebase I've realized that all core implementations of hook_form_alter() are incorrect! Was this on purpose?

damienmckenna’s picture

StatusFileSize
new8.63 KB

Here's a patch to fix all implementations of hook_form_alter() and hook_form_FORM_ID_alter().

Status: Needs review » Needs work

The last submitted patch, drupal6-n1201042-upload_form_alter-4.patch, failed testing.

ppblaauw’s picture

Changing this in the modules would for sites using PHP5.3 cause the following warnings:

warning: Parameter 2 to [modulename]_form_alter() expected to be a reference, value given in .\includes\common.inc on line 2829.

According to the API it should be

hook_form_alter(&$form, &$form_state, $form_id)

But the core modules you have in the patch in #4 and for example CCK don't pass $form_state by reference.
they use:

hook_form_alter(&$form, $form_state, $form_id)

It is stated that PHP5.3 is supported for Drupal 6.14 and up, according to the system requirements page.
Should the API documentation be changed for Drupal 6?

Edit:See also http://drupal.org/node/649106 for an explanation

marciaj’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal6-n1201042-upload_form_alter-4.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.