Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -711,9 +711,15 @@ |
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
715 | | - if ( isset( $options['GROUP BY'] ) ) $preLimitTail .= " GROUP BY {$options['GROUP BY']}"; |
716 | | - if ( isset( $options['HAVING'] ) ) $preLimitTail .= " HAVING {$options['HAVING']}"; |
717 | | - if ( isset( $options['ORDER BY'] ) ) $preLimitTail .= " ORDER BY {$options['ORDER BY']}"; |
| 715 | + if ( isset( $options['GROUP BY'] ) ) { |
| 716 | + $preLimitTail .= " GROUP BY {$options['GROUP BY']}"; |
| 717 | + } |
| 718 | + if ( isset( $options['HAVING'] ) ) { |
| 719 | + $preLimitTail .= " HAVING {$options['HAVING']}"; |
| 720 | + } |
| 721 | + if ( isset( $options['ORDER BY'] ) ) { |
| 722 | + $preLimitTail .= " ORDER BY {$options['ORDER BY']}"; |
| 723 | + } |
718 | 724 | |
719 | 725 | //if (isset($options['LIMIT'])) { |
720 | 726 | // $tailOpts .= $this->limitResult('', $options['LIMIT'], |
— | — | @@ -721,19 +727,41 @@ |
722 | 728 | // : false); |
723 | 729 | //} |
724 | 730 | |
725 | | - if ( isset( $noKeyOptions['FOR UPDATE'] ) ) $postLimitTail .= ' FOR UPDATE'; |
726 | | - if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) $postLimitTail .= ' LOCK IN SHARE MODE'; |
727 | | - if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT'; |
| 731 | + if ( isset( $noKeyOptions['FOR UPDATE'] ) ) { |
| 732 | + $postLimitTail .= ' FOR UPDATE'; |
| 733 | + } |
| 734 | + if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) { |
| 735 | + $postLimitTail .= ' LOCK IN SHARE MODE'; |
| 736 | + } |
| 737 | + if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) { |
| 738 | + $startOpts .= 'DISTINCT'; |
| 739 | + } |
728 | 740 | |
729 | 741 | # Various MySQL extensions |
730 | | - if ( isset( $noKeyOptions['STRAIGHT_JOIN'] ) ) $startOpts .= ' /*! STRAIGHT_JOIN */'; |
731 | | - if ( isset( $noKeyOptions['HIGH_PRIORITY'] ) ) $startOpts .= ' HIGH_PRIORITY'; |
732 | | - if ( isset( $noKeyOptions['SQL_BIG_RESULT'] ) ) $startOpts .= ' SQL_BIG_RESULT'; |
733 | | - if ( isset( $noKeyOptions['SQL_BUFFER_RESULT'] ) ) $startOpts .= ' SQL_BUFFER_RESULT'; |
734 | | - if ( isset( $noKeyOptions['SQL_SMALL_RESULT'] ) ) $startOpts .= ' SQL_SMALL_RESULT'; |
735 | | - if ( isset( $noKeyOptions['SQL_CALC_FOUND_ROWS'] ) ) $startOpts .= ' SQL_CALC_FOUND_ROWS'; |
736 | | - if ( isset( $noKeyOptions['SQL_CACHE'] ) ) $startOpts .= ' SQL_CACHE'; |
737 | | - if ( isset( $noKeyOptions['SQL_NO_CACHE'] ) ) $startOpts .= ' SQL_NO_CACHE'; |
| 742 | + if ( isset( $noKeyOptions['STRAIGHT_JOIN'] ) ) { |
| 743 | + $startOpts .= ' /*! STRAIGHT_JOIN */'; |
| 744 | + } |
| 745 | + if ( isset( $noKeyOptions['HIGH_PRIORITY'] ) ) { |
| 746 | + $startOpts .= ' HIGH_PRIORITY'; |
| 747 | + } |
| 748 | + if ( isset( $noKeyOptions['SQL_BIG_RESULT'] ) ) { |
| 749 | + $startOpts .= ' SQL_BIG_RESULT'; |
| 750 | + } |
| 751 | + if ( isset( $noKeyOptions['SQL_BUFFER_RESULT'] ) ) { |
| 752 | + $startOpts .= ' SQL_BUFFER_RESULT'; |
| 753 | + } |
| 754 | + if ( isset( $noKeyOptions['SQL_SMALL_RESULT'] ) ) { |
| 755 | + $startOpts .= ' SQL_SMALL_RESULT'; |
| 756 | + } |
| 757 | + if ( isset( $noKeyOptions['SQL_CALC_FOUND_ROWS'] ) ) { |
| 758 | + $startOpts .= ' SQL_CALC_FOUND_ROWS'; |
| 759 | + } |
| 760 | + if ( isset( $noKeyOptions['SQL_CACHE'] ) ) { |
| 761 | + $startOpts .= ' SQL_CACHE'; |
| 762 | + } |
| 763 | + if ( isset( $noKeyOptions['SQL_NO_CACHE'] ) ) { |
| 764 | + $startOpts .= ' SQL_NO_CACHE'; |
| 765 | + } |
738 | 766 | |
739 | 767 | if ( isset( $options['USE INDEX'] ) && ! is_array( $options['USE INDEX'] ) ) { |
740 | 768 | $useIndex = $this->useIndexClause( $options['USE INDEX'] ); |
— | — | @@ -783,10 +811,11 @@ |
784 | 812 | $options = array( $options ); |
785 | 813 | } |
786 | 814 | if( is_array( $table ) ) { |
787 | | - if ( !empty($join_conds) || ( isset( $options['USE INDEX'] ) && is_array( @$options['USE INDEX'] ) ) ) |
| 815 | + if ( !empty($join_conds) || ( isset( $options['USE INDEX'] ) && is_array( @$options['USE INDEX'] ) ) ) { |
788 | 816 | $from = ' FROM ' . $this->tableNamesWithUseIndexOrJOIN( $table, @$options['USE INDEX'], $join_conds ); |
789 | | - else |
| 817 | + } else { |
790 | 818 | $from = ' FROM ' . implode( ',', array_map( array( &$this, 'tableName' ), $table ) ); |
| 819 | + } |
791 | 820 | } elseif ($table!='') { |
792 | 821 | if ($table{0}==' ') { |
793 | 822 | $from = ' FROM ' . $table; |
— | — | @@ -840,8 +869,9 @@ |
841 | 870 | function selectRow( $table, $vars, $conds, $fname = 'DatabaseBase::selectRow', $options = array(), $join_conds = array() ) { |
842 | 871 | $options['LIMIT'] = 1; |
843 | 872 | $res = $this->select( $table, $vars, $conds, $fname, $options, $join_conds ); |
844 | | - if ( $res === false ) |
| 873 | + if ( $res === false ) { |
845 | 874 | return false; |
| 875 | + } |
846 | 876 | if ( !$this->numRows($res) ) { |
847 | 877 | return false; |
848 | 878 | } |
— | — | @@ -1114,7 +1144,7 @@ |
1115 | 1145 | } elseif ( ($mode == LIST_SET) && is_numeric( $field ) ) { |
1116 | 1146 | $list .= "$value"; |
1117 | 1147 | } elseif ( ($mode == LIST_AND || $mode == LIST_OR) && is_array($value) ) { |
1118 | | - if( count( $value ) == 0 ) { |
| 1148 | + if ( count( $value ) == 0 ) { |
1119 | 1149 | throw new MWException( __METHOD__.': empty input' ); |
1120 | 1150 | } elseif( count( $value ) == 1 ) { |
1121 | 1151 | // Special-case single values, as IN isn't terribly efficient |
— | — | @@ -1125,7 +1155,7 @@ |
1126 | 1156 | } else { |
1127 | 1157 | $list .= $field." IN (".$this->makeList($value).") "; |
1128 | 1158 | } |
1129 | | - } elseif( $value === null ) { |
| 1159 | + } elseif ( $value === null ) { |
1130 | 1160 | if ( $mode == LIST_AND || $mode == LIST_OR ) { |
1131 | 1161 | $list .= "$field IS "; |
1132 | 1162 | } elseif ( $mode == LIST_SET ) { |
— | — | @@ -1377,7 +1407,7 @@ |
1378 | 1408 | 'un_user_id' => 'user_id', |
1379 | 1409 | 'un_user_ip' => 'user_ip', |
1380 | 1410 | ); |
1381 | | - if( isset( $renamed[$index] ) ) { |
| 1411 | + if ( isset( $renamed[$index] ) ) { |
1382 | 1412 | return $renamed[$index]; |
1383 | 1413 | } else { |
1384 | 1414 | return $index; |
— | — | @@ -1614,7 +1644,7 @@ |
1615 | 1645 | $selectOptions = array( $selectOptions ); |
1616 | 1646 | } |
1617 | 1647 | list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions ); |
1618 | | - if( is_array( $srcTable ) ) { |
| 1648 | + if ( is_array( $srcTable ) ) { |
1619 | 1649 | $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) ); |
1620 | 1650 | } else { |
1621 | 1651 | $srcTable = $this->tableName( $srcTable ); |
— | — | @@ -1774,7 +1804,7 @@ |
1775 | 1805 | $this->reportQueryError( $error, $errno, $sql, $fname ); |
1776 | 1806 | } |
1777 | 1807 | } |
1778 | | - } while( $this->wasDeadlock() && --$tries > 0 ); |
| 1808 | + } while ( $this->wasDeadlock() && --$tries > 0 ); |
1779 | 1809 | $this->ignoreErrors( $oldIgnore ); |
1780 | 1810 | if ( $tries <= 0 ) { |
1781 | 1811 | $this->rollback( $myFname ); |
— | — | @@ -1942,7 +1972,7 @@ |
1943 | 1973 | * Local database timestamp format or null |
1944 | 1974 | */ |
1945 | 1975 | function timestampOrNull( $ts = null ) { |
1946 | | - if( is_null( $ts ) ) { |
| 1976 | + if ( is_null( $ts ) ) { |
1947 | 1977 | return null; |
1948 | 1978 | } else { |
1949 | 1979 | return $this->timestamp( $ts ); |
— | — | @@ -1953,7 +1983,7 @@ |
1954 | 1984 | * @todo document |
1955 | 1985 | */ |
1956 | 1986 | function resultObject( $result ) { |
1957 | | - if( empty( $result ) ) { |
| 1987 | + if ( empty( $result ) ) { |
1958 | 1988 | return false; |
1959 | 1989 | } elseif ( $result instanceof ResultWrapper ) { |
1960 | 1990 | return $result; |
— | — | @@ -2095,8 +2125,12 @@ |
2096 | 2126 | $line = trim( fgets( $fp, 1024 ) ); |
2097 | 2127 | $sl = strlen( $line ) - 1; |
2098 | 2128 | |
2099 | | - if ( $sl < 0 ) { continue; } |
2100 | | - if ( '-' == $line{0} && '-' == $line{1} ) { continue; } |
| 2129 | + if ( $sl < 0 ) { |
| 2130 | + continue; |
| 2131 | + } |
| 2132 | + if ( '-' == $line{0} && '-' == $line{1} ) { |
| 2133 | + continue; |
| 2134 | + } |
2101 | 2135 | |
2102 | 2136 | ## Allow dollar quoting for function declarations |
2103 | 2137 | if (substr($line,0,4) == '$mw$') { |
— | — | @@ -2115,7 +2149,9 @@ |
2116 | 2150 | } |
2117 | 2151 | } |
2118 | 2152 | |
2119 | | - if ( $cmd != '' ) { $cmd .= ' '; } |
| 2153 | + if ( $cmd != '' ) { |
| 2154 | + $cmd .= ' '; |
| 2155 | + } |
2120 | 2156 | $cmd .= "$line\n"; |
2121 | 2157 | |
2122 | 2158 | if ( $done ) { |
— | — | @@ -2151,7 +2187,7 @@ |
2152 | 2188 | |
2153 | 2189 | // Ordinary variables |
2154 | 2190 | foreach ( $varnames as $var ) { |
2155 | | - if( isset( $GLOBALS[$var] ) ) { |
| 2191 | + if ( isset( $GLOBALS[$var] ) ) { |
2156 | 2192 | $val = addslashes( $GLOBALS[$var] ); // FIXME: safety check? |
2157 | 2193 | $ins = str_replace( '{$' . $var . '}', $val, $ins ); |
2158 | 2194 | $ins = str_replace( '/*$' . $var . '*/`', '`' . $val, $ins ); |