Repository navigation
Conversation
|
Hey @patcon I am interested in this as getting an error in windows using PHP Serialize but not in my mac 'do_unserialize' : undefined_method '[]' for nil:NilClass (NoMethodError)How would the following look leveraging json_encode? def load_configuration
@aliases = PHP.unserialize(`#{@drush} eval 'print serialize(_drush_sitealias_all_list());'`).inject({}) do |h,(k,v)|
if k != '@none'
h[k.sub(/^@/,'')] = v
end
h
end
@normalized_aliases = {}
end |
|
Heyo! def load_configuration
stdout = %x[ #{@drush} eval 'print json_encode(_drush_sitealias_all_list());' ]
@aliases = JSON.parse(stdout).inject({}) do |h,(k,v)|
if k != '@none'
h[k.sub(/^@/,'')] = v
end
h
end
@normalized_aliases = {}
end |
|
Basically just swap:
:) |
|
Untested, but that should... work? |
|
I'm not in a position to test right now but I created a branch based on the one from @patcon with one small change that I think is needed. https://github.com/xforty/drush-deploy/tree/feature/remove-serialize-lib |
|
Ah cool! Just wanted to point out that the function name might be misleading, as it's not really unserializing, right? Or am I missing something? It's decoding a json string into a hash :) |
|
Tested out the feature branch and works great! :) |
|
Wait my bad I wasn't running off of the feature branch since wasn't using bundle exec. Now running with it I get the following error: configuration.rb:34:in 'load_configuration': uninitialized constant Drush Deploy::Configuration::JSON (NameError)I added to drush_deploy.rb: require 'json'and now the error I receive is: common.rb:155:in 'initialize' : A JSON text must at least contain two octets.I think the second error is actually just windows + msysgit again. As when I added require 'json' the script worked on my mac. |
|
Might be odd that it's empty regardless, but Edit: I don't think |
A totally minor thing, but you could probably remove the dep on that lib if you used
drush eval 'print json_encode([...]);'instead of usingphp_serialize()on the PHP array objects :)I see you also use it in a
drush php-scriptcall in databases.rb, but it should be swappable too. Maybe I'm missing something though.