Changeset 477
- Timestamp:
- 10/26/08 14:31:28 (3 years ago)
- Location:
- wiki-toolkit/trunk
- Files:
-
- 1 added
- 4 modified
-
lib/Wiki/Toolkit/Store/Database.pm (modified) (5 diffs)
-
lib/Wiki/Toolkit/Store/MySQL.pm (modified) (1 diff)
-
lib/Wiki/Toolkit/Store/Pg.pm (modified) (1 diff)
-
lib/Wiki/Toolkit/Store/SQLite.pm (modified) (1 diff)
-
t/401_null_change.t (added)
Legend:
- Unmodified
- Added
- Removed
-
wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Database.pm
r466 r477 176 176 =item B<metadata> - a reference to a hash containing any caller-supplied 177 177 metadata sent along the last time the node was written 178 179 =back 178 180 179 181 The node parameter is mandatory. The version parameter is optional and … … 282 284 } 283 285 284 # Expects a hash as returned by ->retrieve_node 286 # Expects a hash as returned by ->retrieve_node - it's actually slightly lax 287 # in this, in that while ->retrieve_node always wraps up the metadata values in 288 # (refs to) arrays, this method will accept scalar metadata values too. 285 289 sub _checksum { 286 290 my ($self, %node_data) = @_; … … 288 292 my %metadata = %{ $node_data{metadata} || {} }; 289 293 foreach my $key ( sort keys %metadata ) { 290 $string .= "\0\0\0" . $key . "\0\0" 291 . join("\0", sort @{$metadata{$key}} ); 294 $string .= "\0\0\0" . $key . "\0\0"; 295 my $val = $metadata{$key}; 296 if ( ref $val eq "ARRAY" ) { 297 $string .= join("\0", sort @$val ); 298 } else { 299 $string .= $val; 300 } 292 301 } 293 302 return md5_hex($self->charset_encode($string)); … … 451 460 you (or your chosen subclass). This method shouldn't really be used 452 461 directly as it might overwrite someone else's changes. Croaks on error 453 but otherwise returns the version number of the update just made. 462 but otherwise returns the version number of the update just made. A 463 return value of -1 indicates that the change was not applied. This 464 may be because the plugins voted against the change, or because the 465 content and metadata in the proposed new version were identical to the 466 current version (a "null" change). 454 467 455 468 Supplying a ref to an array of nodes that this ones links to is … … 511 524 if($write_allowed < 1) { 512 525 # The plugins didn't want to allow this action 526 return -1; 527 } 528 529 if ( $self->_checksum( %args ) eq $args{checksum} ) { 530 # Refuse to commit as nothing has changed 513 531 return -1; 514 532 } -
wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/MySQL.pm
r466 r477 47 47 C<write_node_post_locking> with all supplied arguments, unlocks the 48 48 node. Returns the version of the updated node on successful writing, 0 if 49 checksum doesn't match, croaks on error.49 checksum doesn't match, -1 if the change was not applied, croaks on error. 50 50 51 51 Note: Uses MySQL's user level locking, so any locks are released when -
wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Pg.pm
r466 r477 47 47 C<write_node_post_locking> with all supplied arguments, unlocks the 48 48 node. Returns the version of the updated node on successful writing, 0 if 49 checksum doesn't match, croaks on error.49 checksum doesn't match, -1 if the change was not applied, croaks on error. 50 50 51 51 =cut -
wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/SQLite.pm
r466 r477 58 58 C<write_node_post_locking> with all supplied arguments, unlocks the 59 59 node. Returns the version of the updated node on successful writing, 0 if 60 checksum doesn't match, croaks on error.60 checksum doesn't match, -1 if the change was not applied, croaks on error. 61 61 62 62 =cut
