puppetlabs-apache icon indicating copy to clipboard operation
puppetlabs-apache copied to clipboard

Fix deprecation warning about performing a regex comparison on a hash

Open smokris opened this issue 3 years ago • 1 comments

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.

smokris avatar Aug 11 '22 20:08 smokris

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.

smokris avatar Aug 14 '22 02:08 smokris

@ekohl Are you good with the above explanation?? ^^^

david22swan avatar Sep 05 '22 10:09 david22swan

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

ekohl avatar Sep 07 '22 11:09 ekohl

Ok, everything looks good to merge then Thanks for putting in the work

david22swan avatar Sep 08 '22 08:09 david22swan