Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The prices per role table stores the vid number, but it removes the previous revisions' prices. This is a particular issue for a site which implements workflow control where changes must be approved/published as updating the prices would involve the creation of a new revision - but then the published version of prices would default to the products default price.
I've identified the problem as being in uc_price_per_role_nodeapi:
...
case 'insert':
case 'update':
db_query("DELETE FROM {uc_price_per_role_prices} WHERE nid = %d", $node->nid);
...
Comment | File | Size | Author |
---|---|---|---|
#8 | 1080772-8-fix-revision-prices.patch | 976 bytes | fenstrat |
#5 | revision-fix-for-saving-prices-1080772-5.patch | 921 bytes | horuskol |
#2 | revision-fix-for-saving-prices-1080772-2.patch | 21.08 KB | horuskol |
Comments
Comment #1
horuskol CreditAttribution: horuskol commentedI have a patch ready to commit in git, but I don't know what version to apply - should it be 6.x-1.1 or master?
Comment #2
horuskol CreditAttribution: horuskol commentedPatch file built against master (6.x-1.1)
Comment #3
horuskol CreditAttribution: horuskol commentedForgot to set to "needs review"
Comment #4
fenstratYour patch includes uc_price_per_role.module twice, once diff'd against itself and once against /dev/null - you need to remove the second one.
As for the change it does seem logical. The {uc_price_per_role_prices} table is storing prices per revision but as you've noted hook_nodeapi() is deleting all revisions when a node is updated.
Comment #5
horuskol CreditAttribution: horuskol commentedI just had a look, and it seems the patch has also caught the backup file that Kate automatically generates (you can tell by the ~ at the end). I guess because this file doesn't exist, it's diff'd against /dev/null - sorry. I've learnt to read the patch file to make sure this happens again.
I have rebuilt and re-uploaded the patch (after checking).
In hindsight - I think the problem was the use of 'git add -a' from the instructions... looks like git doesn't ignore "hidden" files on that switch.
Comment #6
fenstratGood to go. Does what it says on the box. Revision prices don't get nuked on node update.
Also, I'd say that this is totally superfluous as it's not run on node update any more. There should never be any prices in {uc_price_per_role_prices} on node insert as this is a new node.
Comment #7
fenstratWhoo, I just realised that the patch in #5 doesn't do what is intended in all cases.
It does achieve the goal of not nuking any previous revision prices. However if you resave a node with revisioning disabled then you'll get 2 entries in the {uc_price_per_role_prices} with the same nid and vid. Problem. So what needs to be done is a query to see if there is any entry with the nid and vid if so update, otherwise insert.
Comment #8
fenstratThis is a far more straight forward approach. It only removes the current vid about to be saved.
Comment #9
horuskol CreditAttribution: horuskol commentednice catch - hadn't thought about non-revisioned systems.
Comment #10
fenstratRTBC as per #9
Comment #11
longwaveCommitted #8 to 6.x and 7.x, thanks for the patch.