おおよそ
Nucleusは標準で4種類のXML-RPCインターフェイスをサポートしていて、それらは以下のとおり。
- "blogger."で始まるBlogger API
- "metaWeblog."で始まるmetaWeblog API
- "mt."で始まるMovable Type API
- "nucleus."で始まるNucleus API (deprecatedでマニュアルにも書いてない)
で、(すでに非推奨であるNucleus APIは放っておくとして)アイテム追加機能を提供するBlogger APIとmetaWeblog APIについて、アイテムのコメントを許可するか否か(closedでないのか、あるいはclosedなのか)決定する条件が微妙に食い違ってる気が。
Blogger APIはコメントを許可する/許可しないという設定項目を持たない。Nucleusではこれを使ってアイテムを投稿した場合にはコメントは許可されることになる(実際にはブログの設定に依存)。
metaWeblog APIではMovable Typeで実装された拡張"mt_allow_comments"を使ってこの設定ができる。Nucleusではこの値を省略したとき(というか拡張を使用しなかったとき)にアイテムがclosedになってしまう。
APIの仕様的に間違ってるわけではなさそう(未確認)だし、バグというわけでもないんですが、要望の形でFlySprayにでも投げておこうかと思う次第。
変更案
手元の3.3 日本語EUC版のパッチ(未検証)。"mt_allow_comments"が未指定の場合に、closedが指定されなかったとしてアイテムを作成するようにしたつもりのもの。
56c56,61
< $comments = (int) _getStructVal($struct, 'mt_allow_comments') ? 0 : 1;
---
> $comments = $struct->structmem('mt_allow_comments');
> if ($comments) {
> $closed = (int) _getStructVal($struct, 'mt_allow_comments') ? 0 : 1;
> } else {
> $closed = 0;
> }
61c66
< $res = _addItem($blogid, $username, $password, $title, $content, $more, $publish, $comments, $category);
---
> $res = _addItem($blogid, $username, $password, $title, $content, $more, $publish, $closed, $category);
追記
mt_allow_comments = 2 ?
#5366 (XMLRPC interface misinterprets mt_allow_comments value) - WordPress Trac - Trac。
Boolean型じゃなかったのか。
この場合の変更案
上記の参照先に依れば、mt_allow_commentsの値とコメントの表示・投稿の可否についてはこんな感じらしい(?)。
| mt_allow_commentsの値 | 過去のコメントの閲覧 | 新規コメントの追加 |
|---|---|---|
| 0 | 不可 | 不可 |
| 1 | 可 | 可 |
| 2 | 可 | 不可 |
Nucleusでは0と2の状態の差がアイテムに設定できないので、0と2を同様にclosed設定を行う指定だと解釈すべきだと思う。
以下のやつは"mt_allow_commentsが指定されていて、なおかつその値が1以外ならclosed"なパターン、のつもり。上の例に加えてeditPostの変更を加えている。
56c56,61
< $comments = (int) _getStructVal($struct, 'mt_allow_comments') ? 0 : 1;
---
> $comments = $struct->structmem('mt_allow_comments');
> if ($comments) {
> $closed = (intval(_getStructVal($struct, 'mt_allow_comments')) == 1) ? 0 : 1;
> } else {
> $closed = 0;
> }
61c66
< $res = _addItem($blogid, $username, $password, $title, $content, $more, $publish, $comments, $category);
---
> $res = _addItem($blogid, $username, $password, $title, $content, $more, $publish, $closed, $category);
190c195
< $comments = (int) _getStructVal($struct, 'mt_allow_comments') ? 0 : 1;
---
> $closed = (intval(_getStructVal($struct, 'mt_allow_comments')) == 1) ? 0 : 1;
192c197
< $comments = $old['closed'];
---
> $closed = $old['closed'];
195c200
< $res = _edititem($itemid, $username, $password, $catid, $title, $content, $more, $wasdraft, $publish, $comments);
---
> $res = _edititem($itemid, $username, $password, $catid, $title, $content, $more, $wasdraft, $publish, $closed);
海外フォーラム参照
Nucleus Support :: View topic - Posting via XML-RPC disables comments。
簡単な直し方。closedにしない人に。