crud.inc logic for inserting to boxes
rcourtna - October 19, 2007 - 22:23
| Project: | Install Profile API and Profile Wizard |
| Version: | 5.x-1.1 |
| Component: | Profile Wizard |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (code needs review) |
Description
/**
* Creates a new block.
*/
function install_add_block($module, $delta, $theme, $status, $weight, $region, $visibility, $pages, $custom, $throttle, $title) {
db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle, title) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, '%s')", $module, $delta, $theme, $status, $weight, $region, $visibility, $pages, $custom, $throttle, $title);
if ($module == 'block') {
$box = db_fetch_object(db_query('SELECT * FROM {boxes} WHERE bid=%d', $delta));
db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')", $box->bid, $box->body, $box->info, $box->format);
}
}note:
$box = db_fetch_object(db_query('SELECT * FROM {boxes} WHERE bid=%d', $delta));
db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')", $box->bid, $box->body, $box->info, $box->format);Won't $box always contain null values? How can we do a select from boxes before we actually insert into it? :-)
AFAICT, the Wizard only exports the blocks data, and not the actual box content.

#1
Here is a patch that fixes this functionality. It also fixes an argument order issue between crud.inc and the export code for install_add_block().