PHP4のDOMXML拡張モジュールをPHP5で動かしてみようとして無駄な時間を過ごした
最近「PHP5で動いている環境でDOMXML拡張モジュールを動かすようにしてみました」と人づてに聞いたので「え?そんなのできるの?」と半信半疑でトライしてみたのですが。。。本当にできた。
軽く確認した程度ですが、PHP4のDOMXMLやPHP5のSimpleXMLが確認できました。こりゃすげぇ。。。と思っていたら(やっぱり)落とし穴があったようで。。。費やした時間を返してくれ。_| ̄|○
まず、確認できたのは5.2系統だけでした。
5.3系統は色々と試してみた結果、データの構造がカナリ違っていることに気がついて、小手先のやり方では駄目なようです。残念。
確認できた5.2系統でも(恐らく、以下の部分が原因で)PHP5のDOM関数が正しく動いていない模様。
/usr/local/src/php-5.2.10RC2/ext/domxml/php_domxml.c:1588: INIT_OVERLOADED_CLASS_ENTRY(ce, "domdocument", php_domxmldoc_class_functions, NULL, NULL, NULL);
他にも重複してそうな名前は一杯ありそう。。。という事はあれか。「PHP4からの移植がメインで、とりあえず新機能は使わないからサクっとPHP5に移行したいんだよね。でもDOMXML拡張モジュールがネックなんだよねぇ。。。」という人向けの話?。。。虚しい。
ビルドも(案の定)すんなりとはいきませんでしたが、この辺を参考にしつつビルドも無事に成功。
気が向いたら深追いするかもしれませんが(やっぱり)うまい話には裏があるんだなぁ。。。と痛感しました。
% cd /usr/local/src % ls -l total 29508 drwxr-xr-x 14 masugata php 4096 Aug 6 2008 php-4.4.9 -rwxr-xr-x 1 masugata php 5638143 Jun 12 15:57 php-4.4.9.tar.gz drwxr-xr-x 14 masugata php 4096 Jun 11 21:15 php-5.2.10RC2 -rw-r--r-- 1 masugata php 11383360 Jun 12 15:57 php-5.2.10RC2.tar.gz % cd ./php-5.2.10RC2/ext % cp -r ../../php-4.4.9/ext/domxml . % ls -l ./domxml total 192 -rw-r--r-- 1 masugata php 40 Jun 12 18:20 CREDITS -rw-r--r-- 1 masugata php 1202 Jun 12 18:20 TODO -rw-r--r-- 1 masugata php 5396 Jun 12 18:20 config.m4 -rw-r--r-- 1 masugata php 5524 Jun 12 18:20 domxml.dsp -rw-r--r-- 1 masugata php 148027 Jun 12 18:20 php_domxml.c -rw-r--r-- 1 masugata php 8324 Jun 12 18:20 php_domxml.h drwxr-xr-x 2 masugata php 4096 Jun 12 18:20 tests % diff -u /usr/local/src/php-4.4.9/ext/domxml/php_domxml.c ./domxml/php_domxml.c --- /usr/local/src/php-4.4.9/ext/domxml/php_domxml.c 2007-12-31 16:22:46.000000000 +0900 +++ ./domxml/php_domxml.c 2009-06-12 18:25:48.000000000 +0900 @@ -206,16 +206,18 @@ static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC); static int node_children(zval **children, xmlNode *nodep TSRMLS_DC); +/******************************************************************************************* static unsigned char first_args_force_ref[] = { 1, BYREF_FORCE }; static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE }; static unsigned char third_args_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; +*******************************************************************************************/ static zend_function_entry domxml_functions[] = { PHP_FE(domxml_version, NULL) - PHP_FE(xmldoc, third_args_force_ref) - PHP_FALIAS(domxml_open_mem, xmldoc, third_args_force_ref) - PHP_FE(xmldocfile, third_args_force_ref) - PHP_FALIAS(domxml_open_file, xmldocfile, third_args_force_ref) + PHP_FE(xmldoc, third_arg_force_ref) + PHP_FALIAS(domxml_open_mem, xmldoc, third_arg_force_ref) + PHP_FE(xmldocfile, third_arg_force_ref) + PHP_FALIAS(domxml_open_file, xmldocfile, third_arg_force_ref) #if defined(LIBXML_HTML_ENABLED) PHP_FE(html_doc, NULL) PHP_FE(html_doc_file, NULL) @@ -297,7 +299,7 @@ PHP_FALIAS(set_content, domxml_node_set_content, NULL) PHP_FALIAS(new_xmldoc, domxml_new_xmldoc, NULL) PHP_FALIAS(domxml_dumpmem, domxml_dump_mem, NULL) - PHP_FE(domxml_doc_validate, second_args_force_ref) + PHP_FE(domxml_doc_validate, second_arg_force_ref) PHP_FE(domxml_doc_xinclude, NULL) {NULL, NULL, NULL} }; @@ -341,7 +343,7 @@ PHP_FALIAS(xpath_new_context, xpath_new_context, NULL) PHP_FALIAS(xptr_new_context, xptr_new_context, NULL) #endif - PHP_FALIAS(validate, domxml_doc_validate, first_args_force_ref) + PHP_FALIAS(validate, domxml_doc_validate, first_arg_force_ref) PHP_FALIAS(xinclude, domxml_doc_xinclude, NULL) {NULL, NULL, NULL} % cd ../ % rm ./configure % ./buildconf --force Forcing buildconf using default Zend directory buildconf: checking installation... buildconf: autoconf version 2.13 (ok) rebuilding configure rebuilding main/php_config.h.in % ./configure \ --enable-debug \ --with-libxml-dir=/usr \ --with-dom=/usr \ --with-zlib-dir=/usr \ --enable-mbstring \ --without-pear \ --without-iconv \ --disable-cgi\ --disable-hash \ --disable-pdo \ --without-pdo-sqlite \ --without-sqlite \ --disable-json \ --disable-filter \ --disable-session % gmake % sapi/cli/php -v PHP 5.2.10RC2 (cli) (built: Jun 12 2009 18:30:50) (DEBUG) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies % sapi/cli/php -i | grep dom Configure Command => './configure' '--enable-debug' '--with-libxml-dir=/usr' '--with-dom=/usr' '--with-zlib-dir=/usr' '--enable-mbstring' '--without-pear' '--without-iconv' '--disable-cgi' '--disable-hash' '--disable-pdo' '--without-pdo-sqlite' '--without-sqlite' '--disable-json' '--disable-filter' '--disable-session' dom domxml session.cookie_domain => no value => no value %