r7354 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7353‎ | r7354 | r7355 >
Date:11:33, 3 February 2005
Author:vibber
Status:old
Tags:
Comment:
* (bug 1458) Don't save if edit form submission is incomplete
Modified paths:
  • /branches/REL1_4/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_4/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: branches/REL1_4/phase3/includes/EditPage.php
@@ -81,37 +81,51 @@
8282 * @todo document
8383 */
8484 function importFormData( &$request ) {
85 - # These fields need to be checked for encoding.
86 - # Also remove trailing whitespace, but don't remove _initial_
87 - # whitespace from the text boxes. This may be significant formatting.
88 - $this->textbox1 = rtrim( $request->getText( 'wpTextbox1' ) );
89 - $this->textbox2 = rtrim( $request->getText( 'wpTextbox2' ) );
90 - $this->summary = trim( $request->getText( 'wpSummary' ) );
 85+ if( $request->wasPosted() ) {
 86+ # These fields need to be checked for encoding.
 87+ # Also remove trailing whitespace, but don't remove _initial_
 88+ # whitespace from the text boxes. This may be significant formatting.
 89+ $this->textbox1 = rtrim( $request->getText( 'wpTextbox1' ) );
 90+ $this->textbox2 = rtrim( $request->getText( 'wpTextbox2' ) );
 91+ $this->summary = trim( $request->getText( 'wpSummary' ) );
 92+
 93+ $this->edittime = $request->getVal( 'wpEdittime' );
 94+ if( is_null( $this->edittime ) ) {
 95+ # If the form is incomplete, force to preview.
 96+ $this->preview = true;
 97+ } else {
 98+ # Some browsers will not report any submit button
 99+ # if the user hits enter in the comment box.
 100+ # The unmarked state will be assumed to be a save,
 101+ # if the form seems otherwise complete.
 102+ $this->preview = $request->getCheck( 'wpPreview' );
 103+ }
 104+ $this->save = !$this->preview;
 105+ if( !preg_match( '/^\d{14}$/', $this->edittime )) {
 106+ $this->edittime = null;
 107+ }
 108+
 109+ $this->minoredit = $request->getCheck( 'wpMinoredit' );
 110+ $this->watchthis = $request->getCheck( 'wpWatchthis' );
 111+ } else {
 112+ # Not a posted form? Start with nothing.
 113+ $this->textbox1 = '';
 114+ $this->textbox2 = '';
 115+ $this->summary = '';
 116+ $this->edittime = '';
 117+ $this->preview = false;
 118+ $this->save = false;
 119+ $this->minoredit = false;
 120+ $this->watchthis = false;
 121+ }
91122
92 - $this->edittime = $request->getVal( 'wpEdittime' );
93 - if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = '';
94 -
95 - $this->preview = $request->getCheck( 'wpPreview' );
96 - $this->save = $request->wasPosted() && !$this->preview;
97 - $this->minoredit = $request->getCheck( 'wpMinoredit' );
98 - $this->watchthis = $request->getCheck( 'wpWatchthis' );
99 -
100123 $this->oldid = $request->getInt( 'oldid' );
101124
102125 # Section edit can come from either the form or a link
103126 $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
104127 }
105128
106 - /**
107 - * Since there is only one text field on the edit form,
108 - * pressing <enter> will cause the form to be submitted, but
109 - * the submit button value won't appear in the query, so we
110 - * Fake it here before going back to edit(). This is kind of
111 - * ugly, but it helps some old URLs to still work.
112 - */
113129 function submit() {
114 - if( !$this->preview ) $this->save = true;
115 -
116130 $this->edit();
117131 }
118132
Index: branches/REL1_4/phase3/RELEASE-NOTES
@@ -278,6 +278,7 @@
279279 * (bug 1228) Fix double-escaping on &amp; sequences in [enclosed] URLs
280280 * (bug 1435) Fixed many CSS errors
281281 * (bug 1457) Fix XHTML validation on category column list
 282+* (bug 1458) Don't save if edit form submission is incomplete
282283
283284 === Caveats ===
284285

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r7353* (bug 1458) Don't save if form submission seems incomplete...vibber11:26, 3 February 2005

Status & tagging log