r25424 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25423‎ | r25424 | r25425 >
Date:08:22, 3 September 2007
Author:ilabarg1
Status:old
Tags:
Comment:
[EditPage.php]-All prints cleaned.
Modified paths:
  • /branches/ApiEdit_Vodafone/includes/EditPage.php (modified) (history)

Diff [purge]

Index: branches/ApiEdit_Vodafone/includes/EditPage.php
@@ -664,7 +664,6 @@
665665
666666 if( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) )
667667 {
668 -print "AS-->(IN1) wfRunHooks(EditPage::attemptSave) = false <br>";
669668 wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" );
670669 return self::AS_EXIST_HOOK_ERROR_A;
671670 // return false;
@@ -673,16 +672,10 @@
674673 # Reintegrate metadata
675674 if ( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ;
676675 $this->mMetaData = '' ;
677 -print "attemptSave --> mTitle: ".$this->mTitle."<br>";
678 -print "attemptSave --> texbox1: ".$this->tilabarg01extbox1."<br>";
679 -print "attemptSave --> mMetaData: ".$this->mMetaData."<br>";
680 -print "attemptSave --> section: ".$this->section."<br>";
681 -print "attemptSave --> summary:".$this->summary."<br>";
682676
683677 # Check for spam
684678 $matches = array();
685679 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
686 -print "AS-->(IN2) Checking for spam..<br>";
687680 // $this->spamPage ( $matches[0] );
688681 wfProfileOut( "$fname-checks" );
689682 wfProfileOut( $fname );
@@ -690,7 +683,6 @@
691684 // return false;
692685 }
693686 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
694 -print "AS-->(IN3) Filtering contents..<br>";
695687 # Error messages or other handling should be performed by the filter function
696688 wfProfileOut( $fname );
697689 wfProfileOut( "$fname-checks" );
@@ -699,13 +691,11 @@
700692 }
701693 if ( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError ) ) ) {
702694 # Error messages etc. could be handled within the hook...
703 -print "AS-->(IN4) wfRinHooks = false (EditFilter', array) <br>";
704695 wfProfileOut( $fname );
705696 wfProfileOut( "$fname-checks" );
706697 return AS_EXIST_HOOK_ERROR_B;
707698 // return false;
708699 } elseif( $this->hookError != '' ) {
709 -print "AS-->(IN-IN4.1) this->hookError != ''<br>";
710700 # ...or the hook could be expecting us to produce an error
711701 wfProfileOut( "$fname-checks " );
712702 wfProfileOut( $fname );
@@ -713,7 +703,6 @@
714704 // return true;
715705 }
716706 if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
717 -print "AS-->(IN5) wgUser->isBlockedFrom( this->mTitle, false )<br>";
718707 # Check block state against master, thus 'false'.
719708 // $this->blockedPage();
720709 wfProfileOut( "$fname-checks" );
@@ -722,9 +711,7 @@
723712 // return false;
724713 }
725714 $this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
726 -print "AS-->this->kblength;".$this->kblength."<br>";
727715 if ( $this->kblength > $wgMaxArticleSize ) {
728 -print "AS-->(IN6) this->kblength > wgMaxArticleSize<br>";
729716 // Error will be displayed by showEditForm()
730717 // $this->tooBig = true;
731718 wfProfileOut( "$fname-checks" );
@@ -734,9 +721,7 @@
735722 }
736723
737724 if ( !$wgUser->isAllowed('edit') ) {
738 -print "AS-->(IN7) !wgUser->isAllowed('edit')<br>";
739725 if ( $wgUser->isAnon() ) {
740 -print "AS-->(IN-IN7.1)wgUser->isAnon()<br>";
741726 // $this->userNotLoggedInPage();
742727 wfProfileOut( "$fname-checks" );
743728 wfProfileOut( $fname );
@@ -744,7 +729,6 @@
745730 // return false;
746731 }
747732 else {
748 -print "AS-->(IN-IN7.2)!wgUser->isAnon()<br>";
749733 // $wgOut->readOnlyPage();
750734 wfProfileOut( "$fname-checks" );
751735 wfProfileOut( $fname );
@@ -754,7 +738,6 @@
755739 }
756740
757741 if ( wfReadOnly() ) {
758 -print "AS-->(IN8) wfReadOnly()<br>";
759742 // $wgOut->readOnlyPage();
760743 wfProfileOut( "$fname-checks" );
761744 wfProfileOut( $fname );
@@ -762,7 +745,6 @@
763746 // return false;
764747 }
765748 if ( $wgUser->pingLimiter() ) {
766 -print "AS-->(IN9) wgUser->pingLimiter()<br>";
767749 // $wgOut->rateLimited();
768750 wfProfileOut( "$fname-checks" );
769751 wfProfileOut( $fname );
@@ -773,7 +755,6 @@
774756 # If the article has been deleted while editing, don't save it without
775757 # confirmation
776758 if ( $this->deletedSinceEdit && !$this->recreate ) {
777 -print "AS-->(IN10) this->deletedSinceEdit && !this->recreate <br>";
778759 wfProfileOut( "$fname-checks" );
779760 wfProfileOut( $fname );
780761 return self::AS_ARTICLE_WAS_DELETED;
@@ -784,13 +765,9 @@
785766
786767 # If article is new, insert it.
787768 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
788 -print "attemptSave --> aid: ".$aid."<br>";
789 -print "attemptSave --> minoredit: ".$this->minoredit."<br>";
790769 if ( 0 == $aid ) {
791 -print "AS-->(IN11) aid = 0, NEW ARTICLE<br>";
792770 // Late check for create permission, just in case *PARANOIA*
793771 if ( !$this->mTitle->userCan( 'create' ) ) {
794 -print "AS-->(IN-IN11.1) aid = 0, !this->mTitle->userCan('create')<br>";
795772 wfDebug( "$fname: no create permission\n" );
796773 wfProfileOut( $fname );
797774 return self::AS_NO_CREATE_PERMISSION;
@@ -800,49 +777,32 @@
801778
802779 # Don't save a new article if it's blank.
803780 if ( ( '' == $this->textbox1 ) ) {
804 -print "AS-->(IN-IN11.2) aid = 0, '' == this->textbox1<br>";
805781 wfProfileOut( $fname );
806782 return self::AS_BLANK_ARTICLE;
807783 // return false;
808784 }
809785
810786 $isComment=($this->section=='new');
811 -print "AS-->(IN11) aid = 0,isComment:".$isComment."<br>";
812 -print "AS-->(IN11) aid = 0,this->textbox1:".$this->textbox1."<br>";
813 -print "AS-->(IN11) aid = 0,this->summary".$this->summary."<br>";
814 -print "AS-->(IN11) aid = 0,this->minoredit:".$this->minoredit."<br>";
815 -print "AS-->(IN11) aid = 0,this->watchthis:".$this->watchthis."<br>";
816787 $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
817788 $this->minoredit, $this->watchthis, false, $isComment);
818789 wfProfileOut( $fname );
819790 return self::AS_SUCCESS_NEW_ARTICLE;
820791 // return false;
821792 }
822 -print "AS-->ARTICLE EXIST (aid=".$aid.")<br>";
823793 # Article exists. Check for edit conflict.
824794 $this->mArticle->clear(); # Force reload of dates, etc.
825795 $this->mArticle->forUpdate( true ); # Lock the article
826 -print "AS-->this->mArticle->getTimestamp():".$this->mArticle->getTimestamp()."<br>";
827 -print "AS-->this->edittime:".$this->edittime."<br>";
828796 wfDebug("timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n");
829797 if( $this->mArticle->getTimestamp() != $this->edittime ) {
830 -print "AS-->(IN12) this->mArticle->getTimestamp() != this->edittime<br>";
831798 $this->isConflict = true;
832 -print "AS-->(IN12)mArticle->getUserText(): ".$this->mArticle->getUserText()."<br>";
833 -print "AS-->(IN12)wgUser->getName(): ".$wgUser->getName()."<br>";
834 -print "AS-->(IN12)this->mArticle->getComment(): ".$this->mArticle->getComment()."<br>";
835 -print "AS-->(IN12)this->summary: ".$this->summary."<br>";
836799 if( $this->section == 'new' ) {
837 -print "AS-->(IN-IN12.1) this->section == 'new'<br>";
838800 if( $this->mArticle->getUserText() == $wgUser->getName() &&
839801 $this->mArticle->getComment() == $this->summary ) {
840 -print "AS-->(IN-IN-IN12.1.1) Texto propietario, getcomment = summary<br>";
841802 // Probably a duplicate submission of a new comment.
842803 // This can happen when squid resends a request after
843804 // a timeout but the first one actually went through.
844805 wfDebug( "EditPage::editForm duplicate new section submission; trigger edit conflict!\n" );
845806 } else {
846 -print "AS-->(IN-IN-IN12.1.2) New comment; suppress conflict<br>";
847807 // New comment; suppress conflict.
848808 $this->isConflict = false;
849809 wfDebug( "EditPage::editForm conflict suppressed; new section\n" );
@@ -850,73 +810,54 @@
851811 }
852812 }
853813 $userid = $wgUser->getID();
854 -print "AS-->userid: ".$userid."<br>";
855 -print "AS --> conflict_B: ".$this->isConflict."<br>";
856814 if ( $this->isConflict) {
857 -print "AS-->(IN13) entra x 2=>EXIST CONFLICT<br>";
858815 wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
859816 $this->mArticle->getTimestamp() . "')\n" );
860817 $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime);
861818 }
862819 else {
863 -print "AS-->(IN14) no entra x 2=>NOT EXIST CONFLICT<br>";
864820 wfDebug( "EditPage::editForm getting section '$this->section'\n" );
865821 $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
866822 }
867 -print "AS-->text: ".$text."<br>";
868823
869824 if( is_null( $text ) ) {
870825 wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" );
871 -print "AS-->(IN15) text es null (conflicto)<br>";
872826 $this->isConflict = true;
873827 $text = $this->textbox1;
874 -print "AS-->(IN15)text: ".$text."<br>";
875828 }
876829
877830 # Suppress edit conflict with self, except for section edits where merging is required.
878831 if ( ( $this->section == '' ) && ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
879 -print "AS-->(IN16) Se elimina el conflicto al no ser anonimo,section ser 0 y ser creador del articulo.<br>";
880832 wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" );
881833 $this->isConflict = false;
882834 } else {
883 -print "AS-->(IN17) Anon o Section != 0 or not owner<br>";
884835 # switch from section editing to normal editing in edit conflict
885836 if($this->isConflict) {
886 -print "AS-->(IN-IN17.1) EXIST CONFLICT!<br>";
887837 # Attempt merge
888838 if( $this->mergeChangesInto( $text ) ){
889 -print "AS-->(IN-IN-IN17.1.1)this->mergeChangesInto(text)=>merge successfully so conflict cleaned<br>";
890839 // Successful merge! Maybe we should tell the user the good news?
891840 $this->isConflict = false;
892841 wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" );
893842 } else {
894843 $this->section = '';
895844 $this->textbox1 = $text;
896 -print "AS-->(IN-IN-IN17.1.2)Merge failed so conflict here yet<br>";
897845 wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" );
898846 }
899847 }
900848 }
901 -print "AS--> Exit from IFS<br>";
902849
903850 if ( $this->isConflict ) {
904 -print "AS -->(IN18) this->isConflict: ".$this->isConflict." => EXIT!<br>";
905851 wfProfileOut( $fname );
906852 return self::AS_CONFLICT_DETECTED;
907853 // return true;
908854 }
909 -print "<br>AS-->------------------------------------<br><br>";
910 -print "AS--> NO MORE CONFLICTS <br>";
911855
912856 $oldtext = $this->mArticle->getContent();
913 -print "AS --> oldtext: ".$oldtext."<br>";
914857
915858 # Handle the user preference to force summaries here, but not for null edits
916859 if( $this->section != 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary')
917860 && 0 != strcmp($oldtext, $text) && !Article::getRedirectAutosummary( $text )) {
918 -print "<br>AS-->(IN19)Summary mandatory according preferences<br>";
919861 if( md5( $this->summary ) == $this->autoSumm ) {
920 -print "<br>AS-->(IN-IN19.1)Testing autosummary MD5 token<br> =>EXIT!";
921862 $this->missingSummary = true;
922863 wfProfileOut( $fname );
923864 return self::AS_SUMMARY_NEEDED_A;
@@ -926,34 +867,26 @@
927868
928869 #And a similar thing for new sections
929870 if( $this->section == 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary' ) ) {
930 -print "<br>AS-->(IN20)Summary mandatory in new sections<br>";
931871 if (trim($this->summary) == '') {
932 -print "<br>AS-->(IN-IN20.1)summary=''<br> =>EXIT!";
933872 $this->missingSummary = true;
934873 wfProfileOut( $fname );
935874 return self::AS_SUMMARY_NEEDED_B;
936875 // return( true );
937876 }
938877 }
939 -print "<br>AS-->------------------------------------<br><br>";
940 -print "AS-->**** SINCE HERE ALL RIGTH ****<br>";
941878 # All's well
942879 wfProfileIn( "$fname-sectionanchor" );
943880 $sectionanchor = '';
944881 if( $this->section == 'new' ) {
945 -print "AS-->(IN21)Section= new<br>";
946882 if ( $this->textbox1 == '' ) {
947 -print "AS-->(IN-IN21.1)Section= new & this->textbox1 == ''=>EXIT!<br>";
948883 $this->missingComment = true;
949884 return self::AS_TEXTBOX_EMPTY;
950885 // return true;
951886 }
952887 if( $this->summary != '' ) {
953 -print "AS-->(IN-IN21.2)Section= new & this->summary != ''<br>";
954888 $sectionanchor = $this->sectionAnchor( $this->summary );
955889 }
956890 } elseif( $this->section != '' ) {
957 -print "AS-->(IN22)Section != '' or NEW<br>";
958891 # Try to get a section anchor from the section source, redirect to edited section if header found
959892 # XXX: might be better to integrate this into Article::replaceSection
960893 # for duplicate heading checking and maybe parsing
@@ -972,13 +905,9 @@
973906 // replace that into a duplicated mess.
974907 $this->textbox1 = $text;
975908 $this->section = '';
976 -print "AS-->this->textbox1:".$this->textbox1."<br>";
977 -print "AS-->this->section:".$this->section."<br>";
978909 // Check for length errors again now that the section is merged in
979910 $this->kblength = (int)(strlen( $text ) / 1024);
980 -print "AS --> kblength: ".$this->kblength."<br>";
981911 if ( $this->kblength > $wgMaxArticleSize ) {
982 -print "AS -->(IN23) kblength > wgMaxArticleSize=>EXIT!<br>";
983912 $this->tooBig = true;
984913 wfProfileOut( $fname );
985914 return self::AS_MAX_ARTICLE_SIZE_EXCEDED;
@@ -986,20 +915,14 @@
987916 }
988917
989918 # update the article here
990 -print "<br>AS-->------------------------------------<br><br>";
991 -print "AS-->**** LETS UPDATE ARTICLE ****<br>";
992919 if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
993920 $this->watchthis, '', $sectionanchor ) ) {
994 -print "AS-->(IN24) Articulo actualizado=>Success<br>";
995921 wfProfileOut( $fname );
996922 return self::AS_SUCCESS_UPDATE;
997923 // return false;
998924 } else {
999 -print "AS-->(IN25) UPDATE FAILED! => Conflict<br>";
1000925 $this->isConflict = true;
1001926 }
1002 -print "AS-->End of attempSave and exit with true (fail)<br>";
1003 -print "<br>AS-->------------------------------------<br><br>";
1004927 wfProfileOut( $fname );
1005928 return self::AS_END;
1006929 // return true;
@@ -1667,8 +1590,6 @@
16681591 * @todo document
16691592 */
16701593 function mergeChangesInto( &$editText ){
1671 - print "!!!!!!!!!!!!!!!!!!!!this->revid:".$this->revid."<br>";
1672 - print "mergeChanges->edittext:".$editText."<br>";
16731594 $fname = 'EditPage::mergeChangesInto';
16741595 wfProfileIn( $fname );
16751596
@@ -1679,7 +1600,6 @@
16801601 $db, $this->mArticle->mTitle, $this->edittime );
16811602 //$baseRevision=true;
16821603 if( is_null( $baseRevision ) ) {
1683 -print "mergeChanges-->baseRevision es NULL<br>";
16841604 wfProfileOut( $fname );
16851605 //break;
16861606 return false;
@@ -1690,7 +1610,6 @@
16911611 $currentRevision = Revision::loadFromTitle(
16921612 $db, $this->mArticle->mTitle );
16931613 if( is_null( $currentRevision ) ) {
1694 - print "mergeChanges-->currentRevision es NULL<br>";
16951614 wfProfileOut( $fname );
16961615 return false;
16971616 }

Status & tagging log