magento-lts
magento-lts copied to clipboard
Table 'dbName.core_file_storage' doesn't exist
I am on OpenMage 20.0.16 and PHP8.0
In the Exception.log, I see the following entries:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbName.core_file_storage' doesn't exist in /var/www/vhosts/....../lib/Zend/Db/Statement/Pdo.php:228 Stack trace: #0 /var/www/vhosts/....../lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute() #1 /var/www/vhosts/....../lib/Varien/Db/Statement/Pdo/Mysql.php(103): Zend_Db_Statement_Pdo->_execute() #2 /var/www/vhosts/....../app/code/core/Zend/Db/Statement.php(290): Varien_Db_Statement_Pdo_Mysql->_execute() #3 /var/www/vhosts/....../lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute() #4 /var/www/vhosts/....../lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query() #5 /var/www/vhosts/....../lib/Varien/Db/Adapter/Pdo/Mysql.php(501): Zend_Db_Adapter_Pdo_Abstract->query() #6 /var/www/vhosts/....../lib/Zend/Db/Adapter/Abstract.php(756): Varien_Db_Adapter_Pdo_Mysql->query() #7 /var/www/vhosts/....../app/code/core/Mage/Core/Model/Resource/File/Storage/Database.php(144): Zend_Db_Adapter_Abstract->fetchRow() #8 /var/www/vhosts/....../app/code/core/Mage/Core/Model/File/Storage/Database.php(118): Mage_Core_Model_Resource_File_Storage_Database->loadByFilename() #9 /var/www/vhosts/....../get.php(148): Mage_Core_Model_File_Storage_Database->loadByFilename() #10 {main}
Next Zend_Db_Statement_Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbName.core_file_storage' doesn't exist, query was: SELECT
e
.* FROMcore_file_storage
ASe
WHERE (filename = 'filaname.jpg') AND (directory = 'catalog/product/cache/3/thumbnail/77x100/9df78eab33525d08d6e5fb8d27136e95/m/i') in /var/www/vhosts/....../lib/Zend/Db/Statement/Pdo.php:235 Stack trace: #0 /var/www/vhosts/....../lib/Varien/Db/Statement/Pdo/Mysql.php(103): Zend_Db_Statement_Pdo->_execute() #1 /var/www/vhosts/....../app/code/core/Zend/Db/Statement.php(290): Varien_Db_Statement_Pdo_Mysql->_execute() #2 /var/www/vhosts/....../lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute() #3 /var/www/vhosts/....../lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query() #4 /var/www/vhosts/....../lib/Varien/Db/Adapter/Pdo/Mysql.php(501): Zend_Db_Adapter_Pdo_Abstract->query() #5 /var/www/vhosts/....../lib/Zend/Db/Adapter/Abstract.php(756): Varien_Db_Adapter_Pdo_Mysql->query() #6 /var/www/vhosts/....../app/code/core/Mage/Core/Model/Resource/File/Storage/Database.php(144): Zend_Db_Adapter_Abstract->fetchRow() #7 /var/www/vhosts/....../app/code/core/Mage/Core/Model/File/Storage/Database.php(118): Mage_Core_Model_Resource_File_Storage_Database->loadByFilename() #8 /var/www/vhosts/....../get.php(148): Mage_Core_Model_File_Storage_Database->loadByFilename() #9 {main}
The requested images to not exist (as far as I checked - probably someone should do a cleanup there) - The table does not exist.
I don't really get, what the corresponding code really does? ( Starting here: https://github.com/OpenMage/magento-lts/blob/37642edbac1c2695269c1653c42aaed72f36a136/get.php#L143 ) Can I savely ignore these Exceptions? Is something really broken? Is this code a left-over from some cleanup?
/Edit: Media is saved on the file system, not in the database. /Edit 2: So, the same file on a 20.0.14 installation ignores this exception per comment and also does not have this table. -> So... These questions remain:
- Can I ignore this error? -> Probably, because an older version of OM does so, too
- What should this code archive? -> ???
- Should this table normally exist? -> ???
You can search for the error with Google because there are many references over the years. In a post on Stackexchange, someone recommended creating that table in the database, if it doesn't exist.
You can also go to the Backend > System > Configuration and check if there is anything stored in the database. If not just press the [Save] configuration button. I faced this problem when I switched from PHP 7.0 to 8.1 and upgrading Magento old versions to OpenMage. If I remember correctly this is how I solved it.
Nice catch.
This table does no exist in "sample date" too, but is created when you change media storage to DB. So if you migrate a shop where config is set to use DB, but the table does not exist, you may run into this error.
Quick fix: got to admin section, set media storage to DB and hit "Synchronize".
should we do something about this or not?
We can do more but we have to simulate the issue to understand how it happens. I fixed it then but honestly speaking I didn't make it public, nor could I replicate it afterwards. Either we will have to change something in the code or mention a solution in the README file. I personally don't like the idea of creating that table in the database just to make the error disappear, I've never used the facility to store media files in the database.
@daboss84 what's your configuration for:

It seems to make storage is configured on database but without clicking the "syncronize" the table is not created.
I received that error message without having the modification in the Backend as in your image. I solved it by changing the "Media Storage" value with saving then going back to the initial value also with saving. I didn't want to create the table.
@fballiano I never had DB as media storage (nor do I really want to have it)
Isn't it possible to query this setting before executing this code block (or using core/file_storage_database )? (Sadly, I did not have time to further investigate this code block - had and have some other issues since the last upgrade (but nothing for this issue tracker for now))
For the time beeing I just commented out the exception printing like it was before - but it feels wrong to handle it this way.
/Edit: "Dummy-synchronizing" is, in my eyes, a bad idea, too.
#2627 should fix your issue.