BSF_Update_Manager::remove_stale_bsf_updates( object $_transient_data, array|null $all_products = null )

Remove stale update entries of BSF products from the update_plugins transient data.


Description

An update entry becomes stale when the version installed on disk is already up to date with the offered version — e.g. when the entry was injected from a stale stored product version right after an update. Leaving it in place makes WordPress offer/auto-install the same version again.


Parameters

$_transient_data

(object) (Required) Transient Data.

$all_products

(array|null) (Optional) Pre-fetched product list to reuse, avoiding a repeat scan of every product file. Defaults to null (fetched internally).

Default value: null


Return

(object) $_transient_data


Source

File: admin/bsf-core/class-bsf-update-manager.php

		public function remove_stale_bsf_updates( $_transient_data, $all_products = null ) {
			if ( empty( $_transient_data->response ) || ! is_array( $_transient_data->response ) ) {
				return $_transient_data;
			}

			if ( null === $all_products ) {
				$all_products = $this->get_all_products_for_type( 'plugins' );
			}

			foreach ( $all_products as $key => $product ) {
				$product_id = isset( $product['id'] ) ? $product['id'] : '';
				$template   = $this->get_product_template( $product );

				if ( '' === $template || ! isset( $_transient_data->response[ $template ] ) ) {
					continue;
				}

				$entry = $_transient_data->response[ $template ];

				// Only touch entries injected by this updater — never wp.org ones.
				if ( ! is_object( $entry ) || ! isset( $entry->id ) || $entry->id !== $product_id || ! isset( $entry->new_version ) ) {
					continue;
				}

				$live_version = bsf_get_current_version( $template, 'plugins' );

				if ( ! empty( $live_version ) && ! version_compare( $entry->new_version, $live_version, '>' ) ) {
					unset( $_transient_data->response[ $template ] );
				}
			}

			return $_transient_data;
		}

Changelog

Changelog
Version Description
1.29.15 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.