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

Do not find references for empty values #21799

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Oct 12, 2021

Overview

Do not find references for empty strings or null values when looking for references to an entity

Before

The reference count query throws a fatal error if the target column is NULL and returns matches for an empty string

After

A result of 0 is returned when there is no usable value

Technical Details

When looking for references to a column we really want references to 'real values' not empty fields. 0 is a bit ambiguous & behaviour is unchanged.

Comments

@civibot
Copy link

civibot bot commented Oct 12, 2021

(Standard links)

@civibot civibot bot added the master label Oct 12, 2021
@@ -113,7 +113,7 @@ public function findReferences($targetDao) {
public function getReferenceCount($targetDao) {
$targetColumn = $this->getTargetKey();
$params = [
1 => [$targetDao->$targetColumn, 'String'],
1 => [$targetDao->$targetColumn ?? '', 'String'],
Copy link
Contributor

Choose a reason for hiding this comment

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

also I would have thought that needs to be $targetDao->{$targetColumn} but that seems fine for the casting tho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seamuslee001 I've updated this to bypass the query if null rather than 'make it work' after more thought/discussion. I did adopt your syntax although I think they are probably equally ok

@eileenmcnaughton eileenmcnaughton changed the title Cast null to string where string expected Do not find references for empty values Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants