Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 629 - Remove duplicate strtoupper #825

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix column names if read filter calls in XLSX reader skip columns - [#777](https://github.com/PHPOffice/PhpSpreadsheet/pull/777)
- Fix LOOKUP function which was breaking on edge cases - [#796](https://github.com/PHPOffice/PhpSpreadsheet/issues/796)
- Fix VLOOKUP with exact matches
- Improved performance when loading large spreadsheets - [#825](https://github.com/PHPOffice/PhpSpreadsheet/pull/825)

## [1.5.2] - 2018-11-25

Expand Down
10 changes: 5 additions & 5 deletions src/PhpSpreadsheet/Worksheet/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,11 @@ public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $
*/
public function getCell($pCoordinate, $createIfNotExists = true)
{
// Uppercase coordinate
$pCoordinateUpper = strtoupper($pCoordinate);

// Check cell collection
if ($this->cellCollection->has(strtoupper($pCoordinate))) {
if ($this->cellCollection->has($pCoordinateUpper)) {
Copy link
Author

Choose a reason for hiding this comment

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

This seems like a bug to me. Shouldn't get use the same key we checked with has? Based on the code in Cells I think this can return null.

return $this->cellCollection->get($pCoordinate);
}

Expand All @@ -1214,17 +1217,14 @@ public function getCell($pCoordinate, $createIfNotExists = true)
}
}

// Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate);

if (Coordinate::coordinateIsRange($pCoordinate)) {
Copy link
Author

Choose a reason for hiding this comment

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

None of these checks actually need to use the uppercase version as they are only checking for symbols, not letters.

throw new Exception('Cell coordinate can not be a range of cells.');
} elseif (strpos($pCoordinate, '$') !== false) {
throw new Exception('Cell coordinate must not be absolute.');
}

// Create new cell object, if required
return $createIfNotExists ? $this->createNewCell($pCoordinate) : null;
return $createIfNotExists ? $this->createNewCell($pCoordinateUpper) : null;
}

/**
Expand Down