CakePHP の 1.3.14 から 2.0.5 への移行 (私が書いたわけではない非常に大きなプロジェクト) がほぼ完了しました。残っている問題の 1 つは、XML ヘルパーの廃止に関するものです。
2.0.5 の新しい XML クラスは、以前は機能していた場所で失敗します。移行ガイドには、「現在、このクラスはデータを操作しなくなり、SimpleXMLElement のラッパーになっています」と記載されています http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#xml
以前は次を使用していました:
file_put_contents($xml_file, $this->Xml->serialize($quote, array('encoding' => 'UTF-8')));
上記を次のものに置き換えてみました。
$xml = Xml::build($quote, array(
'encoding' => 'UTF-8',
'format' => 'attributes'));
ただし、「無効な入力」というメッセージを含む例外「XmlException」が表示されるだけです。以下にサンプル配列を含めました。基本的に、新しい XML クラスは配列入力が好きではありません。アプリケーションには、複雑な XML を生成する部分がいくつかあり、同じ問題があります。
誰かがこの問題に遭遇しましたか? これをデバッグするには永遠にかかります。
潜在的な回避策は、古い Xml.php とヘルパーをコピーしてプラグインを作成することだと思いますが、可能であればこれをすべて機能させたいと思います。
サンプル配列:
Array
(
[Quote] => Array
(
[id] => 1
[quote_template_id] => 1
[project_id] => 1
[quote_status_id] => 1
[client_id] => 1
[date_added] => 2011-05-11
[is_archived] => 0
[comment] => Revision 2.
)
[Project] => Array
(
[id] => 1
[project_status_id] => 2
[user_id] => 5
[salesperson_id] => 5
[site_id] => 1
[name] => Test Project
[description] =>
[is_archived] => 0
[date_added] => 2011-05-11
[expected_start] => 2011-05-11
[Actual_start] =>
[expected_finish] => 2011-05-11
[actual_finish] =>
[special_clearance] => 1
[ProjectStatus] => Array
(
[id] => 2
[name] => Tendering
)
[User] => Array
(
[id] => 5
[user_group_id] => 5
[username] => operations
[password] => 7de1e823411aec881a96475e614d6286b944e92b
[first_name] => Operations
[last_name] => Person
[contact_phone] => 0400 000 000
[contact_number] => 0400 000 000
[emerg_contact_name] => 123
[emerg_contact_phone] => 0400 000 000
[is_active] => 1
[is_reset_required] => 0
[address] => 123
[state] => VIC
[suburb] => 123
[postcode] => 3000
[full_name] => Operations Person
)
[Site] => Array
(
[id] => 1
[site_type_id] => 1
[zone_id] => 1
[name] => Highpoint Test Site
[address] => 200 Rosamond Road
[suburb] => Maribyrnong
[postcode] => 3032
[state] => VIC
[melway_ref] => -
[date_added] => 2011-02-25 11:19:00
[comment] => This is just a test site
[is_active] => 1
)
[Salesperson] => Array
(
[id] => 5
[user_group_id] => 5
[username] => operations
[password] => 7de1e823411aec881a96475e614d6286b944e92b
[first_name] => Operations
[last_name] => Person
[contact_phone] => 0400 000 000
[contact_number] => 0400 000 000
[emerg_contact_name] => 123
[emerg_contact_phone] => 0400 000 000
[is_active] => 1
[is_reset_required] => 0
[address] => 123
[state] => VIC
[suburb] => 123
[postcode] => 3000
[full_name] => Operations Person
)
[ProjectStatusChange] => Array
(
[0] => Array
(
[id] => 1
[project_id] => 1
[project_status_id] => 1
[created] => 2011-05-11 17:27:14
)
[1] => Array
(
[id] => 2
[project_id] => 1
[project_status_id] => 2
[created] => 2011-05-11 17:27:23
)
)
[EquipType] => Array
(
[0] => Array
(
[id] => 2
[category_id] => 3
[name] => 1-3.5 Tonne Excavator
[description] => this is just a test excavator
[is_usable_for_cartage] => 0
[EquipTypesProject] => Array
(
[id] => 1
[equip_type_id] => 2
[project_id] => 1
)
)
[1] => Array
(
[id] => 4
[category_id] => 3
[name] => Float to Site
[description] =>
[is_usable_for_cartage] => 0
[EquipTypesProject] => Array
(
[id] => 2
[equip_type_id] => 4
[project_id] => 1
)
)
)
[MaterialType] => Array
(
[0] => Array
(
[id] => 6
[code] => IB
[name] => Clean Brick
[is_active] => 1
[MaterialTypesProject] => Array
(
[id] => 4
[material_type_id] => 6
[project_id] => 1
[is_importable] => 0
[is_exportable] => 0
)
)
[1] => Array
(
[id] => 28
[code] => C
[name] => General Clay
[is_active] => 1
[MaterialTypesProject] => Array
(
[id] => 5
[material_type_id] => 28
[project_id] => 1
[is_importable] => 0
[is_exportable] => 0
)
)
[2] => Array
(
[id] => 38
[code] => S
[name] => Sand
[is_active] => 1
[MaterialTypesProject] => Array
(
[id] => 6
[material_type_id] => 38
[project_id] => 1
[is_importable] => 0
[is_exportable] => 0
)
)
)
)
[QuoteStatus] => Array
(
[id] => 1
[name] => Tendering
[Quote] => Array
(
[0] => Array
(
[id] => 1
[quote_template_id] => 1
[project_id] => 1
[quote_status_id] => 1
[client_id] => 1
[date_added] => 2011-05-11
[is_archived] => 0
)
)
)
[Revision] => Array
(
[0] => Array
(
[Revision] => Array
(
[id] => 3
[quote_id] => 1
[name] => Q-1-3
[comment] => Revision 2.
[user_id] => 5
[revision_time] => 2011-05-11 17:32:55
[quote_status_id] => 1
)
)
)
[QuoteContact] => Array
(
[0] => Array
(
[id] => 1
[contact_id] => 18
[quote_id] => 1
[Contact] => Array
(
[SEQNO] => 18
[SALUTATION] => Mr
[FIRSTNAME] => Bob
[LASTNAME] => Test
[TITLE] => Sales
[MOBILE] =>
[DIRECTPHONE] => 612-9999 9999
[DIRECTFAX] => 612-9999 9999
[HOMEPHONE] =>
[EMAIL] => asdf@asdf.com.au
[NOTES] =>
[ADDRESS1] => PO BOX 1111
[ADDRESS2] => PENRITH
[ADDRESS3] => NSW AUSTRALIA
[ADDRESS4] =>
[DELADDR5] =>
[DELADDR6] =>
[POST_CODE] =>
[DELADDR1] => 1 CLARKE ST
[DELADDR2] => PENRITH
[DELADDR3] => SYDNEY
[DELADDR4] => AUSTRALIA
[ISACTIVE] => Y
[ADVERTSOURCE] => 0
[SALESNO] => 1
[FULLNAME] => Bob Chancellor
[COMPANY_ACCNO] =>
[COMPANY_ACCTYPE] =>
[MSN_ID] =>
[YAHOO_ID] =>
[SKYPE_ID] =>
[ADDRESS5] =>
[LAST_UPDATED] => 2010-05-19 16:39:42
[id] => 18
[name] => Bob Test
[email] => asdf@asdf.com.au
)
[Quote] => Array
(
[id] => 1
[quote_template_id] => 1
[project_id] => 1
[quote_status_id] => 1
[client_id] => 1
[date_added] => 2011-05-11
[is_archived] => 0
)
)
)
)