Index: branches/werdna/restrictions-separation/maintenance/updaters.inc |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | array( 'filearchive', 'patch-filearchive.sql' ), |
39 | 39 | array( 'redirect', 'patch-redirect.sql' ), |
40 | 40 | array( 'querycachetwo', 'patch-querycachetwo.sql' ), |
| 41 | +# array( 'page_restrictions', 'patch-page_restrictions.sql' ), |
41 | 42 | ); |
42 | 43 | |
43 | 44 | $wgNewFields = array( |
— | — | @@ -925,6 +926,68 @@ |
926 | 927 | } |
927 | 928 | } |
928 | 929 | |
| 930 | +function do_restrictions_update() { |
| 931 | + # Adding page_restrictions table, obsoleting page.page_restrictions. |
| 932 | + # Migrating old restrictions to new table |
| 933 | + # -- Andrew Garrett, January 2007. |
| 934 | + |
| 935 | + global $wgDatabase; |
| 936 | + |
| 937 | + $name = 'page_restrictions'; |
| 938 | + $patch = 'patch-page_restrictions.sql'; |
| 939 | + |
| 940 | + if ( $wgDatabase->tableExists( $name ) ) { |
| 941 | + echo "...$name table already exists.\n"; |
| 942 | + } else { |
| 943 | + echo "Creating $name table..."; |
| 944 | + dbsource( archive($patch), $wgDatabase ); |
| 945 | + echo "ok\n"; |
| 946 | + |
| 947 | + echo "Migrating old restrictions to new table..."; |
| 948 | + |
| 949 | + $res = $wgDatabase->select( 'page', array( 'page_id', 'page_restrictions' ), array("page_restrictions!=''", "page_restrictions!='edit=:move='"), __METHOD__ ); |
| 950 | + |
| 951 | + $count = 0; |
| 952 | + |
| 953 | + while ($row = $wgDatabase->fetchObject($res) ) { |
| 954 | + $count = ($count + 1) % 100; |
| 955 | + |
| 956 | + if ($count == 0) { |
| 957 | + if ( function_exists( 'wfWaitForSlaves' ) ) { |
| 958 | + wfWaitForSlaves( 10 ); |
| 959 | + } else { |
| 960 | + sleep( 1 ); |
| 961 | + } |
| 962 | + } |
| 963 | + |
| 964 | + # Figure out what the restrictions are.. |
| 965 | + $id = $row->page_id; |
| 966 | + $flatterrestrictions = $row->page_restrictions; |
| 967 | + |
| 968 | + $flatrestrictions = explode( ':', $flatterrestrictions ); |
| 969 | + |
| 970 | + $restrictions = array (); |
| 971 | + |
| 972 | + foreach( $flatrestrictions as $restriction ) { |
| 973 | + $thisrestriction = explode('=', $restriction); |
| 974 | + |
| 975 | + $restriction_type = $thisrestriction[0]; |
| 976 | + $restriction_level = $thisrestriction[1]; |
| 977 | + |
| 978 | + $restrictions[$restriction_type] = $restriction_level; |
| 979 | + |
| 980 | + $wgDatabase->insert( 'page_restrictions', array ( 'pr_page' => $id, |
| 981 | + 'pr_type' => $restriction_type, |
| 982 | + 'pr_level' => $restriction_level, |
| 983 | + 'pr_cascade' => 0 ), __METHOD ); |
| 984 | + } |
| 985 | + |
| 986 | + echo "ok\n"; |
| 987 | + } |
| 988 | + } |
| 989 | + |
| 990 | +} |
| 991 | + |
929 | 992 | function do_postgres_updates() { |
930 | 993 | global $wgDatabase, $wgVersion, $wgDBmwschema; |
931 | 994 | |
Index: branches/werdna/restrictions-separation/maintenance/tables.sql |
— | — | @@ -1047,7 +1047,7 @@ |
1048 | 1048 | -- and deletions may refer to different page records as time |
1049 | 1049 | -- goes by. |
1050 | 1050 | rd_namespace int NOT NULL default '0', |
1051 | | - rd_title varchar(255) binary NOT NULL default '', |
| 1051 | + rd_title varchar(2deleted.55) binary NOT NULL default '', |
1052 | 1052 | |
1053 | 1053 | PRIMARY KEY rd_from (rd_from), |
1054 | 1054 | KEY rd_ns_title (rd_namespace,rd_title,rd_from) |
— | — | @@ -1075,4 +1075,23 @@ |
1076 | 1076 | |
1077 | 1077 | ) TYPE=InnoDB; |
1078 | 1078 | |
| 1079 | +--- Used for storing page restrictions (i.e. protection levels) |
| 1080 | +CREATE TABLE /*$wgDBprefix*/page_restrictions ( |
| 1081 | + -- Page to apply restrictions to (Foreign Key to page). |
| 1082 | + pr_page int(8) NOT NULL, |
| 1083 | + -- The protection type (edit, move, etc) |
| 1084 | + pr_type varchar(255) NOT NULL, |
| 1085 | + -- The protection level (Sysop, autoconfirmed, etc) |
| 1086 | + pr_level varchar(255) NOT NULL, |
| 1087 | + -- Whether or not to cascade the protection down to pages transcluded. |
| 1088 | + pr_cascade tinyint(4) NOT NULL, |
| 1089 | + |
| 1090 | + PRIMARY KEY (pr_page,pr_type), |
| 1091 | + |
| 1092 | + KEY pr_page (pr_page), |
| 1093 | + KEY pr_typelevel (pr_type,pr_level), |
| 1094 | + KEY pr_level (pr_level), |
| 1095 | + KEY pr_cascade (pr_cascade) |
| 1096 | +) TYPE=InnoDB; |
| 1097 | + |
1079 | 1098 | -- vim: sw=2 sts=2 et |
Index: branches/werdna/restrictions-separation/includes/Title.php |
— | — | @@ -1349,7 +1349,7 @@ |
1350 | 1350 | |
1351 | 1351 | function areRestrictionsCascading() { |
1352 | 1352 | if (!$this->mRestrictionsLoaded) { |
1353 | | - $this->getRestrictions(); |
| 1353 | + $this->loadRestrictions(); |
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | return $this->mCascadeRestrictions; |