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

Update class-indieauth-authorize.php #273

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

janboddez
Copy link
Contributor

Even though the default value for $error is null, we should probably not make assumptions about expected return values. By returning $error rather than a hardcoded null, we respect other plugins' possible changes.

Jetpack, for instance, calls this filter like so (i.e., with $error equal to true): https://github.com/Automattic/jetpack/blob/e29cee2d08516e93486e4dcd0b102244e7609ed4/projects/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php#L190-L195. May be weird, but if we then return null, things break.

@janboddez
Copy link
Contributor Author

Oh, forgot to mention that this should fix #265.

@janboddez
Copy link
Contributor Author

May be weird, but if we then return null, things break.

Turns out true is actually valid ... (https://developer.wordpress.org/reference/hooks/rest_authentication_errors/). Either way, probably safest to just allow other plugins to do their thing and just return whatever value we were passed (or an error, of course)!

Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

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

👍

@janboddez
Copy link
Contributor Author

janboddez commented Aug 12, 2024

Made a few more changes.

Just one, actually, the rest was updating the PHPDoc.

Anyway, so, I was wondering. If the $error arg is in fact non-empty (because the filter was called, like Jetpack does, with true as its first argument), should we always simply return it?

Maybe it's equally "safe" to still allow IndieAuth to return any error it encountered? Or rather, if this isn't an "IndieAuth request," no error would get set anyway (at least, that's what I'm assuming), and as a result the $error arg would be returned unchanged regardless. If that's the case, there's no need for the "empty" check. (I think?)

@dshanske
Copy link
Member

Looks good to me.

@dshanske dshanske merged commit e810911 into indieweb:trunk Aug 13, 2024
7 checks passed
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.

3 participants