Automattic\WooCommerce\Internal\PushNotifications\DataStores

NotificationPreferencesDataStore::migrate │ public │ WC 10.8.0

Upgrade an envelope to the current schema version.

Pure transformation — does not persist. Missing or malformed preferences entries are replaced with an empty array; the service layer is responsible for filling in defaults from the empty case.

Метод класса: NotificationPreferencesDataStore{}

Хуков нет.

Возвращает

array. Envelope upgraded to self::CURRENT_SCHEMA_VERSION.

Использование

$NotificationPreferencesDataStore = new NotificationPreferencesDataStore();
$NotificationPreferencesDataStore->migrate( $data, $from_version ): array;
$data(массив) (обязательный)
The stored envelope (expected keys: schema_version, preferences).
$from_version(int) (обязательный)
The schema version currently on disk.

Список изменений

С версии 10.8.0 Введена.

Код NotificationPreferencesDataStore::migrate() WC 11.2.2

public function migrate( array $data, int $from_version ): array {
	// Parameter reserved for future schema migrations.
	unset( $from_version );

	$preferences = isset( $data['preferences'] ) && is_array( $data['preferences'] )
		? $data['preferences']
		: array();

	// For v1 the envelope shape is stable; we only normalize the version tag.

	return array(
		'schema_version' => self::CURRENT_SCHEMA_VERSION,
		'preferences'    => $preferences,
	);
}