[wp-trac] [WordPress Trac] #10819: Suggestion: Addition to dbDelta - returns FALSE on mySQL error
WordPress Trac
wp-trac at lists.automattic.com
Sun Sep 20 22:07:47 UTC 2009
#10819: Suggestion: Addition to dbDelta - returns FALSE on mySQL error
-----------------------------+----------------------------------------------
Reporter: tinwatchman | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Unassigned
Component: Upgrade/Install | Version: 2.8.4
Severity: normal | Keywords: has-patch, needs-testing, 2nd-opinion, dev-feedback
-----------------------------+----------------------------------------------
I don't have any idea how to submit or recommend a change to the WordPress
core, but I'm going to give this a shot anyway... having just spent a lot
of time struggling with the dbDelta function while programming a plugin, I
had a possible suggestion to make. It strikes me that said function would
be a lot easier to use if something similar to the following code was
added, starting on line 1363 of wp-admin/includes/upgrade.php:
if($execute) {
$query_error_num = 0;
foreach($allqueries as $query) {
//echo "<pre style=\"border:1px solid #ccc;margin-
top:5px;\">".print_r($query, true)."</pre>\n";
$qresult = $wpdb->query($query);
if ($qresult === false) {
$query_error_num++;
$qerror = 'error' . $query_error_num;
$for_update[$qerror] = "Query error - The
following query failed: " . $query;
}
}
}
return $for_update;
There's probably a more optimized way to go about it - programming isn't
my strong suit by any stretch of the means - but at least this way errors
caused when *creating* tables with the function will return some kind of
error message, even if it's PHP only.
Opinions?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10819>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list