r37542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37541‎ | r37542 | r37543 >
Date:22:11, 10 July 2008
Author:brion
Status:old
Tags:
Comment:
Hold back $wgTrackLinkChanges for a little bit; reverting r37322, 37430, 37432, 37435.
Even disabled, it's started interfering with regular tasks like running the parser tests.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)
  • /trunk/phase3/maintenance/postgres/archives/patch-recentlinkchanges.sql (deleted) (history)
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
@@ -454,7 +454,7 @@
455455 'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
456456 'categorylinks', 'templatelinks', 'externallinks', 'langlinks',
457457 'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
458 - 'recentchanges', 'recentlinkchanges', 'watchlist', 'math', 'interwiki',
 458+ 'recentchanges', 'watchlist', 'math', 'interwiki',
459459 'querycache', 'objectcache', 'job', 'redirect', 'querycachetwo',
460460 'archive', 'user_groups', 'page_props', 'category'
461461 );
Index: trunk/phase3/maintenance/postgres/archives/patch-recentlinkchanges.sql
@@ -1,12 +0,0 @@
2 -CREATE SEQUENCE recentlinkchanges_rcl_id_seq;
3 -CREATE TABLE recentlinkchanges (
4 - rlc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('recentlinkchanges_rcl_id_seq'),
5 - rlc_type TEXT NOT NULL,
6 - rlc_timestamp TIMESTAMPTZ NOT NULL,
7 - rlc_action SMALLINT NOT NULL DEFAULT 0,
8 - rlc_from INTEGER NOT NULL,
9 - rlc_to_namespace SMALLINT,
10 - rlc_to_title TEXT,
11 - rlc_to_blob TEXT
12 -);
13 -CREATE INDEX recentlinkchanges_type ON recentlinkchanges(rlc_type);
Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -538,19 +538,6 @@
539539 );
540540
541541
542 -CREATE SEQUENCE recentlinkchanges_rcl_id_seq;
543 -CREATE TABLE recentlinkchanges (
544 - rlc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('recentlinkchanges_rcl_id_seq'),
545 - rlc_type TEXT NOT NULL,
546 - rlc_timestamp TIMESTAMPTZ NOT NULL,
547 - rlc_action SMALLINT NOT NULL DEFAULT 0,
548 - rlc_from INTEGER NOT NULL,
549 - rlc_to_namespace SMALLINT,
550 - rlc_to_title TEXT,
551 - rlc_to_blob TEXT
552 -);
553 -CREATE INDEX recentlinkchanges_type ON recentlinkchanges(rlc_type);
554 -
555542 CREATE SEQUENCE category_id_seq;
556543 CREATE TABLE category (
557544 cat_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('category_id_seq'),
Index: trunk/phase3/maintenance/updaters.inc
@@ -1423,7 +1423,6 @@
14241424 array("page_restrictions", "patch-page_restrictions.sql"),
14251425 array("profiling", "patch-profiling.sql"),
14261426 array("protected_titles", "patch-protected_titles.sql"),
1427 - array("recentlinkchanges", "patch-recentlinkchanges.sql"),
14281427 array("redirect", "patch-redirect.sql"),
14291428 array("updatelog", "patch-updatelog.sql"),
14301429 );
Index: trunk/phase3/maintenance/tables.sql
@@ -1237,28 +1237,4 @@
12381238 PRIMARY KEY (ul_key)
12391239 ) /*$wgDBTableOptions*/;
12401240
1241 -CREATE TABLE /*$wgDBprefix*/recentlinkchanges (
1242 - rlc_id int unsigned NOT NULL auto_increment,
1243 -
1244 - -- page, image, category, ...
1245 - rlc_type varchar(15) binary NOT NULL,
1246 - rlc_timestamp binary(14) NOT NULL default '',
1247 - -- 1: insert; 2: deletion;
1248 - -- should probably make this an enum...
1249 - rlc_action tinyint NOT NULL default 0,
1250 -
1251 - -- page where the links are on
1252 - rlc_from int NOT NULL,
1253 -
1254 - rlc_to_namespace int,
1255 - rlc_to_title varchar(255) binary,
1256 - rlc_to_blob blob,
1257 -
1258 - PRIMARY KEY (rlc_id),
1259 - KEY from_timestamp (rlc_type, rlc_timestamp),
1260 - KEY to_timestamp (rlc_to_namespace, rlc_to_title, rlc_timestamp)
1261 -) /*$wgDBTableOptions*/;
1262 -
12631241 -- vim: sw=2 sts=2 et
Index: trunk/phase3/includes/LinksUpdate.php
@@ -12,19 +12,12 @@
1313 var $mId, //!< Page ID of the article linked from
1414 $mTitle, //!< Title object of the article linked from
1515 $mLinks, //!< Map of title strings to IDs for the links in the document
16 - $mExistingLinks,
1716 $mImages, //!< DB keys of the images used, in the array key only
18 - $mExistingImages,
1917 $mTemplates, //!< Map of title strings to IDs for the template references, including broken ones
20 - $mExistingTemplates,
2118 $mExternals, //!< URLs of external links, array key only
22 - $mExistingExternals,
2319 $mCategories, //!< Map of category names to sort keys
24 - $mExistingCategories,
2520 $mInterlangs, //!< Map of language codes to titles
26 - $mExistingInterlangs,
2721 $mProperties, //!< Map of arbitrary name to value
28 - $mExistingProperties,
2922 $mDb, //!< Database connection reference
3023 $mOptions, //!< SELECT options to be used (array)
3124 $mRecursive; //!< Whether to queue jobs for recursive updates
@@ -82,7 +75,7 @@
8376 * Update link tables with outgoing links from an updated article
8477 */
8578 function doUpdate() {
86 - global $wgUseDumbLinkUpdate, $wgTrackLinkChanges;
 79+ global $wgUseDumbLinkUpdate;
8780
8881 wfRunHooks( 'LinksUpdate', array( &$this ) );
8982 if ( $wgUseDumbLinkUpdate ) {
@@ -90,8 +83,6 @@
9184 } else {
9285 $this->doIncrementalUpdate();
9386 }
94 - if ( $wgTrackLinkChanges )
95 - $this->makeRecentlinkchanges();
9687 wfRunHooks( 'LinksUpdateComplete', array( &$this ) );
9788
9889 }
@@ -574,9 +565,6 @@
575566 * @private
576567 */
577568 function getExistingLinks() {
578 - if ( is_array( $this->mExistingLinks ) )
579 - return $this->mExistingLinks;
580 -
581569 $res = $this->mDb->select( 'pagelinks', array( 'pl_namespace', 'pl_title' ),
582570 array( 'pl_from' => $this->mId ), __METHOD__, $this->mOptions );
583571 $arr = array();
@@ -587,7 +575,7 @@
588576 $arr[$row->pl_namespace][$row->pl_title] = 1;
589577 }
590578 $this->mDb->freeResult( $res );
591 - return $this->mExistingLinks = $arr;
 579+ return $arr;
592580 }
593581
594582 /**
@@ -595,9 +583,6 @@
596584 * @private
597585 */
598586 function getExistingTemplates() {
599 - if ( is_array( $this->mExistingTemplates ) )
600 - return $this->mExistingTemplates;
601 -
602587 $res = $this->mDb->select( 'templatelinks', array( 'tl_namespace', 'tl_title' ),
603588 array( 'tl_from' => $this->mId ), __METHOD__, $this->mOptions );
604589 $arr = array();
@@ -608,7 +593,7 @@
609594 $arr[$row->tl_namespace][$row->tl_title] = 1;
610595 }
611596 $this->mDb->freeResult( $res );
612 - return $this->mExistingTemplates = $arr;
 597+ return $arr;
613598 }
614599
615600 /**
@@ -616,9 +601,6 @@
617602 * @private
618603 */
619604 function getExistingImages() {
620 - if ( is_array( $this->mExistingImages ) )
621 - return $this->mExistingImages;
622 -
623605 $res = $this->mDb->select( 'imagelinks', array( 'il_to' ),
624606 array( 'il_from' => $this->mId ), __METHOD__, $this->mOptions );
625607 $arr = array();
@@ -626,7 +608,7 @@
627609 $arr[$row->il_to] = 1;
628610 }
629611 $this->mDb->freeResult( $res );
630 - return $this->mExistingImages = $arr;
 612+ return $arr;
631613 }
632614
633615 /**
@@ -634,9 +616,6 @@
635617 * @private
636618 */
637619 function getExistingExternals() {
638 - if ( is_array( $this->mExistingExternals ) )
639 - return $this->mExistingExternals;
640 -
641620 $res = $this->mDb->select( 'externallinks', array( 'el_to' ),
642621 array( 'el_from' => $this->mId ), __METHOD__, $this->mOptions );
643622 $arr = array();
@@ -644,7 +623,7 @@
645624 $arr[$row->el_to] = 1;
646625 }
647626 $this->mDb->freeResult( $res );
648 - return $this->mExistingExternals = $arr;
 627+ return $arr;
649628 }
650629
651630 /**
@@ -652,9 +631,6 @@
653632 * @private
654633 */
655634 function getExistingCategories() {
656 - if ( is_array( $this->mExistingCategories ) )
657 - return $this->mExistingCategories;
658 -
659635 $res = $this->mDb->select( 'categorylinks', array( 'cl_to', 'cl_sortkey' ),
660636 array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
661637 $arr = array();
@@ -662,7 +638,7 @@
663639 $arr[$row->cl_to] = $row->cl_sortkey;
664640 }
665641 $this->mDb->freeResult( $res );
666 - return $this->mExistingCategories = $arr;
 642+ return $arr;
667643 }
668644
669645 /**
@@ -671,16 +647,13 @@
672648 * @private
673649 */
674650 function getExistingInterlangs() {
675 - if ( is_array( $this->mExistingInterlangs ) )
676 - return $this->mExistingInterlangs;
677 -
678651 $res = $this->mDb->select( 'langlinks', array( 'll_lang', 'll_title' ),
679652 array( 'll_from' => $this->mId ), __METHOD__, $this->mOptions );
680653 $arr = array();
681654 while ( $row = $this->mDb->fetchObject( $res ) ) {
682655 $arr[$row->ll_lang] = $row->ll_title;
683656 }
684 - return $this->mExistingInterlangs = $arr;
 657+ return $arr;
685658 }
686659
687660 /**
@@ -688,9 +661,6 @@
689662 * @private
690663 */
691664 function getExistingProperties() {
692 - if ( is_array( $this->mExistingProperties ) )
693 - return $this->mExistingProperties;
694 -
695665 $res = $this->mDb->select( 'page_props', array( 'pp_propname', 'pp_value' ),
696666 array( 'pp_page' => $this->mId ), __METHOD__, $this->mOptions );
697667 $arr = array();
@@ -698,7 +668,7 @@
699669 $arr[$row->pp_propname] = $row->pp_value;
700670 }
701671 $this->mDb->freeResult( $res );
702 - return $this->mExistingProperties = $arr;
 672+ return $arr;
703673 }
704674
705675
@@ -728,124 +698,4 @@
729699 }
730700 }
731701 }
732 -
733 - // Recentlinkchanges constants
734 - const INSERTION = 1;
735 - const DELETION = 2;
736 - private static $rlcFields = array(
737 - 'rlc_type',
738 - 'rlc_timestamp',
739 - 'rlc_action',
740 - 'rlc_from',
741 - 'rlc_to_namespace',
742 - 'rlc_to_title',
743 - 'rlc_to_blob'
744 - );
745 - /*
746 - * Insert items to recentlinkchanges
747 - */
748 - function makeRecentlinkchanges() {
749 - $insert = array();
750 - $now = $this->mDb->timestamp();
751 -
752 - // Category changes
753 - $existing = array_keys( $this->getExistingCategories() );
754 - $current = array_keys( $this->mCategories );
755 - $this->simpleAddToLinkchanges( $insert, 'category', $now, $existing, $current, NS_CATEGORY );
756 -
757 - // External links
758 - $existing = array_keys( $this->getExistingExternals() );
759 - $current = array_keys( $this->mExternals );
760 - $insertions = array_diff( $current, $existing );
761 - foreach ( $insertions as $item )
762 - $insert[] = array(
763 - 'external', $now, self::INSERTION,
764 - $this->mId, null, null, $item );
765 - $deletions = array_diff( $existing, $current );
766 - foreach ( $deletions as $item )
767 - $insert[] = array(
768 - 'external', $now, self::DELETION,
769 - $this->mId, null, null, $item );
770 -
771 - // Image changes
772 - $existing = array_keys( $this->getExistingImages() );
773 - $current = array_keys( $this->mImages );
774 - $this->simpleAddToLinkchanges( $insert, 'image', $now, $existing, $current, NS_IMAGE );
775 -
776 - // Interlangs
777 - $existing = $this->getExistingInterlangs();
778 - $current = $this->mInterlangs;
779 - $this->assocAddToLinkchanges( $insert, 'interlang', $existing, $current );
780 -
781 - // Page links
782 - $existing = $this->getExistingLinks();
783 - $current = $this->mLinks;
784 - $this->addToLinkChangesByNamespace( $insert, 'page', $now, $existing, $current);
785 -
786 - // Properties
787 - $existing = $this->getExistingProperties();
788 - $current = $this->mProperties;
789 - $this->assocAddToLinkchanges( $insert, 'property', $existing, $current );
790 -
791 - // Templates
792 - $existing = $this->getExistingTemplates();
793 - $current = $this->mTemplates;
794 - $this->addToLinkChangesByNamespace( $insert, 'template', $now, $existing, $current);
795 -
796 - $this->mDb->insert( 'recentlinkchanges', $insert, __METHOD__ );
797 -
798 - }
799 -
800 - /*
801 - * Compute the difference for arrays of titles with namespace $ns and add
802 - * them to $insert.
803 - */
804 - private function simpleAddToLinkchanges( &$insert, $type, $now, $existing, $current, $ns ) {
805 -
806 - $insertions = array_diff( $current, $existing );
807 - foreach ( $insertions as $item )
808 - $insert[] = array_combine(self::$rlcFields, array(
809 - $type, $now, self::INSERTION,
810 - $this->mId, $ns, $item, null
811 - ) );
812 - $deletions = array_diff( $existing, $current );
813 - foreach ( $deletions as $item )
814 - $insert[] = array_combine(self::$rlcFields, array(
815 - $type, $now, self::DELETION,
816 - $this->mId, $ns, $item, null
817 - ) );
818 -
819 - }
820 -
821 - /*
822 - * Compute the difference for associative arrays and insert them to
823 - * $insert as title => blob.
824 - */
825 - function assocAddToLinkChanges( &$insert, $type, $now, $existing, $current ) {
826 - $insertions = array_diff_assoc( $current, $existing );
827 - foreach ( $insertions as $key => $value )
828 - $insert[] = array_combine(self::$rlcFields, array(
829 - $type, $now, self::INSERTION,
830 - $this->mId, null, $key, $value
831 - ) );
832 - $deletions = array_diff_assoc( $existing, $current );
833 - foreach ( $deletions as $key => $value )
834 - $insert[] = array_combine(self::$rlcFields, array(
835 - $type, $now, self::DELETION,
836 - $this->mId, null, $key, $value
837 - ) );
838 - }
839 -
840 - /*
841 - * Format arrays in the form $namespace => $titleArray for use in
842 - * simpleAddLinkLinkChanges
843 - */
844 - function addToLinkChangesByNamespace( &$insert, $type, $now, $existing, $current ) {
845 - $namespaces = array_merge( array_keys( $existing ), array_keys( $current ) );
846 - foreach ( $namespaces as $ns )
847 - $this->simpleAddToLinkchanges( $insert, $type, $now,
848 - isset( $existing[$ns] ) ? array_keys( $existing[$ns] ) : array(),
849 - isset( $current[$ns] ) ? array_keys( $current[$ns] ) : array(),
850 - $ns );
851 - }
852702 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3265,8 +3265,3 @@
32663266 * ting this variable false.
32673267 */
32683268 $wgUseAutomaticEditSummaries = true;
3269 -
3270 -/*
3271 - * Track link changes
3272 - */
3273 -$wgTrackLinkChanges = false;
Index: trunk/phase3/RELEASE-NOTES
@@ -185,9 +185,7 @@
186186 * Add a new hook NormalizeMessageKey to allow extensions to replace messages before
187187 the database is potentially queried
188188 * (bug 9736) Redirects on Special:Fewestrevisions are now marked as such.
189 -* (bug 13588) Experimentally track link changes if $wgTrackLinkChanges is set
190 - to true. Requires schema change.
191 -
 189+
192190 === Bug fixes in 1.13 ===
193191
194192 * (bug 10677) Add link to the file description page on the shared repository

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r37322(bug 13588) Experimentally track link changes if $wgTrackLinkChanges is set t...btongminh15:02, 8 July 2008

Status & tagging log