Title: Plugin creates Error 500 in Console
Last modified: September 4, 2022

---

# Plugin creates Error 500 in Console

 *  Resolved [lodoubleg](https://wordpress.org/support/users/loqee/)
 * (@loqee)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/)
 * See the error log:
 *     ```
       [04-Sep-2022 18:41:50 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function download_url() in /wp-content/plugins/gdpr-press/includes/class-download.php:90
       Stack trace:
       #0 /wp-content/plugins/gdpr-press/includes/class-download.php(44): Gdpress_Download->download_to_tmp()
       #1 /wp-content/plugins/gdpr-press/includes/class-rewrite-url.php(335): Gdpress_Download->download_file()
       #2 /wp-content/plugins/gdpr-press/includes/class-rewrite-url.php(200): Gdpress_RewriteUrl->process_requests()
       #3 /wp-includes/class-wp-hook.php(303): Gdpress_RewriteUrl->rewrite_urls()
       #4 /wp-includes/plugin.php(189): WP_Hook->apply_filters()
       #5 /wp-content/plugins/gdpr-press/includes/class-rewrite-url.php(137): apply_filters()
       #6 [internal function]: Gdpress_RewriteUrl->return_buffer()
       #7 /wp-includes/functions.php(5107 in /wp-content/plugins/gdpr-press/includes/class-download.php on line 90
       ```
   
 * please fix it! thank you

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15978111)
 * Hi!
 * To verify: which PHP and WordPress version are you running?
 *  Thread Starter [lodoubleg](https://wordpress.org/support/users/loqee/)
 * (@loqee)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15978114)
 * hi. wow, that was fast!
 * WordPress 5.8.5
    PHP 7.4.30
 * in console it gives an error 500 at line 1 of source (doctype part)
    page still
   shows up, but throws this error above into the error.log
    -  This reply was modified 3 years, 8 months ago by [lodoubleg](https://wordpress.org/support/users/loqee/).
 *  Thread Starter [lodoubleg](https://wordpress.org/support/users/loqee/)
 * (@loqee)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15978120)
    -  This reply was modified 3 years, 8 months ago by [lodoubleg](https://wordpress.org/support/users/loqee/).
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15978131)
 * Thanks! I’ll look into it tomorrow.
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15979903)
 * Hi again!
 * Can you verify if this file exists in your WordPress install?
 * `wp-admin/includes/file.php`
 * Please also check if that file contains a line starting with `function download_url(`
 * Looking forward to your findings!
 *  Thread Starter [lodoubleg](https://wordpress.org/support/users/loqee/)
 * (@loqee)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15979954)
 * hello,
 * yes the file is there and the function code starts at line # 1086
 *     ```
       function download_url( $url, $timeout = 300, $signature_verification = false ) {
       	// WARNING: The file is not automatically deleted, the script must unlink() the file.
       	if ( ! $url ) {
       		return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
       	}
   
       	$url_filename = basename( parse_url( $url, PHP_URL_PATH ) );
   
       	$tmpfname = wp_tempnam( $url_filename );
       	if ( ! $tmpfname ) {
       		return new WP_Error( 'http_no_file', __( 'Could not create temporary file.' ) );
       	}
   
       	$response = wp_safe_remote_get(
       		$url,
       		array(
       			'timeout'  => $timeout,
       			'stream'   => true,
       			'filename' => $tmpfname,
       		)
       	);
   
       	if ( is_wp_error( $response ) ) {
       		unlink( $tmpfname );
       		return $response;
       	}
   
       	$response_code = wp_remote_retrieve_response_code( $response );
   
       	if ( 200 !== $response_code ) {
       		$data = array(
       			'code' => $response_code,
       		);
   
       		// Retrieve a sample of the response body for debugging purposes.
       		$tmpf = fopen( $tmpfname, 'rb' );
   
       		if ( $tmpf ) {
       			/**
       			 * Filters the maximum error response body size in <code>download_url()</code>.
       			 *
       			 * @since 5.1.0
       			 *
       			 * @see download_url()
       			 *
       			 * @param int $size The maximum error response body size. Default 1 KB.
       			 */
       			$response_size = apply_filters( 'download_url_error_max_body_size', KB_IN_BYTES );
   
       			$data['body'] = fread( $tmpf, $response_size );
       			fclose( $tmpf );
       		}
   
       		unlink( $tmpfname );
   
       		return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data );
       	}
   
       	$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
   
       	if ( $content_md5 ) {
       		$md5_check = verify_file_md5( $tmpfname, $content_md5 );
   
       		if ( is_wp_error( $md5_check ) ) {
       			unlink( $tmpfname );
       			return $md5_check;
       		}
       	}
   
       	// If the caller expects signature verification to occur, check to see if this URL supports it.
       	if ( $signature_verification ) {
       		/**
       		 * Filters the list of hosts which should have Signature Verification attempted on.
       		 *
       		 * @since 5.2.0
       		 *
       		 * @param string[] $hostnames List of hostnames.
       		 */
       		$signed_hostnames = apply_filters( 'wp_signature_hosts', array( 'wordpress.org', 'downloads.wordpress.org', 's.w.org' ) );
   
       		$signature_verification = in_array( parse_url( $url, PHP_URL_HOST ), $signed_hostnames, true );
       	}
   
       	// Perform signature valiation if supported.
       	if ( $signature_verification ) {
       		$signature = wp_remote_retrieve_header( $response, 'x-content-signature' );
   
       		if ( ! $signature ) {
       			// Retrieve signatures from a file if the header wasn't included.
       			// WordPress.org stores signatures at $package_url.sig.
   
       			$signature_url = false;
       			$url_path      = parse_url( $url, PHP_URL_PATH );
   
       			if ( '.zip' === substr( $url_path, -4 ) || '.tar.gz' === substr( $url_path, -7 ) ) {
       				$signature_url = str_replace( $url_path, $url_path . '.sig', $url );
       			}
   
       			/**
       			 * Filters the URL where the signature for a file is located.
       			 *
       			 * @since 5.2.0
       			 *
       			 * @param false|string $signature_url The URL where signatures can be found for a file, or false if none are known.
       			 * @param string $url                 The URL being verified.
       			 */
       			$signature_url = apply_filters( 'wp_signature_url', $signature_url, $url );
   
       			if ( $signature_url ) {
       				$signature_request = wp_safe_remote_get(
       					$signature_url,
       					array(
       						'limit_response_size' => 10 * KB_IN_BYTES, // 10KB should be large enough for quite a few signatures.
       					)
       				);
   
       				if ( ! is_wp_error( $signature_request ) && 200 === wp_remote_retrieve_response_code( $signature_request ) ) {
       					$signature = explode( "\n", wp_remote_retrieve_body( $signature_request ) );
       				}
       			}
       		}
   
       		// Perform the checks.
       		$signature_verification = verify_file_signature( $tmpfname, $signature, basename( parse_url( $url, PHP_URL_PATH ) ) );
       	}
   
       	if ( is_wp_error( $signature_verification ) ) {
       		if (
       			/**
       			 * Filters whether Signature Verification failures should be allowed to soft fail.
       			 *
       			 * WARNING: This may be removed from a future release.
       			 *
       			 * @since 5.2.0
       			 *
       			 * @param bool   $signature_softfail If a softfail is allowed.
       			 * @param string $url                The url being accessed.
       			 */
       			apply_filters( 'wp_signature_softfail', true, $url )
       		) {
       			$signature_verification->add_data( $tmpfname, 'softfail-filename' );
       		} else {
       			// Hard-fail.
       			unlink( $tmpfname );
       		}
   
       		return $signature_verification;
       	}
   
       	return $tmpfname;
       }
       ```
   
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15980107)
 * Wow, I fixed this issue a month ago, but never published a release. I just did.
   It’s fixed 🙂
 *  Thread Starter [lodoubleg](https://wordpress.org/support/users/loqee/)
 * (@loqee)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15980416)
 * very nice. thank you for your fast work !
 *  Plugin Author [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * (@daanvandenbergh)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15980515)
 * No problem! When you have a minute, I’d highly appreciate a review. You can do
   so [here](https://wordpress.org/support/plugin/gdpr-press/reviews/#new-post).

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Plugin creates Error 500 in Console’ is closed to new replies.

 * ![](https://ps.w.org/gdpr-press/assets/icon-256x256.png?rev=3498092)
 * [GDPRess | Eliminate external requests to increase GDPR compliance](https://wordpress.org/plugins/gdpr-press/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gdpr-press/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gdpr-press/)
 * [Active Topics](https://wordpress.org/support/plugin/gdpr-press/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gdpr-press/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gdpr-press/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Daan van den Bergh](https://wordpress.org/support/users/daanvandenbergh/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/plugin-creates-error-500-in-console/#post-15980515)
 * Status: resolved