From: Tim Düsterhus Date: Sat, 2 Feb 2013 20:00:02 +0000 (+0100) Subject: Use short ternary statement X-Git-Tag: 2.0.0_Beta_1~516^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=37f28ebd9f27d57268709e462627ab78595ab98b;p=GitHub%2FWoltLab%2FWCF.git Use short ternary statement --- diff --git a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php index 47eaa25df5..0b569cca55 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php @@ -571,10 +571,10 @@ class LanguageEditor extends DatabaseObjectEditor implements IEditableCachedObje // search and replace $matches = 0; if ($useRegex) { - $newValue = preg_replace('~'.$search.'~s', $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), -1, $matches); + $newValue = preg_replace('~'.$search.'~s', $replace, ($row['languageCustomItemValue'] ?: $row['languageItemValue']), -1, $matches); } else { - $newValue = StringUtil::replaceIgnoreCase($search, $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), $matches); + $newValue = StringUtil::replaceIgnoreCase($search, $replace, ($row['languageCustomItemValue'] ?: $row['languageItemValue']), $matches); } if ($matches > 0) { diff --git a/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php b/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php index b9a611c386..667ede87c9 100644 --- a/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php +++ b/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php @@ -117,11 +117,11 @@ class SQLParser { case 'ALTER TABLE': // add index if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+ADD\s+(?:(UNIQUE|FULLTEXT)\s+)?(?:INDEX|KEY)\s+(?:(\w+)\s*)?\((\s*\w+\s*(?:,\s*\w+\s*)*)\)~is', $query, $match)) { - $this->executeAddIndexStatement($match[1], ($match[3] ? $match[3] : self::getGenericIndexName($match[1], $match[4])), array('type' => strtoupper($match[2]), 'columns' => $match[4])); + $this->executeAddIndexStatement($match[1], ($match[3] ?: self::getGenericIndexName($match[1], $match[4])), array('type' => strtoupper($match[2]), 'columns' => $match[4])); } // add foreign key else if (preg_match('~^ALTER\s+TABLE\s+(\w+)\s+ADD\s+FOREIGN KEY\s+(?:(\w+)\s*)?\((\s*\w+\s*(?:,\s*\w+\s*)*)\)\s+REFERENCES\s+(\w+)\s+\((\s*\w+\s*(?:,\s*\w+\s*)*)\)(?:\s+ON\s+(UPDATE|DELETE)\s+(CASCADE|SET NULL|NO ACTION))?~is', $query, $match)) { - $this->executeAddForeignKeyStatement($match[1], ($match[2] ? $match[2] : self::getGenericIndexName($match[1], $match[3], 'fk')), array('columns' => $match[3], 'referencedTable' => $match[4], 'referencedColumns' => $match[5], 'operation' => $match[6], 'action' => $match[7])); + $this->executeAddForeignKeyStatement($match[1], ($match[2] ?: self::getGenericIndexName($match[1], $match[3], 'fk')), array('columns' => $match[3], 'referencedTable' => $match[4], 'referencedColumns' => $match[5], 'operation' => $match[6], 'action' => $match[7])); } // add/change column else if (preg_match("~^ALTER\s+TABLE\s+(\w+)\s+(?:(ADD)\s+(?:COLUMN\s+)?|(CHANGE)\s+(?:COLUMN\s+)?(\w+)\s+)(\w+)\s+(\w+)(?:\s*\((\s*(?:\d+(?:\s*,\s*\d+)?|'[^']*'(?:\s*,\s*'[^']*')*))\))?(?:\s+UNSIGNED)?(?:\s+(NOT NULL|NULL))?(?:\s+DEFAULT\s+(\d+.\d+|\d+|NULL|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'))?(?:\s+(AUTO_INCREMENT))?(?:\s+(UNIQUE|PRIMARY)(?: KEY)?)?~is", $query, $match)) { @@ -168,7 +168,7 @@ class SQLParser { case 'CREATE INDEX': if (preg_match('~^CREATE\s+(?:(UNIQUE|FULLTEXT)\s+)?INDEX\s+(\w+)\s+ON\s+(\w+)\s+\((\s*\w+\s*(?:,\s*\w+\s*)*)\)~is', $query, $match)) { - $this->executeAddIndexStatement($match[3], ($match[2] ? $match[2] : self::getGenericIndexName($match[3], $match[4])), array('type' => strtoupper($match[1]), 'columns' => $match[4])); + $this->executeAddIndexStatement($match[3], ($match[2] ?: self::getGenericIndexName($match[3], $match[4])), array('type' => strtoupper($match[1]), 'columns' => $match[4])); } else { throw new SystemException("Unsupported SQL statement '".$query."'");