We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29850
    • 9 Posts
    昨日MODx0.9.6を新規インストールし、本を読みながら設定をしてみたのですが、WebLoginのスニペットにおいて下記のエラー
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - Incorrect integer value: ’aaa’ for column ’id’ at row 1 »
    SQL: REPLACE INTO `modx`.`modx_active_users` (internalKey, username, lasthit, action, id, ip) values(-1, ’username’, ’1183809300’, ’998’, ’NULL’, ’127.0.0.1’)

    が発生しました。これはDBに設定しようとしているNULLがクオートされ’NULL’となっているためのエラーです。

    トレースしてみると、assets\snippets\weblogin.processor.inc.phpの380行で$itemid値が’NULL’の際に生成しているSQLに問題があることがわかりました。

    // web users are stored with negative id
    $sql = "REPLACE INTO $dbase.`".$table_prefix."active_users` (internalKey, username, lasthit, action, id, ip) values(-".$_SESSION[’webInternalKey’].", ’".$_SESSION[’webShortname’]."’, ’".$lasthittime."’, ’".$a."’, ’".$itemid."’, ’$ip’)";


    下記の通り修正してみたところ動作しています。

    if ($itemid == "NULL") {
    $sql = "REPLACE INTO $dbase.`".$table_prefix."active_users` (internalKey, username, lasthit, action, id, ip) values(-".$_SESSION[’webInternalKey’].", ’".$_SESSION[’webShortname’]."’, ’".$lasthittime."’, ’".$a."’, NULL, ’$ip’)";
    } else {
    $sql = "REPLACE INTO $dbase.`".$table_prefix."active_users` (internalKey, username, lasthit, action, id, ip) values(-".$_SESSION[’webInternalKey’].", ’".$_SESSION[’webShortname’]."’, ’".$lasthittime."’, ’".$a."’, ’".$itemid."’, ’$ip’)";
    }


    同様の問題がassets\snippets\weblogin.inc.phpの110行にもありましたので、同じ様に修正しました。

    最新のバージョンで起こる問題ですがリリース直後でもありません、既に同様の報告がありそうで検索してみたのですが、これというものを見つけることができませんでした。最新のインストーラーに同梱のスニペットでもあり、新らしくはじめられる方が同様の問題にハマることが減ればと思い投稿させていただきました。

    動作確認は、
    apache 2.2.4
    PHP Version 5.2.3
    MySQL 5.0.22
    で行っています。

    またなにかありましたら、宜しくお願いします。