-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix compatibility with Laravel 10.30 — lowercase the $passthru
array values
#2661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Treggats. Thank you for identifying and fixing this bug.
Could you add a test for each method to ensure we don't have regression?
'insertGetId', | ||
'insertOrIgnore', | ||
'insertUsing', | ||
'insertgetid', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you said in the comment in #2659 makes sense, the latter part.
Personally I like to be specific/remove magic, but that's the way Laravel works and we need to align with that.
In short, close #2659 in favour of this one.
It seems to be fixed by #2661. Both solutions will work, yours removes a layer of magics but it is more fragile if the implementation changes in Laravel.
a little sidenote, locally I made the following change. I won't commit it as its a personal preference though it doesn't seem to impact the current codebase. diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 36cc870..23bc44a 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -34,5 +34,7 @@
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
+
+ <exclude name="Generic.Formatting.MultipleStatementAlignment" />
</rule>
</ruleset> |
You can commit this change. It annoys me too. |
I will follow suit then. |
'max', | ||
'min', | ||
'pluck', | ||
'pull', | ||
'push', | ||
'raw', | ||
'sum', | ||
'toSql', | ||
'tomql', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced as it is not supported
self::assertNotInstanceOf(expected: $className, actual: $builder->{$method}(...$parameters)); | ||
} | ||
|
||
public static function provideFunctionNames(): Generator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide supported methods, which should not return a Builder instance.
$builder = User::query()->newQuery(); | ||
assert($builder instanceof Builder); | ||
|
||
$this->expectException($exceptionClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify that certain methods are not supported, checking both the exception type and its message
Currently the The |
While testing, I just realized that it breaks compatibility with One strategy for maintaining compatibility would be to modify this list in |
]; | ||
|
||
yield 'dd' => [ | ||
'dd', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can create a separate issue to support this, once this PR get merged.
This comment was marked as outdated.
This comment was marked as outdated.
f80b7ac
to
abcba92
Compare
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## 4.0 #2661 +/- ##
============================================
+ Coverage 90.99% 91.20% +0.20%
Complexity 757 757
============================================
Files 35 35
Lines 1933 1933
============================================
+ Hits 1759 1763 +4
+ Misses 174 170 -4
|
'max', | ||
'min', | ||
'pluck', | ||
'pull', | ||
'push', | ||
'raw', | ||
'sum', | ||
'toSql', | ||
'tomql', | ||
// Kept for compatibility with Laravel < 10.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here I was trying to conditionally set the method names casing 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and verbose solutions are often good enough.
abcba92
to
a14a822
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Treggats for the time you've devoted to correcting the breaking changes coming from Laravel.
$passthru
array values$passthru
array values
I'm going to make a release tomorrow. |
fixes #2660
fixes #2656
As explained in the issue, Laravel updated the way Builder methods are called. The list of methods in the
$passthru
property now should be lowercase.Currently they are not, and this causes the methods to not be called, but passed on and thus returning the Builder instance.
This PR makes them all lowercase, which will fix this issue. I have tested this in our application and it works.