function UrlHelper::uncompressQueryParameter

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Component/Utility/UrlHelper.php \Drupal\Component\Utility\UrlHelper::uncompressQueryParameter()

Takes a compressed parameter and converts it back to the original.

Parameters

string $compressed: A string as compressed by \Drupal\Component\Utility\UrlHelper::compressQueryParameter().

Return value

string The uncompressed data, or the original string if it cannot be uncompressed.

See also

\Drupal\Component\Utility\UrlHelper::compressQueryParameter()

8 calls to UrlHelper::uncompressQueryParameter()
AjaxPageState::parseAjaxPageState in core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php
Parse the ajax_page_state variable in the request.
AjaxTest::testDrupalSettingsCachingRegression in core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
Tests that AJAX loaded libraries are not retained between requests.
AssetControllerBase::deliver in core/modules/system/src/Controller/AssetControllerBase.php
Generates an aggregate, given a filename.
AssetOptimizationTest::setInvalidLibrary in core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php
Replaces the 'include' entry in the given URL with an invalid value.
BrowserTestBase::getDrupalSettings in core/tests/Drupal/Tests/BrowserTestBase.php
Gets the JavaScript drupalSettings variable for the currently-loaded page.

... See full list

File

core/lib/Drupal/Component/Utility/UrlHelper.php, line 103

Class

UrlHelper
Helper class URL based methods.

Namespace

Drupal\Component\Utility

Code

public static function uncompressQueryParameter(string $compressed) : string {
    // Because this comes from user data, suppress the PHP warning that
    // gzcompress() throws if the base64-encoded string is invalid.
    $return = @gzuncompress(base64_decode(str_replace([
        '-',
        '_',
    ], [
        '+',
        '/',
    ], $compressed)));
    // If we failed to uncompress the query parameter, it may be a stale link
    // from before compression was implemented with the URL parameter
    // uncompressed already, or it may be an incorrectly formatted URL.
    // In either case, pass back the original string to the caller.
    return $return === FALSE ? $compressed : $return;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.