Opened 5 years ago

Closed 5 years ago

#820 closed Bug (fixed)

Piwik_ViewDataTable: $this->dataTable->getFirstRow() returns false and attempts to access getColumns()

Reported by: andrew.johnstone Owned by:
Priority: major Milestone: Piwik 0.4.1
Component: Core Keywords:
Cc: Sensitive:

Description

If empty result set you cannot retrieve the columns, see modified code below

        /**
         * Returns columns names to display, in order.
         * If no columns were specified to be displayed, return all columns found in the first row.
         * @param array PHP array conversion of the data table
         * @return array
         */
        public function getColumnsToDisplay()
        {
                if(empty($this->columnsToDisplay))
                {
                        $row = $this->dataTable->getFirstRow();
                        if (empty($row))
                                return array();

                        return array_keys($row->getColumns());
                }
                $this->columnsToDisplay = array_filter($this->columnsToDisplay);
                return $this->columnsToDisplay;
        }

Change History (2)

comment:1 Changed 5 years ago by vipsoft (robocoder)

  • Milestone set to 1 - Piwik 0.4.1

comment:2 Changed 5 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from new to closed

(In [1245]) fixes #820

Note: See TracTickets for help on using tickets.