File: 0013-wuth02-Modify_pages_that_were_previously_deleted_and_recreated.patch

package info (click to toggle)
libwww-mediawiki-client-perl 0.31-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,132 kB
  • sloc: perl: 1,672; makefile: 14
file content (56 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Author: Brett Wuth <wuth@castrov.cuug.ab.ca>
Last-Update: 2013-07-09
Bug-Debian: https://bugs.debian.org/715419
Description: Enable editing pages that were deleted and recreated
 Mediawiki allows a page to be deleted and subsequently recreated.  In
 order to make changes to such pages, the server provides and requires
 the client to keep track of the "start date" of the page.  mvs does
 not do this, so cannot edit these pages.
 
 The attached patch resolves this problem.

--- a/lib/WWW/Mediawiki/Client.pm
+++ b/lib/WWW/Mediawiki/Client.pm
@@ -258,6 +258,7 @@ use constant EDIT_SUBMIT_NAME   => 'wpSa
 use constant EDIT_SUBMIT_VALUE  => 'Save Page';
 use constant EDIT_PREVIEW_NAME  => 'wpPreview';
 use constant EDIT_PREVIEW_VALUE => 'Show preview';
+use constant EDIT_START_NAME    => 'wpStarttime';
 use constant EDIT_TIME_NAME     => 'wpEdittime';
 use constant EDIT_TOKEN_NAME    => 'wpEditToken';
 use constant EDIT_WATCH_NAME    => 'wpWatchthis';
@@ -1242,6 +1243,7 @@ sub get_server_page {
         ) unless $res->is_success;
     my $doc = $res->decoded_content;
     my $text = $self->_get_wiki_text($doc);
+    $self->{edit}->{start} = $self->_get_start_date($doc);
     $self->{edit}->{date} = $self->_get_edit_date($doc);
     $self->{edit}->{token} = $self->_get_edit_token($doc);
     $self->{edit}->{watch_now} = $self->_get_edit_is_watching($doc);
@@ -1528,6 +1530,18 @@ sub _get_page_headline {
     return $text;
 }
 
+sub _get_start_date {
+    my ($self, $doc) = @_;
+    my $p = HTML::TokeParser->new(\$doc);
+    my $date;
+    while (my $tag = $p->get_tag('input')) {
+        next unless exists $tag->[1]->{type} and $tag->[1]->{type} eq 'hidden';
+        next unless $tag->[1]->{name} eq EDIT_START_NAME;
+        $date = $tag->[1]->{value};
+    }
+    return $date;
+}
+
 sub _get_edit_date {
     my ($self, $doc) = @_;
     my $p = HTML::TokeParser->new(\$doc);
@@ -1746,6 +1760,7 @@ sub _upload_file {
             $act_name           => $act_value,
             &TEXTAREA_NAME      => $text,
             &COMMENT_NAME       => $self->{commit_message},
+            &EDIT_START_NAME    => $self->{edit}->{start},
             &EDIT_TIME_NAME     => $self->{edit}->{date},
             &EDIT_TOKEN_NAME    => $self->{edit}->{token},
 	    @params,