Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -283,8 +283,6 @@ |
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | | - |
288 | | - |
289 | 287 | function add_field( $table, $field, $patch, $fullpath = false ) { |
290 | 288 | global $wgDatabase; |
291 | 289 | if ( !$wgDatabase->tableExists( $table ) ) { |
— | — | @@ -499,7 +497,6 @@ |
500 | 498 | wfOut( "Done.\n" ); |
501 | 499 | } |
502 | 500 | |
503 | | - |
504 | 501 | function do_user_update() { |
505 | 502 | global $wgDatabase; |
506 | 503 | if ( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) { |
— | — | @@ -1177,7 +1174,6 @@ |
1178 | 1175 | flush(); |
1179 | 1176 | } |
1180 | 1177 | |
1181 | | - |
1182 | 1178 | wfOut( "Deleting old default messages (this may take a long time!)..." ); |
1183 | 1179 | if ( !defined( 'MW_NO_SETUP' ) ) { |
1184 | 1180 | define( 'MW_NO_SETUP', true ); |
— | — | @@ -1405,8 +1401,6 @@ |
1406 | 1402 | } |
1407 | 1403 | } |
1408 | 1404 | |
1409 | | - |
1410 | | - |
1411 | 1405 | /*********************************************************************** |
1412 | 1406 | * Start PG stuff |
1413 | 1407 | * TODO: merge with above |
— | — | @@ -1423,8 +1417,9 @@ |
1424 | 1418 | $res = $wgDatabase->query( sprintf( $q, |
1425 | 1419 | $wgDatabase->addQuotes( $table ), |
1426 | 1420 | $wgDatabase->addQuotes( $wgDBmwschema ) ) ); |
1427 | | - if ( !$res ) |
| 1421 | + if ( !$res ) { |
1428 | 1422 | return null; |
| 1423 | + } |
1429 | 1424 | |
1430 | 1425 | $cols = array(); |
1431 | 1426 | while ( $r = $wgDatabase->fetchRow( $res ) ) { |
— | — | @@ -1451,8 +1446,9 @@ |
1452 | 1447 | $res = $wgDatabase->query( sprintf( $q, |
1453 | 1448 | $wgDatabase->addQuotes( $wgDBmwschema ), |
1454 | 1449 | $wgDatabase->addQuotes( $idx ) ) ); |
1455 | | - if ( !$res ) |
| 1450 | + if ( !$res ) { |
1456 | 1451 | return null; |
| 1452 | + } |
1457 | 1453 | if ( !( $r = $wgDatabase->fetchRow( $res ) ) ) { |
1458 | 1454 | $wgDatabase->freeResult( $res ); |
1459 | 1455 | return null; |
— | — | @@ -1472,8 +1468,9 @@ |
1473 | 1469 | AND attrelid=pg_class.oid |
1474 | 1470 | END; |
1475 | 1471 | $r2 = $wgDatabase->query( sprintf( $query, $rid ) ); |
1476 | | - if ( !$r2 ) |
| 1472 | + if ( !$r2 ) { |
1477 | 1473 | return null; |
| 1474 | + } |
1478 | 1475 | if ( !( $row2 = $wgDatabase->fetchRow( $r2 ) ) ) { |
1479 | 1476 | $wgDatabase->freeResult( $r2 ); |
1480 | 1477 | return null; |
— | — | @@ -1505,8 +1502,9 @@ |
1506 | 1503 | $r = $wgDatabase->query( sprintf( $q, |
1507 | 1504 | $wgDatabase->addQuotes( $wgDBmwschema ), |
1508 | 1505 | $wgDatabase->addQuotes( $fkey ) ) ); |
1509 | | - if ( !( $row = $wgDatabase->fetchRow( $r ) ) ) |
| 1506 | + if ( !( $row = $wgDatabase->fetchRow( $r ) ) ) { |
1510 | 1507 | return null; |
| 1508 | + } |
1511 | 1509 | return $row[0]; |
1512 | 1510 | } |
1513 | 1511 | |
— | — | @@ -1523,8 +1521,9 @@ |
1524 | 1522 | $wgDatabase->addQuotes( $table ), |
1525 | 1523 | $wgDatabase->addQuotes( $rule ) ) ); |
1526 | 1524 | $row = $wgDatabase->fetchRow( $r ); |
1527 | | - if ( !$row ) |
| 1525 | + if ( !$row ) { |
1528 | 1526 | return null; |
| 1527 | + } |
1529 | 1528 | $d = $row[0]; |
1530 | 1529 | $wgDatabase->freeResult( $r ); |
1531 | 1530 | return $d; |
— | — | @@ -1540,8 +1539,9 @@ |
1541 | 1540 | $wgShowExceptionDetails = 1; |
1542 | 1541 | |
1543 | 1542 | # Just in case their LocalSettings.php does not have this: |
1544 | | - if ( !isset( $wgDBmwschema ) ) |
| 1543 | + if ( !isset( $wgDBmwschema ) ) { |
1545 | 1544 | $wgDBmwschema = 'mediawiki'; |
| 1545 | + } |
1546 | 1546 | |
1547 | 1547 | # Verify that this user is configured correctly |
1548 | 1548 | $safeuser = $wgDatabase->addQuotes( $wgDBuser ); |
— | — | @@ -1554,8 +1554,7 @@ |
1555 | 1555 | } |
1556 | 1556 | if ( !array_key_exists( 'search_path', $conf ) ) { |
1557 | 1557 | $search_path = ''; |
1558 | | - } |
1559 | | - else { |
| 1558 | + } else { |
1560 | 1559 | $search_path = $conf['search_path']; |
1561 | 1560 | } |
1562 | 1561 | if ( strpos( $search_path, $wgDBmwschema ) === false ) { |
— | — | @@ -1570,8 +1569,7 @@ |
1571 | 1570 | if ( array_key_exists( 'search_path', $conf ) === false || $search_path != $conf['search_path'] ) { |
1572 | 1571 | $wgDatabase->doQuery( "ALTER USER $wgDBuser SET search_path = $search_path" ); |
1573 | 1572 | $wgDatabase->doQuery( "SET search_path = $search_path" ); |
1574 | | - } |
1575 | | - else { |
| 1573 | + } else { |
1576 | 1574 | $path = $conf['search_path']; |
1577 | 1575 | wfOut( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" ); |
1578 | 1576 | } |
— | — | @@ -1586,8 +1584,7 @@ |
1587 | 1585 | wfOut( "Setting $key to '$value' for user \"$wgDBuser\"\n" ); |
1588 | 1586 | $wgDatabase->doQuery( "ALTER USER $wgDBuser SET $key = '$value'" ); |
1589 | 1587 | $wgDatabase->doQuery( "SET $key = '$value'" ); |
1590 | | - } |
1591 | | - else { |
| 1588 | + } else { |
1592 | 1589 | wfOut( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" ); |
1593 | 1590 | } |
1594 | 1591 | } |
— | — | @@ -1857,12 +1854,10 @@ |
1858 | 1855 | if ( 'NOT NULL' === $nc[2] ) { |
1859 | 1856 | wfOut( "Changing \"$nc[0].$nc[1]\" to not allow NULLs\n" ); |
1860 | 1857 | $wgDatabase->query( "ALTER TABLE $nc[0] ALTER $nc[1] SET NOT NULL" ); |
1861 | | - } |
1862 | | - else { |
| 1858 | + } else { |
1863 | 1859 | wfOut( "... column \"$nc[0].$nc[1]\" is already set as NULL\n" ); |
1864 | 1860 | } |
1865 | | - } |
1866 | | - else { |
| 1861 | + } else { |
1867 | 1862 | # # It's NOT NULL - does it need to be NULL? |
1868 | 1863 | if ( 'NULL' === $nc[2] ) { |
1869 | 1864 | wfOut( "Changing \"$nc[0].$nc[1]\" to allow NULLs\n" ); |
— | — | @@ -1879,11 +1874,10 @@ |
1880 | 1875 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" ); |
1881 | 1876 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" ); |
1882 | 1877 | $wgDatabase->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" ); |
1883 | | - } |
1884 | | - else |
| 1878 | + } else { |
1885 | 1879 | wfOut( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" ); |
| 1880 | + } |
1886 | 1881 | |
1887 | | - |
1888 | 1882 | foreach ( $newindexes as $ni ) { |
1889 | 1883 | if ( pg_index_exists( $ni[0], $ni[1] ) ) { |
1890 | 1884 | wfOut( "... index \"$ni[1]\" on table \"$ni[0]\" already exists\n" ); |
— | — | @@ -1904,8 +1898,7 @@ |
1905 | 1899 | |
1906 | 1900 | if ( $wgDatabase->hasConstraint( "oldimage_oi_name_fkey_cascaded" ) ) { |
1907 | 1901 | wfOut( "... table \"oldimage\" has correct cascading delete/update foreign key to image\n" ); |
1908 | | - } |
1909 | | - else { |
| 1902 | + } else { |
1910 | 1903 | if ( $wgDatabase->hasConstraint( "oldimage_oi_name_fkey" ) ) { |
1911 | 1904 | $wgDatabase->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" ); |
1912 | 1905 | } |
— | — | @@ -1920,38 +1913,37 @@ |
1921 | 1914 | if ( !$wgDatabase->triggerExists( "page", "page_deleted" ) ) { |
1922 | 1915 | wfOut( "Adding function and trigger \"page_deleted\" to table \"page\"\n" ); |
1923 | 1916 | $wgDatabase->sourceFile( archive( 'patch-page_deleted.sql' ) ); |
1924 | | - } |
1925 | | - else |
| 1917 | + } else { |
1926 | 1918 | wfOut( "... table \"page\" has \"page_deleted\" trigger\n" ); |
| 1919 | + } |
1927 | 1920 | |
1928 | 1921 | $fi = $wgDatabase->fieldInfo( "recentchanges", "rc_cur_id" ); |
1929 | 1922 | if ( !$fi->nullable() ) { |
1930 | 1923 | wfOut( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" ); |
1931 | 1924 | $wgDatabase->sourceFile( archive( 'patch-rc_cur_id-not-null.sql' ) ); |
1932 | | - } |
1933 | | - else |
| 1925 | + } else { |
1934 | 1926 | wfOut( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" ); |
| 1927 | + } |
1935 | 1928 | |
1936 | 1929 | $pu = pg_describe_index( "pagelink_unique" ); |
1937 | 1930 | if ( !is_null( $pu ) && ( $pu[0] != "pl_from" || $pu[1] != "pl_namespace" || $pu[2] != "pl_title" ) ) { |
1938 | 1931 | wfOut( "Dropping obsolete version of index \"pagelink_unique index\"\n" ); |
1939 | 1932 | $wgDatabase->query( "DROP INDEX pagelink_unique" ); |
1940 | 1933 | $pu = null; |
1941 | | - } |
1942 | | - else |
| 1934 | + } else { |
1943 | 1935 | wfOut( "... obsolete version of index \"pagelink_unique index\" does not exist\n" ); |
| 1936 | + } |
1944 | 1937 | |
1945 | 1938 | if ( is_null( $pu ) ) { |
1946 | 1939 | wfOut( "Creating index \"pagelink_unique index\"\n" ); |
1947 | 1940 | $wgDatabase->query( "CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)" ); |
1948 | | - } |
1949 | | - else |
| 1941 | + } else { |
1950 | 1942 | wfOut( "... index \"pagelink_unique_index\" already exists\n" ); |
| 1943 | + } |
1951 | 1944 | |
1952 | 1945 | if ( pg_fkey_deltype( "revision_rev_user_fkey" ) == 'r' ) { |
1953 | 1946 | wfOut( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" ); |
1954 | | - } |
1955 | | - else { |
| 1947 | + } else { |
1956 | 1948 | wfOut( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" ); |
1957 | 1949 | $wgDatabase->sourceFile( archive( 'patch-revision_rev_user_fkey.sql' ) ); |
1958 | 1950 | } |
— | — | @@ -1963,8 +1955,7 @@ |
1964 | 1956 | } |
1965 | 1957 | if ( pg_index_exists( 'ipblocks', 'ipb_address_unique' ) ) { |
1966 | 1958 | wfOut( "... have ipb_address_unique\n" ); |
1967 | | - } |
1968 | | - else { |
| 1959 | + } else { |
1969 | 1960 | wfOut( "Adding ipb_address_unique index\n" ); |
1970 | 1961 | $wgDatabase->sourceFile( archive( 'patch-ipb_address_unique.sql' ) ); |
1971 | 1962 | } |
— | — | @@ -2039,7 +2030,7 @@ |
2040 | 2031 | if ( $fi->is_deferred() && $fi->is_deferrable() ) { |
2041 | 2032 | continue; |
2042 | 2033 | } |
2043 | | - wfOut( "Altering column \"$dc[0].$dc[1]\" to be DEFERRABLE INITTALLY DEFERRED\n" ); |
| 2034 | + wfOut( "Altering column \"$dc[0].$dc[1]\" to be DEFERRABLE INITIALLY DEFERRED\n" ); |
2044 | 2035 | $conname = $fi->conname(); |
2045 | 2036 | $clause = $dc[2]; |
2046 | 2037 | $command = "ALTER TABLE $dc[0] DROP CONSTRAINT $conname"; |
— | — | @@ -2054,7 +2045,8 @@ |
2055 | 2046 | |
2056 | 2047 | # # If the server is 8.3 or higher, rewrite the tsearch2 triggers |
2057 | 2048 | # # in case they have the old 'default' versions |
2058 | | - if ( $numver >= 8.3 ) |
| 2049 | + if ( $numver >= 8.3 ) { |
2059 | 2050 | $wgDatabase->sourceFile( archive( 'patch-tsearch2funcs.sql' ) ); |
| 2051 | + } |
2060 | 2052 | return; |
2061 | 2053 | } |