Skip to content

FIX Fix condition checking if a member exists#11794

Merged
GuySartorelli merged 1 commit intosilverstripe:6.0from
creative-commoners:pulls/6.0/fix-change-password
Jul 20, 2025
Merged

FIX Fix condition checking if a member exists#11794
GuySartorelli merged 1 commit intosilverstripe:6.0from
creative-commoners:pulls/6.0/fix-change-password

Conversation

@GuySartorelli
Copy link
Copy Markdown
Member

$hash = $session->get('AutoLoginHash');
if ($hash) {
if (!Member::get()->filter(['AutoLoginHash' => $hash])) {
if (!Member::get()->filter(['AutoLoginHash' => $hash])->exists()) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I could have changed filter() to find() but using exists() is more efficient both in the db itself (uses a SELECT 1 CASE EXISTS (SELECT <where etc>) ELSE 0 query) and in PHP-land since it's a boolean and therefore we don't have to hydrate a whole DataObject record just to throw it away.

Copy link
Copy Markdown
Contributor

@michalkleiner michalkleiner left a comment

Choose a reason for hiding this comment

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

👍 MOG

@GuySartorelli GuySartorelli merged commit 063de0a into silverstripe:6.0 Jul 20, 2025
13 checks passed
@GuySartorelli GuySartorelli deleted the pulls/6.0/fix-change-password branch July 20, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants