-
Notifications
You must be signed in to change notification settings - Fork 2
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
Major Craft 3 API Updates #4
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4f7b06e
Updated the maxPowerCaptain method call to the latest Craft 3 API
3bcaef8
We should only be passing userdata if it exists
f78ecf2
Rewrote the task infrastructure to use the new Craft 3 queue and jobs
15c6b32
Fixed two instances where we still had the word “task” instead of “job”
981886e
If the job fails we should be returning false
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Did an error come up in your testing? The
$userdata
param should benull
(default value from the method signature) if no argument is provided, which should be fine to pass into thearray_walk
...?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.
I did yes; check out the latter half of #2. It's complaining that the parameter passed to the
$callable
needs to be a boolean but we're passing null. Based on thearray_walk
docs, the$userdata
parameter is optional hence the solution I used here. If there is a better way to solve I'd love to know because it doesn't seem like the cleanest method 🤔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.
A ha! So, you're right — we need to only pass that parameter downstream if the argument is actually provided — but it has nothing to do with
array_walk
.Specifically,
array_walk
doesn't care what kind of argument is passed there. It's the downstream method that cares. (In this case,saveElement
is looking for a boolean param, probably to toggle some validation logic. The fact that we were passing a defaultnull
was fine witharray_walk
, butsaveElement
complained.)We can't predict whether a target method will ever expect a second param, so we shouldn't presume to put a default value there. We should let our user do that, in cases where they know it's relevant to the target method.
However, a simple truthiness check isn't a good idea here. (What if the
$userdata
isfalse
, ornull
, or[]
, or0
, or anything else that casts to a false boolean? That argument will never be passed through.) The correct check to use here isisset()
.