Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zend_Config_Yaml broken #20

Closed
blinktag opened this issue Oct 4, 2019 · 6 comments
Closed

Zend_Config_Yaml broken #20

blinktag opened this issue Oct 4, 2019 · 6 comments

Comments

@blinktag
Copy link

blinktag commented Oct 4, 2019

3e9b26c#diff-9235a8f0d83484e2adcf78f7ebffe2caL292

This change broke Zend_Config_Yaml because the class was using the internal array pointer to handle the loop's search space with each() and prev(). Since PHP7 foreach no longer respects the internal array pointer, so adding next() in the loop wouldn't help either

I have attempted my best at solving this issue by using array_slice() to handle the loop's search space in https://gist.github.com/blinktag/b2757d9f20177237b21b0270436b6009

It now correctly handles the following yaml:

development:
  maindb:
    default:  true
    host:     data.server.com.local
    username: db_user
    password: -
    dbname:   db_development
    adapter:  pdo_mysql
    profiler:
      enabled: true
      class: Zend_Db_Profiler

However it duplicates maindb's sub-values in the root of the config object, and I haven't been able to figure this part out:

$database_config = new Zend_Config_Yaml('database.yml', APPLICATION_ENV);
dump($database_config);

Zend_Config_Yaml {#17 ▼
  #_skipExtends: false
  #_yamlDecoder: array:2 [▶]
  #_allowModifications: false
  #_index: 0
  #_count: 10
  #_data: array:10 [▼
    "maindb" => Zend_Config {#18 ▼
      #_allowModifications: false
      #_index: 0
      #_count: 9
      #_data: array:9 [▼
        "default" => true
        "host" => "data.server.com.local"
        "username" => "db_user"
        "password" => "-"
        "dbname" => "db_development"
        "adapter" => "pdo_mysql"
        "profiler" => Zend_Config {#20 ▶}
        "enabled" => true
        "class" => "Zend_Db_Profiler"
      ]
      #_skipNextIteration: null
      #_loadedSection: null
      #_extends: []
      #_loadFileErrorStr: null
    }
    "default" => true
    "host" => "data.server.com.local"
    "username" => "db_user"
    "password" => "-"
    "dbname" => "db_development"
    "adapter" => "pdo_mysql"
    "profiler" => Zend_Config {#21 ▶}
    "enabled" => true
    "class" => "Zend_Db_Profiler"
  ]
  #_skipNextIteration: null
  #_loadedSection: "development"
  #_extends: []
  #_loadFileErrorStr: null
}

Perhaps someone with better recursion skills can take a look at this

@Shardj
Copy link
Owner

Shardj commented Oct 4, 2019

Thanks I'll take a look

@Shardj
Copy link
Owner

Shardj commented Oct 4, 2019

b74c432

Should be fixed

@Shardj Shardj closed this as completed Oct 4, 2019
@blinktag
Copy link
Author

blinktag commented Oct 4, 2019

Thanks for the quick turnaround! Seems to still be borked when dealing with multiple subkeys.

Example:

development:
  maindb:
    default:  true
    host:     data.server.com.local
    username: db_user
    password: -
    dbname:   db_development
    adapter:  pdo_mysql
    profiler:
      enabled: true
      class: Zend_Db_Profiler
  otherdb:
    default:  true
    host:     data.server.com.local
    username: db_user
    password: -
    dbname:   other_development
    adapter:  pdo_mysql

Will return only

Zend_Config_Yaml {#21 ▼
  #_skipExtends: false
  #_yamlDecoder: array:2 [▶]
  #_allowModifications: false
  #_index: 0
  #_count: 1
  #_data: array:1 [▼
    "maindb" => Zend_Config {#26 ▼
      #_allowModifications: false
      #_index: 0
      #_count: 7
      #_data: array:7 [▼
        "default" => true
        "host" => "data.server.com.local"
        "username" => "db_user"
        "password" => "-"
        "dbname" => "db_development"
        "adapter" => "pdo_mysql"
        "profiler" => Zend_Config {#25 ▶}
      ]
      #_skipNextIteration: null
      #_loadedSection: null
      #_extends: []
      #_loadFileErrorStr: null
    }
  ]
  #_skipNextIteration: null
  #_loadedSection: "development"
  #_extends: []
  #_loadFileErrorStr: null
}

It ignores otherdb and any other subkeys after the first subkey for some reason

@blinktag
Copy link
Author

blinktag commented Oct 4, 2019

Figured it out. removing the reference for $lines in the signature of _decodeYaml() fixes this issue

@Shardj Shardj reopened this Oct 4, 2019
@Shardj
Copy link
Owner

Shardj commented Oct 4, 2019

I'll sort it out on Monday, or make a pull request and I might see it and accept it before Monday

@blinktag
Copy link
Author

blinktag commented Oct 4, 2019

#21

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants