まずは、「デバッグ方法」を適用した環境で検証する方向で進めています。
これについて報告しながら進めて参りたいと思います。ディレクトリ「vtigercrm」は
apache2のDocumentRootである「/var/www/」に格納しています。
ここから________________________________
PHP
・Turn on log4php.debug library usage, in file config.performance.php
'LOG4PHP_DEBUG' => true,
訳:config.performance.phpで、log4php.debugライブラリの使用をオンにします
ファイル:vtigercrm/config.performance.php
デフォルト:'LOG4PHP_DEBUG' => false,
変更後:'LOG4PHP_DEBUG' => true,
・Set the log level, in file log4php.properties
log4php.rootLogger = DEBUG, A1
訳:log4php.propertiesで、ログレベルを設定
ファイル:vtigercrm/log4php.properties
デフォルト:log4php.rootLogger=FATAL,A1
変更後:log4php.rootLogger = DEBUG, A1
Database
・Turn on debugging as adb instanced in include/database/PearDatabase (at end of file)
if(empty($adb)) {
$adb = new PearDatabase();
$adb->connect();
// ADD THIS LINE
$adb->setDebug(true);
}
訳:PearDatabaseの最後にインスタンス化ADBなどのデバッグをオンにします。
ファイル:vtigercrm/include/database/PearDatabase.php
デフォルト:
if(empty($adb)) {^M
$adb = new PearDatabase();^M
$adb->connect();^M
}^M
変更後:
if(empty($adb)) {^M
$adb = new PearDatabase();^M
$adb->connect();^M
$adb->setDebug(true);^M
}^M
Smarty
・In file, Smarty_setup.php add the following to class constructor function
function vtigerCRM_Smarty() {
$this->Smarty();
$this->template_dir = 'Smarty/templates';
// ...
// ADD THIS LINE
$this->debugging = true;
}
訳:クラスコンストラクタ関数に以下を追加
ファイル:Smarty_setup.php
備考:ファイルがvtigercrm6.0にはなかったため編集しませんでした(vtigercrm5.4にはある)。
PHP Files
・To print all the SQL commands to the browser
In include/database/PearDatabase.php near line 680
replace:
//$this->database->debug = true;
with:
$this->database->debug = true;
訳:ブラウザにすべてのSQLコマンドを印刷する。
ファイル:vtigercrm/include/database/PearDatabase.php
実際:
行番号
879 function setDebug($value) {^M
880 $this->database->debug = $value;^M
881 }^M
となっておりましたので、setDebugで検索したところ、1075行目に
行番号
1072 if(empty($adb)) {^M
1073 $adb = new PearDatabase();^M
1074 $adb->connect();^M
1075 $adb->setDebug(true);^M
1076 }^M
を発見しました。trueなので変更しませんでした。
・To print DEBUG log data to the logfile logs/vtigercrm.log. In log4php.properties
replace:
log4php.rootLogger=FATAL,A1
with:
log4php.rootLogger=DEBUG,A1
訳:vtigercrm.logにデバッグログデータを印刷する。
ファイル:vtigercrm/log4php.properties
備考:これは既に設定済み
最後のこの辺は、これは任意のPHPファイルの任意の場所に行を挿入する説明のようですが、よくわかっていませんので設定しませんでした。
・To print a value (or array) to the browser, insert the following in the PHP file:
trigger_error('TempDebug: $someVariable="'.print_r($someVariable, TRUE) .'"');
Don't forget to remove it afterward!
・Better still, to print an array to the browser in a more legible format we add opening and closing HTML <PRE> tags:
trigger_error('TempDebug: $smallArray=<PRE>"'.print_r($smallArray, TRUE) .'"</PRE>');
Note however that trigger_error() truncates the output if the array is large. The following works on large arrays:
trigger_error('TempDebug: $largeArray:...'); print_r("<PRE>"); print_r($largeArray); print_r("</PRE>");
ここまで________________________________
なにやらページにコードが吐き出されるようになりました。動作はしているのでログインし、見積りをエクスポートさせた
結果が下記の通りです。
ここから________________________________
(mysql): SELECT tabid, name, ownedby FROM vtiger_tab
(mysql): SELECT tabid, fieldname, fieldid, fieldlabel, columnname, tablename, uitype, typeofdata, presence FROM vtiger_field WHERE tabid in ('29')
(mysql): SELECT * FROM vtiger_tab
(mysql): SELECT fieldname,modulename,tablename,entityidfield,entityidcolumn from vtiger_entityname
(mysql): SELECT tabid, fieldname, fieldid, fieldlabel, columnname, tablename, uitype, typeofdata, presence FROM vtiger_field WHERE tabid in ('20')
(mysql): SELECT vtiger_quotes.quote_no AS vtiger_quotesquote_no,vtiger_quotes.subject AS vtiger_quotessubject,vtiger_quotes.potentialid AS vtiger_quotespotential_id,vtiger_quotes.quotestage AS vtiger_quotesquotestage,vtiger_quotes.validtill AS vtiger_quotesvalidtill,vtiger_quotes.contactid AS vtiger_quotescontact_id,vtiger_quotes.carrier AS vtiger_quotescarrier,vtiger_quotes.subtotal AS vtiger_quoteshdnsubtotal,vtiger_quotes.shipping AS vtiger_quotesshipping,vtiger_quotes.inventorymanager AS vtiger_quotesassigned_user_id1,vtiger_quotes.adjustment AS vtiger_quotestxtadjustment,vtiger_quotes.total AS vtiger_quoteshdngrandtotal,vtiger_quotes.taxtype AS vtiger_quoteshdntaxtype,vtiger_quotes.discount_percent AS vtiger_quoteshdndiscountpercent,vtiger_quotes.discount_amount AS vtiger_quoteshdndiscountamount,vtiger_quotes.s_h_amount AS vtiger_quoteshdns_h_amount,vtiger_quotes.accountid AS vtiger_quotesaccount_id,vtiger_crmentity.smownerid AS vtiger_crmentityassigned_user_id,vtiger_crmentity.createdtime AS vtiger_crmentitycreatedtime,vtiger_crmentity.modifiedtime AS vtiger_crmentitymodifiedtime,vtiger_crmentity.modifiedby AS vtiger_crmentitymodifiedby,vtiger_quotes.currency_id AS vtiger_quotescurrency_id,vtiger_quotes.conversion_rate AS vtiger_quotesconversion_rate,vtiger_quotesbillads.bill_street AS vtiger_quotesbilladsbill_street,vtiger_quotesshipads.ship_street AS vtiger_quotesshipadsship_street,vtiger_quotesbillads.bill_city AS vtiger_quotesbilladsbill_city,vtiger_quotesshipads.ship_city AS vtiger_quotesshipadsship_city,vtiger_quotesbillads.bill_state AS vtiger_quotesbilladsbill_state,vtiger_quotesshipads.ship_state AS vtiger_quotesshipadsship_state,vtiger_quotesbillads.bill_code AS vtiger_quotesbilladsbill_code,vtiger_quotesshipads.ship_code AS vtiger_quotesshipadsship_code,vtiger_quotesbillads.bill_country AS vtiger_quotesbilladsbill_country,vtiger_quotesshipads.ship_country AS vtiger_quotesshipadsship_country,vtiger_quotesbillads.bill_pobox AS vtiger_quotesbilladsbill_pobox,vtiger_quotesshipads.ship_pobox AS vtiger_quotesshipadsship_pobox,vtiger_crmentity.description AS vtiger_crmentitydescription,vtiger_quotes.terms_conditions AS vtiger_quotesterms_conditions,vtiger_inventoryproductrel.productid AS vtiger_inventoryproductrelproductid,vtiger_inventoryproductrel.quantity AS vtiger_inventoryproductrelquantity,vtiger_inventoryproductrel.listprice AS vtiger_inventoryproductrellistprice,vtiger_inventoryproductrel.comment AS vtiger_inventoryproductrelcomment,vtiger_inventoryproductrel.discount_amount AS vtiger_inventoryproductreldiscount_amount,vtiger_inventoryproductrel.discount_percent AS vtiger_inventoryproductreldiscount_percent,vtiger_inventoryproductrel.tax1 AS vtiger_inventoryproductreltax1,vtiger_inventoryproductrel.tax2 AS vtiger_inventoryproductreltax2,vtiger_inventoryproductrel.tax3 AS vtiger_inventoryproductreltax3,vtiger_quotes.pre_tax_total AS vtiger_quotespre_tax_total,vtiger_quotes.s_h_percent AS vtiger_quoteshdns_h_percent,vtiger_crmentity.deleted FROM vtiger_crmentity LEFT JOIN vtiger_quotes ON vtiger_quotes.quoteid=vtiger_crmentity.crmid LEFT JOIN vtiger_quotesbillads ON vtiger_quotesbillads.quotebilladdressid=vtiger_crmentity.crmid LEFT JOIN vtiger_quotesshipads ON vtiger_quotesshipads.quoteshipaddressid=vtiger_crmentity.crmid LEFT JOIN vtiger_quotescf ON vtiger_quotescf.quoteid=vtiger_crmentity.crmid LEFT JOIN vtiger_inventoryproductrel ON
vtiger_inventoryproductrel.id=vtiger_crmentity.crmid WHERE vtiger_crmentity.crmid='4' LIMIT 1
(mysql): SELECT vtiger_quotes.quote_no AS vtiger_quotesquote_no,vtiger_quotes.subject AS vtiger_quotessubject,vtiger_quotes.potentialid AS vtiger_quotespotential_id,vtiger_quotes.quotestage AS vtiger_quotesquotestage,vtiger_quotes.validtill AS vtiger_quotesvalidtill,vtiger_quotes.contactid AS vtiger_quotescontact_id,vtiger_quotes.carrier AS vtiger_quotescarrier,vtiger_quotes.subtotal AS vtiger_quoteshdnsubtotal,vtiger_quotes.shipping AS vtiger_quotesshipping,vtiger_quotes.inventorymanager AS vtiger_quotesassigned_user_id1,vtiger_quotes.adjustment AS vtiger_quotestxtadjustment,vtiger_quotes.total AS vtiger_quoteshdngrandtotal,vtiger_quotes.taxtype AS vtiger_quoteshdntaxtype,vtiger_quotes.discount_percent AS vtiger_quoteshdndiscountpercent,vtiger_quotes.discount_amount AS vtiger_quoteshdndiscountamount,vtiger_quotes.s_h_amount AS vtiger_quoteshdns_h_amount,vtiger_quotes.accountid AS vtiger_quotesaccount_id,vtiger_crmentity.smownerid AS vtiger_crmentityassigned_user_id,vtiger_crmentity.createdtime AS vtiger_crmentitycreatedtime,vtiger_crmentity.modifiedtime AS vtiger_crmentitymodifiedtime,vtiger_crmentity.modifiedby AS vtiger_crmentitymodifiedby,vtiger_quotes.currency_id AS vtiger_quotescurrency_id,vtiger_quotes.conversion_rate AS vtiger_quotesconversion_rate,vtiger_quotesbillads.bill_street AS vtiger_quotesbilladsbill_street,vtiger_quotesshipads.ship_street AS vtiger_quotesshipadsship_street,vtiger_quotesbillads.bill_city AS vtiger_quotesbilladsbill_city,vtiger_quotesshipads.ship_city AS vtiger_quotesshipadsship_city,vtiger_quotesbillads.bill_state AS vtiger_quotesbilladsbill_state,vtiger_quotesshipads.ship_state AS vtiger_quotesshipadsship_state,vtiger_quotesbillads.bill_code AS vtiger_quotesbilladsbill_code,vtiger_quotesshipads.ship_code AS vtiger_quotesshipadsship_code,vtiger_quotesbillads.bill_country AS vtiger_quotesbilladsbill_country,vtiger_quotesshipads.ship_country AS vtiger_quotesshipadsship_country,vtiger_quotesbillads.bill_pobox AS vtiger_quotesbilladsbill_pobox,vtiger_quotesshipads.ship_pobox AS vtiger_quotesshipadsship_pobox,vtiger_crmentity.description AS vtiger_crmentitydescription,vtiger_quotes.terms_conditions AS vtiger_quotesterms_conditions,vtiger_inventoryproductrel.productid AS vtiger_inventoryproductrelproductid,vtiger_inventoryproductrel.quantity AS vtiger_inventoryproductrelquantity,vtiger_inventoryproductrel.listprice AS vtiger_inventoryproductrellistprice,vtiger_inventoryproductrel.comment AS vtiger_inventoryproductrelcomment,vtiger_inventoryproductrel.discount_amount AS vtiger_inventoryproductreldiscount_amount,vtiger_inventoryproductrel.discount_percent AS vtiger_inventoryproductreldiscount_percent,vtiger_inventoryproductrel.tax1 AS vtiger_inventoryproductreltax1,vtiger_inventoryproductrel.tax2 AS vtiger_inventoryproductreltax2,vtiger_inventoryproductrel.tax3 AS vtiger_inventoryproductreltax3,vtiger_quotes.pre_tax_total AS vtiger_quotespre_tax_total,vtiger_quotes.s_h_percent AS vtiger_quoteshdns_h_percent,vtiger_crmentity.deleted FROM vtiger_crmentity LEFT JOIN vtiger_quotes ON vtiger_quotes.quoteid=vtiger_crmentity.crmid LEFT JOIN vtiger_quotesbillads ON vtiger_quotesbillads.quotebilladdressid=vtiger_crmentity.crmid LEFT JOIN vtiger_quotesshipads ON vtiger_quotesshipads.quoteshipaddressid=vtiger_crmentity.crmid LEFT JOIN vtiger_quotescf ON vtiger_quotescf.quoteid=vtiger_crmentity.crmid LEFT JOIN vtiger_inventoryproductrel ON
vtiger_inventoryproductrel.id=vtiger_crmentity.crmid WHERE vtiger_crmentity.crmid='4' LIMIT 1
(mysql): SELECT * FROM vtiger_field WHERE tabid='20'
(mysql): SELECT case when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname, case when vtiger_products.productid != '' then vtiger_products.productcode else vtiger_service.service_no end as productcode, case when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price, case when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock, case when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype, vtiger_inventoryproductrel.listprice, vtiger_inventoryproductrel.description AS product_description, vtiger_inventoryproductrel.*,vtiger_crmentity.deleted FROM vtiger_inventoryproductrel LEFT JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid LEFT JOIN vtiger_products ON vtiger_products.productid=vtiger_inventoryproductrel.productid LEFT JOIN vtiger_service ON vtiger_service.serviceid=vtiger_inventoryproductrel.productid WHERE id='4' ORDER BY sequence_no
(mysql): SELECT productid as prod_id from vtiger_inventorysubproductrel WHERE id='4' AND sequence_no=1
(mysql): select taxtype from vtiger_quotes where quoteid='4'
(mysql): SELECT vtiger_producttaxrel.*, vtiger_inventorytaxinfo.* FROM vtiger_inventorytaxinfo INNER JOIN vtiger_producttaxrel ON vtiger_inventorytaxinfo.taxid = vtiger_producttaxrel.taxid WHERE vtiger_producttaxrel.productid = '3'
(mysql): select taxname,taxid from vtiger_inventorytaxinfo
(mysql): select * from vtiger_inventoryproductrel where id='4'
(mysql): select * from vtiger_inventorytaxinfo where deleted=0 order by taxid
(mysql): SELECT * FROM vtiger_shippingtaxinfo WHERE deleted=0
(mysql): SELECT shtax1 FROM vtiger_inventoryshippingrel WHERE id='4'
(mysql): SELECT shtax2 FROM vtiger_inventoryshippingrel WHERE id='4'
(mysql): SELECT shtax3 FROM vtiger_inventoryshippingrel WHERE id='4'
(mysql): select shtax1 from vtiger_inventoryshippingrel where id= '4'
(mysql): select shtax2 from vtiger_inventoryshippingrel where id= '4'
(mysql): select shtax3 from vtiger_inventoryshippingrel where id= '4'
(mysql): SELECT quote_no FROM vtiger_quotes WHERE quoteid = 4
(mysql): SELECT * FROM vtiger_organizationdetails
(mysql): SELECT crmid, setype, label FROM vtiger_crmentity WHERE crmid='2'
(mysql): SELECT * FROM vtiger_currency_info
(mysql): SELECT currency_symbol FROM vtiger_currency_info WHERE id='1'
ここまで________________________________
もしかしたら頓珍漢なことしてるのかも知れませんが、せっかく出力させたので載せました。
しかし、私にはこれらのコードが何を意味しているのかさっぱりわかりません。
今後の方向性を考えながら少し休憩したいと思います。