r43073 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43072‎ | r43073 | r43074 >
Date:12:39, 2 November 2008
Author:siebrand
Status:old
Tags:
Comment:
Resolve four notices when creating a page with "No layout". 4 remaining, marked with FIXME.
Modified paths:
  • /trunk/extensions/uniwiki/GenericEditPage/GenericEditPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/uniwiki/GenericEditPage/GenericEditPage.php
@@ -82,7 +82,9 @@
8383
8484 /* if no layout tag was found, this
8585 * function does nothing useful */
86 - if ( !$matches[1][0] ) return array();
 86+ if ( !isset( $matches[1][0] ) ) {
 87+ return array();
 88+ }
8789
8890 /* get the wiki markup (containing the
8991 * directives) from this page's layout */
@@ -437,6 +439,7 @@
438440
439441 /* special case: if the first (un-named) section has text in the layout,
440442 * but not in the page, copy it. otherwise, use the page text (even if empty) */
 443+ // FIXME: Undefined offset: 0 in scenario without layout
441444 $result[] = ( $layout[0]['text'] && !$page[0]['text'] ) ? $layout[0] : $page[0];
442445
443446 /* only show the un-named section if it is being used. as
@@ -482,8 +485,10 @@
483486 }
484487 }
485488
486 - if ( $insert_at === null ) $result[] = $page[$i];
487 - else array_splice ( $result, $insert_at, 0, array( $page[$i] ) );
 489+ if ( $insert_at === null )
 490+ $result[] = $page[$i];
 491+ else
 492+ array_splice ( $result, $insert_at, 0, array( $page[$i] ) );
488493 }
489494
490495 /* check to see if there were any sections in use
@@ -584,6 +589,7 @@
585590
586591
587592 // if this section has a title, show it
 593+ // FIXME: Undefined index: title in scenario without layout
588594 if ( $result[$i]['title'] ) {
589595 $title = $result[$i]['title'];
590596 if ( $result[$i]['lock-header'] ) {
@@ -601,6 +607,7 @@
602608 /* always add a textarea, whether or
603609 * not it is currently in use. titles
604610 * without text are kind of useless */
 611+ // FIXME: Undefined index: lock-text in scenario without layout
605612 if ( $result[$i]['lock-text'] ) {
606613
607614 /* render the wiki markup into HTML, the old-school
@@ -647,6 +654,7 @@
648655
649656
650657 // pass the layout name back, to be re-appended
 658+ // FIXME: Undefined offset: 0 in scenario without layout
651659 $out->addHTML ( "<input type='hidden' name='layout-name' value='{$layout[0]['name']}' />" );
652660
653661
@@ -695,12 +703,12 @@
696704 * pressing the "switch mode" button, then
697705 * set a global to do some jiggery-pokery
698706 * in the displayEditPage function, later */
699 - if ( $data['switch-mode'] )
 707+ if ( isset( $data['switch-mode'] ) )
700708 $wgSwitchMode = true;
701709
702710 /* if we are editing in classic mode,
703711 * then this function does nothing! */
704 - if ( $data['edit-mode'] != "generic" )
 712+ if ( isset( $data['edit-mode'] ) && $data['edit-mode'] != "generic" )
705713 return true;
706714
707715 /* otherwise, clear the textbox and rebuild it
@@ -759,7 +767,7 @@
760768 }
761769
762770 // finally, re-add the layout name
763 - if ( $data['layout-name'] ) {
 771+ if ( isset( $data['layout-name'] ) ) {
764772 $editpage_Obj->textbox1 .= "<layout name=\"{$data['layout-name']}\" />";
765773 }
766774

Status & tagging log