Repeatable: Always

Steps to repeat:
1) Install Misery,
2) Log in as user assigned to endure Misery,
3) Note error at top of page,
4) Post comment / content

Expected result:
Misery - delay of 5+ seconds and 100% forms do not validate.

Actual result:
Errors & Warnings, no delay, content / comment does get posted.

warning: Parameter 3 to misery_misery_perform() expected to be a reference, value given in /...[redacted].../drupal/includes/module.inc on line 461.

OS: Ubuntu 10.04
Database: MySQL 5.1.41-3ubuntu12.10-log
Web Server: Apache 2.2.21
PHP 5.3.8
Suhosin Extension 0.9.32.1
PHP error_reporting = E_ALL & ~E_NOTICE
PHP display_errors = On
Drupal 6.22

I hope I've done everything correctly so far in my submission. It's rather a lot of work just to point out that one character (the final ampersand (&)) needs removing on line 345:

function misery_misery_perform($handler, $type, &$params = array()) {

to this:

function misery_misery_perform($handler, $type, $params = array()) {

Patch file attached below...

Thanks Daniel, I love Misery!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danielb’s picture

Status: Active » Fixed

I've made that change in both branches, cheers.

Status: Fixed » Closed (fixed)

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

GeduR’s picture

Hi! This bug is also on 7.x-2.0 branch too. (I'm using php 5.3).

VanRon patch seems to fix it.

GeduR’s picture

GeduR’s picture

Status: Closed (fixed) » Active

Sorry, I forgot to reopen the bug.

jtherkel’s picture

Version: 6.x-1.8 » 7.x-2.0
Status: Active » Reviewed & tested by the community

Confirming this as a bug in the Misery 7.x-2.0 branch. I'm running Drupal 7.19 and PHP 5.3.3. The patch in #4 worked.

Prior to applying the patch, there was an issue with the form at admin/people/misery. You had to ensure all your numbers entered in the fields labeled "Chance: % (per page load)" totaled 100% or less.

If you entered 50% for "404 Not found" and 51% for "Delay," you would see the "expected to be a reference" error, and Misery would not function.

The patch looks good to me. Changing the issue version to 7.x-2.0.

Correction: The patch works if you remove ", $params" from the line below in misery.module and do not rely on any miseries that have additional parameters. For example, "Delay configuration" has the Min Delay and Max Delay parameters. I don't think "Delay configuration" works after removing the bit below.

// Change this:

// Perform this misery.
module_invoke($handler_data['#module'], 'misery_perform', $handler, $type, $params);

// To this:
// Perform this misery.
module_invoke($handler_data['#module'], 'misery_perform', $handler, $type);

jtherkel’s picture

Status: Reviewed & tested by the community » Needs work

Changing issue status to "needs work."

GeduR’s picture

I was working a little more in this bug, thinks I've seen:

Misery evaluates all available miseries with misery_random_task so don`t need to add up to 100 as comment #6 said. This works as expected.

Code:

foreach ($handlers as $handler => $handler_data) {
      if ($handler_data['#type'] == $type) {
        $chance = variable_get('misery_' . $handler . '_chance', $handler_data['#default_chance']);
        if (misery_random_task($chance)) {
          // Perform this misery.
          module_invoke($handler_data['#module'], 'misery_perform', $handler, $type, $params);
        }
      }
}

The $params value is used in misery_performs: spam and form_submit so can't be deleted.

With the patch #4 I've tested all miseries and seems to work properly. I've also checked is working the misery_perform with $params: spam & form_submit.

GeduR’s picture

Status: Needs work » Needs review

With the patch #4 I've tested all miseries and seems to work properly. I've also checked is working the misery_perform with $params: spam & form_submit.

GeduR’s picture

Status: Needs review » Fixed

Commited to 7.x.2.x branch

Status: Fixed » Closed (fixed)

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