Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigStorageSchema.php
<?php | <?php | ||||
abstract class PhabricatorConfigStorageSchema extends Phobject { | abstract class PhabricatorConfigStorageSchema extends Phobject { | ||||
const ISSUE_MISSING = 'missing'; | const ISSUE_MISSING = 'missing'; | ||||
const ISSUE_SURPLUS = 'surplus'; | const ISSUE_SURPLUS = 'surplus'; | ||||
const ISSUE_CHARSET = 'charset'; | const ISSUE_CHARSET = 'charset'; | ||||
const ISSUE_COLLATION = 'collation'; | const ISSUE_COLLATION = 'collation'; | ||||
const ISSUE_COLUMNTYPE = 'columntype'; | const ISSUE_COLUMNTYPE = 'columntype'; | ||||
const ISSUE_NULLABLE = 'nullable'; | const ISSUE_NULLABLE = 'nullable'; | ||||
const ISSUE_KEYCOLUMNS = 'keycolumns'; | const ISSUE_KEYCOLUMNS = 'keycolumns'; | ||||
const ISSUE_SUBNOTE = 'subnote'; | |||||
const ISSUE_SUBWARN = 'subwarn'; | const ISSUE_SUBWARN = 'subwarn'; | ||||
const ISSUE_SUBFAIL = 'subfail'; | const ISSUE_SUBFAIL = 'subfail'; | ||||
const STATUS_OKAY = 'okay'; | const STATUS_OKAY = 'okay'; | ||||
const STATUS_NOTE = 'note'; | |||||
const STATUS_WARN = 'warn'; | const STATUS_WARN = 'warn'; | ||||
const STATUS_FAIL = 'fail'; | const STATUS_FAIL = 'fail'; | ||||
private $issues = array(); | private $issues = array(); | ||||
private $name; | private $name; | ||||
abstract public function newEmptyClone(); | abstract public function newEmptyClone(); | ||||
abstract protected function compareToSimilarSchema( | abstract protected function compareToSimilarSchema( | ||||
Show All 26 Lines | public function setIssues(array $issues) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getIssues() { | public function getIssues() { | ||||
$issues = $this->issues; | $issues = $this->issues; | ||||
foreach ($this->getSubschemata() as $sub) { | foreach ($this->getSubschemata() as $sub) { | ||||
switch ($sub->getStatus()) { | switch ($sub->getStatus()) { | ||||
case self::STATUS_NOTE: | |||||
$issues[self::ISSUE_SUBNOTE] = self::ISSUE_SUBNOTE; | |||||
break; | |||||
case self::STATUS_WARN: | case self::STATUS_WARN: | ||||
$issues[self::ISSUE_SUBWARN] = self::ISSUE_SUBWARN; | $issues[self::ISSUE_SUBWARN] = self::ISSUE_SUBWARN; | ||||
break; | break; | ||||
case self::STATUS_FAIL: | case self::STATUS_FAIL: | ||||
$issues[self::ISSUE_SUBFAIL] = self::ISSUE_SUBFAIL; | $issues[self::ISSUE_SUBFAIL] = self::ISSUE_SUBFAIL; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
Show All 33 Lines | switch ($issue) { | ||||
case self::ISSUE_COLLATION: | case self::ISSUE_COLLATION: | ||||
return pht('Better Collation Available'); | return pht('Better Collation Available'); | ||||
case self::ISSUE_COLUMNTYPE: | case self::ISSUE_COLUMNTYPE: | ||||
return pht('Wrong Column Type'); | return pht('Wrong Column Type'); | ||||
case self::ISSUE_NULLABLE: | case self::ISSUE_NULLABLE: | ||||
return pht('Wrong Nullable Setting'); | return pht('Wrong Nullable Setting'); | ||||
case self::ISSUE_KEYCOLUMNS: | case self::ISSUE_KEYCOLUMNS: | ||||
return pht('Key on Wrong Columns'); | return pht('Key on Wrong Columns'); | ||||
case self::ISSUE_SUBNOTE: | |||||
return pht('Subschemata Have Notices'); | |||||
case self::ISSUE_SUBWARN: | case self::ISSUE_SUBWARN: | ||||
return pht('Subschemata Have Warnings'); | return pht('Subschemata Have Warnings'); | ||||
case self::ISSUE_SUBFAIL: | case self::ISSUE_SUBFAIL: | ||||
return pht('Subschemata Have Failures'); | return pht('Subschemata Have Failures'); | ||||
default: | default: | ||||
throw new Exception(pht('Unknown schema issue "%s"!', $issue)); | throw new Exception(pht('Unknown schema issue "%s"!', $issue)); | ||||
} | } | ||||
} | } | ||||
Show All 9 Lines | switch ($issue) { | ||||
case self::ISSUE_COLLATION: | case self::ISSUE_COLLATION: | ||||
return pht('This schema can use a better collation.'); | return pht('This schema can use a better collation.'); | ||||
case self::ISSUE_COLUMNTYPE: | case self::ISSUE_COLUMNTYPE: | ||||
return pht('This schema can use a better column type.'); | return pht('This schema can use a better column type.'); | ||||
case self::ISSUE_NULLABLE: | case self::ISSUE_NULLABLE: | ||||
return pht('This schema has the wrong nullable setting.'); | return pht('This schema has the wrong nullable setting.'); | ||||
case self::ISSUE_KEYCOLUMNS: | case self::ISSUE_KEYCOLUMNS: | ||||
return pht('This schema is on the wrong columns.'); | return pht('This schema is on the wrong columns.'); | ||||
case self::ISSUE_SUBNOTE: | |||||
return pht('Subschemata have setup notices.'); | |||||
case self::ISSUE_SUBWARN: | case self::ISSUE_SUBWARN: | ||||
return pht('Subschemata have setup warnings.'); | return pht('Subschemata have setup warnings.'); | ||||
case self::ISSUE_SUBFAIL: | case self::ISSUE_SUBFAIL: | ||||
return pht('Subschemata have setup failures.'); | return pht('Subschemata have setup failures.'); | ||||
default: | default: | ||||
throw new Exception(pht('Unknown schema issue "%s"!', $issue)); | throw new Exception(pht('Unknown schema issue "%s"!', $issue)); | ||||
} | } | ||||
} | } | ||||
public static function getIssueStatus($issue) { | public static function getIssueStatus($issue) { | ||||
switch ($issue) { | switch ($issue) { | ||||
case self::ISSUE_MISSING: | case self::ISSUE_MISSING: | ||||
case self::ISSUE_SUBFAIL: | case self::ISSUE_SUBFAIL: | ||||
return self::STATUS_FAIL; | return self::STATUS_FAIL; | ||||
case self::ISSUE_SURPLUS: | case self::ISSUE_SURPLUS: | ||||
case self::ISSUE_CHARSET: | |||||
case self::ISSUE_COLLATION: | |||||
case self::ISSUE_COLUMNTYPE: | case self::ISSUE_COLUMNTYPE: | ||||
case self::ISSUE_SUBWARN: | case self::ISSUE_SUBWARN: | ||||
case self::ISSUE_KEYCOLUMNS: | case self::ISSUE_KEYCOLUMNS: | ||||
case self::ISSUE_NULLABLE: | case self::ISSUE_NULLABLE: | ||||
return self::STATUS_WARN; | return self::STATUS_WARN; | ||||
case self::ISSUE_SUBNOTE: | |||||
case self::ISSUE_CHARSET: | |||||
case self::ISSUE_COLLATION: | |||||
return self::STATUS_NOTE; | |||||
default: | default: | ||||
throw new Exception(pht('Unknown schema issue "%s"!', $issue)); | throw new Exception(pht('Unknown schema issue "%s"!', $issue)); | ||||
} | } | ||||
} | } | ||||
public static function getStatusSeverity($status) { | public static function getStatusSeverity($status) { | ||||
switch ($status) { | switch ($status) { | ||||
case self::STATUS_FAIL: | case self::STATUS_FAIL: | ||||
return 2; | return 3; | ||||
case self::STATUS_WARN: | case self::STATUS_WARN: | ||||
return 2; | |||||
case self::STATUS_NOTE: | |||||
return 1; | return 1; | ||||
case self::STATUS_OKAY: | case self::STATUS_OKAY: | ||||
return 0; | return 0; | ||||
default: | default: | ||||
throw new Exception(pht('Unknown schema status "%s"!', $status)); | throw new Exception(pht('Unknown schema status "%s"!', $status)); | ||||
} | } | ||||
} | } | ||||
Show All 13 Lines |