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

Update ReferenceHelper.php #1873

Merged
merged 3 commits into from
Mar 1, 2021

Conversation

ivanstan
Copy link
Contributor

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

Fixes issue #1872

Copy link
Member

@MarkBaker MarkBaker left a comment

Choose a reason for hiding this comment

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

Thank you for identifying this problem, and for the resolution

@@ -608,7 +608,12 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee
// Update workbook: define names
if (count($pSheet->getParent()->getDefinedNames()) > 0) {
foreach ($pSheet->getParent()->getDefinedNames() as $definedName) {
if ($definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
$hash = null;
if ($definedName->getWorksheet()) {
Copy link
Member

Choose a reason for hiding this comment

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

Just for the sake of readability, can you do an explicit comparison for not null)..

This is something that I've been doing in all the code that I've been working with recently, and it does make the if comparison a lot more explicit rather than relying on the loose typed truthiness/falsiness of PHP

@@ -608,7 +608,7 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee
// Update workbook: define names
if (count($pSheet->getParent()->getDefinedNames()) > 0) {
foreach ($pSheet->getParent()->getDefinedNames() as $definedName) {
if ($definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
if ($definedName->getWorksheet() !== null && $definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarkBaker does this make sense?
I don't think updateCellReference should be called on a null worksheet

Copy link
Member

Choose a reason for hiding this comment

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

Makes perfect sense. thanks for the quick update

@@ -608,7 +608,7 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee
// Update workbook: define names
if (count($pSheet->getParent()->getDefinedNames()) > 0) {
foreach ($pSheet->getParent()->getDefinedNames() as $definedName) {
if ($definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
if ($definedName->getWorksheet() !== null && $definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
Copy link
Member

Choose a reason for hiding this comment

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

Makes perfect sense. thanks for the quick update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants