$query = $this->connection
        ->queryRange('SELECT session FROM {sessions} WHERE sid = :sid', 0, 1, ['sid' => Crypt::hashBase64($sid)]);

should be

$query = $this->connection
        ->queryRange('SELECT session FROM {sessions} WHERE sid = :sid', 0, 1, [':sid' => Crypt::hashBase64($sid)]);

I don't know why it works even without the semicolon, but I think it's better to use the same value as the placeholder.

Comments

lussoluca created an issue. See original summary.

lussoluca’s picture

Status: Active » Needs review
StatusFileSize
new561 bytes

Status: Needs review » Needs work

The last submitted patch, 2: typo_in-2567835-2.patch, failed testing.

lussoluca’s picture

StatusFileSize
new711 bytes

Ops, wrong patch

lussoluca’s picture

Status: Needs work » Needs review

The last submitted patch, 2: typo_in-2567835-2.patch, failed testing.

valthebald’s picture

Patch looks good, but I wonder how the current code can even work?

lussoluca’s picture

I don't know, maybe an undocumented feature of MySQL?

valthebald’s picture

Status: Needs review » Reviewed & tested by the community

This is indeed undocumented feature of PDO (see http://stackoverflow.com/questions/9778887/is-the-leading-colon-for-para...)

TL;DR: we should always use colon in parameter name - PDO adds colon to parameter name if it's missing, but this may stop working in future PHP releases.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: typo_in-2567835-4.patch, failed testing.

alvar0hurtad0’s picture

Status: Needs work » Needs review
StatusFileSize
new711 bytes

Here's the patch (maybe again).

valthebald’s picture

Status: Needs review » Reviewed & tested by the community

Looks like testbot hiccup. You didn't need to create a new patch, retesting the old one should be enough.
I wonder if there is a way to find similar typos in the core, if they exist?

alvar0hurtad0’s picture

I fac the two parches are not equal, #11 has an extra blank space on the comments than #4

valthebald’s picture

@alvar0hurtad0: next time please use interdiff :)

xjm’s picture

Status: Reviewed & tested by the community » Fixed

Trippy. Thanks @valthebald for checking how that could possibly ever work; otherwise I would have suspected a bug and missing test coverage.

Committed and pushed to 8.0.x. Thanks!

  • xjm committed 56365fd on 8.0.x
    Issue #2567835 by lussoluca, alvar0hurtad0, valthebald: Typo in...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.