Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Renaming an internal client name tries to insert a new quota, and causes the following error:
user warning: Duplicate entry '338-sites' for key 'PRIMARY' query: INSERT INTO hosting_client_quota (client, resource, value) VALUES (338, 'sites', '0') in /var/aegir/hostmaster-6.x-1.2/profiles/hostmaster/modules/hosting/quota/hosting_quota.module on line 154.
Comments
Comment #1
ergonlogicCommitted fix to my dev repo: http://drupalcode.org/sandbox/ergonlogic/1226310.git/commit/9688a7015129...
Also, this error was thrown whenever a client node was updated, but the quota not changed. So, I've changed the title of this issue to reflect that.
Comment #2
Steven Jones CreditAttribution: Steven Jones commentedHmm...I think that maybe we should just try to fix the
hosting_quota_set_limit
function so that we can call it safely at all times?We're trying to do a merge query, and in D6 the best attempt at one is to do a SELECT and then decide on a INSERT or UPDATE.
Comment #3
ergonlogicOK, I'll take a look at making
hosting_quota_set_limit()
safe.I still think the absense of a
hosting_quota_get_limit()
function is an oversight. I guess it would be a change to the API, though...Comment #4
ergonlogicPlease take a look at http://drupalcode.org/sandbox/ergonlogic/1226310.git/commit/ddf76d426cba... for a safe implementation of
hosting_quota_set_limit()
Comment #5
Steven Jones CreditAttribution: Steven Jones commentedI'm happy with adding a
hosting_quota_get_limit
function, api additions are slightly different from api changes.Detailed review:
The documentation of
hosting_quota_set_limit
needs some work, most lines need a full-stop at the end, and we don't indicate the type of parameters, so you can drop 'int', and 'string' etc.There's an extra space between the function name and the arguments.
Can you rewrite the
hosting_quota_set_limit
to use the merge query 'degenerate' pattern, this is described here for D7: http://drupal.org/node/310085. Essentially, if we just do a SELECT count to see if we need to do an UPDATE or an INSERT then we can just do it. I wouldn't expect it to callhosting_quota_get_limit
btw.Once all that's done, we should be good to go!
Comment #6
ergonlogicOK, this should implement the "degenerate" pattern: http://drupalcode.org/sandbox/ergonlogic/1226310.git/commit/6718a154eb18...
Let me know if that'll work.
Sorry for the delay in posting this.
Comment #7
Steven Jones CreditAttribution: Steven Jones commentedThanks for the fix!
It was almost there, just missing a db_result, but I added that in for you in:
http://drupalcode.org/project/hostmaster.git/commit/e719fab273b9c9f7608a...
Tested and pushed to both branches. Many thanks!