Merge pull request #8212 from MrPetovan/task/release-cache-buster

Release Cache Buster
This commit is contained in:
Philipp 2020-02-01 18:45:58 +01:00 committed by GitHub
commit 346da998df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 141 additions and 113 deletions

View file

@ -15,6 +15,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\Module\Special\HTTPException as ModuleHTTPException;
use Friendica\Network\HTTPException;
use Friendica\Util\Network;
use Friendica\Util\Strings;
/**
@ -151,6 +152,8 @@ class Page implements ArrayAccess
*/
public function registerStylesheet($path)
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
if (mb_strpos($path, $this->basePath . DIRECTORY_SEPARATOR) === 0) {
$path = mb_substr($path, mb_strlen($this->basePath . DIRECTORY_SEPARATOR));
}
@ -334,6 +337,8 @@ class Page implements ArrayAccess
*/
public function registerFooterScript($path)
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
$url = str_replace($this->basePath . DIRECTORY_SEPARATOR, '', $path);
$this->footerScripts[] = trim($url, '/');

View file

@ -870,4 +870,27 @@ class Network
return $url;
}
/**
* Adds query string parameters to the provided URI. Replace the value of existing keys.
*
* @param string $path
* @param array $additionalParams Associative array of parameters
* @return string
*/
public static function appendQueryParam(string $path, array $additionalParams)
{
$parsed = parse_url($path);
$params = [];
if (!empty($parsed['query'])) {
parse_str($parsed['query'], $params);
}
$params = array_merge($params, $additionalParams);
$parsed['query'] = http_build_query($params);
return self::unparseURL($parsed);
}
}