diff --git a/migrations/container/20200106125626_site-command_add_bcmath_config.php b/migrations/container/20200106125626_site-command_add_bcmath_config.php new file mode 100644 index 00000000..f9adf304 --- /dev/null +++ b/migrations/container/20200106125626_site-command_add_bcmath_config.php @@ -0,0 +1,113 @@ +sites = Site::all(); + if ( $this->is_first_execution || ! $this->sites ) { + $this->skip_this_migration = true; + } + } + + /** + * Execute php config updates. + * + * @throws EE\ExitException + */ + public function up() { + + if ( $this->skip_this_migration ) { + EE::debug( 'Skipping add-bcmath-config update migration as it is not needed.' ); + + return; + } + self::$rsp = new RevertableStepProcessor(); + + foreach ( $this->sites as $site ) { + + if ( ! in_array( $site->site_type, [ 'php', 'wp' ], true ) ) { + continue; + } + + if ( '5.6' === $site->php_version ) { + continue; + } + + EE::debug( "Found site: $site->site_url of type: $site->site_type" ); + EE::debug( "Starting add-bcmath-config updates for: $site->site_url" ); + + // Create bcmath config file. + $bcmath_config_file = EE_BACKUP_DIR . '/docker-php-ext-bcmath.ini'; + $this->fs->dumpFile( $bcmath_config_file, 'extension=bcmath.so' ); + + $bcmath_config_site_path = $site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-bcmath.ini'; + + self::$rsp->add_step( + "to-$site->site_url-add-bcmath-config", + 'EE\Migration\SiteContainers::backup_restore', + null, + [ $bcmath_config_file, $bcmath_config_site_path ], + null + ); + } + + if ( ! self::$rsp->execute() ) { + throw new \Exception( 'Unable to run add-bcmath-config upadte migrations.' ); + } + + } + + /** + * Bring back the existing old php config. + * + * @throws EE\ExitException + */ + public function down() { + + if ( $this->skip_this_migration ) { + EE::debug( 'Skipping add-bcmath-config update migration as it is not needed.' ); + + return; + } + self::$rsp = new RevertableStepProcessor(); + + foreach ( $this->sites as $site ) { + + EE::debug( "Reverting add-bcmath-config updates for: $site->site_url" ); + + $bcmath_config_site_path = $site->site_fs_path . '/config/php/php/conf.d/docker-php-ext-bcmath.ini'; + + if ( ! in_array( $site->site_type, [ 'php', 'wp' ], true ) ) { + continue; + } + + if ( '5.6' === $site->php_version ) { + continue; + } + + if ( ! $this->fs->exists( $bcmath_config_site_path ) ) { + continue; + } else { + $this->fs->remove( $bcmath_config_site_path ); + } + } + + if ( ! self::$rsp->execute() ) { + throw new \Exception( 'Unable to revert php add-bcmath-config migrations.' ); + } + } +} diff --git a/templates/config/php-fpm/php70.zip b/templates/config/php-fpm/php70.zip index 1d3955b1..4205b77d 100644 Binary files a/templates/config/php-fpm/php70.zip and b/templates/config/php-fpm/php70.zip differ diff --git a/templates/config/php-fpm/php72.zip b/templates/config/php-fpm/php72.zip index 76cde46f..6bb7e01b 100644 Binary files a/templates/config/php-fpm/php72.zip and b/templates/config/php-fpm/php72.zip differ diff --git a/templates/config/php-fpm/php73.zip b/templates/config/php-fpm/php73.zip index 0fdd61f6..f4e0377f 100644 Binary files a/templates/config/php-fpm/php73.zip and b/templates/config/php-fpm/php73.zip differ diff --git a/templates/config/php-fpm/php74.zip b/templates/config/php-fpm/php74.zip index 4f8512f7..061006df 100644 Binary files a/templates/config/php-fpm/php74.zip and b/templates/config/php-fpm/php74.zip differ