Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add URL Details endpoint to REST API to allow retrieval of info about…
… a remote URL (#18042) * Scaffold out basic new endpoint * Implement basic retrival of title tag from remote url * Adds validation, sanitization and permissions checks. * i18n fixes and docblocks * Adds caching of remote request * Update with feedback * Tie up loose ends * Remove unneed replacements * Account for Custom Post Types in permissions check Addresses #18042 (comment) * Improve error handling * Improve args checking * Refactor to enable query of more data in future. * Use md5 Addresses #18042 (comment) * Extract utility functions * Fix lint errors * Add unit test scaffold * Attempt to mock HTTP requests for testing. Needs work. * Use DIR convention * Allow opt out of cache functionality via filter * Force tests to opt out of cache. Fix broken tests. * Adjust 404 case to use standard response code * Add dedicated methods to mock success/failure HTTP responses * Add test for empty body in response. This should trigger a failed response because we can’t read details from a URL which doesn’t provide a HTTP body. * Add ability to filter request args. Update tests to account. * Document cache filter * Iniital attempt at adding schema * Add test for unautenticated user. * Adjust schema to use WP convention * Adjust schema defaults * Add endpoint args schema test * Removes filter to bypass cache. This already exists in core as https://core.trac.wordpress.org/browser/tags/5.6/src/wp-includes/option.php#L785 * Use existing transient filter to test cache and bypass for majority of tests Fixes #18042 (comment) * Use default timeout. Addresses #18042 (comment) * Removes unnecessary default from schema Addresses #18042 (comment) * Use predefine constants for response size Resolves #18042 (comment) * Rearrange test code order * Adds ability to filter cache expiration Addresses #18042 (review) * Allow filtering the data retrived for a given URL Addresses #18042 (comment) * Remove @access comments Addresses #18042 (comment) * Prefer custom error message over get_status_header_desc Addresses #18042 (comment) * Utilise add_additional_fields_schema Addresses #18042 (comment) * Utilise add_additional_fields_to_object Addresses #18042 (comment) * Enable filtering of response object Filter on both cached and uncached response. * Add test to assert on ability to filter uncached responses * Rename url placeholder literal * Ensure accurately testing for correctly passed cached variable in filter args * Update to test filtering of both cached and uncached responses * Fixing linting * Use array offset syntax prefered by Core Addresses #18042 (comment) * Remove from cache and update filter See #18042 (comment) * Update filter name to align with standards Addresses #18042 (comment) * Update response code to align with Core standards Addresses #18042 (comment) * Update cache ttl in docs to use variable Addresses #18042 (comment) * Use comment to reference canonical version of filter docs Addresses #18042 (comment) * Update to cache entire HTTP response body and remove additional filter Addresses #18042 (comment) * Tweak code comments * Remove need to encode/decode cache value Co-authored-by: Konstantin Obenland <[email protected]>
- Loading branch information