Skip to content

Commit

Permalink
Revert "Fixed issue #13606: Unable to reset manually asset (#1044)"
Browse files Browse the repository at this point in the history
This reverts commit 4a52dbf.
  • Loading branch information
Shnoulle authored and lacrioque committed Apr 18, 2018
1 parent 43a5f04 commit 929dcee
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions application/core/LSYii_AssetManager.php
@@ -1,9 +1,10 @@
<?php

/**
* LimeSurvey
* Copyright (C) 2007-2018 The LimeSurvey Project Team / Carsten Schmitz
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v3 or later, see LICENSE.php
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
Expand All @@ -13,13 +14,27 @@

class LSYii_AssetManager extends CAssetManager
{
/* inheritdoc */
protected function hash($path)
/**
* Generates path segments relative to basePath.
*
* This method is used instead of the original, so the hash is taken
* from LS version number instead of folder/file last modified time.
* Using file/folder causes a lot of problems due to FTP and other file
* transfers not updating the time stamp, forcing LS to use touch()
* in a lot of places instead. touch() can now be removed - the assets
* will be updated every time a version number is changed.
*
* @param string $file for which public path will be created.
* @param bool $hashByName whether the published directory should be named as the hashed basename.
* @return string path segments without basePath.
* @since 1.1.13
*/
protected function generatePath($file, $hashByName = false)
{
$assetsVersionNumber = Yii::app()->getConfig('assetsversionnumber');
$versionNumber = Yii::app()->getConfig('versionnumber');
$dbVersion = Yii::app()->getConfig('dbversionnumber');
$iCustomassetversionnumber = Yii::app()->getConfig('customassetversionnumber',1);
$iCustomassetversionnumber = (function_exists('getGlobalSetting') ) ? getGlobalSetting('customassetversionnumber'):1; // When called from installer, function getGlobalSetting() is not available

if (empty($assetsVersionNumber)
|| empty($versionNumber)
Expand All @@ -28,7 +43,15 @@ protected function hash($path)
'Could not create asset manager path hash: One of these configs are empty: assetsversionnumber/versionnumber/dbversionnumber.'
);
}

$lsVersion = $assetsVersionNumber.$versionNumber.$dbVersion.$iCustomassetversionnumber;
return sprintf('%x',crc32($path.$lsVersion));

if (is_file($file)) {
$pathForHashing = $hashByName ? dirname($file) : dirname($file).$lsVersion;
} else {
$pathForHashing = $hashByName ? $file : $file.$lsVersion;
}

return $this->hash($pathForHashing);
}
}

1 comment on commit 929dcee

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue here ?

The previous system have issue … and replace the Yii version by our own seems really best …

Please sign in to comment.