Make WordPress Core

Opened 16 months ago

Last modified 16 months ago

#58286 new defect (bug)

Growing database due to unnecessary transients containing "g_url_details_response_"

Reported by: davidki's profile davidki Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 6.2
Component: Database Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I created 2 external links in the block editor. This created 2 different transients in the database in wp_options, that have a different dynamic part at the end:

_site_transient_g_url_details_response_ab62baf1c770821f259d255001f7a9b9
_site_transient_g_url_details_response_f6ce245428f26d29c355a44ceb3b9bf3

This transient contains "g_url_details_response_" and is produced by file class-wp-rest-url-details-controller.php

The value of such created transient is entire html from URL to which I link.

I only want to add some external link in gutenberg editor. Why on earth is necessary to parse the entire html from URL to which I link?

What if I will have for example 20 external affiliate links on one page and I will have 1000 such pages.

This will unnecessarily bloat the database with useless and unnecessary data!

How can I prevent the creation of transients whose name part contains "g_url_details_response_"?

I tryed it using this filter:

apply_filters( "pre_set_site_transient_{$transient}", mixed $value, string $transient ) 

But it needs full transient name, which is created dynamically using this function

private function build_cache_key_for_url( $url ) {
	return 'g_url_details_response_' . md5( $url );
}

from file class-wp-rest-url-details-controller.php

So please remove these pointless transients from wordpress or give users a way to prevent them from being created!

Thank you for any reply,

david

Change History (2)

#1 @SergeyBiryukov
16 months ago

  • Description modified (diff)

#2 @petitphp
16 months ago

Hello @davidki

When clicking on links in the editor, Gutenberg will attempt to display a preview of for external links (page title + primary image or favicon).

The rest controller you mentioned will make a request to the remote URL to load the first hundred bytes and retrieve the @head@ tag to extract the relevant information. To speed up the process and avoid spamming the remote servers, each response will be cached in a transient for one hour.

At first glance, it doesn't seem to be a way of disabling the preview mechanism in the editor. You can open an issue in the Gutenberg repository to propose that enhancement.

As for the transients, they should be cleaned automatically every day after they expired.

Note: See TracTickets for help on using tickets.