Magento Forum

Page 2 of 3
[Solved]Can’t read image folder after upgrate to 1.5.0.1
 
traffictechie
Jr. Member
 
Total Posts:  9
Joined:  2010-03-12
 

This remains a problem - the wysiwyg editor does not recognize any folders it created previously no matter what permission settings you use.

 
Magento Community Magento Community
Magento Community
Magento Community
 
yamadans
Jr. Member
 
Total Posts:  6
Joined:  2011-02-19
 

Same problem, Any fixes yet.....

 
Magento Community Magento Community
Magento Community
Magento Community
 
clorne
Sr. Member
 
Total Posts:  236
Joined:  2008-01-10
London
 

Yes I think there is a small issue with one of the files probably Tree.php.  When it looks for the image directories, sub directories and files it looks for the table “ _core_directory_storage” but with the most recent upgrade this table seems not to be included.  I don’t know whether this is intentional or not as this table does not seem to be used! 

Whatever, the net result is that any sub-directories which are created do not appear.

I have tried adding _core_directory_storage to all my DBs and it seems to work so if you back up your database you could run

SET FOREIGN_KEY_CHECKS=0;

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- --------------------------------------------------------

--
-- 
Table structure for table `{your prefix}_core_directory_storage`
--

CREATE TABLE IF NOT EXISTS `{your prefix}_core_directory_storage` (
  `
directory_idint(10unsigned NOT NULL AUTO_INCREMENT,
  `
namevarchar(255NOT NULL DEFAULT '',
  `
pathvarchar(255NOT NULL DEFAULT '',
  `
upload_timetimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `
parent_idint(10unsigned DEFAULT NULL,
  
PRIMARY KEY (`directory_id`),
  
UNIQUE KEY `IDX_DIRECTORY_PATH` (`name`,`path`),
  
KEY `parent_id` (`parent_id`)
ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Directory storage' AUTO_INCREMENT=;

--
-- 
Dumping data for table `{your prefix}_core_directory_storage`
--

--
-- 
Constraints for dumped tables
--

--
-- 
Constraints for table `{your prefix}_core_directory_storage`
--
ALTER TABLE `{your prefix}_core_directory_storage`
  
ADD CONSTRAINT `FK_DIRECTORY_PARENT_IDFOREIGN KEY (`parent_id`) REFERENCES `{your prefix}_core_directory_storage` (`directory_id`) ON DELETE CASCADE ON UPDATE CASCADE;

SET FOREIGN_KEY_CHECKS=1;

OR go to

app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php—getDirsCollection

and comment out

$subDirectories Mage::getModel('core/file_storage_directory_database')->getSubdirectories($path);

        foreach (
$subDirectories as $directory{
            $fullPath 
rtrim($pathDS) . DS $directory['name'];
            if (!
file_exists($fullPath)) {
                mkdir
($fullPath0777true);
            
}
        }

To change the base image directory go to

app/code/core/Mage/Cms/Model/Wysiwyg/Config.php

and change the constant IMAGE_DIRECTORY =

 
Magento Community Magento Community
Magento Community
Magento Community
 
SimonFunk
Member
 
Total Posts:  49
Joined:  2009-07-23
 

fixed for me! thx a lot!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ConFX
Member
 
Total Posts:  37
Joined:  2009-05-29
 

Hi,
within my installation the table was created (upgrade from 1.4.1.1 to 1.5.1.0). But it didn’t work, too.
I just had to set in app/code/core/Mage/Cms/Model/Wysiwyg/Config.php

const IMAGE_DIRECTORY 'wysiwyg';
to
const IMAGE_DIRECTORY '.';

Cheers
ConFX

 
Magento Community Magento Community
Magento Community
Magento Community
 
dwhiting
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2010-10-14
 
clorne - 31 May 2011 10:58 AM


OR go to

app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php—getDirsCollection

and comment out

$subDirectories Mage::getModel('core/file_storage_directory_database')->getSubdirectories($path);

        foreach (
$subDirectories as $directory{
            $fullPath 
rtrim($pathDS) . DS $directory['name'];
            if (!
file_exists($fullPath)) {
                mkdir
($fullPath0777true);
            
}
        }


To change the base image directory go to

app/code/core/Mage/Cms/Model/Wysiwyg/Config.php

and change the constant IMAGE_DIRECTORY =

Thanks!  This solved it for me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GFEMajor
Sr. Member
 
Total Posts:  138
Joined:  2010-01-11
 

Hi,

having the same Problem. I changed the base image dir to ‘’ (so the media folder is used),
but when i comment out the code

$subDirectories Mage::getModel('core/file_storage_directory_database')->getSubdirectories($path);
        
        foreach (
$subDirectories as $directory{
            $fullPath 
rtrim($pathDS) . DS $directory['name'];
            if (!
file_exists($fullPath)) {
                mkdir
($fullPath0777true);
            
}
        }

all subdirectorys contain the content of the media folder.
Any suggestions to that???

EDIT:

Never mind. I installed the Database table and this does the trick, although no data is saved there. Changing back the other Code to default.

 
Magento Community Magento Community
Magento Community
Magento Community
 
paniccure
Jr. Member
 
Total Posts:  2
Joined:  2011-06-26
 

Guys me too kaving the same problem.Please somebody fix that and let us know.Looking forward to it

 
Magento Community Magento Community
Magento Community
Magento Community
 
freelancewebdesignstafford
Jr. Member
 
Total Posts:  7
Joined:  2009-10-03
 

Thanks clorne!

That worked great for me grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tim Hengeveld
Jr. Member
 
Total Posts:  21
Joined:  2010-12-14
 

For anyone with the same problem, but who doesn\’t want to overwrite the core, here is a mini extension to apply the fix (changing the Storage.php, not the database table solution).

First create your etc/modules/<mynamespace>_<mymodule>.xml as usuall.

Next create in app/code/local/<mynamespace>/<mymodule>/etc/config.xml

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<config>
    <
modules>
        <
Mynamespace_Mymodule>
            <
version>0.1.0</version>
                </
Mynamespace_Mymodule>
        </
modules>
    <global>
                <
models>
                        <
cms>
                                <
rewrite>
                                        <
wysiwyg_images_storage>Mynamespace_Mymodule_Model_Wysiwyg_Images_Storage</wysiwyg_images_storage>
                                </
rewrite>
                        </
cms>
                </
models>
        </global>
</
config>

Now create in app/code/local/<mynamespace>/<mymodule>/Model/Wysiwyg/Images/Storage.php

<?php

class Mynamespace_Mymodule_Model_Wysiwyg_Images_Storage extends Mage_Cms_Model_Wysiwyg_Images_Storage
{
    
/**
     * Return one-level child directories for specified path
     *
     * @param string $path Parent directory path
     * @return Varien_Data_Collection_Filesystem
     */
    
public function getDirsCollection($path)
    
{
        
// Simple plugin fix provided by Tim Hengeveld - Lite Webdesigns - www.litewebdesigns.nl
        // Based on the idea of Clorne (http://www.magentocommerce.com/boards/member/9241/), as posted in this thread: http://www.magentocommerce.com/boards/viewthread/220720/P15/

        // These lines are removed to fix the displaying of folders in Wysiwyg editor when inserting an image.
        // Simply remove this extension once Magento has fixed this bug: http://www.magentocommerce.com/bug-tracking/issue?issue=11242
        /*$subDirectories = Mage::getModel(\'core/file_storage_directory_database\')->getSubdirectories($path);

        foreach ($subDirectories as $directory) {
            $fullPath = rtrim($path, DS) . DS . $directory[\'name\'];
            if (!file_exists($fullPath)) {
                mkdir($fullPath, 0777, true);
            }
        }*/

        
$conditions = array(\'reg_exp\' => array(), \'plain\' => array());

        foreach (
$this->getConfig()->dirs->exclude->children() as $dir{
            $conditions[$dir
->getAttribute(\'regexp\') ? \'reg_exp\' \'plain\'][(string) $dir] true;
        
}
        
// \"include\" section takes precedence and can revoke directory exclusion
        
foreach ($this->getConfig()->dirs->include->children() as $dir{
            
unset($conditions[\'regexp\'][(string) $dir]$conditions[\'plain\'][(string) $dir]);
        
}

        $regExp 
$conditions[\'reg_exp\'? (\'~\' implode(\'|\'array_keys($conditions[\'reg_exp\'])) . \'~i\') : null;
        
$collection $this->getCollection($path)
            ->
setCollectDirs(true)
            ->
setCollectFiles(false)
            ->
setCollectRecursively(false);
        
$storageRootLength strlen($this->getHelper()->getStorageRoot());

        foreach (
$collection as $key => $value{
            $rootChildParts 
explode(DIRECTORY_SEPARATORsubstr($value->getFilename(), $storageRootLength));

            if (
array_key_exists($rootChildParts[0]$conditions[\'plain\'])
                || (
$regExp && preg_match($regExp$value->getFilename()))) {
                $collection
->removeItemByKey($key);
            
}
        }

        
return $collection;
    
}
}

Simply disable / remove this plugin once Magento releases a fix for this bug.

Kind regards,
Tim

 
Magento Community Magento Community
Magento Community
Magento Community
 
matthewpavkov
Jr. Member
 
Total Posts:  7
Joined:  2010-02-27
Ohio
 

The database solution posted by clorne (in this thread) worked for me.

I should also mention I’m using Magento ver. 1.5.1.0

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

@Tim Hengeveld:: Thank you for the solution

I must re-iterate for everyone not to modify core code. You can easily over ride core by putting your file and the folder structure in local/Mage

 
Magento Community Magento Community
Magento Community
Magento Community
 
ctrol
Member
 
Total Posts:  43
Joined:  2010-10-22
 

Thx For your sulotion!
It works !

 
Magento Community Magento Community
Magento Community
Magento Community
 
webcoop
Jr. Member
 
Total Posts:  1
Joined:  2011-06-27
 

I’ve tried Tim Hengeveld’s solution and get this error in the log file:

Failed opening 'Mynamespace_Mymodule_Model_Wysiwyg_Images_Storage.php' for inclusion (include_path='/var/www/magento_test/includes/src:.:/usr/share/php:/usr/share/pear')  in /var/www/magento_test/includes/src/Varien_Autoload.php on line 93

(where Mynamespace_Mymodule are my local folder names).

Any ideas?

Should support.php be in app/code/local/Mage/Cms/mymodule/ or in app/code/local/mymodule/ or somewhere else?

Thanks grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
carlamo83
Jr. Member
 
Total Posts:  1
Joined:  2012-01-16
 

I have recently upgraded also and have this issue.

Magento seems to be looking in to media/wysiwyg/ for the files and directories, so why can\’t we simply create a symbolic link:

e.g:
cd media/wysiwyg/
ln -s ../../media .

Just means they will have to expand the media folder first in the directory structure, but all the files will then be visible without modifying any code.

Any thoughts on this?

Thanks

Carl

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 3