Adapt Your Add-ons and Themes to CS-Cart 4.21.2

Core Changes

Changes in TyghHttp class

The transport now declares the URL schemes it works with in Tygh\Http::SUPPORTED_SCHEMES (http, https, ftp, ftps). A request URL is accepted only when it uses one of them and names a host, and the same applies to a redirect target; a location outside that list makes the request fail with an error instead. The list is also applied to the curl handle through CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS, so the transport behaves the same way on every supported libcurl version and PHP configuration.

If your add-on passes a location with another scheme to Tygh\Http, or to a function built on top of it, use the API of that protocol directly instead.

Response state (Tygh\Http::getError(), Tygh\Http::getErrorFields(), Tygh\Http::getHeaders(), Tygh\Http::getStatus()) belongs to a single request: it is reset when a request starts, so it always describes the request that has just run.

Changes in fn_check_user_type() function

The create_vendor_admin key of the user data is no longer taken into account when the user type is determined.

To create a vendor administrator, set the runtime.users.allow_vendor_admin_creation registry key around the fn_update_user() call and pass the user type explicitly:

Registry::set('runtime.users.allow_vendor_admin_creation', true);

try {
    list($user_id) = fn_update_user(0, $user_data, $auth, false, $notify);
} finally {
    Registry::del('runtime.users.allow_vendor_admin_creation');
}

New functions

  • Tygh\Http::isSupportedUrl($url) - whether the transport works with the given URL: it uses a supported scheme and names a host.
  • Tygh\Shippings\PickupPoints\Repository::getPickupPointExtraData($provider, $pickup_point_code) - Gets the service data of a single pickup point.
  • Tygh\Shippings\PickupPoints\Repository::storePickupPoints(array $pickup_points, $cache_key) - Stores a portion of pickup points; the synchronization state is set separately by setPickupPointSyncState().
  • Tygh\Shippings\PickupPoints\Dto\LookupData\PickupPointsLookupContext::isExtraDataRequired() - Gets whether the service data of pickup points must be loaded.
  • Tygh\Shippings\PickupPoints\Dto\LookupData\PickupPointsLookupContext::setExtraDataRequired($is_extra_data_required) - Sets whether the service data of pickup points must be loaded.

Changed functions

  • fn_get_contents($location, $base_dir = '', $timeout = null) - a location that carries a scheme is fetched only when Tygh\Http::isSupportedUrl() accepts it, and returns an empty string otherwise. A plain filesystem path is read as before. The signature is unchanged.
- Tygh\Shippings\PickupPoints\Repository::findPickupPointsByProviderAndCacheKey($provider, $cache_key)
+ Tygh\Shippings\PickupPoints\Repository::findPickupPointsByProviderAndCacheKey($provider, $cache_key, $with_extra_data = true)

New settings

  • $config['tweaks']['yandex_delivery_rate_cache_ttl'] - How long, in seconds, a priced answer of the Yandex Delivery calculator may be replayed before the calculator is asked again. Defaults to 600.

File manager

Remote file fetching is scoped to network protocols

Fetching a file by URL uses http, https, ftp and ftps, both for the request itself and for the redirects it follows, on every supported libcurl version.

  • elFinder::restrictCurlProtocols($curl) - applies that list to a curl handle; call it on a handle of your own that follows redirects.