Closed (fixed)
Project:
Copyright
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 May 2007 at 16:41 UTC
Updated:
14 Jun 2007 at 17:49 UTC
I don't know how, but I ended up with a few rows having cpyid=0 in the copyright_node table.
Having such entries the check
if ($license->cpyid) {
in line 559 doesn't work and the insert statement 2 lines below fails.
I suggest changing the check to if ($license) or if (isset(license->cpyid))
Deleting all rows with cpyid=0 from the copyright_node table got me working again, but I'm still a bit worried about all this.
Comments
Comment #1
ray007 commentedI think I tracked down the source of the problem:
I have a user with the permission to edit somebody else' nodes, but without permission "administer copyright". In this case, the form_alter hook doesn't add the copyright fields to the node-edit form.
In the nodeapi hook with $op = 'insert' or 'update' you check whether copyright are enabled for this contenttype, but not whether there's actually a valid entry in $node->cpyid (line 447).
A simple if (!empty($node->cpyid)) check around the copyright_node_save() call should solve all problems.
Comments?
Comment #2
Robrecht Jacques commentedThis sounds correct - good catch!
I've added an
if (isset($node->cpyid)) {.Fixed in 5.x-1.x-dev, will be added to next release of the copyright module.
Comment #3
ray007 commentedI'm not a big fan of isset() checks in such situations, since they tend to not work when the property exists with a value of 0 or ''.
We'll see how it works out ...
Comment #4
Robrecht Jacques commentedisset()checks whether the value is set, whether this is a0or empty string or not, doesn't matter. If$nodehas a property calledcpyidit will do the right thing.empty()on the other hand will returnTRUEif$node->cpyid == 0.So I believe
isset()is the right thing to test here. On the other hand, sincecpyidcan't be0,!empty()would work too, but then you have to doif (isset($node->cpyid) && !empty($node->cpyid))to avoid PHP5 warnings/errors.Comment #5
ray007 commentedisset() is the right thing to use if you're absolutely sure there will never ever be a property with the empty value.
I've already sent in several patches for other modules where the maintainers thought the same, but then there did come in a value of 0 or '' from somewhere ...
Comment #6
(not verified) commented