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

Issue #56: Refactor CoolRequest #68

Merged
merged 38 commits into from
Dec 3, 2024
Merged

Conversation

donquixote
Copy link
Collaborator

Further changes will be done in a follow-up issue.

@donquixote donquixote force-pushed the issue-56-refactor-CoolRequest branch from 9c78e89 to bd16013 Compare November 28, 2024 10:23
@donquixote donquixote force-pushed the issue-56-refactor-CoolRequest branch 2 times, most recently from a88a469 to 6b73cbb Compare November 28, 2024 12:10
"The configured Collabora Online server address must begin with 'http://' or 'https://'. Found '%s'.",
$wopi_client_server,
));
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All this validation of config values seems a bit out of place.
In most of Drupal core, config values are simply trusted - for better or worse.

But, currently the config form itself does not really validate these settings.
We do have a schema, but in the config form I can just enter any value I like for the server and host url, e.g. "abc".

Imo we should keep the validation as-is for now, and only change it once we have proper validation in the form.

(The validation is coming from the original code, it has been moved around and refactored but it is still mostly equivalent with the original code.)

Original steps:
- Rename vars in strStartsWith().
- Simplify strStartsWith().
- Fix strStartsWith() by using strpos() instead of strrpos().
- Replace strStartsWith() with str_starts_with().
It can happen that file_get_contents() hangs at the end of a stream, waiting for more data.
With curl it seems this does not happen.

Even better would be to use e.g. Guzzle http client, but that's too big a change for now.
Changes:
- Narrow parameter type for $discovery_parsed, don't check for NULL or FALSE anymore.
- Use (string) cast instead of strval().
- Harden the condition for return value from xpath.
- Let getWopiSrcUrl() always return string or throw exception.
- Inline the function.
- Invert if statement, to align with the rest.
@donquixote donquixote force-pushed the issue-56-refactor-CoolRequest branch from 6b73cbb to 840ead8 Compare November 29, 2024 14:49
@donquixote donquixote force-pushed the issue-56-refactor-CoolRequest branch from 840ead8 to c40af62 Compare December 3, 2024 09:09
@donquixote donquixote force-pushed the issue-56-refactor-CoolRequest branch 2 times, most recently from 143cce9 to 7ebfa5c Compare December 3, 2024 12:02
@donquixote donquixote force-pushed the issue-56-refactor-CoolRequest branch from 7ebfa5c to e663b8d Compare December 3, 2024 12:10
@donquixote donquixote merged commit b2f0a1e into main Dec 3, 2024
3 checks passed
@donquixote donquixote deleted the issue-56-refactor-CoolRequest branch December 3, 2024 13:48
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