Skip to content

Commit

Permalink
Clarify return values for pf_de_https() and related methods.
Browse files Browse the repository at this point in the history
See #1167.
  • Loading branch information
boonebgorges committed Sep 14, 2023
1 parent 5798c18 commit 4de8eac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Controllers/HTTPTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function url_is_aggregation_service( $url ) {
*
* @param string $url URL.
* @param string $deprecated No longer used.
* @return mixed
* @return array
*/
public function get_url_content( $url, $deprecated = '' ) {
$url = str_replace( '&', '&', $url );
Expand Down
4 changes: 0 additions & 4 deletions Controllers/PF_Readability.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ public function readability_object( $url ) {

$request = pf_de_https( $url, 'wp_remote_get' );

if ( is_wp_error( $request ) ) {
$content = 'error-secured';
return $content;
}
if ( ! empty( $request['body'] ) ) {
$html = $request['body'];
} elseif ( ! empty( $request ) && ( ! is_array( $request ) ) ) {
Expand Down
8 changes: 4 additions & 4 deletions Libraries/PFOpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PFOpenGraph implements Iterator {
* false on error.
*
* @param $URI URI to page to parse for Open Graph data
* @return PFOpenGraph|bool
* @return PFOpenGraph|false
*/
public static function fetch( $URI ) {
$cache_key = 'wp_remote_get_' . $URI;
Expand All @@ -55,10 +55,10 @@ public static function fetch( $URI ) {
$response_body = $cached;
} else {
$response = pf_de_https( $URI, 'wp_remote_get' );
if ( $response && ! is_wp_error( $response ) ) {
$response_body = wp_remote_retrieve_body( $response );
if ( $response ) {
$response_body = $response['body'];
wp_cache_set( $cache_key, $response_body, 'pressforward_external_pages' );
}
wp_cache_set( $cache_key, $response_body, 'pressforward_external_pages' );
}

if ( ! $response_body ) {
Expand Down
6 changes: 3 additions & 3 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ function pf_prep_item_for_submit( $item ) {
*
* @param string $url URL.
* @param bool|callable $callback Function to call first to try and get the URL.
* @return string|object $r Returns the string URL, converted, when no function is passed.
* Otherwise returns the result of the function after being
* checked for accessibility.
* @return string|array $r Returns the string URL, converted, when no function is passed.
* Otherwise returns the result of the function after being
* checked for accessibility.
*/
function pf_de_https( $url, $callback = false ) {
$url_orig = $url;
Expand Down

0 comments on commit 4de8eac

Please sign in to comment.