puppetlabs-apache
puppetlabs-apache copied to clipboard
Fix deprecation warning about performing a regex comparison on a hash
I'm getting warnings like this for each puppet agent run:
templates/vhost/_require.erb:3: warning: deprecated Object#=~ is called on Hash; it always returns nil
This PR changes the logic to only performing the regex comparison when the requires value is a string.
Don't you have the same problem on line 24?
Hmm, good question. Here's line 24:
<%- if !(_item['require'] && _item['require'] != '') && _item['require'] !~ /unmanaged/i && !(_item['auth_require']) -%>
When _item['require'] is a hash, !(_item['require'] && _item['require'] != '') evaluates to false, so the other clauses are not evaluated, and thus it doesn't emit the "deprecated Object#=~ is called on Hash" warning.
@ekohl Are you good with the above explanation?? ^^^
If my logic there is correct, I think we don't need to modify it now.
Just to clarify: if _require is nil then it does nil !~ /unmanaged/i, but that doesn't raise any deprecation warning.
Submitted my suggestion as a separate PR: https://github.com/puppetlabs/puppetlabs-apache/pull/2303
Ok, everything looks good to merge then Thanks for putting in the work