From e6b7ad2e003356dd5ba8ec92c2efc477dcc8a019 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 19 Jan 2013 08:41:45 -0800 Subject: [PATCH] Migrate `max_allowed_packet` and GD checks to new setup stuff Summary: These are nonblocking warnings and can move to post-install. Test Plan: Broke my environment and observed the warnings. Reviewers: btrahan, vrana Reviewed By: vrana CC: aran, asherkin Maniphest Tasks: T2228 Differential Revision: https://secure.phabricator.com/D4505 --- src/__phutil_library_map__.php | 4 + .../config/check/PhabricatorSetupCheckGD.php | 48 ++++++++++++ .../check/PhabricatorSetupCheckMySQL.php | 29 +++++++ src/infrastructure/PhabricatorSetup.php | 77 ------------------- 4 files changed, 81 insertions(+), 77 deletions(-) create mode 100644 src/applications/config/check/PhabricatorSetupCheckGD.php create mode 100644 src/applications/config/check/PhabricatorSetupCheckMySQL.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3748827b6f..c6c685e358 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1205,8 +1205,10 @@ phutil_register_library_map(array( 'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php', 'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php', 'PhabricatorSetupCheckExtraConfig' => 'applications/config/check/PhabricatorSetupCheckExtraConfig.php', + 'PhabricatorSetupCheckGD' => 'applications/config/check/PhabricatorSetupCheckGD.php', 'PhabricatorSetupCheckInvalidConfig' => 'applications/config/check/PhabricatorSetupCheckInvalidConfig.php', 'PhabricatorSetupCheckMail' => 'applications/config/check/PhabricatorSetupCheckMail.php', + 'PhabricatorSetupCheckMySQL' => 'applications/config/check/PhabricatorSetupCheckMySQL.php', 'PhabricatorSetupCheckStorage' => 'applications/config/check/PhabricatorSetupCheckStorage.php', 'PhabricatorSetupCheckTimezone' => 'applications/config/check/PhabricatorSetupCheckTimezone.php', 'PhabricatorSetupIssue' => 'applications/config/issue/PhabricatorSetupIssue.php', @@ -2555,8 +2557,10 @@ phutil_register_library_map(array( 'PhabricatorSettingsPanelSearchPreferences' => 'PhabricatorSettingsPanel', 'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck', 'PhabricatorSetupCheckExtraConfig' => 'PhabricatorSetupCheck', + 'PhabricatorSetupCheckGD' => 'PhabricatorSetupCheck', 'PhabricatorSetupCheckInvalidConfig' => 'PhabricatorSetupCheck', 'PhabricatorSetupCheckMail' => 'PhabricatorSetupCheck', + 'PhabricatorSetupCheckMySQL' => 'PhabricatorSetupCheck', 'PhabricatorSetupCheckStorage' => 'PhabricatorSetupCheck', 'PhabricatorSetupCheckTimezone' => 'PhabricatorSetupCheck', 'PhabricatorSetupIssueView' => 'AphrontView', diff --git a/src/applications/config/check/PhabricatorSetupCheckGD.php b/src/applications/config/check/PhabricatorSetupCheckGD.php new file mode 100644 index 0000000000..3a1fd70c2d --- /dev/null +++ b/src/applications/config/check/PhabricatorSetupCheckGD.php @@ -0,0 +1,48 @@ +newIssue('extension.gd') + ->setName(pht("Missing 'gd' Extension")) + ->setMessage($message); + } else { + $image_type_map = array( + 'imagecreatefrompng' => 'PNG', + 'imagecreatefromgif' => 'GIF', + 'imagecreatefromjpeg' => 'JPEG', + ); + + $have = array(); + foreach ($image_type_map as $function => $image_type) { + if (function_exists($function)) { + $have[] = $image_type; + } + } + + $missing = array_diff($image_type_map, $have); + if ($missing) { + $missing = implode(', ', $missing); + $have = implode(', ', $have); + + $message = pht( + "The 'gd' extension has support for only some image types. ". + "Phabricator will be unable to process images of the missing ". + "types until you build 'gd' with support for them. ". + "Supported types: %s. Missing types: %s.", + $have, + $missing); + + $this->newIssue('extension.gd.support') + ->setName(pht("Partial 'gd' Support")) + ->setMessage($message); + } + } + } +} diff --git a/src/applications/config/check/PhabricatorSetupCheckMySQL.php b/src/applications/config/check/PhabricatorSetupCheckMySQL.php new file mode 100644 index 0000000000..e8de03bb51 --- /dev/null +++ b/src/applications/config/check/PhabricatorSetupCheckMySQL.php @@ -0,0 +1,29 @@ +establishConnection('w'); + + $max_allowed_packet = queryfx_one( + $conn_raw, + 'SHOW VARIABLES LIKE %s', + 'max_allowed_packet'); + $max_allowed_packet = idx($max_allowed_packet, 'Value', PHP_INT_MAX); + + $recommended_minimum = 1024 * 1024; + if ($max_allowed_packet < $recommended_minimum) { + $message = pht( + "MySQL is configured with a very small 'max_allowed_packet' (%d), ". + "which may cause some large writes to fail. Strongly consider raising ". + "this to at least %d in your MySQL configuration.", + $max_allowed_packet, + $recommended_minimum); + + $this->newIssue('mysql.max_allowed_packet') + ->setName(pht('Small MySQL "max_allowed_packet"')) + ->setMessage($message); + } + } + +} diff --git a/src/infrastructure/PhabricatorSetup.php b/src/infrastructure/PhabricatorSetup.php index bae168c521..322a8cdf2e 100644 --- a/src/infrastructure/PhabricatorSetup.php +++ b/src/infrastructure/PhabricatorSetup.php @@ -361,38 +361,6 @@ final class PhabricatorSetup { self::write("[OKAY] Basic configuration OKAY\n"); - $issue_gd_warning = false; - self::writeHeader('GD LIBRARY'); - if (extension_loaded('gd')) { - self::write(" okay Extension 'gd' is loaded.\n"); - $image_type_map = array( - 'imagepng' => 'PNG', - 'imagegif' => 'GIF', - 'imagejpeg' => 'JPEG', - ); - foreach ($image_type_map as $function => $image_type) { - if (function_exists($function)) { - self::write(" okay Support for '{$image_type}' is available.\n"); - } else { - self::write(" warn Support for '{$image_type}' is not available!\n"); - $issue_gd_warning = true; - } - } - } else { - self::write(" warn Extension 'gd' is not loaded.\n"); - $issue_gd_warning = true; - } - - if ($issue_gd_warning) { - self::write( - "[WARN] The 'gd' library is missing or lacks full support. ". - "Phabricator will not be able to generate image thumbnails without ". - "gd.\n"); - } else { - self::write("[OKAY] 'gd' loaded and has full image type support.\n"); - } - - self::writeHeader('FACEBOOK INTEGRATION'); $fb_auth = PhabricatorEnv::getEnvConfig('facebook.auth-enabled'); if (!$fb_auth) { @@ -432,14 +400,6 @@ final class PhabricatorSetup { $conn_pass = $conf->getPassword(); $conn_host = $conf->getHost(); - $timeout = ini_get('mysql.connect_timeout'); - if ($timeout > 5) { - self::writeNote( - "Your MySQL connect timeout is very high ({$timeout} seconds). ". - "Consider reducing it to 5 or below by setting ". - "'mysql.connect_timeout' in your php.ini."); - } - self::write(" okay Trying to connect to MySQL database ". "{$conn_user}@{$conn_host}...\n"); @@ -501,43 +461,6 @@ final class PhabricatorSetup { self::write(" okay Databases have been initialized.\n"); } - $index_min_length = queryfx_one( - $conn_raw, - 'SHOW VARIABLES LIKE %s', - 'ft_min_word_len'); - $index_min_length = idx($index_min_length, 'Value', 4); - if ($index_min_length >= 4) { - self::writeNote( - "MySQL is configured with a 'ft_min_word_len' of 4 or greater, which ". - "means you will not be able to search for 3-letter terms. Consider ". - "setting this in your configuration:\n". - "\n". - " [mysqld]\n". - " ft_min_word_len=3\n". - "\n". - "Then optionally run:\n". - "\n". - " REPAIR TABLE {$namespace}_search.search_documentfield QUICK;\n". - "\n". - "...to reindex existing documents."); - } - - $max_allowed_packet = queryfx_one( - $conn_raw, - 'SHOW VARIABLES LIKE %s', - 'max_allowed_packet'); - $max_allowed_packet = idx($max_allowed_packet, 'Value', PHP_INT_MAX); - - $recommended_minimum = 1024 * 1024; - if ($max_allowed_packet < $recommended_minimum) { - self::writeNote( - "MySQL is configured with a small 'max_allowed_packet' ". - "('{$max_allowed_packet}'), which may cause some large writes to ". - "fail. Consider raising this to at least {$recommended_minimum}."); - } else { - self::write(" okay max_allowed_packet = {$max_allowed_packet}.\n"); - } - self::write("[OKAY] Database and storage configuration OKAY\n"); self::writeHeader('SUCCESS!');