PAYONE-GmbH / magento-2

PAYONE Payment Extension for Magento 2
28 stars 58 forks source link

Tables get called without prefix #8

Closed grasdaggel closed 7 years ago

grasdaggel commented 7 years ago

The module calls database table names without adding the needed prefix, which leads to exception errors.

Next Zend_Db_Statement_Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'webuser_copy.sales_order' doesn't exist, query was:  SELECT
                        *
                    FROM
                        sales_order
                    WHERE
                        entity_id = :entity_id in /home/webuser/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /home/webuser/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(95): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/webuser/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#2 /home/webuser/public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/webuser/public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query(' SELECT\n       ...', Array)
#4 /home/webuser/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(444): Zend_Db_Adapter_Pdo_Abstract->query(' SELECT\n       ...', Array)
#5 /home/webuser/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(499): Magento\Framework\DB\Adapter\Pdo\Mysql->_query(' SELECT\n       ...', Array)
#6 /home/webuser/public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(756): Magento\Framework\DB\Adapter\Pdo\Mysql->query(' SELECT\n       ...', Array)
#7 /home/webuser/public_html/app/code/Payone/Core/Helper/Database.php(145): Zend_Db_Adapter_Abstract->fetchRow(' SELECT\n       ...', Array)
#8 /home/webuser/public_html/app/code/Payone/Core/Model/UiComponent/DataProvider.php(96): Payone\Core\Helper\Database->getIncrementIdByOrderId('132')
#9 /home/webuser/public_html/vendor/magento/framework/View/Element/UiComponent/DataProvider/DataProvider.php(108): Payone\Core\Model\UiComponent\DataProvider->prepareUpdateUrl()
#10 /home/webuser/public_html/app/code/Payone/Core/Model/UiComponent/DataProvider.php(74): Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider->__construct('payone_protocol...', 'id', 'order_id', Object(Magento\Framework\View\Element\UiComponent\DataProvider\Reporting), Object(Magento\Framework\Api\Search\SearchCriteriaBuilder), Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Api\FilterBuilder), Array, Array)
#11 /home/webuser/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(118): Payone\Core\Model\UiComponent\DataProvider->__construct('payone_protocol...', 'id', 'order_id', Object(Magento\Framework\View\Element\UiComponent\DataProvider\Reporting), Object(Magento\Framework\Api\Search\SearchCriteriaBuilder), Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Api\FilterBuilder), Object(Payone\Core\Helper\Database), Array, Array)
#12 /home/webuser/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Payone\\Core\\Mod...', Array)
#13 /home/webuser/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Payone\\Core\\Mod...', Array)
#14 /home/webuser/public_html/vendor/magento/framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php(60): Magento\Framework\ObjectManager\ObjectManager->create('Payone\\Core\\Mod...', Array)
#15 /home/webuser/public_html/var/generation/Magento/Framework/Data/Argument/InterpreterInterface/Proxy.php(95): Magento\Framework\View\Element\UiComponent\Argument\Interpreter\ConfigurableObject->evaluate(Array)
#16 /home/webuser/public_html/vendor/magento/framework/Data/Argument/Interpreter/Composite.php(61): Magento\Framework\Data\Argument\InterpreterInterface\Proxy->evaluate(Array)
#17 /home/webuser/public_html/vendor/magento/module-ui/Model/Manager.php(191): Magento\Framework\Data\Argument\Interpreter\Composite->evaluate(Array)
#18 /home/webuser/public_html/vendor/magento/module-ui/Model/Manager.php(194): Magento\Ui\Model\Manager->evaluateComponentArguments(Array)
#19 /home/webuser/public_html/vendor/magento/module-ui/Model/Manager.php(175): Magento\Ui\Model\Manager->evaluateComponentArguments(Array)
#20 /home/webuser/public_html/vendor/magento/framework/View/Element/UiComponentFactory.php(139): Magento\Ui\Model\Manager->prepareData('payone_sales_or...')
#21 /home/webuser/public_html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(124): Magento\Framework\View\Element\UiComponentFactory->create('payone_sales_or...', NULL, Array)
#22 /home/webuser/public_html/vendor/magento/framework/View/Layout/Generator/UiComponent.php(93): Magento\Framework\View\Layout\Generator\UiComponent->generateComponent(Object(Magento\Framework\View\Layout\Data\Structure), 'payone_sales_or...', Array, Object(Magento\Framework\View\Layout\Interceptor))
#23 /home/webuser/public_html/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\UiComponent->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#24 /home/webuser/public_html/vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#25 /home/webuser/public_html/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()
#26 /home/webuser/public_html/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#27 /home/webuser/public_html/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#28 /home/webuser/public_html/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#29 /home/webuser/public_html/vendor/magento/framework/View/Layout.php(244): Magento\Framework\View\Layout\Builder->build()
#30 /home/webuser/public_html/vendor/magento/framework/View/Layout.php(859): Magento\Framework\View\Layout->build()
#31 /home/webuser/public_html/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout->getBlock('menu')
#32 /home/webuser/public_html/vendor/magento/module-backend/Model/View/Result/Page.php(59): Magento\Framework\View\Layout\Interceptor->getBlock('menu')
#33 /home/webuser/public_html/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Sales::...')
#34 /home/webuser/public_html/vendor/magento/module-sales/Controller/Adminhtml/Order.php(133): Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu('Magento_Sales::...')
#35 /home/webuser/public_html/vendor/magento/module-sales/Controller/Adminhtml/Order/View.php(23): Magento\Sales\Controller\Adminhtml\Order->_initAction()
#36 /home/webuser/public_html/var/generation/Magento/Sales/Controller/Adminhtml/Order/View/Interceptor.php(24): Magento\Sales\Controller\Adminhtml\Order\View->execute()
#37 /home/webuser/public_html/vendor/magento/framework/App/Action/Action.php(102): Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->execute()
#38 /home/webuser/public_html/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#39 [internal function]: Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#40 /home/webuser/public_html/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#41 /home/webuser/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callParent('dispatch', Array)
#42 /home/webuser/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Sales\\C...', 'dispatch', Object(Magento\Sales\Controller\Adminhtml\Order\View\Interceptor), Array, 'adminAuthentica...')
#43 /home/webuser/public_html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#44 [internal function]: Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Sales\Controller\Adminhtml\Order\View\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#45 /home/webuser/public_html/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#46 /home/webuser/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Sales\\C...', 'dispatch', Object(Magento\Sales\Controller\Adminhtml\Order\View\Interceptor), Array, 'designLoader')
#47 /home/webuser/public_html/vendor/magento/framework/App/Action/Plugin/Design.php(39): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#48 [internal function]: Magento\Framework\App\Action\Plugin\Design->aroundDispatch(Object(Magento\Sales\Controller\Adminhtml\Order\View\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#49 /home/webuser/public_html/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#50 /home/webuser/public_html/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Sales\\C...', 'dispatch', Object(Magento\Sales\Controller\Adminhtml\Order\View\Interceptor), Array, 'adminMassaction...')
#51 /home/webuser/public_html/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#52 [internal function]: Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Sales\Controller\Adminhtml\Order\View\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#53 /home/webuser/public_html/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array)
#54 /home/webuser/public_html/var/generation/Magento/Sales/Controller/Adminhtml/Order/View/Interceptor.php(39): Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->___callPlugins('dispatch', Array, Array)
#55 /home/webuser/public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Sales\Controller\Adminhtml\Order\View\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#56 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#57 /home/webuser/public_html/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#58 /home/webuser/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#59 /home/webuser/public_html/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#60 /home/webuser/public_html/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#61 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#62 /home/webuser/public_html/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array)
#63 /home/webuser/public_html/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#64 /home/webuser/public_html/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#65 /home/webuser/public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#66 /home/webuser/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#67 {main} [] []

In file app/code/Payone/Core/Helper/Database.php are the functions located at:

/**
     * Get increment_id from order by given order id
     *
     * @param  string $sOrderId
     * @return string|bool
     */
    public function getIncrementIdByOrderId($sOrderId)
    {
        $oDb = $this->getDb();
        $sQuery = " SELECT
                        *
                    FROM
                        ".$oDb->getTableName('sales_order')."
                    WHERE
                        entity_id = :entity_id";
        $aResult = $oDb->fetchRow($sQuery, ['entity_id' => $sOrderId]);
        if ($aResult) {
            return $aResult['increment_id'];
        }
        return false;
    }

Seems like something is missing here. If I try to modify the calling database table to cc_sales_order (cc_ is our prefix) it works perfectly nice. Seems this function just don't get the prefix, other functions doesn't seem to have problems... Very weird. Maybe re-initiate the prefix request or get it directly from env.php? Just an idea...

fjbender commented 7 years ago

@Fatchip-Support looks like a bug to me, please take a look.

grasdaggel commented 7 years ago

Somehow other functions get the correct database value, otherwise they would have dropped errors earlier. Seems very weird to me. Manual fix in this function worked as workaround for us, but can't be the solution somehow. Please investigate this ASAP as we are trying to offer our customers PayOne as PSP for Mage2.

grasdaggel commented 7 years ago

Any updates on this?

PAYONE-GmbH commented 7 years ago

should be fixed with the last commit ...