Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

fix Trying to access array offset on value of type null #395

Merged
merged 1 commit into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RowGateway/AbstractRowGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function delete()
$where = [];
// primary key is always an array even if its a single column
foreach ($this->primaryKeyColumn as $pkColumn) {
$where[$pkColumn] = $this->primaryKeyData[$pkColumn];
$where[$pkColumn] = ($this->primaryKeyData ? $this->primaryKeyData[$pkColumn] : null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two comments here:

  • brackets are redundant
  • we should use isset($this->primaryKeyData[$pkColumn]), imo

}

// @todo determine if we need to do a select to ensure 1 row will be affected
Expand Down
6 changes: 4 additions & 2 deletions src/TableGateway/AbstractTableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ public function selectWith(Select $select)
protected function executeSelect(Select $select)
{
$selectState = $select->getRawState();
if ($selectState['table'] != $this->table
if (isset($selectState['table'])
&& $selectState['table'] != $this->table
&& (is_array($selectState['table'])
&& end($selectState['table']) != $this->table)
) {
Expand All @@ -225,7 +226,8 @@ protected function executeSelect(Select $select)
);
}

if ($selectState['columns'] == [Select::SQL_STAR]
if (isset($selectState['columns'])
&& $selectState['columns'] == [Select::SQL_STAR]
&& $this->columns !== []) {
$select->columns($this->columns);
}
Expand Down