Hello,

We have this errors repeated every time a user visits a form:

The function include_once() (civicrm.settings.php:549) called deprecated function variable_get(). It will be removed in the next major release of Backdrop.

The function _webform2pdf_init_tcpdf() (webform2pdf.theme.inc:31) called deprecated function variable_get(). It will be removed in the next major release of Backdrop

I will appreciate any advice.

 

Thanks!  

Andrés

Accepted answer

There's a new release of Web2PDF that should address that part of the problem.

For the CiviCRM error, the conditional call to check the existence of variable_get is unnecessary because clean_url is in system.core from the outset in Backdrop. So you can just remove that check from your civicrm.settings.php file, i.e., change the code I quoted above to

if (!defined('CIVICRM_CLEANURL')) {
  if ( function_exists('config_get') && config_get('system.core', 'clean_url') != 0) {
    define('CIVICRM_CLEANURL', 1 );
  }
  elseif( function_exists('get_option') && get_option('permalink_structure') != '' ) {
    define('CIVICRM_CLEANURL', 1 );
  }
  else {
    define('CIVICRM_CLEANURL', 0);
  }
}

Most helpful answers

That looks like a new and different issue with the Webform2PDF module, and seems to be following logic that depends in part on the webform email settings.

Do you by any chance have the ability to use a debugger on this, and/or make test changes in a development environment, or is this a live/production site?

Hi Andrés,

You can post an issue in the issue queue for Webform2PDF (at https://github.com/backdrop-contrib/webform2pdf/issues/) — although, since I'm the maintainer, I've now seen this and will have a bugfix release out very soon that addresses it!

The CiviCRM one is a bit harder to track down, because the civicrm.settings.php file is generated during installation and can be modified. Could you quote the lines around line 549 of civicrm.settings.php, so we can see what variable is being called?

Comments

bugfolder's picture

Hi Andrés,

You can post an issue in the issue queue for Webform2PDF (at https://github.com/backdrop-contrib/webform2pdf/issues/) — although, since I'm the maintainer, I've now seen this and will have a bugfix release out very soon that addresses it!

The CiviCRM one is a bit harder to track down, because the civicrm.settings.php file is generated during installation and can be modified. Could you quote the lines around line 549 of civicrm.settings.php, so we can see what variable is being called?

bugfolder's picture

Guessing that it's this (?):

if (!defined('CIVICRM_CLEANURL')) {
  if ( function_exists('variable_get') && variable_get('clean_url', '0') != '0') {
    define('CIVICRM_CLEANURL', 1 );
  }
  elseif ( function_exists('config_get') && config_get('system.core', 'clean_url') != 0) {
    define('CIVICRM_CLEANURL', 1 );
  }
  elseif( function_exists('get_option') && get_option('permalink_structure') != '' ) {
    define('CIVICRM_CLEANURL', 1 );
  }
  else {
    define('CIVICRM_CLEANURL', 0);
  }
}

Hello!

Thanks for your responses.

Yes, these are the lines involved in the problem. It seems an issue with clean URLs.

Andrés

 

bugfolder's picture

There's a new release of Web2PDF that should address that part of the problem.

For the CiviCRM error, the conditional call to check the existence of variable_get is unnecessary because clean_url is in system.core from the outset in Backdrop. So you can just remove that check from your civicrm.settings.php file, i.e., change the code I quoted above to

if (!defined('CIVICRM_CLEANURL')) {
  if ( function_exists('config_get') && config_get('system.core', 'clean_url') != 0) {
    define('CIVICRM_CLEANURL', 1 );
  }
  elseif( function_exists('get_option') && get_option('permalink_structure') != '' ) {
    define('CIVICRM_CLEANURL', 1 );
  }
  else {
    define('CIVICRM_CLEANURL', 0);
  }
}

Thanks! It was very helpful!

The problem appears to be solved with the change proposed in civicrm.settings.php.

But after updating the module I've seen php warnings when sending a form:

Warning: array_map(): Expected parameter 2 to be an array, null given in array_map() (line 25 of ...public_html/modules/webform2pdf/includes/webform2pdf.mail.inc).

Warning: array_merge(): Expected parameter 2 to be an array, null given in array_merge() (line 24 of ...public_html/modules/webform2pdf/includes/webform2pdf.mail.inc).

Notice: Undefined index: value in webform2pdf_send2pdf() (line 19 of .../public_html/modules/webform2pdf/includes/webform2pdf.mail.inc).

Regards,

Andrés

bugfolder's picture

That looks like a new and different issue with the Webform2PDF module, and seems to be following logic that depends in part on the webform email settings.

Do you by any chance have the ability to use a debugger on this, and/or make test changes in a development environment, or is this a live/production site?

Hello!

Thank you for your responses!

Yes, this is a live site, but I can make a copy and test it in a development environment.

Regards,

Andrés

   

 

 

bugfolder's picture

I can make a copy and test it in a development environment.

Let's do that, then. Please install and enable the Devel module, go to Permissions and give all roles "Access developer information" permission (ONLY on the dev site, of course!).

Then try replacing function webform2pdf_send2pdf() with this instrumented version and repeat the form submission that was causing the notice:

function webform2pdf_send2pdf($node, $submission) {
  $webform2pdf = _webform2pdf_get_template($node->nid);
  $nopdf = array();
  if (isset($webform2pdf['enabled']) && $webform2pdf['enabled'] && $webform2pdf['pdf_send_email']) {
    $no_mail = isset($webform2pdf['no_send_email_addr']) ? $webform2pdf['no_send_email_addr'] : FALSE;
dpm($no_mail,'$no_mail');
    if (is_array($no_mail)) {
      $no_mail = array_diff($no_mail, array(0));
      if ( !empty($no_mail) ) {
        foreach ($no_mail as $eid) {
          $email_addresses = $node->webform['emails'][$eid]['email'];
dpm($eid,'$eid');
dpm($email_addresses,'$email_addresses');
          if ( isset($node->webform['components'][$email_addresses]) ) {
            $email_addresses = $submission->data[$eid]['value'];
          }
          else {
            $email_addresses = array_filter(explode(',', check_plain($node->webform['emails'][$eid]['email'])));
          }
          $nopdf = array_merge($nopdf, $email_addresses);
dpm($nopdf,'$nopdf (1)');
          $nopdf = array_map("trim", $nopdf);
dpm($nopdf,'$nopdf (2)');
        }
      }
    }

    // Check for a multi-page form that is not yet complete.
    return array('nid' => $node->nid, 'sid' => $submission->sid, 'nopdf' => $nopdf);
  }
}

Hello!

I could make a backup and try the changes in a development copy of the site.

I changed the function to the new version and observed only the following errors:

The line 39 shows:

dpm($no_mail,'$no_mail');

Regards,

Andrés