]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fully deprecating file matrix use with username.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 29 Oct 2009 21:02:21 +0000 (21:02 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 29 Oct 2009 21:02:21 +0000 (21:02 +0000)
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

engine/lib/filestore.php
engine/tests/objects/filestore.php

index 92e8a760e98adc68cc099fc920e1b3bc495c5305..455d011d53d9965b8caf2a715d60b8cbeb42e3c0 100644 (file)
@@ -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() {
index 0a11c265b65c495dcc658a3238cd0f991e6fe2b7..a262a7c3fb7489b280b6cdede533a1ea904b24a3 100644 (file)
@@ -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);