Guest User

Untitled

a guest
Jul 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. --- a/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Migration.php
  2. +++ b/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Migration.php
  3. @@ -225,10 +225,16 @@ class Doctrine_Migration
  4. */
  5. public function setCurrentVersion($number)
  6. {
  7. - if ($this->hasMigrated()) {
  8. - $this->_connection->exec("UPDATE " . $this->_migrationTableName . " SET version = $number");
  9. - } else {
  10. - $this->_connection->exec("INSERT INTO " . $this->_migrationTableName . " (version) VALUES ($number)");
  11. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  12. + try {
  13. + $this->_connection = $conn;
  14. + if ($this->hasMigrated()) {
  15. + $conn->exec("UPDATE " . $this->_migrationTableName . " SET version = $number");
  16. + } else {
  17. + $conn->exec("INSERT INTO " . $this->_migrationTableName . " (version) VALUES ($number)");
  18. + }
  19. + } catch (Exception $e) {
  20. + }
  21. }
  22. }
  23.  
  24. @@ -241,9 +247,17 @@ class Doctrine_Migration
  25. {
  26. $this->_createMigrationTable();
  27.  
  28. - $result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationTableName);
  29. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  30. + try {
  31. + $result = $conn->fetchColumn("SELECT version FROM " . $this->_migrationTableName);
  32. + if (isset($result[0])) {
  33. + return $result[0];
  34. + }
  35. + } catch (Exception $e) {
  36. + }
  37. + }
  38.  
  39. - return isset($result[0]) ? $result[0]:0;
  40. + return 0;
  41. }
  42.  
  43. /**
  44. @@ -255,9 +269,17 @@ class Doctrine_Migration
  45. {
  46. $this->_createMigrationTable();
  47.  
  48. - $result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationTableName);
  49. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  50. + try {
  51. + $result = $conn->fetchColumn("SELECT version FROM " . $this->_migrationTableName);
  52. + if (isset($result[0])) {
  53. + return true;
  54. + }
  55. + } catch (Exception $e) {
  56. + }
  57. + }
  58.  
  59. - return isset($result[0]) ? true:false;
  60. + return false;
  61. }
  62.  
  63. /**
  64. @@ -316,7 +338,9 @@ class Doctrine_Migration
  65.  
  66. $this->_createMigrationTable();
  67.  
  68. - $this->_connection->beginTransaction();
  69. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  70. + $conn->beginTransaction();
  71. + }
  72.  
  73. try {
  74. // If nothing specified then lets assume we are migrating from
  75. @@ -331,7 +355,9 @@ class Doctrine_Migration
  76. }
  77.  
  78. if ($this->hasErrors()) {
  79. - $this->_connection->rollback();
  80. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  81. + $conn->rollback();
  82. + }
  83.  
  84. if ($dryRun) {
  85. return false;
  86. @@ -340,14 +366,18 @@ class Doctrine_Migration
  87. }
  88. } else {
  89. if ($dryRun) {
  90. - $this->_connection->rollback();
  91. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  92. + $conn->rollback();
  93. + }
  94. if ($this->hasErrors()) {
  95. return false;
  96. } else {
  97. return $to;
  98. }
  99. } else {
  100. - $this->_connection->commit();
  101. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  102. + $conn->commit();
  103. + }
  104. $this->setCurrentVersion($to);
  105. return $to;
  106. }
  107. @@ -500,6 +530,9 @@ class Doctrine_Migration
  108. try {
  109. $migration = $this->getMigrationClass($num);
  110.  
  111. + $conn = $this->getConnection();
  112. + $this->setConnection($migration->getConnection());
  113. +
  114. $method = 'pre' . $direction;
  115. $migration->$method();
  116.  
  117. @@ -531,6 +564,8 @@ class Doctrine_Migration
  118.  
  119. $method = 'post' . $direction;
  120. $migration->$method();
  121. +
  122. + $this->setConnection($conn);
  123. } catch (Exception $e) {
  124. $this->addError($e);
  125. }
  126. @@ -551,12 +586,13 @@ class Doctrine_Migration
  127.  
  128. $this->_migrationTableCreated = true;
  129.  
  130. - try {
  131. - $this->_connection->export->createTable($this->_migrationTableName, array('version' => array('type' => 'integer', 'size' => 11)));
  132. -
  133. - return true;
  134. - } catch(Exception $e) {
  135. - return false;
  136. + foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) {
  137. + try {
  138. + $conn->export->createTable($this->_migrationTableName, array('version' => array('type' => 'integer', 'size' => 11)));
  139. + } catch (Exception $e) {
  140. + }
  141. }
  142. +
  143. + return true;
  144. }
  145. }
Add Comment
Please, Sign In to add comment