您在這裡

Ubercart更新錯誤

Yuer's 的頭像
Yuer 在 2009-02-09 (週一) 14:41 發表

我將Ubercart 2更新到目前最新版後,執行update.php 出現以下錯誤

An error occurred. http://*******/update.php?id=16&op=do
Fatal error: Call to undefined function db_next_id() in /home/***/public_html/*******/modules/ubercart/uc_catalog/uc_catalog.install on line 161

db_next_id() 是 5.x 以下的版本使用的函式
到 6.x 已經改為使用 db_last_insert_id() 函式了
請先確定是否安裝到 for 5.x 版本的模組

我用的是 ubercart-6.x-2.0-beta3 和 D6.9,為最新版無誤
但是在 ubercart/uc_catalog/uc_catalog.install中
第161,162,178,179中的function uc_catalog_update_6()、function uc_catalog_update_7()都有出現db_next_id
直接將之改成db_last_insert_id()不知會何樣...

function uc_catalog_update_6() {
$ret = array();

if (module_exists('imagecache')) {
$preset_id = db_next_id('{imagecache_preset}_presetid'); //這裡
$action_id = db_next_id('{imagecache_action}_actionid'); //還有這裡
db_query("INSERT INTO {imagecache_preset} (presetid, presetname) VALUES (%d, 'uc_catalog')", $preset_id);
db_query("INSERT INTO {imagecache_action} (actionid, presetid, weight, data) VALUES (%d, %d, 0, '%s')", $action_id, $preset_id, 'a:4:{s:8:"function";s:5:"scale";s:3:"fit";s:6:"inside";s:5:"width";s:2:"96";s:6:"height";s:2:"96";}');
cache_clear_all('imagecache:presets', 'cache');
$ret[] = array('success' => TRUE, 'query' => "INSERT INTO {imagecache_preset} (presetid, presetname) VALUES (". $preset_id .", 'uc_catalog')");
$ret[] = array('success' => TRUE, 'query' => "INSERT INTO {imagecache_action} (actionid, presetid, weight, data) VALUES (". $action_id .", ". $preset_id .", 0, '". 'a:4:{s:8:"function";s:5:"scale";s:3:"fit";s:6:"inside";s:5:"width";s:2:"96";s:6:"height";s:2:"96";}' ."')");
}

return $ret;
}

你可以先把這兩行註解

$preset_id = db_next_id('{imagecache_preset}_presetid'); //這裡
$action_id = db_next_id('{imagecache_action}_actionid'); //還有這裡

然後複製這兩行在下方貼上,把 db_next_id() 改成 db_last_insert_id() 試試

或是把 imagecache 模組停用
這樣應該就不會執行這一段程式碼

唉呀呀,連db_num_rows()也不行

The db_num_rows() method was removed from the database abstraction layer in 6.x core

這兒有,http://drupal.org/node/114774

還有uc_product.install也有一樣的情形,都修改後,更新成功
但還是有錯誤碼,如下

* warning: Missing argument 2 for db_last_insert_id(), called in /home/***/public_html/***/modules/ubercart/uc_product/uc_product.install on line 459 and defined in /home/***/public_html/***/includes/database.mysql-common.inc on line 531.
* warning: Missing argument 2 for db_last_insert_id(), called in /home/***/public_html/***/modules/ubercart/uc_product/uc_product.install on line 460 and defined in /home/***/public_html/***/includes/database.mysql-common.inc on line 531.
* user warning: Can't DROP 'uc_roles_products_model'; check that column/key exists query: ALTER TABLE uc_roles_products DROP INDEX uc_roles_products_model in /home/***/public_html/***/includes/database.mysql-common.inc on line 448.
* user warning: Duplicate key name 'model' query: ALTER TABLE uc_roles_products ADD INDEX model (model) in /home/***/public_html/***/includes/database.mysql-common.inc on line 434.