Pengecualian PDO saat menjalankan cron: pengiriman antrian buletin gagal (Kolom tidak dikenal 'main_table.data' dalam 'daftar bidang')

15

pekerjaan cron gagal saat memproses antrian buletin. Saya mendebug panggilan PDO dan sepertinya Magento sedang mencampur bidang di sini. Saya tidak tahu di mana Magento (atau Zend PDO) mendapatkan bidang untuk dipilih, tetapi kelihatannya benar-benar membingungkan:

Sepertinya Magento gagal mendapatkan nama depan pelanggan. Pilihan terakhir adalah:

SELECT eav_entity_type.* FROM eav_entity_type WHERE (eav_entity_type.entity_type_code='customer')

DESCRIBE customer_eav_attribute

DESCRIBE customer_eav_attribute_website

kemudian datang pilih dengan daftar bidang yang tidak ada:

SELECT main_table.data, main_table.lifetime, main_table.expire, main_table.priority, additional_table.attribute_id, additional_table.is_visible, additional_table.input_filter, additional_table.multiline_count, additional_table.validate_rules, additional_table.is_system, additional_table.sort_order, additional_table.data_model, scope_table.website_id AS scope_website_id, scope_table.is_visible AS scope_is_visible, scope_table.multiline_count AS scope_multiline_count FROM eav_attribute AS main_table INNER JOIN customer_eav_attribute AS additional_table ON additional_table.attribute_id = main_table.attribute_id LEFT JOIN customer_eav_attribute_website AS scope_table ON scope_table.attribute_id = main_table.attribute_id AND scope_table.website_id = :scope_website_id WHERE (main_table.entity_type_id = :mt_entity_type_id)

Parameter untuk permintaan itu: :mt_entity_type_id' => 1dan:scope_website_id' => 0

ini memunculkan

exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'main_table.data' in 'field list''

karena tabel eav_attribute tidak menyertakan data bidang, masa pakai, kedaluwarsa, atau prioritas.

Inilah jejak tumpukan lengkap:

Stack trace:
0 /usr/www/users/weartb/shop/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
1 /usr/www/users/weartb/shop/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
2 /usr/www/users/weartb/shop/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
3 /usr/www/users/weartb/shop/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
4 /usr/www/users/weartb/shop/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `main_ta...', Array)
5 /usr/www/users/weartb/shop/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)
6 /usr/www/users/weartb/shop/lib/Zend/Db/Adapter/Abstract.php(737): Varien_Db_Adapter_Pdo_Mysql->query('SELECT `main_ta...', Array)
7 /usr/www/users/weartb/shop/lib/Varien/Data/Collection/Db.php(734): Zend_Db_Adapter_Abstract->fetchAll('SELECT `main_ta...', Array)
8 /usr/www/users/weartb/shop/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT `main_ta...', Array)
9 /usr/www/users/weartb/shop/app/code/core/Mage/Eav/Model/Config.php(356): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
10 /usr/www/users/weartb/shop/app/code/core/Mage/Eav/Model/Config.php(478): Mage_Eav_Model_Config->_initAttributes(Object(Mage_Eav_Model_Entity_Type))
11 /usr/www/users/weartb/shop/app/code/core/Mage/Eav/Model/Entity/Abstract.php(512): Mage_Eav_Model_Config->getEntityAttributeCodes(Object(Mage_Eav_Model_Entity_Type), Object(Mage_Customer_Model_Customer))
12 /usr/www/users/weartb/shop/app/code/core/Mage/Customer/Model/Customer.php(340): Mage_Eav_Model_Entity_Abstract->loadAllAttributes(Object(Mage_Customer_Model_Customer))
13 /usr/www/users/weartb/shop/app/code/core/Mage/Customer/Model/Customer.php(354): Mage_Customer_Model_Customer->getAttributes()
14 /usr/www/users/weartb/shop/app/code/core/Mage/Newsletter/Model/Resource/Subscriber/Collection.php(134): Mage_Customer_Model_Customer->getAttribute('firstname')
15 /usr/www/users/weartb/shop/app/code/core/Mage/Newsletter/Model/Queue.php(191): Mage_Newsletter_Model_Resource_Subscriber_Collection->showCustomerInfo()
16 [internal function]: Mage_Newsletter_Model_Queue->sendPerSubscriber(20)
17 /usr/www/users/weartb/shop/lib/Varien/Data/Collection.php(466): call_user_func_array(Array, Array)
18 /usr/www/users/weartb/shop/app/code/core/Mage/Newsletter/Model/Observer.php(70): Varien_Data_Collection->walk('sendPerSubscrib...', Array)
19 [internal function]: Mage_Newsletter_Model_Observer->scheduledSend(Object(Mage_Cron_Model_Schedule))
20 /usr/www/users/weartb/shop/app/code/core/Mage/Cron/Model/Observer.php(325): call_user_func_array(Array, Array)
21 /usr/www/users/weartb/shop/app/code/core/Mage/Cron/Model/Observer.php(72): Mage_Cron_Model_Observer->_processJob(Object(Mage_Cron_Model_Schedule), Object(Mage_Core_Model_Config_Element))
22 /usr/www/users/weartb/shop/app/code/core/Mage/Core/Model/App.php(1338): Mage_Cron_Model_Observer->dispatch(Object(Varien_Event_Observer))
23 /usr/www/users/weartb/shop/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Cron_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
24 /usr/www/users/weartb/shop/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
25 /usr/www/users/weartb/shop/cron.php(84): Mage::dispatchEvent('default')
26 {main}

Semuanya tampak baik-baik saja sampai ada Mage_Customer_Model_Customer->getAttribute('firstname')panggilan telepon.

Kami tidak memperluas model pelanggan atau menggunakan modul apa pun yang melakukannya, juga mempratinjau buletin berfungsi dengan baik dan mengirimkannya secara manual juga, jadi pengecualian ini hanya terjadi ketika Magento mencoba memproses antrean buletin melalui panggilan cron.

lars.schwarz
sumber
Apa versi Magento? Di Magento 1.9.0.1 saya bisa menjalankan Zend_Debug::dump(Mage::getModel('customer/customer')->getAttribute('firstname'));dan mendapatkan Mage_Customer_Model_Attributekembali yang valid . Dapatkah Anda secara manual mengkonfirmasi dalam database yang atribut firstnamedalam eav_attributedan memiliki hak entity_type_iddari eav_entity_type?
Tyler V.

Jawaban:

3

Saya pikir Anda telah memodifikasi aplikasi file inti / kode / core / Mage / Newsletter / Model / Sumber Daya / Pelanggan / Collection.php

Silakan periksa fungsi showCustomerInfo () di dekat baris 130. Seharusnya:

public function showCustomerInfo()
{
    $adapter = $this->getConnection();
    $customer = Mage::getModel('customer/customer');
    $firstname  = $customer->getAttribute('firstname');
    $lastname   = $customer->getAttribute('lastname');

    $this->getSelect()
        ->joinLeft(
            array('customer_lastname_table'=>$lastname->getBackend()->getTable()),
            $adapter->quoteInto('customer_lastname_table.entity_id=main_table.customer_id
             AND customer_lastname_table.attribute_id = ?', (int)$lastname->getAttributeId()),
            array('customer_lastname'=>'value')
        )
        ->joinLeft(
            array('customer_firstname_table'=>$firstname->getBackend()->getTable()),
            $adapter->quoteInto('customer_firstname_table.entity_id=main_table.customer_id
             AND customer_firstname_table.attribute_id = ?', (int)$firstname->getAttributeId()),
            array('customer_firstname'=>'value')
        );

    return $this;
}

Kenapa saya berpikir begitu?

  1. Log kesalahan Anda menunjukkan apa yang tidak melibatkan ekstensi pihak ke-3 atau file Mage / lokal.

  2. Kueri SQL standar untuk tindakan Magento ini tidak memiliki bagian 'main_table.data, main_table.lifetime, main_table.expire, main_table.priority,'.

ToxaBes
sumber
1

Berjalan melalui jejak tumpukan Anda, SQL Anda akan terlihat seperti ini:

SELECT `main_table`.`attribute_id`, `main_table`.`entity_type_id`, `main_table`.`attribute_code`, `main_table`.`attribute_model`, `main_table`.`backend_model`, `main_table`.`backend_type`, `main_table`.`backend_table`, `main_table`.`frontend_model`, `main_table`.`frontend_input`, `main_table`.`frontend_label`, `main_table`.`frontend_class`, `main_table`.`source_model`, `main_table`.`is_required`, `main_table`.`is_user_defined`, `main_table`.`default_value`, `main_table`.`is_unique`, `main_table`.`note`, `additional_table`.`is_visible`, `additional_table`.`input_filter`, `additional_table`.`multiline_count`, `additional_table`.`validate_rules`, `additional_table`.`is_system`, `additional_table`.`sort_order`, `additional_table`.`data_model`, `scope_table`.`website_id` AS `scope_website_id`, `scope_table`.`is_visible` AS `scope_is_visible`, `scope_table`.`is_required` AS `scope_is_required`, `scope_table`.`default_value` AS `scope_default_value`, `scope_table`.`multiline_count` AS `scope_multiline_count` FROM `eav_attribute` AS `main_table`
 INNER JOIN `customer_eav_attribute` AS `additional_table` ON additional_table.attribute_id = main_table.attribute_id
 LEFT JOIN `customer_eav_attribute_website` AS `scope_table` ON scope_table.attribute_id = main_table.attribute_id AND scope_table.website_id = :scope_website_id WHERE (main_table.entity_type_id = :mt_entity_type_id)

Saya sepertinya tidak dapat menemukan kolom yang tidak dikenal di Magento, namun saya memiliki tipuan licik ini ada hubungannya dengan sesi / cache tetapi tidak 100% yakin. Apakah Anda telah mengaktifkan Redis mungkin? Jika demikian, nonaktifkan dan hapus cache dan lihat hasilnya.

Shaughn
sumber