I was reading through the code for hosting_task and came across the hosting_task_handler_filter_hosting_task_type views filter handler. Upon inspection, it looks like it has several code issues.

Let's take a read:

function get_value_options() {
    if (!isset($this->value_options)) {
      $this->value_title = t('Task Type');
      $tasks = array(); // FIXME: This variable is never used. Shouldn't this be $options?
      foreach (array('site', 'platform') as $task) { // FIXME: This version of the $task variable isn't ever referenced.
        $types = hosting_available_tasks('site'); // FIXME: Shouldn't 'site' be $task (or whatever name we come up with for the iterator?)
        foreach ($types as $type => $task) { // FIXME: $task is re-declared.
          $options[$type] = $task['title'];
        }
      }
      $this->value_options = $options;
    }
  }

Here's my proposed re-work:

function get_value_options() {
    if (!isset($this->value_options)) {
      $this->value_title = t('Task Type');

      $options = array();

      foreach (array('site', 'platform') as $type) {
        $tasks = hosting_available_tasks($type);

        if (!empty($tasks)) {
          foreach ($tasks as $identifier => $task) {
            $options[$identifier] = $task['title'];
          }
        }
      }

      $this->value_options = $options;
    }
  }

Comments

Steven Jones’s picture

Status: Active » Fixed

Yeah, the views code doesn't get used as much as it should...thanks for the fix!

GuyPaddock’s picture

Thanks, Steven!

Status: Fixed » Closed (fixed)

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

  • Commit 1d5c157 on 7.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x authored by GuyPaddock, committed by Steven Jones:
    Issue #1282172 by GuyPaddock: Fixed...

  • Commit 1d5c157 on 7.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x authored by GuyPaddock, committed by Steven Jones:
    Issue #1282172 by GuyPaddock: Fixed...