Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Resolves #207
Browse files Browse the repository at this point in the history
Signed-off-by: Jason McCallister <jason@craftcms.com>
  • Loading branch information
jasonmccallister committed Sep 14, 2020
1 parent 343b676 commit 7e8879c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

## Fixed
- An issue causing `php iniset memory_limit` to not show as an available command.
- An issue where `php iniset` commands we not setting the correct values. ([#207](https://github.com/craftcms/nitro/issues/207))

### 1.0.1 - 2020-08-12

Expand Down
2 changes: 1 addition & 1 deletion internal/nitrod/iniset.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *NitroService) PhpIniSettings(ctx context.Context, request *ChangePhpIni
}

// change setting using sed
if output, err := s.command.Run("sed", []string{"-i", "s|" + setting + "|" + setting + " = " + value + "|g", "/etc/php/" + version + "/fpm/php.ini"}); err != nil {
if output, err := s.command.Run("sed", []string{"-i", "/" + setting + `/c\` + setting + " = " + value, "/etc/php/" + version + "/fpm/php.ini"}); err != nil {
s.logger.Println("error changing ini setting, error:", err)
s.logger.Println("output:", string(output))
return nil, status.Errorf(codes.Unknown, string(output))
Expand Down
14 changes: 7 additions & 7 deletions internal/nitrod/initset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|memory_limit|memory_limit = 512M|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/memory_limit/c\memory_limit = 512M`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand All @@ -61,7 +61,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|max_file_uploads|max_file_uploads = 400|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/max_file_uploads/c\max_file_uploads = 400`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand All @@ -82,7 +82,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|max_input_time|max_input_time = 4000|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/max_input_time/c\max_input_time = 4000`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand All @@ -103,7 +103,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|upload_max_filesize|upload_max_filesize = 10M|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/upload_max_filesize/c\upload_max_filesize = 10M`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand All @@ -124,7 +124,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|upload_max_filesize|upload_max_filesize = 10M|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/upload_max_filesize/c\upload_max_filesize = 10M`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand All @@ -145,7 +145,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|max_input_vars|max_input_vars = 1000|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/max_input_vars/c\max_input_vars = 1000`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestNitrodService_PhpIniSettings(t *testing.T) {
wantCommands: []string{"sed", "service"},
wantArgs: []map[string][]string{
{
"sed": {"-i", "s|max_execution_time|max_execution_time = 300|g", "/etc/php/7.4/fpm/php.ini"},
"sed": {"-i", `/max_execution_time/c\max_execution_time = 300`, "/etc/php/7.4/fpm/php.ini"},
},
{
"service": {"php7.4-fpm", "restart"},
Expand Down

0 comments on commit 7e8879c

Please # to comment.