Index: trunk/extensions/BotQuery/query.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | * 0) Function to call |
113 | 113 | * 1) true/false - does this property work on individual pages? (false for site's metadata) |
114 | 114 | * 2) array of accepted parameters |
115 | | - * 3) array of default parameter values. If the default value is an array itself, only the listed values are allowed, and the 1st value is taken as default. |
| 115 | + * 3) array of default parameter values |
116 | 116 | * 4) Format description |
117 | 117 | */ |
118 | 118 | var $propGenerators = array( |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | "blfilter - Of all given pages, which should be queried:", |
211 | 211 | " 'nonredirects', 'existing' (blue links, default), or 'all' (red links)", |
212 | 212 | "bllimit - how many total links to return", |
213 | | - "blcontfrom - from which point to continue. Use the 'next' value from the previous queries.", |
| 213 | + "blcontfrom - from which point to continue. Use the 'next' value from previous queries.", |
214 | 214 | "Example: query.php?what=backlinks&titles=Main%20Page&bllimit=10", |
215 | 215 | )), |
216 | 216 | 'embeddedin' => array( 'genPageBackLinksHelper', false, |
— | — | @@ -221,40 +221,35 @@ |
222 | 222 | "eifilter - Of all given pages, which should be queried:", |
223 | 223 | " 'nonredirects', 'existing' (blue links, default), or 'all' (red links)", |
224 | 224 | "eilimit - how many total links to return", |
225 | | - "eicontfrom - from which point to continue. Use the 'next' value from the previous queries.", |
| 225 | + "eicontfrom - from which point to continue. Use the 'next' value from previous queries.", |
226 | 226 | "Example: query.php?what=embeddedin&titles=Template:Stub&eilimit=10", |
227 | 227 | )), |
228 | 228 | 'imagelinks' => array( 'genPageBackLinksHelper', false, |
229 | 229 | array( 'ilfilter', 'illimit', 'ilcontfrom' ), |
230 | | - array( array('all', 'existing', 'nonredirects'), 50, null ), |
| 230 | + array( array('existing', 'nonredirects', 'all'), 50, null ), |
231 | 231 | array( |
232 | 232 | "What pages use this image(s)", |
233 | 233 | "ilfilter - Of all given images, which should be queried:", |
234 | | - " 'nonredirects', 'existing', or 'all' (default, includes non-existant or those stored on Wikimedia Commons)", |
| 234 | + " 'nonredirects', 'existing' (default), or 'all' (including non-existant)", |
235 | 235 | "illimit - how many total links to return", |
236 | | - "ilcontfrom - from which point to continue. Use the 'next' value from the previous queries.", |
237 | | - "Example: query.php?what=imagelinks&titles=Image:HermitageAcrossNeva.jpg&illimit=10", |
| 236 | + "ilcontfrom - from which point to continue. Use the 'next' value from previous queries.", |
| 237 | + "Example: query.php?what=imagelinks&titles=image:test.jpg&illimit=10", |
238 | 238 | )), |
239 | 239 | 'revisions' => array( 'genPageHistory', false, |
240 | | - array( 'rvcomments', 'rvcontent', 'rvlimit', 'rvoffset', 'rvstart', 'rvend' ), |
241 | | - array( false, false, 50, 0, null, null ), |
| 240 | + array( 'rvcomments', 'rvlimit', 'rvoffset', 'rvstart', 'rvend' ), |
| 241 | + array( false, 50, 0, null, null ), |
242 | 242 | array( |
243 | 243 | "Revision history - Lists edits performed to the given pages", |
244 | 244 | "Parameters supported:", |
245 | 245 | "rvcomments - if specified, the result will include summary strings", |
246 | | - "rvcontent - if specified, the result will include raw wiki text.", |
247 | | - " This parameter is *very slow*, use only when needed.", |
248 | 246 | "rvlimit - how many links to return *for each title*", |
249 | 247 | "rvoffset - when too many results are found, use this to page", |
250 | 248 | "rvstart - timestamp of the earliest entry", |
251 | 249 | "rvend - timestamp of the latest entry", |
252 | 250 | "Example: query.php?what=revisions&titles=Main%20Page&rvlimit=10&rvcomments", |
253 | 251 | )), |
254 | | - 'content' => array( 'genPageContent', false, null, null, |
255 | | - array( |
256 | | - "Raw page content - Retrieves raw wiki markup for each page.", |
257 | | - "This query is *very slow*! Please optimize content requests to reduce load on the servers.", |
258 | | - "Duplicate results may be obtained through revisions+rvcontent request", |
| 252 | + 'content' => array( 'genPageContent', false, null, null, array( |
| 253 | + "Raw page content", |
259 | 254 | "Example: query.php?what=content&titles=Main%20Page", |
260 | 255 | )), |
261 | 256 | ); |
— | — | @@ -325,7 +320,9 @@ |
326 | 321 | function output($isError = false) { |
327 | 322 | global $wgRequest, $wgUser; |
328 | 323 | |
329 | | - $this->recordProfiling( 'total', 'time', $this->totalStartTime ); |
| 324 | + // hack: pretend that profiling was started at the begining of the class execution. |
| 325 | + $this->startTime = $this->totalStartTime; |
| 326 | + $this->endProfiling( 'total' ); |
330 | 327 | |
331 | 328 | $printer = $this->outputGenerators[$this->format][GEN_FUNCTION]; |
332 | 329 | $mime = $this->outputGenerators[$this->format][GEN_MIME]; |
— | — | @@ -407,7 +404,7 @@ |
408 | 405 | */ |
409 | 406 | function genPageInfo() { |
410 | 407 | global $wgUser, $wgRequest; |
411 | | - $this->startProfiling(); |
| 408 | + |
412 | 409 | $where = array(); |
413 | 410 | |
414 | 411 | // |
— | — | @@ -417,8 +414,8 @@ |
418 | 415 | if( $titles !== null ) { |
419 | 416 | $titles = explode( '|', $titles ); |
420 | 417 | $linkBatch = new LinkBatch; |
421 | | - foreach ( $titles as &$titleString ) { |
422 | | - $titleObj = &Title::newFromText( $titleString ); |
| 418 | + foreach ( $titles as $titleString ) { |
| 419 | + $titleObj = Title::newFromText( $titleString ); |
423 | 420 | if ( !$titleObj ) { |
424 | 421 | $this->dieUsage( "bad title $titleString", 'pi_invalidtitle' ); |
425 | 422 | } |
— | — | @@ -445,6 +442,7 @@ |
446 | 443 | } else { |
447 | 444 | $nonexistentPages = array(); // empty data to keep unset() happy |
448 | 445 | } |
| 446 | + |
449 | 447 | // |
450 | 448 | // List of Page IDs |
451 | 449 | // |
— | — | @@ -460,10 +458,9 @@ |
461 | 459 | $where['page_id'] = $pageids; |
462 | 460 | $this->requestsize += count($pageids); |
463 | 461 | } |
464 | | - |
| 462 | + |
465 | 463 | // Do we have anything to do? |
466 | 464 | if( $this->requestsize == 0 ) { |
467 | | - // Do not end profiling here, as it will introduce an element to the data object, and the usage screen may not be shown. |
468 | 465 | return false; // Nothing to do for any of the page generators |
469 | 466 | } |
470 | 467 | |
— | — | @@ -484,12 +481,12 @@ |
485 | 482 | // Query page information with the given lists of titles & pageIDs |
486 | 483 | // |
487 | 484 | $this->redirectPageIds = array(); |
488 | | - $this->startDbProfiling(); |
| 485 | + $this->startProfiling(); |
489 | 486 | $res = $this->db->select( 'page', |
490 | 487 | array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_touched', 'page_latest' ), |
491 | 488 | $this->db->makeList( $where, LIST_OR ), |
492 | 489 | $this->classname . '::genPageInfo' ); |
493 | | - $this->endDbProfiling('pageInfo'); |
| 490 | + $this->endProfiling('pageInfo'); |
494 | 491 | while( $row = $this->db->fetchObject( $res ) ) { |
495 | 492 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
496 | 493 | if ( !$title->userCanRead() ) { |
— | — | @@ -571,7 +568,7 @@ |
572 | 569 | $data['_element'] = 'title'; |
573 | 570 | $data[] = $givenTitle; |
574 | 571 | } |
575 | | - $this->endProfiling('pageInfo'); |
| 572 | + |
576 | 573 | return true; // success |
577 | 574 | } |
578 | 575 | |
— | — | @@ -586,7 +583,6 @@ |
587 | 584 | */ |
588 | 585 | function genMetaSiteInfo(&$prop, &$genInfo) { |
589 | 586 | global $wgSitename, $wgVersion, $wgCapitalLinks; |
590 | | - $this->startProfiling(); |
591 | 587 | $meta = array(); |
592 | 588 | $mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) ); |
593 | 589 | |
— | — | @@ -597,7 +593,6 @@ |
598 | 594 | $meta['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // "case-insensitive" option is reserved for future |
599 | 595 | |
600 | 596 | $this->data['meta']['site'] = $meta; |
601 | | - $this->endProfiling($prop); |
602 | 597 | } |
603 | 598 | |
604 | 599 | /** |
— | — | @@ -605,14 +600,12 @@ |
606 | 601 | */ |
607 | 602 | function genMetaNamespaceInfo(&$prop, &$genInfo) { |
608 | 603 | global $wgContLang; |
609 | | - $this->startProfiling(); |
610 | 604 | $meta = array(); |
611 | 605 | $meta['_element'] = 'ns'; |
612 | 606 | foreach( $wgContLang->getFormattedNamespaces() as $ns => $title ) { |
613 | 607 | $meta[$ns] = array( "id"=>$ns, "*" => $title ); |
614 | 608 | } |
615 | 609 | $this->data['meta']['namespaces'] = $meta; |
616 | | - $this->endProfiling($prop); |
617 | 610 | } |
618 | 611 | |
619 | 612 | /** |
— | — | @@ -620,7 +613,7 @@ |
621 | 614 | */ |
622 | 615 | function genMetaUserInfo(&$prop, &$genInfo) { |
623 | 616 | global $wgUser; |
624 | | - $this->startProfiling(); |
| 617 | + |
625 | 618 | extract( $this->getParams( $prop, $genInfo )); |
626 | 619 | $meta = array(); |
627 | 620 | $meta['name'] = $wgUser->getName(); |
— | — | @@ -634,14 +627,13 @@ |
635 | 628 | $meta['rights']['_element'] = 'r'; |
636 | 629 | } |
637 | 630 | $this->data['meta']['user'] = $meta; |
638 | | - $this->endProfiling($prop); |
639 | 631 | } |
640 | 632 | |
641 | 633 | /** |
642 | 634 | * Add pagids of the most recently modified pages to the output |
643 | 635 | */ |
644 | 636 | function genMetaRecentChanges(&$prop, &$genInfo) { |
645 | | - $this->startProfiling(); |
| 637 | + |
646 | 638 | extract( $this->getParams( $prop, $genInfo )); |
647 | 639 | # It makes no sense to hide both anons and logged-in users |
648 | 640 | if( in_array('anons', $rchide) && in_array('liu', $rchide) ) { |
— | — | @@ -678,7 +670,7 @@ |
679 | 671 | $options = array( 'USE INDEX' => 'rc_timestamp', 'LIMIT' => $rclimit ); |
680 | 672 | $options['ORDER BY'] = 'rc_timestamp' . ( $rcfrom != '' ? '' : ' DESC' ); |
681 | 673 | |
682 | | - $this->startDbProfiling(); |
| 674 | + $this->startProfiling(); |
683 | 675 | $res = $this->db->select( |
684 | 676 | 'recentchanges', |
685 | 677 | 'rc_cur_id', |
— | — | @@ -686,14 +678,13 @@ |
687 | 679 | $this->classname . '::genMetaRecentChanges', |
688 | 680 | $options |
689 | 681 | ); |
690 | | - $this->endDbProfiling($prop); |
| 682 | + $this->endProfiling($prop); |
691 | 683 | while ( $row = $this->db->fetchObject( $res ) ) { |
692 | 684 | if( $row->rc_cur_id != 0 ) { |
693 | 685 | $this->addRaw( 'pageids', $row->rc_cur_id ); |
694 | 686 | } |
695 | 687 | } |
696 | 688 | $this->db->freeResult( $res ); |
697 | | - $this->endProfiling($prop); |
698 | 689 | } |
699 | 690 | |
700 | 691 | /** |
— | — | @@ -701,12 +692,12 @@ |
702 | 693 | */ |
703 | 694 | function genUserPages(&$prop, &$genInfo) { |
704 | 695 | global $wgContLang; |
705 | | - $this->startProfiling(); |
| 696 | + |
706 | 697 | extract( $this->getParams( $prop, $genInfo )); |
707 | 698 | |
708 | 699 | $this->validateLimit( 'uslimit', $uslimit, 50, 1000 ); |
709 | 700 | |
710 | | - $this->startDbProfiling(); |
| 701 | + $this->startProfiling(); |
711 | 702 | $res = $this->db->select( |
712 | 703 | 'user', |
713 | 704 | 'user_name', |
— | — | @@ -714,7 +705,7 @@ |
715 | 706 | $this->classname . '::genUserPages', |
716 | 707 | array( 'ORDER BY' => 'user_name', 'LIMIT' => $uslimit ) |
717 | 708 | ); |
718 | | - $this->endDbProfiling($prop); |
| 709 | + $this->endProfiling($prop); |
719 | 710 | |
720 | 711 | $userNS = $wgContLang->getNsText(NS_USER); |
721 | 712 | if( !$userNS ) $userNS = 'User'; |
— | — | @@ -724,7 +715,6 @@ |
725 | 716 | $this->addRaw( 'titles', $userNS . $row->user_name ); |
726 | 717 | } |
727 | 718 | $this->db->freeResult( $res ); |
728 | | - $this->endProfiling($prop); |
729 | 719 | } |
730 | 720 | |
731 | 721 | /** |
— | — | @@ -735,7 +725,6 @@ |
736 | 726 | // TODO: This is very inefficient - we can get the actual page information, instead we make two identical query. |
737 | 727 | // |
738 | 728 | global $wgContLang; |
739 | | - $this->startProfiling(); |
740 | 729 | extract( $this->getParams( $prop, $genInfo )); |
741 | 730 | |
742 | 731 | $this->validateLimit( 'aplimit', $aplimit, 50, 1000 ); |
— | — | @@ -747,14 +736,14 @@ |
748 | 737 | $ns .= ':'; |
749 | 738 | } |
750 | 739 | |
751 | | - $this->startDbProfiling(); |
| 740 | + $this->startProfiling(); |
752 | 741 | $res = $this->db->select( |
753 | 742 | 'page', |
754 | 743 | 'page_title', |
755 | 744 | array( 'page_namespace' => intval($apnamespace), 'page_title>=' . $this->db->addQuotes($apfrom) ), |
756 | 745 | $this->classname . '::genMetaAllPages', |
757 | | - array( 'USE INDEX' => 'name_title', 'LIMIT' => $aplimit+1, 'ORDER BY' => 'page_namespace, page_title' )); |
758 | | - $this->endDbProfiling($prop); |
| 746 | + array( 'FORCE INDEX' => 'name_title', 'LIMIT' => $aplimit+1, 'ORDER BY' => 'page_namespace, page_title' )); |
| 747 | + $this->endProfiling($prop); |
759 | 748 | |
760 | 749 | // Add found page ids to the list of requested titles - they will be auto-populated later |
761 | 750 | $count = 0; |
— | — | @@ -767,7 +756,6 @@ |
768 | 757 | $this->addRaw( 'titles', $ns . $row->page_title ); |
769 | 758 | } |
770 | 759 | $this->db->freeResult( $res ); |
771 | | - $this->endProfiling($prop); |
772 | 760 | } |
773 | 761 | |
774 | 762 | /** |
— | — | @@ -778,7 +766,6 @@ |
779 | 767 | // TODO: This is very inefficient - we can get the actual page information, instead we make two identical query. |
780 | 768 | // |
781 | 769 | global $wgContLang; |
782 | | - $this->startProfiling(); |
783 | 770 | extract( $this->getParams( $prop, $genInfo )); |
784 | 771 | $this->validateLimit( 'nllimit', $nllimit, 50, 1000 ); |
785 | 772 | extract( $this->db->tableNames( 'page', 'langlinks' ) ); |
— | — | @@ -794,9 +781,9 @@ |
795 | 782 | . ' ORDER BY page_namespace, page_title' |
796 | 783 | . ' LIMIT ' . intval($nllimit+1); |
797 | 784 | |
798 | | - $this->startDbProfiling(); |
| 785 | + $this->startProfiling(); |
799 | 786 | $res = $this->db->query( $sql, $this->classname . '::genMetaNoLangLinksPages' ); |
800 | | - $this->endDbProfiling($prop); |
| 787 | + $this->endProfiling($prop); |
801 | 788 | |
802 | 789 | // Add found page ids to the list of requested titles - they will be auto-populated later |
803 | 790 | $count = 0; |
— | — | @@ -809,7 +796,6 @@ |
810 | 797 | $this->addRaw( 'pageids', $row->page_id ); |
811 | 798 | } |
812 | 799 | $this->db->freeResult( $res ); |
813 | | - $this->endProfiling($prop); |
814 | 800 | } |
815 | 801 | |
816 | 802 | |
— | — | @@ -826,7 +812,6 @@ |
827 | 813 | if( empty( $this->redirectPageIds ) ) { |
828 | 814 | return; |
829 | 815 | } |
830 | | - $this->startProfiling(); |
831 | 816 | extract( $this->db->tableNames( 'page', 'pagelinks' ) ); |
832 | 817 | |
833 | 818 | // |
— | — | @@ -858,9 +843,9 @@ |
859 | 844 | "pb.page_is_redirect IS NULL OR pb.page_is_redirect = '1'" |
860 | 845 | ), LIST_AND ); |
861 | 846 | |
862 | | - $this->startDbProfiling(); |
| 847 | + $this->startProfiling(); |
863 | 848 | $res = $this->db->query( $sql, $this->classname . '::genRedirectInfo' ); |
864 | | - $this->endDbProfiling('redirects'); |
| 849 | + $this->endProfiling('redirects'); |
865 | 850 | while ( $row = $this->db->fetchObject( $res ) ) { |
866 | 851 | $this->addPageSubElement( $row->a_id, 'redirect', 'to', $this->getLinkInfo( $row->b_namespace, $row->b_title, $row->b_id, $row->b_is_redirect ), false); |
867 | 852 | if( $row->b_is_redirect ) { |
— | — | @@ -868,7 +853,6 @@ |
869 | 854 | } |
870 | 855 | } |
871 | 856 | $this->db->freeResult( $res ); |
872 | | - $this->endProfiling($prop); |
873 | 857 | } |
874 | 858 | |
875 | 859 | var $genPageLinksSettings = array( // database column name prefix, output element name |
— | — | @@ -883,10 +867,9 @@ |
884 | 868 | if( empty($this->nonRedirPageIds) ) { |
885 | 869 | return; |
886 | 870 | } |
887 | | - $this->startProfiling(); |
888 | 871 | extract( $this->genPageLinksSettings[$prop] ); |
889 | 872 | |
890 | | - $this->startDbProfiling(); |
| 873 | + $this->startProfiling(); |
891 | 874 | $res = $this->db->select( |
892 | 875 | $linktbl, |
893 | 876 | array( "{$prefix}_from from_id", |
— | — | @@ -894,7 +877,7 @@ |
895 | 878 | "{$prefix}_title to_title" ), |
896 | 879 | array( "{$prefix}_from" => $this->nonRedirPageIds ), |
897 | 880 | $this->classname . "::genPageLinks_{$code}" ); |
898 | | - $this->endDbProfiling($prop); |
| 881 | + $this->endProfiling($prop); |
899 | 882 | |
900 | 883 | while ( $row = $this->db->fetchObject( $res ) ) { |
901 | 884 | if( $langlinks ) { |
— | — | @@ -905,7 +888,6 @@ |
906 | 889 | $this->addPageSubElement( $row->from_id, $prop, $code, $values); |
907 | 890 | } |
908 | 891 | $this->db->freeResult( $res ); |
909 | | - $this->endProfiling($prop); |
910 | 892 | } |
911 | 893 | |
912 | 894 | var $genPageBackLinksSettings = array( // database column name prefix, output element name |
— | — | @@ -918,7 +900,7 @@ |
919 | 901 | * $type - either 'template' or 'page' |
920 | 902 | */ |
921 | 903 | function genPageBackLinksHelper(&$prop, &$genInfo) { |
922 | | - $this->startProfiling(); |
| 904 | + |
923 | 905 | extract( $this->genPageBackLinksSettings[$prop] ); |
924 | 906 | |
925 | 907 | // |
— | — | @@ -1027,14 +1009,14 @@ |
1028 | 1010 | // |
1029 | 1011 | // Execute |
1030 | 1012 | // |
1031 | | - $this->startDbProfiling(); |
| 1013 | + $this->startProfiling(); |
1032 | 1014 | $res = $this->db->select( |
1033 | 1015 | array( $linktbl, 'page' ), |
1034 | 1016 | $columns, |
1035 | 1017 | $where, |
1036 | 1018 | $this->classname . "::genPageBackLinks_{$code}", |
1037 | 1019 | $options ); |
1038 | | - $this->endDbProfiling($prop); |
| 1020 | + $this->endProfiling($prop); |
1039 | 1021 | |
1040 | 1022 | $count = 0; |
1041 | 1023 | while ( $row = $this->db->fetchObject( $res ) ) { |
— | — | @@ -1049,7 +1031,6 @@ |
1050 | 1032 | $this->addPageSubElement( $pageId, $prop, $code, $values ); |
1051 | 1033 | } |
1052 | 1034 | $this->db->freeResult( $res ); |
1053 | | - $this->endProfiling($prop); |
1054 | 1035 | } |
1055 | 1036 | |
1056 | 1037 | /** |
— | — | @@ -1059,11 +1040,9 @@ |
1060 | 1041 | if( empty( $this->existingPageIds ) ) { |
1061 | 1042 | return; |
1062 | 1043 | } |
1063 | | - $this->startProfiling(); |
1064 | 1044 | extract( $this->getParams( $prop, $genInfo )); |
1065 | 1045 | |
1066 | | - $tables = array('revision'); |
1067 | | - $fields = array('rev_id', 'rev_text_id', 'rev_timestamp', 'rev_user', 'rev_user_text', 'rev_minor_edit'); |
| 1046 | + $fields = array('rev_id', 'rev_timestamp', 'rev_user', 'rev_user_text', 'rev_minor_edit'); |
1068 | 1047 | if( isset($rvcomments) ) { |
1069 | 1048 | $fields[] = 'rev_comment'; |
1070 | 1049 | } |
— | — | @@ -1081,30 +1060,15 @@ |
1082 | 1061 | if( $rvoffset !== 0 ) { |
1083 | 1062 | $options['OFFSET'] = $rvoffset; |
1084 | 1063 | } |
1085 | | - if( isset($rvcontent) ) { |
1086 | | - $this->validateLimit( 'content + rvlimit * pages', $rvlimit * count($this->existingPageIds), 50, 200 ); |
1087 | | - $tables[] = 'text'; |
1088 | | - $fields[] = 'old_id'; |
1089 | | - $fields[] = 'old_text'; |
1090 | | - $fields[] = 'old_flags'; |
1091 | | - $conds[] = 'rev_text_id=old_id'; |
1092 | | - } else { |
1093 | | - $this->validateLimit( 'rvlimit * pages', $rvlimit * count($this->existingPageIds), 200, 2000 ); |
1094 | | - } |
1095 | | - |
1096 | | - $this->startDbProfiling(); |
| 1064 | + $this->validateLimit( 'rvlimit * pages', $rvlimit * count($this->existingPageIds), 200, 2000 ); |
| 1065 | + |
| 1066 | + $this->startProfiling(); |
1097 | 1067 | foreach( $this->existingPageIds as $pageId ) { |
1098 | 1068 | $conds['rev_page'] = $pageId; |
1099 | | - $res = $this->db->select( |
1100 | | - $tables, |
1101 | | - $fields, |
1102 | | - $conds, |
1103 | | - $this->classname . '::genPageHistory', |
1104 | | - $options ); |
| 1069 | + $res = $this->db->select( 'revision', $fields, $conds, $this->classname . '::genPageHistory', $options ); |
1105 | 1070 | while ( $row = $this->db->fetchObject( $res ) ) { |
1106 | 1071 | $vals = array( |
1107 | 1072 | 'revid' => $row->rev_id, |
1108 | | - 'oldid' => $row->rev_text_id, |
1109 | 1073 | 'timestamp' => wfTimestamp( TS_ISO_8601, $row->rev_timestamp ), |
1110 | 1074 | 'user' => $row->rev_user_text, |
1111 | 1075 | ); |
— | — | @@ -1114,17 +1078,11 @@ |
1115 | 1079 | if( $row->rev_minor_edit ) { |
1116 | 1080 | $vals['minor'] = ''; |
1117 | 1081 | } |
1118 | | - if( $rvcomments ) { |
1119 | | - $vals['comment'] = $row->rev_comment; |
1120 | | - } |
1121 | | - if( isset($rvcontent) ) { |
1122 | | - $vals['*'] = Revision::getRevisionText( $row ); |
1123 | | - } |
| 1082 | + $vals['*'] = $rvcomments ? $row->rev_comment : ''; |
1124 | 1083 | $this->addPageSubElement( $pageId, 'revisions', 'rv', $vals); |
1125 | 1084 | } |
1126 | 1085 | $this->db->freeResult( $res ); |
1127 | 1086 | } |
1128 | | - $this->endDbProfiling($prop); |
1129 | 1087 | $this->endProfiling($prop); |
1130 | 1088 | } |
1131 | 1089 | |
— | — | @@ -1135,33 +1093,23 @@ |
1136 | 1094 | if( empty( $this->existingPageIds ) ) { |
1137 | 1095 | return; |
1138 | 1096 | } |
| 1097 | + $this->validateLimit( 'co_querytoobig', count($this->existingPageIds), 50, 200 ); |
1139 | 1098 | $this->startProfiling(); |
1140 | | - |
1141 | | - // Generate the WHERE clause for pageIds+RevisionIds |
1142 | | - $ids = array(); |
1143 | | - foreach( $this->data['pages'] as $pageId => &$page ) { |
1144 | | - if( $pageId > 0 ) { |
1145 | | - $ids[] = "(rev_page=$pageId AND rev_id={$page['revid']})"; |
1146 | | - } |
1147 | | - } |
1148 | | - $this->validateLimit( 'co_querytoobig', count($ids), 50, 200 ); |
1149 | | - |
1150 | | - $this->startDbProfiling(); |
1151 | 1099 | $res = $this->db->select( |
1152 | | - array('revision', 'text'), |
1153 | | - array('rev_page', 'old_id', 'old_text', 'old_flags'), |
1154 | | - array('rev_text_id=old_id', implode('OR', $ids)), |
| 1100 | + array('page', 'revision', 'text'), |
| 1101 | + array('page_id', 'old_id', 'old_text', 'old_flags'), |
| 1102 | + array('page_id=rev_page', 'page_latest=rev_id', 'rev_text_id=old_id', 'page_id' => $this->existingPageIds), |
1155 | 1103 | $this->classname . '::genPageContent' |
1156 | 1104 | ); |
1157 | 1105 | while ( $row = $this->db->fetchObject( $res ) ) { |
1158 | | - $this->addPageSubElement( $row->rev_page, $prop, 'xml:space', 'preserve', false); |
1159 | | - $this->addPageSubElement( $row->rev_page, $prop, '*', Revision::getRevisionText( $row ), false); |
| 1106 | + $this->addPageSubElement( $row->page_id, $prop, 'xml:space', 'preserve', false); |
| 1107 | + $this->addPageSubElement( $row->page_id, $prop, '*', Revision::getRevisionText( $row ), false); |
1160 | 1108 | } |
1161 | 1109 | $this->db->freeResult( $res ); |
1162 | | - $this->endDbProfiling($prop); // Revision::getRevisionText is also a database call, so we include them in this scope |
1163 | | - $this->endProfiling($prop); |
| 1110 | + $this->endProfiling($prop); // getRevisionText is also a database call |
1164 | 1111 | } |
1165 | 1112 | |
| 1113 | + |
1166 | 1114 | // |
1167 | 1115 | // ************************************* UTILITIES ************************************* |
1168 | 1116 | // |
— | — | @@ -1437,33 +1385,15 @@ |
1438 | 1386 | function startProfiling() { |
1439 | 1387 | $this->startTime = wfTime(); |
1440 | 1388 | } |
1441 | | - /** |
1442 | | - * Same as startProfiling, but used for DB access only |
1443 | | - */ |
1444 | | - function startDbProfiling() { |
1445 | | - $this->startDbTime = wfTime(); |
1446 | | - } |
1447 | 1389 | |
1448 | 1390 | /** |
1449 | | - * Records the running time of the given module since last startDbProfiling() call. |
| 1391 | + * Records the running time of the given module since last startProfiling() call. |
1450 | 1392 | */ |
1451 | 1393 | function endProfiling( $module ) { |
1452 | | - $this->recordProfiling( $module, 'time', $this->startTime ); |
| 1394 | + $timeDelta = wfTime() - $this->startTime; |
| 1395 | + unset($this->startTime); |
| 1396 | + $this->addStatusMessage( $module, array( 'time' => sprintf( "%1.2fms", $timeDelta * 1000.0 ) )); |
1453 | 1397 | } |
1454 | | - /** |
1455 | | - * Same as endProfiling, but used for DB access only |
1456 | | - */ |
1457 | | - function endDbProfiling( $module ) { |
1458 | | - $this->recordProfiling( $module, 'dbtime', $this->startDbTime ); |
1459 | | - } |
1460 | | - /** |
1461 | | - * Helper profiling function |
1462 | | - */ |
1463 | | - function recordProfiling( $module, $type, &$start ) { |
1464 | | - $timeDelta = wfTime() - $start; |
1465 | | - unset($start); |
1466 | | - $this->addStatusMessage( $module, array( $type => sprintf( "%1.2fms", $timeDelta * 1000.0 ) )); |
1467 | | - } |
1468 | 1398 | |
1469 | 1399 | /** |
1470 | 1400 | * Validate the value against the minimum and user/bot maximum limits. Prints usage info on failure. |