Development

Changeset 22882

You must first sign up to be able to contribute.

Changeset 22882

Show
Ignore:
Timestamp:
10/08/09 19:44:39 (4 years ago)
Author:
boutell
Message:

Significant bug fix: the default environment was used on the local end of the connection, not the environment specified.
This has been corrected. Also, we reuse the mysql-load and mysql-dump tasks locally as well as remotely.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfSyncContentPlugin/trunk/README

    r22583 r22882  
    8383== Changelog == 
    8484 
    85 * Version 0.9 (still not yet packaged) has been rewritten to use 
     85* Version 0.9.1 corrects a bug in version 0.9 which caused the default environment to be used 
     86rather than the specified environment on the local end of the connection. The correct environment 
     87was used on the remote end. This is a significant bug fix and you should upgrade immediately if you 
     88are using version 0.9. 
     89 
     90Also, the code has been refactored to reuse the mysql-load and mysql-dump tasks locally as well as 
     91remotely, removing redundant code and the potential for problems like the bug fix mentioned above. 
     92 
     93* Version 0.9 has been rewritten to use 
    8694sfDatabaseManager and remote dumping and loading tasks to eliminate 
    8795extra ssh connections and allow the use of any databases.yml file 
  • plugins/sfSyncContentPlugin/trunk/lib/task/synccontentTask.class.php

    r22583 r22882  
    2222        sfCommandArgument::REQUIRED,  
    2323        'The application name ("frontend")'), 
    24       new sfCommandArgument('localenv',  
     24      new sfCommandArgument('env',  
    2525        sfCommandArgument::REQUIRED,  
    2626        'The local environment ("dev")'), 
     
    9090    } 
    9191 
    92     if (!preg_match('/^(\w+)(:(\w+))?$/', $args['localenv'], $matches)) 
     92    if (!preg_match('/^(\w+)(:(\w+))?$/', $args['env'], $matches)) 
    9393    { 
    9494      throw new sfException("Second argument must be an environment name. Example #1: dev Example #2: prod"); 
     
    103103    } 
    104104     
    105     // Drastic simplification due to the new sfDatabaseManager-based approach and 
    106     // the remote dump and load tasks 
    107      
    108     $params = sfSyncContentTools::shellDatabaseParams(sfSyncContentTools::getDatabaseParams($this->configuration)); 
    109  
     105    $binary = $_SERVER['SCRIPT_FILENAME']; 
     106    // A further simplification: use the subsidiary tasks locally too. This resolves issues with the 
     107    // correct environment not being loaded and removes duplicate code 
    110108    if ($direction == 'to') 
    111109    { 
    112       $cmd = "mysqldump --skip-opt --add-drop-table --create-options " . 
    113         "--disable-keys --extended-insert --set-charset $params | " . $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-load --application=$application --env=$envRemote"); 
     110      $cmd = "$binary project:mysql-dump --application=$application --env=$env | " . $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-load --application=$application --env=$envRemote"); 
    114111      $this->_content_sync_system($cmd); 
    115112    } 
    116113    else 
    117114    { 
    118       $cmd = $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-dump --application=$application --env=$envRemote") . " | mysql $params ";  
     115      $cmd = $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-dump --application=$application --env=$envRemote") . " | $binary project:mysql-load --application=$application --env=$env"; 
    119116      $this->_content_sync_system($cmd); 
    120117    } 
     
    146143    $port = $this->sshPort; 
    147144    $this->_content_sync_system("rsync -e 'ssh -p $port' -azC --no-o --no-t --no-p --force --delete --progress " . escapeshellarg($path1) . " " . escapeshellarg($path2)); 
    148   } 
    149  
    150   function _content_sync_format_db_credentials($dbData) 
    151   { 
    152     return "--user=" . escapeshellarg($dbData['user']) .  
    153       " --password=" .  escapeshellarg($dbData['password']) .  
    154       " -h " . escapeshellarg($dbData['host']) . 
    155       " " . $dbData['database']; 
    156145  } 
    157146