Ticket #203: feature-203-ip-address-mod-whitelist-01.diff

File feature-203-ip-address-mod-whitelist-01.diff, 5.0 kB (added by oliver, 23 months ago)

Patch for Wiki::Toolkit to allow version of latest node entry to bubble up to OpenGuides

  • lib/Wiki/Toolkit/Store/Database.pm

    diff -urN wiki-toolkit.orig/lib/Wiki/Toolkit/Store/Database.pm wiki-toolkit/lib/Wiki/Toolkit/Store/Database.pm
    old new  
    450450Making sure that locking/unlocking/transactions happen is left up to 
    451451you (or your chosen subclass). This method shouldn't really be used 
    452452directly as it might overwrite someone else's changes. Croaks on error 
    453 but otherwise returns true. 
     453but otherwise returns the version number of the update just made. 
    454454 
    455455Supplying a ref to an array of nodes that this ones links to is 
    456456optional, but if you do supply it then this node will be returned when 
     
    657657        } 
    658658    } 
    659659 
    660     return 1; 
     660    return $version; 
    661661} 
    662662 
    663663# Returns the timestamp of now, unless epoch is supplied. 
  • lib/Wiki/Toolkit/Store/MySQL.pm

    diff -urN wiki-toolkit.orig/lib/Wiki/Toolkit/Store/MySQL.pm wiki-toolkit/lib/Wiki/Toolkit/Store/MySQL.pm
    old new  
    4545 
    4646Locks the node, verifies the checksum, calls 
    4747C<write_node_post_locking> with all supplied arguments, unlocks the 
    48 node. Returns 1 on successful writing, 0 if checksum doesn't match, 
    49 croaks on error. 
     48node. Returns the version of the updated node  on successful writing, 0 if 
     49checksum doesn't match, croaks on error. 
    5050 
    5151Note:  Uses MySQL's user level locking, so any locks are released when 
    5252the database handle disconnects.  Doing it like this because I can't seem 
  • lib/Wiki/Toolkit/Store/Pg.pm

    diff -urN wiki-toolkit.orig/lib/Wiki/Toolkit/Store/Pg.pm wiki-toolkit/lib/Wiki/Toolkit/Store/Pg.pm
    old new  
    4545 
    4646Locks the node, verifies the checksum, calls 
    4747C<write_node_post_locking> with all supplied arguments, unlocks the 
    48 node. Returns 1 on successful writing, 0 if checksum doesn't match, 
    49 croaks on error. 
     48node. Returns the version of the updated node  on successful writing, 0 if 
     49checksum doesn't match, croaks on error. 
    5050 
    5151=cut 
    5252 
  • lib/Wiki/Toolkit/Store/SQLite.pm

    diff -urN wiki-toolkit.orig/lib/Wiki/Toolkit/Store/SQLite.pm wiki-toolkit/lib/Wiki/Toolkit/Store/SQLite.pm
    old new  
    5656 
    5757Locks the node, verifies the checksum, calls 
    5858C<write_node_post_locking> with all supplied arguments, unlocks the 
    59 node. Returns 1 on successful writing, 0 if checksum doesn't match, 
    60 croaks on error. 
     59node. Returns the version of the updated node  on successful writing, 0 if 
     60checksum doesn't match, croaks on error. 
    6161 
    6262=cut 
    6363 
  • lib/Wiki/Toolkit.pm

    diff -urN wiki-toolkit.orig/lib/Wiki/Toolkit.pm wiki-toolkit/lib/Wiki/Toolkit.pm
    old new  
    792792is ignored except on new nodes. For existing nodes, use  
    793793$wiki->toggle_node_moderation to change the node moderation flag. 
    794794 
    795 Returns 1 on success, 0 on conflict, croaks on error. 
     795Returns the version of the updated node  on success, 0 on conflict, croaks on 
     796error. 
    796797 
    797798B<Note> on the metadata hashref: Any data in here that you wish to 
    798799access directly later must be a key-value pair in which the value is 
     
    852853    if ($search and $content) { 
    853854        $search->index_node($node, $store->charset_encode($content) ); 
    854855    } 
    855     return 1; 
     856    return $ret; 
    856857} 
    857858 
    858859=item B<format> 
  • t/021_moderation.t

    diff -urN wiki-toolkit.orig/t/021_moderation.t wiki-toolkit/t/021_moderation.t
    old new  
    66if ( scalar @Wiki::Toolkit::TestLib::wiki_info == 0 ) { 
    77    plan skip_all => "no backends configured"; 
    88} else { 
    9     plan tests => ( 86 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 
     9    plan tests => ( 89 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 
    1010} 
    1111 
    1212my $iterator = Wiki::Toolkit::TestLib->new_wiki_maker; 
     
    6161 
    6262 
    6363       # Update it 
    64     ok( $wiki->write_node("Moderation", "yy", $mn_data{checksum}), 
    65                "Can update where moderation is enabled" ); 
     64    my $nmn_ver = $wiki->write_node("Moderation", "yy", $mn_data{checksum}); 
     65       ok( $nmn_ver, "Can update where moderation is enabled" ); 
    6666    my %nmn_data = $wiki->retrieve_node("Moderation"); 
    6767    my %nmnv_data = $wiki->retrieve_node(name=>"Moderation", version=>2); 
     68    is( $nmn_data{version}, '1', "Latest moderated version" ); 
     69    is( $nmnv_data{version}, '2', "Latest unmoderated version" ); 
     70    is( $nmn_ver, '2', "Latest (unmoderated) version returned by write_node" ); 
    6871 
    6972       # Check content was updated right 
    7073       is( $nmnv_data{content}, "yy", "Version 2 text");