diff options
author | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-29 21:02:21 +0000 |
---|---|---|
committer | nickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-29 21:02:21 +0000 |
commit | 28767f949a8231d808fb68b764eb65f63b03f138 (patch) | |
tree | 761db5d17c98e3d062ce35945f926926c634b3c1 | |
parent | 428a7565a4046aa73e262c9a13650b7887310104 (diff) | |
download | elgg-28767f949a8231d808fb68b764eb65f63b03f138.tar.gz elgg-28767f949a8231d808fb68b764eb65f63b03f138.tar.bz2 |
Fully deprecating file matrix use with username.
Plugins building the file matrix with the username will still work, but a warning is logged.
git-svn-id: http://code.elgg.org/elgg/trunk@3602 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/filestore.php | 33 | ||||
-rw-r--r-- | engine/tests/objects/filestore.php | 2 |
2 files changed, 8 insertions, 27 deletions
diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index 92e8a760e..455d011d5 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -367,32 +367,13 @@ class ElggDiskFilestore extends ElggFilestore { * @return str */ protected function deprecated_file_matrix($filename) { - $invalid_fs_chars = '*\'\\/"!$%^&*.%(){}[]#~?<>;|¬`@-+='; - - $matrix = ""; - - $name = $filename; - $filename = $this->mb_str_split($filename); - if (!$filename) { - return false; - } - - $len = count($filename); - if ($len>$this->matrix_depth) { - $len = $this->matrix_depth; - } - - for ($n = 0; $n < $len; $n++) { - // Prevent a matrix being formed with unsafe characters - $char = $filename[$n]; - if (strpos($invalid_fs_chars, $char)!==false) { - $char = '_'; - } - - $matrix .= $char . "/"; - } - - return $matrix.$name."/"; + // throw a warning for using deprecated method + $error = 'Deprecated use of ElggDiskFilestore::make_file_matrix. '; + $error .= 'Username passed instead of guid.'; + elgg_log($error, WARNING); + + $user = new ElggUser($filename); + return $this->user_file_matrix($user->guid); } public function getParameters() { diff --git a/engine/tests/objects/filestore.php b/engine/tests/objects/filestore.php index 0a11c265b..a262a7c3f 100644 --- a/engine/tests/objects/filestore.php +++ b/engine/tests/objects/filestore.php @@ -52,7 +52,7 @@ class ElggCoreFilestoreTest extends ElggCoreUnitTest { // check matrix with username $user_dir = $this->filestore->make_file_matrix($user->username); - $this->assertIdentical($user_dir, "f/i/l/e/T/fileTest/"); + $this->assertIdentical($user_dir, "$created/$user->guid/"); // check matrix with guid $guid_dir = $this->filestore->make_file_matrix($user->guid); |