backdrop-contrib / coder_upgrade

Helps automate some/most of the work required to upgrade a module from Drupal to Backdrop 1.x
GNU General Public License v2.0
4 stars 7 forks source link

Values passed into variable_get() that are strings creating unnecessary "dynamic" warnings #56

Closed rbargerhuff closed 3 years ago

rbargerhuff commented 3 years ago

Hello,

We noticed while using coder_upgrade that values passed into variable_get() that contains special characters were being wrapped with single quotes which was ending up as a syntax error due to incorrect conversion. For example:

return variable_get('cas_server_whitelist_failure', t('You do not have permission to login to CAS from this service.'));

While troubleshooting the reason for this, we noticed 2 issues in conversions/call.inc:

First Issue: The variable $raw_value was not being referenced in the preg_match() call which prevented the dynamic warning from being written to the patch file:

// elseif (preg_match('@[\.\s\$\[\]\#\>\(]@', $value)) { elseif (preg_match('@[\.\s\$\[\]\#\>\(]@', $raw_value)) {

Once this was fixed, we noticed that string values that contained a "space" were triggering the dynamic warning so we updated the elseif to account for this:

elseif (!preg_match('@^\'[^\']*\'$@', $raw_value) && preg_match('@[\.\s\$\[\]\#\>\(]@', $raw_value)) {

Cheers!

bugfolder commented 3 years ago

Thanks for finding this (and the fix). Can you submit a PR for it?

rbargerhuff commented 3 years ago

Thanks for finding this (and the fix). Can you submit a PR for it?

You're welcome! Sure thing. Created the Pull Request as requested.