Added comments to missing table civicrm_mailing_abtest in 4.6.alpha1.mysql.tpl
[civicrm-core.git] / CRM / Upgrade / Form.php
index 44256e2e51fc2571b8a2847475b54f69a74eeb66..6f40d682b11509b36aee97abb9edc4f3f8c4a56b 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -82,13 +82,15 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
    * We should not use QuickForm directly. This class provides a lot
    * of default convenient functions, rules and buttons
    *
-   * @param object $state State associated with this form
+   * @param object $state
+   *   State associated with this form.
    * @param \const|\enum $action The mode the form is operating in (None/Create/View/Update/Delete)
-   * @param string $method The type of http method used (GET/POST)
-   * @param string $name The name of the form if different from class name
+   * @param string $method
+   *   The type of http method used (GET/POST).
+   * @param string $name
+   *   The name of the form if different from class name.
    *
    * @return \CRM_Core_Form
-  @access public
    */
   /**
    * @param null|object $state
@@ -96,10 +98,11 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
    * @param string $method
    * @param null|string $name
    */
-  function __construct($state = NULL,
+  public function __construct(
+    $state = NULL,
     $action = CRM_Core_Action::NONE,
     $method = 'post',
-    $name   = NULL
+    $name = NULL
   ) {
     $this->_config = CRM_Core_Config::singleton();
 
@@ -357,11 +360,10 @@ SET    version = '$version'
 
     // sample test list
     /*         $revList = array(
-      '2.1.0', '2.2.beta2', '2.2.beta1', '2.2.alpha1', */
+    '2.1.0', '2.2.beta2', '2.2.beta1', '2.2.alpha1', */
 
     /*                          '2.2.alpha3', '2.2.0', '2.2.2', '2.1.alpha1', '2.1.3'); */
 
-
     usort($revList, 'version_compare');
     return $revList;
   }
@@ -414,8 +416,10 @@ SET    version = '$version'
   public function processSQL($rev) {
     $sqlFile = implode(DIRECTORY_SEPARATOR,
       array(
-        dirname(__FILE__), 'Incremental',
-        'sql', $rev . '.mysql',
+        dirname(__FILE__),
+        'Incremental',
+        'sql',
+        $rev . '.mysql',
       )
     );
     $tplFile = "$sqlFile.tpl";
@@ -438,7 +442,7 @@ SET    version = '$version'
    */
   public function getUpgradeVersions() {
     $latestVer = CRM_Utils_System::version();
-    $currentVer = CRM_Core_BAO_Domain::version(true);
+    $currentVer = CRM_Core_BAO_Domain::version(TRUE);
     if (!$currentVer) {
       CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
     }
@@ -495,23 +499,23 @@ SET    version = '$version'
     $minPhpVersion = '5.3.3';
     if (version_compare($phpVersion, $minPhpVersion) < 0) {
       $error = ts('CiviCRM %3 requires PHP version %1 (or newer), but the current system uses %2 ',
-               array(
-                 1 => $minPhpVersion,
-                 2 => $phpVersion,
-                 3 => $latestVer
-               ));
+        array(
+          1 => $minPhpVersion,
+          2 => $phpVersion,
+          3 => $latestVer,
+        ));
     }
 
     // check for mysql trigger privileges
     if (!CRM_Core_DAO::checkTriggerViewPermission(FALSE, TRUE)) {
       $error = ts('CiviCRM %1 requires MySQL trigger privileges.',
-               array(1 => $latestVer));
+        array(1 => $latestVer));
     }
 
-    if (CRM_Core_DAO::getGlobalSetting('thread_stack', 0) < (1024*self::MINIMUM_THREAD_STACK)) {
+    if (CRM_Core_DAO::getGlobalSetting('thread_stack', 0) < (1024 * self::MINIMUM_THREAD_STACK)) {
       $error = ts('CiviCRM %1 requires MySQL thread stack >= %2k', array(
         1 => $latestVer,
-        2 => self::MINIMUM_THREAD_STACK
+        2 => self::MINIMUM_THREAD_STACK,
       ));
     }
 
@@ -545,9 +549,12 @@ SET    version = '$version'
   /**
    * Fill the queue with upgrade tasks
    *
-   * @param $currentVer string, the original revision
-   * @param $latestVer string, the target (final) revision
-   * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
+   * @param string $currentVer
+   *   the original revision.
+   * @param string $latestVer
+   *   the target (final) revision.
+   * @param string $postUpgradeMessageFile
+   *   path of a modifiable file which lists the post-upgrade messages.
    *
    * @return CRM_Queue
    */
@@ -565,17 +572,17 @@ SET    version = '$version'
       CRM_Core_Error::fatal(ts('Failed to find or create queueing table'));
     }
     $queue = CRM_Queue_Service::singleton()->create(array(
-        'name' => self::QUEUE_NAME,
-        'type' => 'Sql',
-        'reset' => TRUE,
-      ));
+      'name' => self::QUEUE_NAME,
+      'type' => 'Sql',
+      'reset' => TRUE,
+    ));
 
     $revisions = $upgrade->getRevisionSequence();
     foreach ($revisions as $rev) {
       // proceed only if $currentVer < $rev
       if (version_compare($currentVer, $rev) < 0) {
         $beginTask = new CRM_Queue_Task(
-          // callback
+        // callback
           array('CRM_Upgrade_Form', 'doIncrementalUpgradeStart'),
           // arguments
           array($rev),
@@ -584,7 +591,7 @@ SET    version = '$version'
         $queue->createItem($beginTask);
 
         $task = new CRM_Queue_Task(
-          // callback
+        // callback
           array('CRM_Upgrade_Form', 'doIncrementalUpgradeStep'),
           // arguments
           array($rev, $currentVer, $latestVer, $postUpgradeMessageFile),
@@ -593,7 +600,7 @@ SET    version = '$version'
         $queue->createItem($task);
 
         $task = new CRM_Queue_Task(
-          // callback
+        // callback
           array('CRM_Upgrade_Form', 'doIncrementalUpgradeFinish'),
           // arguments
           array($rev, $currentVer, $latestVer, $postUpgradeMessageFile),
@@ -610,7 +617,8 @@ SET    version = '$version'
    * Perform an incremental version update
    *
    * @param CRM_Queue_TaskContext $ctx
-   * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1'
+   * @param string $rev
+   *   the target (intermediate) revision e.g '3.2.alpha1'.
    *
    * @return bool
    */
@@ -628,14 +636,18 @@ SET    version = '$version'
    * Perform an incremental version update
    *
    * @param CRM_Queue_TaskContext $ctx
-   * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1'
-   * @param $originalVer string, the original revision
-   * @param $latestVer string, the target (final) revision
-   * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
+   * @param string $rev
+   *   the target (intermediate) revision e.g '3.2.alpha1'.
+   * @param string $originalVer
+   *   the original revision.
+   * @param string $latestVer
+   *   the target (final) revision.
+   * @param string $postUpgradeMessageFile
+   *   path of a modifiable file which lists the post-upgrade messages.
    *
    * @return bool
    */
-  public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext$ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) {
+  public static function doIncrementalUpgradeStep(CRM_Queue_TaskContext $ctx, $rev, $originalVer, $latestVer, $postUpgradeMessageFile) {
     $upgrade = new CRM_Upgrade_Form();
 
     $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
@@ -645,7 +657,10 @@ SET    version = '$version'
     // pre-db check for major release.
     if ($upgrade->checkVersionRelease($rev, 'alpha1')) {
       if (!(is_callable(array(
-        $versionObject, 'verifyPreDBstate')))) {
+        $versionObject,
+        'verifyPreDBstate',
+      )))
+      ) {
         CRM_Core_Error::fatal("verifyPreDBstate method was not found for $rev");
       }
 
@@ -662,7 +677,9 @@ SET    version = '$version'
     $upgrade->setSchemaStructureTables($rev);
 
     if (is_callable(array(
-      $versionObject, $phpFunctionName))) {
+      $versionObject,
+      $phpFunctionName,
+    ))) {
       $versionObject->$phpFunctionName($rev, $originalVer, $latestVer);
     }
     else {
@@ -671,11 +688,14 @@ SET    version = '$version'
 
     // set post-upgrade-message if any
     if (is_callable(array(
-      $versionObject, 'setPostUpgradeMessage'))) {
+      $versionObject,
+      'setPostUpgradeMessage',
+    ))) {
       $postUpgradeMessage = file_get_contents($postUpgradeMessageFile);
       $versionObject->setPostUpgradeMessage($postUpgradeMessage, $rev);
       file_put_contents($postUpgradeMessageFile, $postUpgradeMessage);
-    } else {
+    }
+    else {
       $postUpgradeMessage = file_get_contents($postUpgradeMessageFile);
       CRM_Upgrade_Incremental_Legacy::setPostUpgradeMessage($postUpgradeMessage, $rev);
       file_put_contents($postUpgradeMessageFile, $postUpgradeMessage);
@@ -688,10 +708,14 @@ SET    version = '$version'
    * Perform an incremental version update
    *
    * @param CRM_Queue_TaskContext $ctx
-   * @param $rev string, the target (intermediate) revision e.g '3.2.alpha1'
-   * @param $currentVer string, the original revision
-   * @param $latestVer string, the target (final) revision
-   * @param $postUpgradeMessageFile string, path of a modifiable file which lists the post-upgrade messages
+   * @param string $rev
+   *   the target (intermediate) revision e.g '3.2.alpha1'.
+   * @param string $currentVer
+   *   the original revision.
+   * @param string $latestVer
+   *   the target (final) revision.
+   * @param string $postUpgradeMessageFile
+   *   path of a modifiable file which lists the post-upgrade messages.
    *
    * @return bool
    */
@@ -735,7 +759,8 @@ SET    version = '$version'
    * by calling the 'setPreUpgradeMessage' on each incremental upgrade
    * object.
    *
-   * @param $preUpgradeMessage string, alterable
+   * @param string $preUpgradeMessage
+   *   alterable.
    * @param $currentVer
    * @param $latestVer
    */
@@ -751,11 +776,14 @@ SET    version = '$version'
         version_compare($rev, '3.2.alpha1') > 0
       ) {
         $versionObject = $this->incrementalPhpObject($rev);
-         if (is_callable(array(
-          $versionObject, 'setPreUpgradeMessage'))) {
-           $versionObject->setPreUpgradeMessage($preUpgradeMessage, $rev, $currentVer);
-         }
+        if (is_callable(array(
+          $versionObject,
+          'setPreUpgradeMessage',
+        ))) {
+          $versionObject->setPreUpgradeMessage($preUpgradeMessage, $rev, $currentVer);
+        }
       }
     }
   }
+
 }