Index: branches/ApiEdit_Vodafone/includes/EditPage.php |
— | — | @@ -664,7 +664,6 @@ |
665 | 665 | |
666 | 666 | if( !wfRunHooks( 'EditPage::attemptSave', array( &$this ) ) ) |
667 | 667 | { |
668 | | -print "AS-->(IN1) wfRunHooks(EditPage::attemptSave) = false <br>"; |
669 | 668 | wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" ); |
670 | 669 | return self::AS_EXIST_HOOK_ERROR_A; |
671 | 670 | // return false; |
— | — | @@ -673,16 +672,10 @@ |
674 | 673 | # Reintegrate metadata |
675 | 674 | if ( $this->mMetaData != '' ) $this->textbox1 .= "\n" . $this->mMetaData ; |
676 | 675 | $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>"; |
682 | 676 | |
683 | 677 | # Check for spam |
684 | 678 | $matches = array(); |
685 | 679 | if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) { |
686 | | -print "AS-->(IN2) Checking for spam..<br>"; |
687 | 680 | // $this->spamPage ( $matches[0] ); |
688 | 681 | wfProfileOut( "$fname-checks" ); |
689 | 682 | wfProfileOut( $fname ); |
— | — | @@ -690,7 +683,6 @@ |
691 | 684 | // return false; |
692 | 685 | } |
693 | 686 | if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) { |
694 | | -print "AS-->(IN3) Filtering contents..<br>"; |
695 | 687 | # Error messages or other handling should be performed by the filter function |
696 | 688 | wfProfileOut( $fname ); |
697 | 689 | wfProfileOut( "$fname-checks" ); |
— | — | @@ -699,13 +691,11 @@ |
700 | 692 | } |
701 | 693 | if ( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError ) ) ) { |
702 | 694 | # Error messages etc. could be handled within the hook... |
703 | | -print "AS-->(IN4) wfRinHooks = false (EditFilter', array) <br>"; |
704 | 695 | wfProfileOut( $fname ); |
705 | 696 | wfProfileOut( "$fname-checks" ); |
706 | 697 | return AS_EXIST_HOOK_ERROR_B; |
707 | 698 | // return false; |
708 | 699 | } elseif( $this->hookError != '' ) { |
709 | | -print "AS-->(IN-IN4.1) this->hookError != ''<br>"; |
710 | 700 | # ...or the hook could be expecting us to produce an error |
711 | 701 | wfProfileOut( "$fname-checks " ); |
712 | 702 | wfProfileOut( $fname ); |
— | — | @@ -713,7 +703,6 @@ |
714 | 704 | // return true; |
715 | 705 | } |
716 | 706 | if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { |
717 | | -print "AS-->(IN5) wgUser->isBlockedFrom( this->mTitle, false )<br>"; |
718 | 707 | # Check block state against master, thus 'false'. |
719 | 708 | // $this->blockedPage(); |
720 | 709 | wfProfileOut( "$fname-checks" ); |
— | — | @@ -722,9 +711,7 @@ |
723 | 712 | // return false; |
724 | 713 | } |
725 | 714 | $this->kblength = (int)(strlen( $this->textbox1 ) / 1024); |
726 | | -print "AS-->this->kblength;".$this->kblength."<br>"; |
727 | 715 | if ( $this->kblength > $wgMaxArticleSize ) { |
728 | | -print "AS-->(IN6) this->kblength > wgMaxArticleSize<br>"; |
729 | 716 | // Error will be displayed by showEditForm() |
730 | 717 | // $this->tooBig = true; |
731 | 718 | wfProfileOut( "$fname-checks" ); |
— | — | @@ -734,9 +721,7 @@ |
735 | 722 | } |
736 | 723 | |
737 | 724 | if ( !$wgUser->isAllowed('edit') ) { |
738 | | -print "AS-->(IN7) !wgUser->isAllowed('edit')<br>"; |
739 | 725 | if ( $wgUser->isAnon() ) { |
740 | | -print "AS-->(IN-IN7.1)wgUser->isAnon()<br>"; |
741 | 726 | // $this->userNotLoggedInPage(); |
742 | 727 | wfProfileOut( "$fname-checks" ); |
743 | 728 | wfProfileOut( $fname ); |
— | — | @@ -744,7 +729,6 @@ |
745 | 730 | // return false; |
746 | 731 | } |
747 | 732 | else { |
748 | | -print "AS-->(IN-IN7.2)!wgUser->isAnon()<br>"; |
749 | 733 | // $wgOut->readOnlyPage(); |
750 | 734 | wfProfileOut( "$fname-checks" ); |
751 | 735 | wfProfileOut( $fname ); |
— | — | @@ -754,7 +738,6 @@ |
755 | 739 | } |
756 | 740 | |
757 | 741 | if ( wfReadOnly() ) { |
758 | | -print "AS-->(IN8) wfReadOnly()<br>"; |
759 | 742 | // $wgOut->readOnlyPage(); |
760 | 743 | wfProfileOut( "$fname-checks" ); |
761 | 744 | wfProfileOut( $fname ); |
— | — | @@ -762,7 +745,6 @@ |
763 | 746 | // return false; |
764 | 747 | } |
765 | 748 | if ( $wgUser->pingLimiter() ) { |
766 | | -print "AS-->(IN9) wgUser->pingLimiter()<br>"; |
767 | 749 | // $wgOut->rateLimited(); |
768 | 750 | wfProfileOut( "$fname-checks" ); |
769 | 751 | wfProfileOut( $fname ); |
— | — | @@ -773,7 +755,6 @@ |
774 | 756 | # If the article has been deleted while editing, don't save it without |
775 | 757 | # confirmation |
776 | 758 | if ( $this->deletedSinceEdit && !$this->recreate ) { |
777 | | -print "AS-->(IN10) this->deletedSinceEdit && !this->recreate <br>"; |
778 | 759 | wfProfileOut( "$fname-checks" ); |
779 | 760 | wfProfileOut( $fname ); |
780 | 761 | return self::AS_ARTICLE_WAS_DELETED; |
— | — | @@ -784,13 +765,9 @@ |
785 | 766 | |
786 | 767 | # If article is new, insert it. |
787 | 768 | $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
788 | | -print "attemptSave --> aid: ".$aid."<br>"; |
789 | | -print "attemptSave --> minoredit: ".$this->minoredit."<br>"; |
790 | 769 | if ( 0 == $aid ) { |
791 | | -print "AS-->(IN11) aid = 0, NEW ARTICLE<br>"; |
792 | 770 | // Late check for create permission, just in case *PARANOIA* |
793 | 771 | if ( !$this->mTitle->userCan( 'create' ) ) { |
794 | | -print "AS-->(IN-IN11.1) aid = 0, !this->mTitle->userCan('create')<br>"; |
795 | 772 | wfDebug( "$fname: no create permission\n" ); |
796 | 773 | wfProfileOut( $fname ); |
797 | 774 | return self::AS_NO_CREATE_PERMISSION; |
— | — | @@ -800,49 +777,32 @@ |
801 | 778 | |
802 | 779 | # Don't save a new article if it's blank. |
803 | 780 | if ( ( '' == $this->textbox1 ) ) { |
804 | | -print "AS-->(IN-IN11.2) aid = 0, '' == this->textbox1<br>"; |
805 | 781 | wfProfileOut( $fname ); |
806 | 782 | return self::AS_BLANK_ARTICLE; |
807 | 783 | // return false; |
808 | 784 | } |
809 | 785 | |
810 | 786 | $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>"; |
816 | 787 | $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, |
817 | 788 | $this->minoredit, $this->watchthis, false, $isComment); |
818 | 789 | wfProfileOut( $fname ); |
819 | 790 | return self::AS_SUCCESS_NEW_ARTICLE; |
820 | 791 | // return false; |
821 | 792 | } |
822 | | -print "AS-->ARTICLE EXIST (aid=".$aid.")<br>"; |
823 | 793 | # Article exists. Check for edit conflict. |
824 | 794 | $this->mArticle->clear(); # Force reload of dates, etc. |
825 | 795 | $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>"; |
828 | 796 | wfDebug("timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n"); |
829 | 797 | if( $this->mArticle->getTimestamp() != $this->edittime ) { |
830 | | -print "AS-->(IN12) this->mArticle->getTimestamp() != this->edittime<br>"; |
831 | 798 | $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>"; |
836 | 799 | if( $this->section == 'new' ) { |
837 | | -print "AS-->(IN-IN12.1) this->section == 'new'<br>"; |
838 | 800 | if( $this->mArticle->getUserText() == $wgUser->getName() && |
839 | 801 | $this->mArticle->getComment() == $this->summary ) { |
840 | | -print "AS-->(IN-IN-IN12.1.1) Texto propietario, getcomment = summary<br>"; |
841 | 802 | // Probably a duplicate submission of a new comment. |
842 | 803 | // This can happen when squid resends a request after |
843 | 804 | // a timeout but the first one actually went through. |
844 | 805 | wfDebug( "EditPage::editForm duplicate new section submission; trigger edit conflict!\n" ); |
845 | 806 | } else { |
846 | | -print "AS-->(IN-IN-IN12.1.2) New comment; suppress conflict<br>"; |
847 | 807 | // New comment; suppress conflict. |
848 | 808 | $this->isConflict = false; |
849 | 809 | wfDebug( "EditPage::editForm conflict suppressed; new section\n" ); |
— | — | @@ -850,73 +810,54 @@ |
851 | 811 | } |
852 | 812 | } |
853 | 813 | $userid = $wgUser->getID(); |
854 | | -print "AS-->userid: ".$userid."<br>"; |
855 | | -print "AS --> conflict_B: ".$this->isConflict."<br>"; |
856 | 814 | if ( $this->isConflict) { |
857 | | -print "AS-->(IN13) entra x 2=>EXIST CONFLICT<br>"; |
858 | 815 | wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" . |
859 | 816 | $this->mArticle->getTimestamp() . "')\n" ); |
860 | 817 | $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime); |
861 | 818 | } |
862 | 819 | else { |
863 | | -print "AS-->(IN14) no entra x 2=>NOT EXIST CONFLICT<br>"; |
864 | 820 | wfDebug( "EditPage::editForm getting section '$this->section'\n" ); |
865 | 821 | $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary); |
866 | 822 | } |
867 | | -print "AS-->text: ".$text."<br>"; |
868 | 823 | |
869 | 824 | if( is_null( $text ) ) { |
870 | 825 | wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" ); |
871 | | -print "AS-->(IN15) text es null (conflicto)<br>"; |
872 | 826 | $this->isConflict = true; |
873 | 827 | $text = $this->textbox1; |
874 | | -print "AS-->(IN15)text: ".$text."<br>"; |
875 | 828 | } |
876 | 829 | |
877 | 830 | # Suppress edit conflict with self, except for section edits where merging is required. |
878 | 831 | 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>"; |
880 | 832 | wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" ); |
881 | 833 | $this->isConflict = false; |
882 | 834 | } else { |
883 | | -print "AS-->(IN17) Anon o Section != 0 or not owner<br>"; |
884 | 835 | # switch from section editing to normal editing in edit conflict |
885 | 836 | if($this->isConflict) { |
886 | | -print "AS-->(IN-IN17.1) EXIST CONFLICT!<br>"; |
887 | 837 | # Attempt merge |
888 | 838 | if( $this->mergeChangesInto( $text ) ){ |
889 | | -print "AS-->(IN-IN-IN17.1.1)this->mergeChangesInto(text)=>merge successfully so conflict cleaned<br>"; |
890 | 839 | // Successful merge! Maybe we should tell the user the good news? |
891 | 840 | $this->isConflict = false; |
892 | 841 | wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" ); |
893 | 842 | } else { |
894 | 843 | $this->section = ''; |
895 | 844 | $this->textbox1 = $text; |
896 | | -print "AS-->(IN-IN-IN17.1.2)Merge failed so conflict here yet<br>"; |
897 | 845 | wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" ); |
898 | 846 | } |
899 | 847 | } |
900 | 848 | } |
901 | | -print "AS--> Exit from IFS<br>"; |
902 | 849 | |
903 | 850 | if ( $this->isConflict ) { |
904 | | -print "AS -->(IN18) this->isConflict: ".$this->isConflict." => EXIT!<br>"; |
905 | 851 | wfProfileOut( $fname ); |
906 | 852 | return self::AS_CONFLICT_DETECTED; |
907 | 853 | // return true; |
908 | 854 | } |
909 | | -print "<br>AS-->------------------------------------<br><br>"; |
910 | | -print "AS--> NO MORE CONFLICTS <br>"; |
911 | 855 | |
912 | 856 | $oldtext = $this->mArticle->getContent(); |
913 | | -print "AS --> oldtext: ".$oldtext."<br>"; |
914 | 857 | |
915 | 858 | # Handle the user preference to force summaries here, but not for null edits |
916 | 859 | if( $this->section != 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary') |
917 | 860 | && 0 != strcmp($oldtext, $text) && !Article::getRedirectAutosummary( $text )) { |
918 | | -print "<br>AS-->(IN19)Summary mandatory according preferences<br>"; |
919 | 861 | if( md5( $this->summary ) == $this->autoSumm ) { |
920 | | -print "<br>AS-->(IN-IN19.1)Testing autosummary MD5 token<br> =>EXIT!"; |
921 | 862 | $this->missingSummary = true; |
922 | 863 | wfProfileOut( $fname ); |
923 | 864 | return self::AS_SUMMARY_NEEDED_A; |
— | — | @@ -926,34 +867,26 @@ |
927 | 868 | |
928 | 869 | #And a similar thing for new sections |
929 | 870 | if( $this->section == 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary' ) ) { |
930 | | -print "<br>AS-->(IN20)Summary mandatory in new sections<br>"; |
931 | 871 | if (trim($this->summary) == '') { |
932 | | -print "<br>AS-->(IN-IN20.1)summary=''<br> =>EXIT!"; |
933 | 872 | $this->missingSummary = true; |
934 | 873 | wfProfileOut( $fname ); |
935 | 874 | return self::AS_SUMMARY_NEEDED_B; |
936 | 875 | // return( true ); |
937 | 876 | } |
938 | 877 | } |
939 | | -print "<br>AS-->------------------------------------<br><br>"; |
940 | | -print "AS-->**** SINCE HERE ALL RIGTH ****<br>"; |
941 | 878 | # All's well |
942 | 879 | wfProfileIn( "$fname-sectionanchor" ); |
943 | 880 | $sectionanchor = ''; |
944 | 881 | if( $this->section == 'new' ) { |
945 | | -print "AS-->(IN21)Section= new<br>"; |
946 | 882 | if ( $this->textbox1 == '' ) { |
947 | | -print "AS-->(IN-IN21.1)Section= new & this->textbox1 == ''=>EXIT!<br>"; |
948 | 883 | $this->missingComment = true; |
949 | 884 | return self::AS_TEXTBOX_EMPTY; |
950 | 885 | // return true; |
951 | 886 | } |
952 | 887 | if( $this->summary != '' ) { |
953 | | -print "AS-->(IN-IN21.2)Section= new & this->summary != ''<br>"; |
954 | 888 | $sectionanchor = $this->sectionAnchor( $this->summary ); |
955 | 889 | } |
956 | 890 | } elseif( $this->section != '' ) { |
957 | | -print "AS-->(IN22)Section != '' or NEW<br>"; |
958 | 891 | # Try to get a section anchor from the section source, redirect to edited section if header found |
959 | 892 | # XXX: might be better to integrate this into Article::replaceSection |
960 | 893 | # for duplicate heading checking and maybe parsing |
— | — | @@ -972,13 +905,9 @@ |
973 | 906 | // replace that into a duplicated mess. |
974 | 907 | $this->textbox1 = $text; |
975 | 908 | $this->section = ''; |
976 | | -print "AS-->this->textbox1:".$this->textbox1."<br>"; |
977 | | -print "AS-->this->section:".$this->section."<br>"; |
978 | 909 | // Check for length errors again now that the section is merged in |
979 | 910 | $this->kblength = (int)(strlen( $text ) / 1024); |
980 | | -print "AS --> kblength: ".$this->kblength."<br>"; |
981 | 911 | if ( $this->kblength > $wgMaxArticleSize ) { |
982 | | -print "AS -->(IN23) kblength > wgMaxArticleSize=>EXIT!<br>"; |
983 | 912 | $this->tooBig = true; |
984 | 913 | wfProfileOut( $fname ); |
985 | 914 | return self::AS_MAX_ARTICLE_SIZE_EXCEDED; |
— | — | @@ -986,20 +915,14 @@ |
987 | 916 | } |
988 | 917 | |
989 | 918 | # update the article here |
990 | | -print "<br>AS-->------------------------------------<br><br>"; |
991 | | -print "AS-->**** LETS UPDATE ARTICLE ****<br>"; |
992 | 919 | if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, |
993 | 920 | $this->watchthis, '', $sectionanchor ) ) { |
994 | | -print "AS-->(IN24) Articulo actualizado=>Success<br>"; |
995 | 921 | wfProfileOut( $fname ); |
996 | 922 | return self::AS_SUCCESS_UPDATE; |
997 | 923 | // return false; |
998 | 924 | } else { |
999 | | -print "AS-->(IN25) UPDATE FAILED! => Conflict<br>"; |
1000 | 925 | $this->isConflict = true; |
1001 | 926 | } |
1002 | | -print "AS-->End of attempSave and exit with true (fail)<br>"; |
1003 | | -print "<br>AS-->------------------------------------<br><br>"; |
1004 | 927 | wfProfileOut( $fname ); |
1005 | 928 | return self::AS_END; |
1006 | 929 | // return true; |
— | — | @@ -1667,8 +1590,6 @@ |
1668 | 1591 | * @todo document |
1669 | 1592 | */ |
1670 | 1593 | function mergeChangesInto( &$editText ){ |
1671 | | - print "!!!!!!!!!!!!!!!!!!!!this->revid:".$this->revid."<br>"; |
1672 | | - print "mergeChanges->edittext:".$editText."<br>"; |
1673 | 1594 | $fname = 'EditPage::mergeChangesInto'; |
1674 | 1595 | wfProfileIn( $fname ); |
1675 | 1596 | |
— | — | @@ -1679,7 +1600,6 @@ |
1680 | 1601 | $db, $this->mArticle->mTitle, $this->edittime ); |
1681 | 1602 | //$baseRevision=true; |
1682 | 1603 | if( is_null( $baseRevision ) ) { |
1683 | | -print "mergeChanges-->baseRevision es NULL<br>"; |
1684 | 1604 | wfProfileOut( $fname ); |
1685 | 1605 | //break; |
1686 | 1606 | return false; |
— | — | @@ -1690,7 +1610,6 @@ |
1691 | 1611 | $currentRevision = Revision::loadFromTitle( |
1692 | 1612 | $db, $this->mArticle->mTitle ); |
1693 | 1613 | if( is_null( $currentRevision ) ) { |
1694 | | - print "mergeChanges-->currentRevision es NULL<br>"; |
1695 | 1614 | wfProfileOut( $fname ); |
1696 | 1615 | return false; |
1697 | 1616 | } |