# Question
Title: Upgrading CiviCRM that is set up outside of the Drupal docroot with symlinks
I am finally upgrading the CiviCRM on a website I didn't develop. It is running on Drupal 7.50, (upgraded from 7.37), and is currently version 4.3.8. Planning to upgrade to 4.7.13.

Here's the thing: it was set up outside of the Drupal docroot, using symlinks and some other setting changes. It works, but it's more complex than the usual setup. Due to the already heavy nature of our Drupal site, it is my understanding that this setup would help with performance issues. I want to both upgrade it and move it into the Drupal sites/all/modules directory.

Aside from the usual steps to perform the upgrade up so many versions, I wanted to see if anyone could anticipate any upgrade problems I might have and evaluate my plan outlined below to complete the upgrade, due to this unique situation? Let me know if this is out of the scope of this forum, and I'll remove it, though it might be helpful if someone else finds themselves in the same boat. I am going to try these steps out on a dev copy before attempting it on production.

**The Setup:**

CiviCRM root is in /var/www/html along with our Drupal Docroot, and all components are as such:

* CiviCRM Home: `/var/www/html/civicrm/v.4.3.8-d7`
* Drupal Home: `/var/www/html/drupal/docroot`
* CiviCRM Settings: `<drupal home>/sites/default/civicrm.settings.php`
* CiviCRM Files: `<drupal home>/sites/default/files/civicrm`
* Symlink to Codebase: `<drupal home>/sites/all/modules/civicrm -> <civicrm root>/v.4.3.8-d7`
* Settings\_Location.php: `<civicrm home>/v.4.3.8-d7/settings_location.php`

```
   define( 'CIVICRM_CONFDIR', '/var/www/html/drupal/docroot/sites' );

```

**The Plan:**

* Back up the Drupal and CiviCRM codebase and database into '/var/www/html/backups'
* Login to Drupal site and put website into maintenance mode; stay logged in
* Disable Drupal CiviCRM integration modules
* \*Delete symlink in `<drupal home>/sites/all/modules`
* Make the `<drupal home>/sites/default` directory writeable to the server
* Download and unpack v4.7.13 to `<drupal home>/sites/all/modules`
* Backup and move civicrm.settings.php file
* Clear browser cache and all files in `<drupal home>/sites/default/files/civicrm/templates_c/`
* Run the install: `http://<drupal home>/civicrm/upgrade?reset=1` (for clean URLS)
* Update the CiviCRM Resource URL
* Re-enable Drupal CiviCRM integration modules
* Check Drupal role settings
* Pull the site out of maintenance mode

\*extra or modified steps I added to the usual ones listed in the upgrade guide:

**Resources** https://wiki.civicrm.org/confluence/display/CRMDOC/Upgrading+CiviCRM+for+Drupal+7

# Answer
> 1 votes
This looks overall good! A few suggestions though:

* I would advise moving Civi 4.3.8 into the sites/all/modules folder separately from the upgrade. Since this is a fairly unique setup, it would be good to eliminate it so that if something goes wrong, you know this isn't the issue. You should be able to do that just by enabling maintenance mode, removing the symlink, and moving the CiviCRM folder to where the symlink was. Make sure there are no references to the incorrect location in `civicrm.settings.php` or in **Administer menu » System Settings » Directories** or **Administer menu » System Settings » Resource URLs**.
* I'm not sure what `settings_location.php` is, that's probably specific to your setup
* Depending on how abused your database is, you may encounter upgrade errors going from 4.3 to 4.7. If so, don't forget when rolling back to drop your CiviCRM database and create a new blank database before restoring! A restore will not delete newly-created tables, and CiviCRM upgrades choke when they try to create a table that already exists.

---
Tags: drupal, upgrade, 4.3
---


# Question
Title: What are the Attributes for the Reserved DeDupe Rules
The reserved dedupe rules don't tell us what they are doing behind the seens. The name and email (reserved) rule says:

> This reserved rule is pre-configured with matching fields to optimize dedupe scanning performance. It matches on:
>
> 1. Email
> 2. First Name
> 3. Last Name

But it doesn't reveal the length, weight or threshold?

I'm kind of assuming that all three have to match exactly for civi to not create a duplicate record (unservised) or for it to not pop-up a duplicate warning (supervised).

Am I correct?

Thanks

# Answer
> 2 votes
From the DB I can see that dedupe\_rule\_group\_id 1 (in civicrm\_dedupe\_rule) has following rows

`id dedupe_rule_group_id rule_table rule_field rule_length rule_weight
 1 1 civicrm_contact first_name NULL 5
 2 1 civicrm_contact last_name NULL 7
 3 1 civicrm_email email NULL 10`

and from civicrm\_dedupe\_rule\_group we have 'threshold = 20'

`id contact_type threshold used name title is_reserved
1 Individual 20 Supervised IndividualSupervised Name and Email (reserved) 1`

ie First 5 Last 7 Email 10 Threshold 20

BUT - Jon points out that this is just a useless remnant from our evolutionary past so take his answer as the valid one.

# Answer
> 5 votes
Pete's answer should be correct, but reserved dedupe rules don't work like normal rules. The original assumption: First name, last name and email must all be identical - is correct.

Dedupe rules with multiple criteria work by running a separate query for each criterion, filling a temp table with the weights. This is flexible but inefficient, so the "reserved" queries are done using a single handwritten SQL query. This particular query is found in `CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised::internal` and overrides the stored query in the database (which is the old query from before reserved queries existed). Here's the query that runs.

```
        SELECT contact1.id as id1, contact2.id as id2, {$rg->threshold} as weight
        FROM civicrm_contact as contact1
          JOIN civicrm_email as email1 ON email1.contact_id=contact1.id
          JOIN civicrm_contact as contact2 ON
            contact1.first_name = contact2.first_name AND
            contact1.last_name = contact2.last_name
          JOIN civicrm_email as email2 ON
            email2.contact_id=contact2.id AND
            email1.email=email2.email
        WHERE contact1.contact_type = 'Individual'");

```

---
Tags: duplicate-contacts
---


title: Does iATS Payment SWIPE work?

text:
# Question
Title: Does iATS Payment SWIPE work?
We are configuring our CiviCRM instance to work with iATS Payments. When setting up an iATS Payments Processor, there are a number of Payment Processor Types. Our initial configuration with WordPress 4.6.1 + CiviCRM 4.7.12 works with Payment Processor Type = "iATS Payments Credit Card". For live events, where we have a tablet handy we would like to set up contribution pages using Payment Processor Type = "iATS Payments SWIPE." Has anyone else done this? Also, iATS has two types of credit card swipers - a USB encrypted card reader, which appears to be what the processor is designed for click here, and another one which plugs into apple and android phone jacks, like the more popular Square card reader. If anyone is using iATS Payments SWIPE, what is your experience at live events? What is the hardware you use: laptop, tablet, phone, ...? and USB card reader or phone-jack reader?

# Answer
We know that the SWIPE processor has been working for some time (at least a couple of years), but we don't have as many live installs using 4.7 or Wordpress, so do let us know how it works out. We have no reason to believe it won't work.

The key functionality of a card reader, aside from reading the card number off of the card's stripe, is to encrypt it, so your card reader would have to be compatible with one of the two expected encryption methods, which you can review at the function iatsSetCreditCardNumber in the js/swipe.js file. If you have one that isn't currently listed but works, then do let us know so we can update the documentation.

And finally - an unrelated word of warning that there are still some issues with contributions in the core CiviCRM 4.7 code. In general, most of the payment functionality is working well, but for example there was a regression in the latest release related to line items (it's not specific to iATS Payments).
> 2 votes

---
Tags: civicontribute, iats
---


# Question
Title: How do I upload images to emails in Civi?
I can't currently upload images into Civi emails - when I click 'send to server' nothing happens, and I can't view the server to browse previously uploaded images either. Have tried various web browsers but each new browser only works temporarily. Any ideas? Thanks.

# Answer
> 3 votes
The most common cause of that symptom in recents releases is due to a security enhancement in an updated version of the wysiwyg editor that is bundled with CiviCRM, that disallows symlinks.

If that is the issue, you can generally fix it by updating the corresponding path in http://example.org/civicrm/admin/setting/path?reset=1 to its non-symlinked version.

If that's not the issue, then reviewing the path and url settings might shed some light on the problem. And if none of that gives you a quick solution, I'd recommend looking at your server logs which should be instructive (either the civicrm log and/or your web service \[apache/etc\] log)

You might also want to review similar posts here:

---
Tags: civimail, images
---


title: Get state/provice id with API3

text:
# Question
Title: Get state/provice id with API3
I wrote an custom contact import script for our NGO. The old contact data only contains valid country / state abbreviation names. For example CH / ZH = Switzerland / Zürich.

When I now want to create a new address over the API I don't see a way to fill out the 'state\_province\_id' field.

I'm able to get the country id with this syntax:

```
$result = civicrm_api3('Country', 'getsingle', array(
        'sequential' => 1,
        'return' => "id",
        'iso_code' => $row["V"],
    ));

if(isset($result["id"])){
   $params["api.address.create"][0]["country_id"] = $result["id"];
}

```

But how can I do the same with the State/Province, since there is no entity I can choose in the API?

# Answer
Alternative way is if you use the table civicrm\_state\_province and the CRM\_Core\_DAO Class, something like this:

```
$query = "SELECT id FROM civicrm_state_province WHERE country_id = %1 AND abbreviation = %2";
$params = array(
  1 => array($countryId, 'Integer'),
  2 => array($abbreviationFromSource, 'String'));
$stateProvinceId = CRM_Core_DAO::singleValueQuery($query, $params);

```
> 3 votes

# Answer
If there is no state/Province API you would have to create one? Assuming you put your import script into an extension, this is not very hard to do. Using civix you can do generate:api StateProvince Get and the codes files (which you then have to adjust) will be generated for you. If you want to know more check out http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension#CreateaModuleExtension-AddanAPIfunction
> 3 votes

# Answer
I ended up just calling the internal method.

```
return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_StateProvince',
  $state_id,
  'abbreviation'
);

```

Takes advantage of a higher level of abstraction than sql so possibly more future proof, but probably not as future proof as using a designated API.

Still seems like you can't find it in the API, although getOptions looks close https://issues.civicrm.org/jira/browse/CRM-15919.
> 3 votes

# Answer
As of January 2017, there is a StateProvince API in CiviCRM: see CRM-19688.
> 3 votes

# Answer
http://localhost:8080/drupal05122016/sites/all/modules/civicrm/extern/rest.php?entity=Address&action=getoptions&api\_key=userkey&key=sitekey&json={"sequential":1,"field":"state\_province\_id","country\_id":1101}
> -3 votes

---
Tags: api, import
---


# Question
Title: How to show time zone in event details page and registration confirmation page
I would like to show the event timezone on the page that lists event details and the page that a registrant gets as confirmation after they register. Today my events are all in the same time zone but that will change in the future.

I can capture the time zone in a custom field but how do I get that custom field to show up

a) on event details pages

b) on registration confirmation pages

c) on event confirmation e-mails (I have read this page re confirmation e-mails which was very helpful, but I do not know how to access a custom field from within a smarty template)

Preferably the solution would not require changes that break upgrades.

Any ideas?

Thank you

# Answer
a) This will happen automatically, assuming you want the "Event Info" page. In fact, it's far more common for folks to ask how to disable or style this. See my next answer for info on that.

b) will require programming knowledge. You can write a CiviCRM extension, or hire someone to do it. Use `hook_civicrm_buildForm` to look up the custom field, inject it into a PHP variable, and to load a template snippet to display it. Maybe also a little bit of jQuery or CSS to alter its appearance/location on the page.

c) depends on whether the custom field is already loaded into the template (I'm not sure). To check, insert `{debug}` into the template and send yourself a test message. If it IS there, great! Just copy/paste the token.

If it's not there, see this answer: How do I pass a variable to a smarty template?
> 1 votes

---
Tags: civievent
---


# Question
Title: Reminder for Incomplete Registration (and continue...)
Is it possible to track incomplete registrations in CiviEvent and send someone a reminder email, that would allow them to finish their registration?

I recently saw this on another Event Registration Platform. It was multistep, so Step 1 was entering an email address to continue. This would facilitate the system.

If you don't complete the form/pay, you are sent a follow up email with link that lets you complete your registration.

In a Drupal/CiviCRM environment, would this be possible somehow if CiviCRM could not cover the use case?

# Answer
> 2 votes
You could implement this with Webform-CiviCRM integration, assuming your registration page is a webform. If it's not, it's still doable, but would take a bit of custom code.

First, set up a "Step 1" webform that just collects email. On submit, redirect to your "step 2" webform (where registration actually happens), passing the email address in the submit URL. Also add the person to an "incomplete registration" group in CiviCRM.

**If event registration is a webform:**

Next, grab the email from the URL on the step 2 webform. See here for detailed instructions.

On submit, use the Rules module to remove the person from the "incomplete registration" group.

**If event registration is a CiviEvent form**

Write a small custom module to pull in the email address on to your CiviEvent form. Details on the technique are here. Alternatively, skip the custom code, but then the email address won't be prepopulated.

Use CiviRules to remove the person from the "incomplete registration" group.

---
Tags: civievent
---


# Question
Title: Pulling a Report of Donors with More than One Donation, Not Recurring
I would like to pull a report of all donors who have more than one contribution. This is slightly different than pulling a report on actual recurring donations. This is my workflow:

* When donors donate one time, they get a thank you card and a receipt
* If donors contribute again in the same year, I save the acknowledgement for the end of the year, and send a PDF listing all the contributions with a total in the form of a generated letter

I want to use the CiviCRM to generate the form letter, but want to exclude everyone that has donated one time, since they will have already received sufficient documentation and acknowledgement.

Any advice on how this can occur?

# Answer
For those who might not already know Summary Fields extension can give you info like 'how many' donations, and i expect via Search Builder you could then drill down to '\> 1' on that field to find just those who have contributed more than once
> 1 votes

# Answer
I was able to generate the list of people who contributed more than one donation by searching for anyone that still hasn't received a thank you. Even though they received one thank you, the subsequent contributions were not marked as having received one.

I did an advanced search for anyone that:

* has not received a thank you
* is in the donor smart group

The donor smart group is anyone that has made a contribution that counts as a donation.
> 0 votes

---
Tags: contributions, mailing, recurring-contributions
---


# Question
Title: What Permission should I grant to allow some Contacts to sens SMS's
I have just installed Twilio Extension (to send SMS's)

What permission must I grant to enable some Contacts to send SMS's (currently, SMS - schedule/send action is only available to me (administrator))

# Answer
Edit All Contacts.

But this is not appropriate (too permissive) : I would prefer a specific, or merged with CiviMail permission.
> 2 votes

---
Tags: sms
---


# Question
Title: How to resolve SMTP connection failing problem with code 535?
After upgrading CiviCRM from 4.6 to 4.7.14 I was not able to send (test) emails via SMTP. I got the following error:

> authentication failure \[SMTP: STARTTLS failed (code: 220, response: 2.0.0 Ready to start TLS)\]

After replacing some code in `/packages/Net/SMTP.php` like Matt suggested I'm now receiving the error:

> authentication failure \[SMTP: Invalid response code received from SMTP server while sending email. This is often caused by a misconfiguration in Outbound Email settings. Please verify the settings at Administer CiviCRM \>\> Global Settings \>\> Outbound Email (SMTP). (code: 535, response: 5.7.8 Error: authentication failed: authentication failure)\]

Maillog says:

> Dec 21 11:19:55 rs0815 postfix/smtpd\[31606\]: warning: SASL authentication failure: client response doesn't match what we generated Dec 21 11:19:55 rs0815 postfix/smtpd\[31606\]: warning: rs0815.rs.example.de\[123.123.123.123\]: SASL DIGEST-MD5 authentication failed: authentication failure

I doesn't make a difference if I use PHP 5.5 or 5.6.

Any idea what could cause this?

# Answer
> 0 votes
I had this very same problem with SMTP and couldn't find a solution with the configuration, although I didn't change the code you mention. I found a workaround by choosing mail() instead of SMTP in Administer\>system settings\>outbound email, since when I've had no problems. The default option should apparently work fine on linux systems, if that is appropriate.

---
Tags: civimail, mailserver
---


# Question
Title: Upgrade from 4.2.7 to 4.7.13 fails during DB 4.4alpha1 update Joomla
The upgrade process keeps failing, I even tried doing upgrades version after version but always when getting to 4.4 it fails when we get the 4.4 alpha1 update, the error that shows is:

```
[Error: Consolidate activity contacts]
Error Field Error Value
Type    DB_Error
Code    -2
Message DB Error: syntax error
Mode    16
UserInfo    UPDATE civicrm_option_value SET is_reserved = 1 WHERE option_group_id = 62 AND value IN (2, , 3) [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 3)' at line 3]
DebugInfo   UPDATE civicrm_option_value SET is_reserved = 1 WHERE option_group_id = 62 AND value IN (2, , 3) [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 3)' at line 3]
PEAR_Exception: DB Error: syntax error in unknown on line unknown
- DB_Error: DB Error: syntax error in unknown on line unknown

```

I keep looking for the error but can't find it, does anyone knows a better way to verify it? Or if you know what error is on this table? (I only left the main columns and deleted the rest)

https://dl.dropboxusercontent.com/u/92433965/civicrm\_option\_value.csv

Server 1 PHP:5.6.8 MySQL:5.6.24

Server 2 PHP:5.6.28-0+deb8u1 MySQL:5.5.53-0+deb8u1

# Answer
I see where the problem is happening and I have a solution, but from the CSV you're sharing, I can't see *why* the problem is happening.

Next time, before upgrading, go to your CiviCRM root and then open `CRM/Upgrade/Incremental/php/FourFour.php`. Around line 543 will be a function called `activityContacts()`. CiviCRM changes how activity contacts are stored in version 4.4+, and this function is meant to facilitate that.

The first several lines are meant to look up the option value records labeled "Activity Source", "Activity Assignees" and "Activity Targets" and set them to be "reserved", so they can't be changed. Based on the SQL in your error, it's not finding "Activity Assignees" - but I don't understand why, your CSV looks fine.

Regardless - you can fix this by ignoring the lookups and manually change the SQL query to use the values that I can see in your CSV file.

Change these lines:

```
    $query = "
UPDATE civicrm_option_value
SET    is_reserved = 1
WHERE  option_group_id = {$optionGroupID} AND value IN ($ovValues)";

```

to this:

```
    $query = "
UPDATE civicrm_option_value
SET    is_reserved = 1
WHERE  option_group_id = {$optionGroupID} AND value IN (1, 2, 3)";

```

Re-run the upgrade and you should get past that error.
> 0 votes

---
Tags: contacts, joomla, upgrade
---


# Question
Title: How does civi replace page content? Wordpress
We were testing out a theme builder and have an issue with Civi not only replacing the page content in the body of the page but also in other areas (sidebar, footer). Did a little reading and know that Civi replaces page content, can you help me understand how that happens? I'd like to figure out if I can in fact make a minor tweak or two to the template or if I need to just scratch it altogether.

WordPress 4.4.5, CiviCRM 4.6.4

TLDR; We were testing out a theme and learned that Civi replaces page content and with the current setup, it's replacing other areas too (sidebar, footer).

# Answer
The CiviCRM plugin only filters the content when the shortcode is present or when the page is the CiviCRM basepage. For shortcodes, it pre-renders the CiviCRM content that the shortcode represents at the `wp` action stage (in order to support multiple shortcodes in, for example, archive pages) and then uses the `the_content` filter to inject the CiviCRM content.

All the relevant code can be found in https://github.com/civicrm/civicrm-wordpress/blob/master/includes/civicrm.shortcodes.php

If you have details of situations where the plugin incorrectly filters content, it would be helpful if you could update your question with specific information so that it can be addressed.
> 1 votes

---
Tags: wordpress
---


# Question
Title: "Access denied" after IP address change (WAMP; Drupal)
I wasted hours of searching Google back and forth, and found no solution: CiviCRM is set up as an internal only CRM system for an organisation (i.e. IP address 192.168.178.36) - so far, so good. Now I took the server with me to work on CiviCRM, so I changed the IP address to 192.168.2.36 accordingly.

I've changed Apaches httpd.conf, and Apache runs without issues. Drupal seems to come up fine, but whenever I want to access CiviCRM via http://192.168.2.36/q=civicrm/dashboard the website answers with

a) the former IP address (192.168.178.36) in the header of the result page,

b) "Access denied - you are not authorized to access this page."

I deleted the content of all drupal cache tables, I deleted the content of the "templates\_c" directory - no success :-(

Please, can someone point me into the right direction?

Regards

Bernhard

# Answer
Setting up a new database isn't necessary. For folks who encounter similar issues in the future: after checking your `BASE_URL` setting in `civicrm.settings.php`, delete your `templates_c` folder (found here), clear all CiviCRM caches, and rebuild your menus. Details on the latter two items are available here.
> 1 votes

# Answer
The answer is hidden deep in the database. I tried to install Drupal again (just the program), and the same message came up. When I then created a new database, everything works as expected.

So be warned that you will need to setup a new database if you plan to move the server to a new location!
> -1 votes

---
Tags: drupal, urls, civicrm.settings.php
---


# Question
Title: Monitor ConfigAndLog .log file in real time
I am upgrading the CiviCRM and would like to monitor the current .log file that is in `<drupal root>/sites/default/files/civicrm/ConfigAndLog/` as it's being updated, in real time. Currently, I know how to view it using the `cat` command via command line on demand only. Is there a command that prints the latest entry as they happen?

I know this probably is less of CiviCRM question and more of a linux question, but others debugging and monitoring CiviCRM processes might find it helpful.

# Answer
`tail -f /your/log/file` will show you lines as they are added to the file.
> 4 votes

---
Tags: drupal, upgrade, configuration, logs
---


# Question
Title: Syntax for drush command civicrm-sql-dump
My attempt to backup my civicrm database using `mysqldump` has failed after a very rocky CiviCRM upgrade process, or it is taking way too long, so I am trying the drush command, `drush civicrm-sql-dump` in drush 7.0.0 on what I hope is finally CiviCRM 4.7.13 but the command is just dumping to the screen. What other information should I provide?

# Answer
> 1 votes
If you run `drush civicrm-sql-dump --help` the output is:

```
Prints the whole CiviCRM database to STDOUT or save to a file.

Examples:
 drush civicrm-sql-dump        Save SQL dump to the directory above Drupal root.
 --result-file=../CiviCRM.sql

Options:
 --data-only                               Dump data without statements to create any of the schema.
 --gzip                                    Compress the dump using the gzip program which must be in your $PATH.
 --result-file                             Save to a file.
 --tables-list                             comma-separated list of tables to transfer.

```

So since you want it in a file rather than on your screen, use the `--result-file` option and tell it what file you want to write to.

---
Tags: drupal, database, mysql, drush, backups
---


# Question
Title: Upgrade froze at 4.7.8, Can't find valid value for qrid
My upgrade has been running for about 8 hours, but it stalled after completing 4.7.7, from 4.3.8 at. I checked `top` to see if Drupal or CiviCRM were running, and there was no indication of the process. I decided to refresh my browser and my cookie must have expired, because Drupal asked me to log in again. Then I pulled up the queue runner in the browser (`https://dev.example.com/civicrm/upgrade/queue/runner`) it spit out the error:

> Sorry but we are not able to provide this at the moment. Could not find valid value for qrid

The log shows that it could not find valid value for qrid. Below is the log from `/sites/files/civicrm/ConfigAndLog`, starting after completing upgrade to 4.7.6:

```
Dec 21 12:18:17  [info] Running task: Begin Upgrade to 4.7.7
Dec 21 12:18:19  [info] Running task: Upgrade DB to 4.7.7
Dec 21 12:18:21  [info] Running task: Upgrade DB to 4.7.7: SQL
Dec 21 12:18:29  [info] Running task: Finish Upgrade DB to 4.7.7
Dec 21 12:20:15  [info] Running task: Begin Upgrade to 4.7.8
Dec 21 12:20:17  [info] Running task: Upgrade DB to 4.7.8
Dec 21 12:20:23  [info] Running task: Upgrade DB to 4.7.8: SQL
Dec 21 12:20:56  [info] Running task: Upgrade mailing foreign key constraints
Dec 21 13:26:27  [info] $Fatal Error Details = Array

(
    [message] => Could not find valid value for qrid
    [code] =>
)

Dec 21 13:26:27  [info] $backTrace = #0 /var/www/html/drupal/docroot/sites/all/modules/civicrm/CRM/Core/Error.php(373): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/html/drupal/docroot/sites/all/modules/civicrm/CRM/Utils/Request.php(120): CRM_Core_Error::fatal("Could not find valid value for qrid")
#2 /var/www/html/drupal/docroot/sites/all/modules/civicrm/CRM/Queue/Page/Runner.php(52): CRM_Utils_Request::retrieve("qrid", "String", Object(CRM_Queue_Page_Runner), TRUE)
#3 /var/www/html/drupal/docroot/sites/all/modules/civicrm/CRM/Core/Invoke.php(312): CRM_Queue_Page_Runner->run((Array:4), NULL)
#4 /var/www/html/drupal/docroot/sites/all/modules/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:13))
#5 /var/www/html/drupal/docroot/sites/all/modules/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:4))
#6 /var/www/html/drupal/docroot/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:4))
#7 [internal function](): civicrm_invoke("upgrade", "queue", "runner")
#8 /var/www/html/drupal/docroot/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:3))
#9 /var/www/html/drupal/docroot/index.php(21): menu_execute_active_handler()
#10 {main}

```

I suspect that the qrid is the queue runner ID and that the queue was lost when Drupal asked me to log in again. The log doesn't show that there was any other issues before the qrid problem. I'm not certain if something was wrong before I was forced to log in again or if that is what did it it.

Furthermore, the file permissions for the civicrm directory in sites/all/modules was somehow changed to an owner I am not familiar with on our server (test2?):

```
    drwxr-xr-x 19 test2 csf      4096 Nov  2 19:32 civicrm
drwxr-sr-- 80 fclub www-data 4096 Oct 16  2015 contrib
drwxr-sr-- 15 fclub www-data 4096 Oct 16  2015 custom
-rw-r--r--  1 fclub www-data  952 Aug  5  2015 README.txt
drwxr-sr-x  2 fclub www-data 4096 Nov  3 22:40 timeago

```

I tried loading this URL to see if that would help:

```
civicrm/upgrade/queue/runner?reset=1&qrid=CRM_Upgrade

```

but then received the error:

> Queue runner must be configured before execution.

I should have used Drush to run the upgrade so I wouldn't have to deal with Browser issues.

**Question 1:** Is there anyway to salvage the progress and continue from 4.7.7, repair the database or reinstate the queue runner?

**Question 2:** How can I figure out what went wrong so that I can try running the upgrade again without this happening?

# Answer
The error message comes from refreshing the browser rather than the upgrade process. The last entry before the error is:

```
Dec 21 12:20:56  [info] Running task: Upgrade mailing foreign key constraints

```

You can find the detail in `CRM/Upgrade/Incremental/php/FourSeven.php` Adding foreign key constraints creates an index which can take a while on a big table. How many rows (count(\*)) do your `civicrm_mailing_event_queue` and `civicrm_mailing_recipients` tables have?

Once the upgrade has started, I don't know how dependent it is on the browser, so it would be worth checking the log later to see if you have any further messages from the upgrade.

If you need to start again, then I'd try this:

1. Restore your database and files back to your starting point at 4.3.8 (you did take full backups didn't you??)
2. Upgrade to 4.7.7
3. Check all is working as expected
4. Take new backups
5. Try upgrading to 4.7.8

If your mailing tables are large you'll need to be patient. If it fails, you can easily go back to 4.7.7 and then work out what to do next.
> 3 votes

---
Tags: drupal, upgrade, error
---


# Question
Title: When profile matches on email and the email that matches is not the primary, it overwrites the primary giving the same email repeated
We have a profile for registering people. It is set to match on email. If an existing contact fills out the form but say uses their billing email address and not the one set as their primary, it matches fine. Great, but then it overwrites the primary with what they just entered. Now we've lost their "primary" email address and have the same email address listed twice, once as billing and once as home.

Is there some nice easy way around this? I'm I missing something?

I suppose I could create another type and set the profile for that. Would still end up with the same address twice but wouldn't loose the other. Or maybe a db trigger to skip the write to the email table if the email address already exists for that user.

Ah, the tangled web we create when we allow contacts to mess with their data.

# Answer
When you create a profile and add Email fields, you can choose which email address the field should represent (Home, Main, Work etc). You could provide both email address fields in the form and label them accordingly. It's not perfect, but might at least make some users more aware of which email address they are supplying.
> 1 votes

---
Tags: profile, email, registration
---


# Question
Title: CiviMail - How do I change the sender email account?
I am trying to send a Thank You email to our donor contributors through CiviMail. We have a message template set up. But our test emails keep showing the wrong sender email account "info@email.com" instead of our goal "donations@email.com." The latter email address is already set up in our From Email Address and Mail Accounts. The CiviCRM manual mentioned that there was a dropdown to change the sender? But I don't see this option anywhere. Please advise.

Stacy

# Answer
The drop-down for the 'from' (sender) email address is on the first page of the mailing screen which is called the 'Define Mailing' screen. The drop-down is appropriately named 'From' with an asterisk by it to denote that it's mandatory. It's likely that you need to look at the 'from' email address table (Administer/CiviMail/From Email Addresses) and check what the default is. This assumes you're using 4.6 or greater.
> 3 votes

---
Tags: civimail, email
---


# Question
Title: CiviCRM Upgrade after 4.0: do I need to update civicrm.settings.php?
From the CiviCRM Upgrade for Drupal wiki article, step 9 indicates that all versions 4.0 or after require editing the civicrm.settings.php file, and provides two options to accomplish this.

> CiviCRM 4.0 and above requires definitions in civicrm.settings.php which previous versions of CiviCRM did not have. There are two methods to put these required definitions into your install:
>
> Create a "dummy" database and install CiviCRM fresh into that. You will need to rename or move your existing civicrm.settings.php. Running the installer anyhow will automatically create a correct civicrm.settings.php file. Then either replace that dummy database with your real one and proceed with the upgrade OR edit the new civicrm.settings.php to point to your real database. Add the definitions manually to your civicrm.settings.php file as below:
>
> If your civicrm.settings.php does not have this section, copy and paste from here into civicrm.settings.php: \[settings follow\]

If the upgrade is starting from a version that is already 4.x, can we completely skip step 9 or what is the recommended way to handle this step?

https://wiki.civicrm.org/confluence/display/CRMDOC/Upgrading+CiviCRM+for+Drupal+7

# Answer
> 2 votes
No, those settings should already be in your civicrm.settings.php - but it would only take a moment to check your file and ensure the values on the wiki page are there.

---
Tags: drupal, upgrade
---


# Question
Title: Strip Drupal Page Template from CiviCRM Contribution Page
I want to strip all Drupal navigation etc coming from page.tpl.php for a particular contribution page and all the associated pages of the contribution process. But all just for one contribution page.

In Drupal I know how to create template suggestions for a Drupal theme that will apply only to a specific path. But I don't thing the template suggestions can handle the query part of the CiviCRM URL.

Ideas?

# Answer
> 0 votes
The themekey module is the answer. ThemeKey can handle query strings.

# Answer
> 1 votes
You can assign CiviCRM to use the default template in your Drupal theme settings. The default theme doesn't engage your Drupal theme and menu system.

In Drupal 7, it's https://www.example.com/admin/appearance, then scroll down to the bottom of the page and you can set your theme for CiviCRM.

If you want to retain your template but just strip out navigation, you may need to make a new template based on it for CiviCRM to use and assign it.

---
Tags: drupal, custom-templates
---


title: Export tags to separate column?

text:
# Question
Title: Export tags to separate column?
When exporting information, is it possible to separate each contacts' various tags into separate columns?

That way I'd be able to sort the resulting spreadsheet by specific tags, instead of having to create a separate spreadsheet for each tag.

# Answer
> 1 votes
What you're asking for isn't doable out of the box. However, most spreadsheet programs (including Excel and LibreOffice Calc) will do this for you. Here's a formula that I tested in LibreOffice and should work without modification in Excel:

```
=IF(ISERR((SEARCH("Volunteer",$A2))), "", "Volunteer")

```

Paste this into an empty column at row 2. Replace both instances of "Volunteer" with the text of the tag you'd like in that column. Change the "A" in "A2" to the letter corresponding to the column that contains your tags. Your new cell will now contain (only) the tag you're searching for in your tags if it's present, or be blank if not. Copy this formula down the page for all rows, and of course repeat in new columns for any other tags you want to track in other columns.

Note that if you're just doing this to count numbers, you're better off with something like this:

```
=COUNTIF(A:A,"Volunteer")

```

---
Tags: export, tags
---


# Question
Title: DB Error: no such field (Joomla - view contact)
please I need help. When I go into the backend to see the details of a contact, I get the following error:

```
Sorry but we are not able to provide this at the moment.
DB Error: no such field

Return to home page.

```

I cant find any error logs, nothing is displayed on the debug, I just dont know where to else look for an issue.

* I also upgraded to the latest version 4.7.14
* I ran the database upgrade successfully
* I downloaded a sql file of the entire database and compared it with a fresh new installation - no difference on the structure

Please, what else can I check?

Thank you in advance

# Answer
> 0 votes
Problem Solved! I had a broken custom profile with broken custom fields. I was not even able to delte those fields and that profile from the backend. Had to go into the Database and delete the entire table which is related to that profile.

That fixed the problem.

---
Tags: contacts, joomla
---


# Question
Title: CiviMail Images always appear broken on screen after uploading correctly
I have been working with CiviMail to upload images directly to the mailing templates from the KC finder image upload. I am successfully able to upload an image via KC finder which looks good when I upload it. However, once I click away to add the image to the template it shows a big red x instead of the actual image. I understand that it might be a permissions issues but I have tried different options for the issue and it does not work. This CiviCRM is on a Windows 2012 server with IIS 8.5 and PHP 5.6.20. I have tried a number of options from not naming the images with dashes to permissions of the server.

# Answer
> 1 votes
If your images are being stored in a directory that prohibits direct access, it will give you that symptom. There's a .htaccess file that performs this function for apache, I'm not sure how that works with MS servers.

Your best bet is to try loading the image directly (e.g. right click on the broken image and load the image in a new tab) and see what the path/url is, and look in your server logs, it should tell you why that image is not being loaded, i.e. either whether it is a permission or just a not-found issue.

# Answer
> 0 votes
The answer to this issue is in the PHP uploads which needs to match the directory upload url. When a file is uploaded via CiviCRM it goes to the temp folder (same like Drupal) and then moves the file to the permanent folder after it has been fully uploaded. If the temp folder and php temp folder do not match exactly then the image will appear broken on the screen. This video actually gave me the idea of a solution - https://www.youtube.com/watch?v=Wrr-dTFfNi8

---
Tags: civimail, images
---


# Question
Title: Is there a mistake in the Upgrading CivCRM for WordPress instructions?
I was following the instructions to upgrade to 4.7.14 here: https://wiki.civicrm.org/confluence/display/CRMDOC/Upgrading+CiviCRM+for+Wordpress It clearly says to extract the zip file in /wp-content/plugins/. It then says to clear caches and point to the upgrade url. This leads to: Your database has already been upgraded to CiviCRM 4.7.13. The extract left things in a directory called: civicrm-4.7.14-wordpress. This implied to me that the upgrade will move things from there to the civicrm directory, but reading things here and elsewhere I suspect that files need to be extracted (or moved) to the civicrm directory. There are no instructions to do that. Should I remove the civicrm/ tree and move civicrm-4.7.14-wordpress/civicrm to plugins/?

# Answer
> 2 votes
The assumption that was made in the instructions is that you must extract the files into the `/wp-content/plugins/` directory and then *rename* the resulting file to `civicrm`, just like the old directory was named. The previous step to this was to backup `/wp-content/plugins/civicrm`.

E.g. Back up and delete `/wp-content/plugins/civicrm` then extract the new version and name it `civicrm` and put it in `/wp-content/plugins/`, thus replace the previous.

---
Tags: upgrade
---


# Question
Title: How do you move SSL to non-SSL? [ Wordpress 4.6.1 + CiviCRM 4.7.14]
I responded to a question re: using Let's Encrypt SSL certs at this comment. I now need to go in the other direction because I made a mirror of our live site on my laptop in an xampp environment (win 10). There I don't have, nor do I want to use, an SSL certificate.

First, I removed the https redirect in .htaccess. Then, I was able to "simply" deactivate the Really Simple SSL plugin by following https://really-simple-ssl.com/knowledge-base/uninstall-websitebackend-not-accessible. This made our local Wordpress site work and I could also get into the back-end. However, CiviCRM does not work from either the back-end or front-facing pages. From the back-end, it generates an error trying to bring up the CiviCRM dashboard. Both give the same error: "Parse error: syntax error, unexpected end of file in C:\vhost\sdbikecoalition\wp-content\uploads\civicrm\civicrm.settings.php on line 450"

\[edit\] And, of course, I checked the civicrm.settings.php file and found nothing suspicious \[/edit\]

I suspect it is because, on our live SSL site, I went to Administer \> System Settings \> Resource URLs and checked Yes on "Force Secure URLs (SSL)". Is there somewhere I can change this by just directly editing a record in the CiviCRM MySQL database?

I suspect that will solve my issue as that was the only thing I did within CiviCRM that was specific to SSL.

# Answer
> 4 votes
Verify the file which is being reported as having a syntax error. PHP has a syntax check mode with `-l` (for "lint").

```
php.exe -l C:\vhost\sdbikecoalition\wp-content\uploads\civicrm\civicrm.settings.php

```

If `civicrm.settings.php` is not valid PHP, CiviCRM will not function - SSL or no SSL.

Note that your local PHP install may differ in version and therefore syntax from the PHP installed on your server.

---
Tags: wordpress, ssl
---


# Question
Title: Membership Contribution Page for Cash or Check Payment
I want Finance Administrators to have the ability to record cash or check membership contributions with predefined Price Sets.

In this aim, I have created a Contribution Page with no Payment Processor.

But when I use this Contribution Page to record someone else's Check or Cash Contribution (i.e. with ...&cid=0)(e.g. https://mysite.com/civicrm/contribute/transact?reset=1&id=8&cid=0), and select the pertaining user, his email is not displayed (while it is if my Contribution Page specified a Payment Processor) :

... and I get the following message : email is a mandatory field

Is there any solution, or is it a bug ?

(I am in Drupal 7.51 / CiviCRM 4.7.12)

# Answer
> 1 votes
I presume you are trying both to simplify things for your Finance Administrators and restrict who has direct access to CiviCRM, but I don't think using a front-facing CiviCRM contribution page will accomplish those aims.

If monetary contributions are involved then a front-facing CiviCRM contribution page will need either to have a payment processor specified or to have the "Pay later option" ticked. Once the pay later option is enabled then the email field will be pre-filled when an existing contact is selected.

However, if the pay later option is ticked then the payment is recorded as "pending (pay later)" so the Finance Aministrators will still need direct access to CiviCRM to record the payment. You also then have a two-step process rather than a one-step process.

It might be easier to use permissions to restrict what Finance Administrators can do in CiviCRM and train them to use a rear-facing form.

And just for completeness for other people looking at this Q&A, at this time CiviCRM pricesets cannot be used with webforms.

# Answer
> 1 votes
Finally, il you use Stripe Processor (maybe also others) and Webforms, you can include the Contribution page in a Webform, which gives the ability :

* to record some membership custom data (e.g. check number, and bank id)
* to fix (or let the user choose) pay later vs pay on line
* to actually pay on the way
* and do this all in one

Great !

---
Tags: civicontribute, contribution-page
---


# Question
Title: CiviCRM 4.7.9 to 4.7.14 fails with no such field
I'm trying to upgrade a CiviCRM 4.7.9 installation to 4.7.14 and the following errors happen during the upgrade process. This site is also using internationalization, but I've made sure the localization files are in place properly.

```
Dec 24 09:50:45  [info] Running task: Upgrade DB to 4.7.11: SQL

Dec 24 09:51:06  [info] Running task: Dashboard schema updates

Dec 24 09:51:33  [info] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )

    [code] => -19
    [message] => DB Error: no such field
    [mode] => 16
    [debug_info] => CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm_dashboard_contact FOR EACH ROW BEGIN  IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_dashboard_contact (id, dashboard_id, contact_id, column_no, is_minimized, is_fullscreen, is_active, weight, created_date, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.dashboard_id, NEW.contact_id, NEW.column_no, NEW.is_minimized, NEW.is_fullscreen, NEW.is_active, NEW.weight, NEW.created_date, COALESCE(@uniqueID, LEFT(CONCAT('c_', unix_timestamp()/3600, CONNECTION_ID()), 17)), @civicrm_user_id, 'insert'); END IF; END [nativecode=1054 ** Unknown column 'is_minimized' in 'NEW']
    [type] => DB_Error
    [user_info] => CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm_dashboard_contact FOR EACH ROW BEGIN  IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_dashboard_contact (id, dashboard_id, contact_id, column_no, is_minimized, is_fullscreen, is_active, weight, created_date, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.dashboard_id, NEW.contact_id, NEW.column_no, NEW.is_minimized, NEW.is_fullscreen, NEW.is_active, NEW.weight, NEW.created_date, COALESCE(@uniqueID, LEFT(CONCAT('c_', unix_timestamp()/3600, CONNECTION_ID()), 17)), @civicrm_user_id, 'insert'); END IF; END [nativecode=1054 ** Unknown column 'is_minimized' in 'NEW']
    [to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm_dashboard_contact FOR EACH ROW BEGIN  IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_dashboard_contact (id, dashboard_id, contact_id, column_no, is_minimized, is_fullscreen, is_active, weight, created_date, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.dashboard_id, NEW.contact_id, NEW.column_no, NEW.is_minimized, NEW.is_fullscreen, NEW.is_active, NEW.weight, NEW.created_date, COALESCE(@uniqueID, LEFT(CONCAT('c_', unix_timestamp()/3600, CONNECTION_ID()), 17)), @civicrm_user_id, 'insert'); END IF; END [nativecode=1054 ** Unknown column 'is_minimized' in 'NEW']"]
)

Dec 24 09:51:33  [info] $backTrace = #0 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Error.php(932): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2 /var/www/html/sites/all/modules/contrib/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error))
#3 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: no such field", -19, 16, (Array:2), "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#4 /var/www/html/sites/all/modules/contrib/civicrm/packages/PEAR.php(575): DB_Error->__construct(-19, 16, (Array:2), "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#5 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -19, NULL, NULL, "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", "DB_Error", TRUE)
#6 /var/www/html/sites/all/modules/contrib/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8))
#7 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
#8 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", "DB_Error", TRUE)
#9 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'is_minimized' in 'NEW'")
#10 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#11 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#12 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/DataObject.php(2438): DB_common->query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#13 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/DataObject.php(1627): DB_DataObject->_query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#14 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/DAO.php(354): DB_DataObject->query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#15 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/DAO.php(1297): CRM_Core_DAO->query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", FALSE)
#16 /var/www/html/sites/all/modules/contrib/civicrm/Civi/Core/SqlTriggers.php(225): CRM_Core_DAO::executeQuery("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", (Array:0), TRUE, NULL, FALSE, FALSE)
#17 /var/www/html/sites/all/modules/contrib/civicrm/Civi/Core/SqlTriggers.php(171): Civi\Core\SqlTriggers->enqueueQuery("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#18 /var/www/html/sites/all/modules/contrib/civicrm/Civi/Core/SqlTriggers.php(70): Civi\Core\SqlTriggers->createTriggers((Array:486), NULL)
#19 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/DAO.php(1975): Civi\Core\SqlTriggers->rebuild(NULL, FALSE)
#20 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/I18n/Schema.php(352): CRM_Core_DAO::triggerRebuild()
#21 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/BAO/SchemaHandler.php(389): CRM_Core_I18n_Schema::rebuildMultilingualSchema((Array:3), NULL)
#22 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Upgrade/Incremental/php/FourSeven.php(829): CRM_Core_BAO_SchemaHandler::dropColumn("civicrm_dashboard_contact", "is_minimized")
#23 [internal function](): CRM_Upgrade_Incremental_php_FourSeven::dashboardSchemaUpdate(Object(CRM_Queue_TaskContext))
#24 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Task.php(88): call_user_func_array((Array:2), (Array:1))
#25 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Runner.php(214): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
#26 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Page/AJAX.php(52): CRM_Queue_Runner->runNext(TRUE)
#27 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/ErrorPolicy.php(106): CRM_Queue_Page_AJAX::{closure}()
#28 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Page/AJAX.php(54): CRM_Queue_ErrorPolicy->call(Object(Closure))
#29 [internal function](): CRM_Queue_Page_AJAX::runNext()
#30 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Invoke.php(276): call_user_func((Array:2))
#31 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#32 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:5))
#33 /var/www/html/sites/all/modules/contrib/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:5))
#34 [internal function](): civicrm_invoke("upgrade", "queue", "ajax", "runNext")
#35 /var/www/html/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:4))
#36 /var/www/html/index.php(21): menu_execute_active_handler()
#37 {main}

Dec 24 09:51:33  [info] $CRM_Queue_Page_AJAX_runNext_error = PEAR_Exception: "DB Error: no such field"
 * ERROR TYPE: DB_Error
 * ERROR CODE: -19
 * ERROR MESSAGE: DB Error: no such field
 * ERROR MODE: 16
 * ERROR USERINFO: CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm_dashboard_contact FOR EACH ROW BEGIN  IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_dashboard_contact (id, dashboard_id, contact_id, column_no, is_minimized, is_fullscreen, is_active, weight, created_date, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.dashboard_id, NEW.contact_id, NEW.column_no, NEW.is_minimized, NEW.is_fullscreen, NEW.is_active, NEW.weight, NEW.created_date, COALESCE(@uniqueID, LEFT(CONCAT('c_', unix_timestamp()/3600, CONNECTION_ID()), 17)), @civicrm_user_id, 'insert'); END IF; END [nativecode=1054 ** Unknown column 'is_minimized' in 'NEW']
 * ERROR DEBUGINFO: CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm_dashboard_contact FOR EACH ROW BEGIN  IF ( @civicrm_disable_logging IS NULL OR @civicrm_disable_logging = 0 ) THEN INSERT INTO log_civicrm_dashboard_contact (id, dashboard_id, contact_id, column_no, is_minimized, is_fullscreen, is_active, weight, created_date, log_conn_id, log_user_id, log_action) VALUES ( NEW.id, NEW.dashboard_id, NEW.contact_id, NEW.column_no, NEW.is_minimized, NEW.is_fullscreen, NEW.is_active, NEW.weight, NEW.created_date, COALESCE(@uniqueID, LEFT(CONCAT('c_', unix_timestamp()/3600, CONNECTION_ID()), 17)), @civicrm_user_id, 'insert'); END IF; END [nativecode=1054 ** Unknown column 'is_minimized' in 'NEW']
#0 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#1 /var/www/html/sites/all/modules/contrib/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error))
#2 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: no such field", -19, 16, (Array:2), "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#3 /var/www/html/sites/all/modules/contrib/civicrm/packages/PEAR.php(575): DB_Error->__construct(-19, 16, (Array:2), "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#4 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -19, NULL, NULL, "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", "DB_Error", TRUE)
#5 /var/www/html/sites/all/modules/contrib/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8))
#6 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
#7 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, "CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", "DB_Error", TRUE)
#8 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'is_minimized' in 'NEW'")
#9 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#10 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#11 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/DataObject.php(2438): DB_common->query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#12 /var/www/html/sites/all/modules/contrib/civicrm/packages/DB/DataObject.php(1627): DB_DataObject->_query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#13 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/DAO.php(354): DB_DataObject->query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#14 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/DAO.php(1297): CRM_Core_DAO->query("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", FALSE)
#15 /var/www/html/sites/all/modules/contrib/civicrm/Civi/Core/SqlTriggers.php(225): CRM_Core_DAO::executeQuery("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...", (Array:0), TRUE, NULL, FALSE, FALSE)
#16 /var/www/html/sites/all/modules/contrib/civicrm/Civi/Core/SqlTriggers.php(171): Civi\Core\SqlTriggers->enqueueQuery("CREATE TRIGGER civicrm_dashboard_contact_after_insert after insert ON civicrm...")
#17 /var/www/html/sites/all/modules/contrib/civicrm/Civi/Core/SqlTriggers.php(70): Civi\Core\SqlTriggers->createTriggers((Array:486), NULL)
#18 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/DAO.php(1975): Civi\Core\SqlTriggers->rebuild(NULL, FALSE)
#19 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/I18n/Schema.php(352): CRM_Core_DAO::triggerRebuild()
#20 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/BAO/SchemaHandler.php(389): CRM_Core_I18n_Schema::rebuildMultilingualSchema((Array:3), NULL)
#21 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Upgrade/Incremental/php/FourSeven.php(829): CRM_Core_BAO_SchemaHandler::dropColumn("civicrm_dashboard_contact", "is_minimized")
#22 [internal function](): CRM_Upgrade_Incremental_php_FourSeven::dashboardSchemaUpdate(Object(CRM_Queue_TaskContext))
#23 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Task.php(88): call_user_func_array((Array:2), (Array:1))
#24 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Runner.php(214): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
#25 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Page/AJAX.php(52): CRM_Queue_Runner->runNext(TRUE)
#26 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/ErrorPolicy.php(106): CRM_Queue_Page_AJAX::{closure}()
#27 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Queue/Page/AJAX.php(54): CRM_Queue_ErrorPolicy->call(Object(Closure))
#28 [internal function](): CRM_Queue_Page_AJAX::runNext()
#29 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Invoke.php(276): call_user_func((Array:2))
#30 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#31 /var/www/html/sites/all/modules/contrib/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:5))
#32 /var/www/html/sites/all/modules/contrib/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:5))
#33 [internal function](): civicrm_invoke("upgrade", "queue", "ajax", "runNext")
#34 /var/www/html/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:4))
#35 /var/www/html/index.php(21): menu_execute_active_handler()
#36 {main}

```

# Answer
> 1 votes
I can confirm. I had to disable the logging setting in CiviCRM before applying any updates. This seems to have resolved the upgrade process for me.

To disable logging go to the settings area in the admin section of CiviCRM.

---
Tags: upgrade, error, fields
---


# Question
Title: How can I monitor the progress of a slow upgrade?
CiviCRM upgrades can take a long time.

What is the best way of seeing where they are up to?

# Answer
The upgrader builds a queue of version-specific upgrade tasks -- then executes them. You can measure progress based on the size of the queue.

If you use the web-based upgrader, it displays a progress-bar based on the queue.

If you use the CLI to upgrade the DB, then it doesn't display a progress-bar. However, it would be patch-welcome to add something. (If I were doing this, I'd write a `cv upgrade` command which borrows heavily from http://symfony.com/doc/current/components/console/helpers/progressbar.html and https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Headless.php).

If you're looking for ways to poke under the hood, then you can look at SQL tables `civicrm_domain` and `civicrm_queue_item`. I wouldn't recommend building external processes on these, but they could be good for a quick peek. These (untested) queries should be interesting:

* `select count(*) from civicrm_queue_item where queue_name = 'CRM_Upgrade'` (the queue gets smaller as tasks progress)
* `select version from civicrm_domain` (updates to reflect the most recent incremental update)
> 5 votes

# Answer
1. **Never try the upgrade on live** :)
2. **Take small steps**. Sometimes CiviCRM chokes on a minor upgrade step, but you can get the upgrader to run from v1.2.3 all the way to v4.5.6 ... in that case, you'll have a more robust process if you don't try to do it all in one leap. You can automate the upgrade to v4.5.6, then work out what's breaking at the next step. (Some examples of why this is even a thing might be helpful? Version numbers in this paragraph are made up.)
3. **Automate the process so that it's repeatable**, and therefore can be tested thoroughly. This means investing a little extra time in writing a bash script which performs the upgrade steps, and then using that script only to perform each test run. This approach means that any extra steps (eg adjusting some index) end up in the script, and the process is repeated as consistently as possible. Some upgrades can take hours, and you want to avoid pressuring yourself to "just make a small change" in order to save starting over.
4. **Have a fast test environment**. On the one hand, it needs to accurately mirror the environment you'll perform the final upgrade on. On the other hand, if you can use a system with solid state drives, or put all of MySQL's data into RAM during the upgrade, you'll save a lot of time. Tune your MySQL. (A couple dozen upgrade runs will give you plenty of data in `mysqltuner` also...)
5. **Observe DB activity during the upgrade**. Use `mytop`, to shows current SQL queries as they happen. (You can do this in SQL with `SHOW FULL PROCESSLIST`, but `mytop` is convenient.) This will let you know if a query is taking a long time, and might inform your approach to help you reduce upgrade time. (*Maybe, it's taking eight hours to upgrade a chunk of data you no longer needed, or maybe you can speed the process by adding an index in your upgrade script, then removing it after the upgrade is done.*) Note also the CiviCRM debug log as mentioned in Jon's comment.
6. **Observe upgrade progress** also: `SELECT version FROM civicrm_domain ;` \- the result will change as CiviCRM progresses through the upgrade steps.
7. **Generate a reduced dataset for testing**. I might bring the total contacts down to a couple thousand from the original dataset, and similarly reduce other large tables to a small sample of the original. This means the process is no longer an accurate test of the upgrade, but it does ensure you are testing schema changes, and if it can reduce each repeated upgrade run by minutes, it can save you hours down the track. If doing this, make sure you then test the full upgrade a few times before deploying - by this stage, it will run without your attention anyway, since (3).
8. **Dump data for components you don't care about**. Some tables in CiviCRM can grow huge, and can steal more time then they deserve. Look at the table sizes (MySQL: show largest tables) and decide which are worth pruning. You might decide to drop mailings more than two years old, or an activity type you retired a while back, or ... (Jon also mentions this here.)
9. **Consider turning off logging**. CiviCRM's trigger logging may affect upgrade performance, and you could turn it off during the upgrade. (This needs to be an informed decision, since a large chunk of data changes "off the radar" during upgrade may not be acceptable to your org.)
10. **Ask for help**. You might find some assistance here or on CiviCRM chat if you're stuck. If you have a challenging upgrade to deal with, it's worth finding a good team to support your CiviCRM site!
> 5 votes

# Answer
If you are upgrading to CiviCRM 4.6.10+, the data is written in two places besides the screen.

One place is the `civicrm_log` database table.

The other is the CiviCRM log file. If you have shell access to your server, consider running `tail -f` on your CiviCRM log, located in the ConfigAndLog directory.
> 3 votes

---
Tags: upgrade
---


# Question
Title: Does class autoloading not work in standalone phpunit testing?
I'm following civix's upgrade instructions to enable unit tests to be executed with standalone phpunit.

I've got my code in a work-in-progress git branch. The first commit captures the civix-generated boilerplate phpunit.xml.dist and bootstrap.php. The second commit captures my attempts to adapt an existing test to the new way of doing things.

With these changes in place, I do:

```
$ cd /path/to/webroot/sites/all/modules/civicrm/tools/extensions/civivolunteer
$ phpunit4 tests/phpunit/api/v3/VolunteerProjectTest.php

```

... and get:

```
PHP Fatal error:  Class 'VolunteerTestAbstract' not found in /path/to/webroot/sites/all/modules/civicrm/tools/extensions/civivolunteer/tests/phpunit/api/v3/VolunteerProjectTest.php on line 6
PHP Stack trace:
PHP   1. {main}() /usr/local/lib/civicrm-buildkit/bin/phpunit4:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/local/lib/civicrm-buildkit/bin/phpunit4:545
PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/TextUI/Command.php:100
PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/TextUI/Command.php:123
PHP   5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/Runner/BaseTestRunner.php:67
PHP   6. PHPUnit_Runner_StandardTestSuiteLoader->load() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/Runner/BaseTestRunner.php:123
PHP   7. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/Runner/StandardTestSuiteLoader.php:39
PHP   8. PHPUnit_Util_Fileloader::load() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/Util/Fileloader.php:38
PHP   9. include_once() phar:///usr/local/lib/civicrm-buildkit/bin/phpunit4/phpunit/Util/Fileloader.php:56

```

Any suggestions?

# Answer
> 2 votes
Civi's autoloader does not load classes outside the CRM directory. In order for that to work, you'll have a few options:

* Implement your own autoloader capable of loading classes inside the test/phpunit dir
* Use require to include the class
* Put the VolunteerTestAbstract class inside your CRM dir

I usually use the second option for that and include/require the class(es) on the bootstrap.php file.

I also like the third option. For that, you would put the class somewhere like CRM\_Volunteer\_Test\_VolunteerTestAbstract and then just extend it. No need for requires or to implement your own autoloader.

# Answer
> 4 votes
This is an issue with intermediate base-classes for tests (like `VolunteerTestAbstract`). The most reliable solution I've found is to put a `require_once` to load the intermediate base-class. For example, this is what I used in `uk.co.vedaconsulting.mosaico`:

```
require_once __DIR__ . '/TestCase.php';

class CRM_Mosaico_MosaicoTemplateTest extends CRM_Mosaico_TestCase implements EndToEndInterface {
     ...
}

```

Unfortunately, it's hard to combine PHPUnit with a classloader that understands extensions. To see why, consider an example command:

```
phpunit4 tests/phpunit/CRM/Mosaico/MosaicoTemplateTest.php

```

Which would then:

* A. Load test files, e.g.
    1. Load `tests/phpunit/bootstrap.php`
    2. Load `tests/phpunit/CRM/Mosaico/MosaicoTemplateTest.php` (which depends on a base class like `CRM_Mosaico_TestCase`)
    3. Load `tests/phpunit/CRM/Mosaico/TestCase.php`
* B. Begin executing the test logic, e.g.
    1. Execute `CiviTestListener`
    2. Execute `setupBeforeClass()`
    3. Execute `setUp()`

The problem arises if the database-initialization (eg `\Civi\Test::headless()->installMe(__DIR__)->apply()`) is put in phase B test-logic (e.g. `CiviTestListener` or `setupBeforeClass()` or `setUp()`) . The database-initialization determines which extensions are active. The active extensions determine the class-loader. But all of this comes too late. During steps A2=\>A3 (when we need autoloading), the extension-enabled class-loader isn't available yet.

Put another way: any code which references an autoloaded extension class has an implicit dependency on the database.

One can resolve this conundrum a couple ways, e.g.

* In `tests/phpunit/bootstrap.php`, fully initialize the system. (Ex: In the line `eval(cv('php:boot --level=classloader', 'phpcode'));`, change the `--level` to `settings` or `full`.) This makes sense if all the tests are end-to-end (`e2e`).
* Load classes in a way which does not implicitly depend on the database. The simplest thing is to do a `require_once` to load the target class. (EDIT: What's a nice place to put the `require_once` statement? I originally put it in each test class, but on second thought... it would be more elegant to put it in `tests/phpunit/boostrap.php`.)

(I'm writing this to help me get the problem a bit clearer in mind... hopefully that will eventually lead to a better solution...)

---
Tags: civix, unit-testing, phpunit, autoloading
---


# Question
Title: Class naming and namespaces: best practice as an extension author?
Noting these related questions (  ) and these two wiki pages ( ) and the psr-0 standard, I remain a bit lost about current best practice in CiviCRM extensions!

So if I have an extenstion `org.goodfolk.magichtml`

Would I put my classes in

```
org.goodfolk.magichtml/Civi/MagicHtml/

```

So in `org.goodfolk.magichtml/Civi/MagicHtml/HtmlFlash.php` I would have the following:

`<?php
 namespace org.goodfolk.magichtml/MagicHtml;
 class HtmlFlash {
 public function squirmLeft() {};
 public function squirmRight() {};
 }`

Is that correct?

or can it be simplified to:

`org.goodfolk.magichtml/Civi/HtmlFlash.php`:

`<?php
 namespace org.goodfolk.magichtml;
 class HtmlFlash {
 public function squirmLeft() {};
 public function squirmRight() {};
 }`

# Answer
## The conventional approach

Generally, the safe play is to make a file like `<myextension>/CRM/MyExtension/MyClass.php`:

```
<?php
class CRM_MyExtension_MyClass { ...}

```

(Be sure to match the capitalization of files and classes.)

Most documentation and tooling is based on `CRM_*` conventions, and a handful of things in core (such as `civicrm_payment_processor_type.class_name`) make quirky assumptions which only work with `CRM_*` classes.

*How it works*: In civix-based extensions, the default `hook_civicrm_config` adds your extension to the `include_path`. The classloader `CRM_Core_ClassLoader` searches the `include_path` automatically for `CRM_*` classes.

*Critique:* In older PHP projects, it was common to automatically link the class-loading with the `include_path`, but in large codebases this can lead to a large number of file-system checks. Now-a-days many frameworks will reduce lookups by pre-generating some kind of map (namespaces\<=\>directories or classes\<=\>files).

## The PSR-4 approach (Civi v4.7+)

PSR-4 is a more contemporary technique in which you explicitly map a directory to a namespace. Many PHP developers have been exposed to PSR-4 through `composer.json`. Civi v4.7 adds `CRM_Extension_ClassLoader`; with this, you can use `info.xml` to declare similar mappings:

```
<extension key="..." type="module">
  ...
  <classloader>
    <psr4 prefix="My\Namespace\" path="src" />
  </classloader>
  ...
</extension>

```

In this case, the file `<myextension>/src/Foo.php` would look like:

```
<?php
namespace My\Namespace;
class Foo { ... }

```

In terms of lookup performance and caching, this should be better than `CRM_Core_ClassLoader`. However, it doesn't have full parity with `CRM_*` in terms of documentation / tooling / testing.

# Custom class loader

You should be able to register your own class-loaders -- e.g. just call `spl_autoload_register(...)` in your module's main PHP file (perhaps in `hook_civicrm_config`). If you do this, I suggest following a convention like PSR-0 or PSR-4.

Compared to the PSR-4/Civi v4.7 approach above:

* Pro: Should be compatible with any version of Civi
* Con: Requires more lines of code
* Con: Has the same issue of negligible documentation / tooling / testing

# PHPUnit Base Classes

There is an issue if you want to write a custom base-class for PHPUnit tests within an extension -- which is the topic of Does class autoloading not work in standalone phpunit testing?
> 5 votes

# Answer
In general, when developing extensions I would take a look at the existing ones authored by the core team or by heavily active contributors. To give some importance on my suggestion below I just checked widely used cms independent extensions available and landed at https://github.com/dlobo/org.civicrm.module.cividiscount.

Extensions that I wrote and most I know hold classes under `<tld.domain.ext>/CRM/ExtensionName/` and follow php's naming conventions there. API methods are located under `api/v3/` and named in api manner (classes reflecting api, methods reflecting actions).
> 0 votes

---
Tags: php, best-practice, coding-standards, autoloading
---


# Question
Title: Reverting CiviCRM on Drupal 7 to last backed up state?
What is the best procedure for reverting the CiviCRM, powered by Drupal 7, back to a previous backed up state, in case of database corruption, failed upgrades or other undesirable changes?

# Answer
> 4 votes
**How to revert the CiviCRM to previous state:**

1. Put Drupal into maintenance mode
2. Disable integration modules
3. Replace `civicrm.settings.php` with backed up copy and check permissions
4. Remove everything in `<drupal_home>/sites/all/modules/civicrm` and replace with backed up version and check permissions
5. Drop civicrm database and import backup database
6. Clear caches and empty `<drupal_home>sites/default/files/civicrm/templates_c` and check permissions
7. Re-enable integration modules
8. Log in, test and debug

**Command Line Cheatsheet for Drush and MySQL, Regarding These Steps:**

Maintenance mode: `drush vset maintenance_mode 1`

Disabling and Enabling CiviCRM Integration Modules:

`drush pm-disable [integration_module]` or `drush pm-enable [integration_module]`

Dropping, re-creating and importing a database in MySQL:

```
mysql -u [username] -p
use [database name];
DROP DATABASE [database];
CREATE DATABASE [database];
source path/to/backup.sql;

```

Clear caches: `drush cc all`

Dealing with templates\_c: `rm <drupal_home>sites/default/files/civicrm/templates_c/*`

---
Tags: drupal, backups
---


# Question
Title: Membership not generated by membership contribution 4.6.18
We are upgrading our database from 4.4.7 to 4.6.18.

On testing, there is an issue related to pending membership payments, generated by the Civi contribution page, not generating a membership on the membership tab when the membership contribution is marked as completed.

I've tested as a new member opting to pay later on our database, then opened the contact record as a member of staff would on receiving funds to mark this contribution as complete. On our live CiviCRM 4.4.7. database, this results in the membership appearing as new, but on CiviCRM 4.6.18. nothing appears on the membership tab.

Is this a bug or is this how 4.6.18 works?

# Answer
Are you using a price set? If so, look at the price sets and make sure that each for membership has a Membership Type chosen in the first field drop-down menu. The notation there states: "***If a membership type is selected, a membership will be created*** *or renewed when users select this option. Leave this blank if you are using this for non-membership options (e.g. magazine subscription).*"

I found that some of mine were empty thus no membership records were created; only the contributions were. This is a bit arcane and not obvious if not researched.

Here are some pics:

https://imagebin.ca/36uQhc0anGfS/civicrm-PriceSets.jpg

https://imagebin.ca/36uR45kYYMny/civicrm-PriceSets-PriceFields.jpg

https://imagebin.ca/36uRKx3WsIvy/civicrm-PriceSets-PriceOption.jpg

Also, I am finding that if you enter the membership using New Contribution it will not record it in the Membership Manager. You have to enter it as New Membership and then the Membership Dues will be recorded as a contribution. This is a little clunky but the workflow is understandable.
> 1 votes

---
Tags: contributions, contribution-page
---


# Question
Title: Send a single mail to fundraising responsible
I want to send a single mail to a responsible address when a certain event occur in my extension. I had a look to some API (Email, Mailing, MailingAB) but but none of these seem to be the right one. There is an API or a class I can use to send mails?

# Answer
> 1 votes
The Email API extension will have example code for you to use for your extension. Its code is available on github: https://github.com/CiviCooP/org.civicoop.emailapi

# Answer
> 1 votes
Finally I used the following code for send a mail:

```
    $mailParams = array(
        'groupName' => '...',
        'from' => '...',
        'toName' => '...',
        'toEmail' => '...',
        'subject' =>  '....',
        'text' => ''....,
    );

   $result = CRM_Utils_Mail::send($mailParams);

```

# Answer
> 0 votes
You may want to have a look at the extension CiviRules that allows you to configure triggers, conditions, and actions such as sending out an email on a certain event.

# Answer
> 0 votes
Take a look at this extension that Sarah Gladstone wrote. It sounds similar to what you're doing and you might be able to get some example code from it.

https://github.com/sgladstone/com.fountaintribe.scheduledcommunication

---
Tags: api, extension, email
---


# Question
Title: DB Error: constraint violation when I try to add profiles to contribution page
I cannot seem to enable profiles on contribution pages. There are no drop-down menus for including profiles, and when I try to type in an existing profile, I get a page with "DB: error: constraint violation." What am I missing? (I am using CiviCRM 4.6.3 on Wordpress 4.2.2.)

Update: Here is a screenshot of the page:

Update:Here is the error/backtrace:

Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`rpwrhsor_civicrm`.`civicrm_uf_join`, CONSTRAINT `FK_civicrm_uf_join_uf_group_id` FOREIGN KEY (`uf_group_id`) REFERENCES `civicrm_uf_group` (`id`)), 1452 Additional Details: Array ( \[callback\] =\> Array ( \[0\] =\> CRM\_Core\_Error  =\> handle )

```
[code] => -3
[message] => DB Error: constraint violation
[mode] => 16
[debug_info] => INSERT INTO civicrm_uf_join (is_active , module , entity_table , entity_id , weight , uf_group_id ) VALUES ( 1 , 'CiviContribute' , 'civicrm_contribution_page' ,  3 ,  2 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`rpwrhsor_civicrm`.`civicrm_uf_join`, CONSTRAINT `FK_civicrm_uf_join_uf_group_id` FOREIGN KEY (`uf_group_id`) REFERENCES `civicrm_uf_group` (`id`))]
[type] => DB_Error
[user_info] => INSERT INTO civicrm_uf_join (is_active , module , entity_table , entity_id , weight , uf_group_id ) VALUES ( 1 , 'CiviContribute' , 'civicrm_contribution_page' ,  3 ,  2 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`rpwrhsor_civicrm`.`civicrm_uf_join`, CONSTRAINT `FK_civicrm_uf_join_uf_group_id` FOREIGN KEY (`uf_group_id`) REFERENCES `civicrm_uf_group` (`id`))]
[to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_uf_join (is_active , module , entity_table , entity_id , weight , uf_group_id ) VALUES ( 1 , 'CiviContribute' , 'civicrm_contribution_page' ,  3 ,  2 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`rpwrhsor_civicrm`.`civicrm_uf_join`, CONSTRAINT `FK_civicrm_uf_join_uf_group_id` FOREIGN KEY (`uf_group_id`) REFERENCES `civicrm_uf_group` (`id`))]"]

```

)

# Answer
> 1 votes
1. Can you compare your screen with this page:

http://wp46.demo.civicrm.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/contribute/custom&reset=1&action=update&id=2

(you will need to login as demo / demo)

2. I suspect its not the same, and most likely there are some javascript errors occuring on your site. You should check the js console when you load the page
3. Seems like the values submitted (i.e. a 0 for uf\_group\_id) is not expected and hence u get the mysql error

# Answer
> 0 votes
I'm currently running into the same issues, which a check on the js console reveals is caused by javascript errors.

The error message reads as follows:

```
JQMIGRATE: Migrate is installed, version 1.4.1
crm.designerapp.js?r=uMjIi:11 Uncaught TypeError: Cannot read property 'Application' of undefined
at HTMLDocument.<anonymous> (crm.designerapp.js?r=uMjIi:11)
at j (jquery.js:3148)
at Object.fireWith [as resolveWith] (jquery.js:3260)
at Function.ready (jquery.js:3472)
at HTMLDocument.J (jquery.js:3503)
backbone.collectionsubset.js?r=uMjIi:225 Uncaught TypeError: Backbone.CollectionSubset is not a constructor at child.Backbone.Collection.subcollection (backbone.collectionsubset.js?r=uMjIi:225)
at HTMLInputElement.<anonymous> (jquery.crmProfileSelector.js?r=uMjIi:34)
at Function.each (jquery.js:384)
at m.fn.init.each (jquery.js:136)
at m.fn.init.$.fn.crmProfileSelector (jquery.crmProfileSelector.js?r=uMjIi:25)
at HTMLInputElement.<anonymous> (jquery.crmProfileSelector.js?r=uMjIi:89)
at Function.each (jquery.js:384)
at m.fn.init.each (jquery.js:136)
at HTMLDivElement.<anonymous> (jquery.crmProfileSelector.js?r=uMjIi:88)
at HTMLDivElement.dispatch (jquery.js:4670)

```

Any advice on resolving these errors?

# Answer
> 0 votes
It's likely a problem/conflict with the javascript from another module.

From this thread on our old forum: https://forum.civicrm.org/index.php?topic=35079.msg149115#msg149115

might be "Jetpack". Try to disable it to see what's happening.

In general: disable the other modules until you find the one that conflicts with civi

---
Tags: civicontribute, profile
---


# Question
Title: Should I change mysql.connect_timeout variable in php.ini?
MySQL has been losing connection on me while trying to complete the upgrade. I am wondering if I should change the php.ini variable `mysql.connect_timeout = 60` to a value of `-1` (unlimited) and if this will help?

# Answer
> 3 votes
I have definitely altered this variable for upgrades, but my notes show I only increased the values to `1800`.

I don't recall whether this was because I found that `-1` didn't work, or because I preferred to not allow a connection to remain open indefinitely.

So yes, I think you should alter it if necessary to complete upgrade.

If you find setting to `-1` works, make sure to change it back post-upgrade!

---
Tags: drupal, upgrade, mysql
---


title: Would this be a fit for us?

text:
# Question
Title: Would this be a fit for us?
We are a small nonprofit that conducts medical missions and are looking for software to help us organize our missions. Your software looks like it could help us, but I have a few questions before signing up for a demo based on our core needs: 1. Can volunteers fill out their own profile that they manage themselves? As in, they sign into a profile and answer questions themselves. 2. Can we edit all the questions asked of volunteers in their profiles? 3. Can we AND volunteers upload documents?

Thanks,

# Answer
> 3 votes
Nadine...

You've asked more than one question, but I'll try to hit them all

1) CiviCRM lets you create public forms (profiles) that users can use to manage information in their contact record, such as email addresses, phone numbers and addresses. Depending on the CMS platform you're using, there are some other ways to allow for self-service updating of information, for example, on Drupal, there's a module called Webform that has excellent CiviCRM integration.

2) The profiles are completely configurable with all the core (built-in) CiviCRM fields and can include custom fields that you've set up in the database.

3) CiviCRM and all the supported CMSes allow for file uploads. CiviCRM lets you store attached files to contact records and activity records and can be configured for other record types, too.

You don't mention if you're going to be managing volunteers with CiviCRM. There's a video with some information about the CiviVolunteer extension on YouTube https://www.youtube.com/watch?v=7hkAlLYBc2Q

# Answer
> 2 votes
You can use a demo for free here: https://civicrm.org/demo

1. It's not really designed for users to log in and answer questions, however, they can log in through your CMS/content management system (Drupal, Wordpress or Joomla driven website) and be given access to update their contact and other information.
2. What you are describing here, editing and posing questions, etc, is something you would do through your website, which could then store the information in CiviCRM
3. Access controls are handled through your website also. Anyone that has access to the CiviCRM would be able to upload documents.

Overall, CiviCRM is designed mostly to manage outreach to and contributions from donors as well as managing memberships, etc. I am not sure if this would be the best fit for what you are trying to do but it could definitely be adapted for your purpose as long as you understand that a lot of that is handled through your content management system first. Also, I wanted to make sure that you understand that you can't "sign up for a demo". It is free, open-source software that you can download and install to your website.

Update: I just found out about CiviSurvey, which might be really beneficial for you. Check it out here: https://docs.civicrm.org/user/en/4.6/survey/what-is-civisurvey/

# Answer
> 2 votes
I just want to make a suggestion : of course, CiviCRM will do all what you want.

But it must be installed upon a CMS : WordPress, Drupal, or Joomla.

From my own experience (I am not a programmer), I strongly recommend Drupal :

* easy to implement (like WordPress),
* easy to learn if you don't know it (like WordPress, but a different approach),
* very flexible in terms of permissions (more than WordPress),
* last, but not least : You can use WebForm and CiviCRM WebForm Integration Modules, which will make it very easy to do all what you ask for.

---
Tags: evaluating-civicrm, civivolunteer
---


# Question
Title: How to reduce database bloat for faster upgrading?
In order to speed up slow upgrades, experienced folk ( ) recommend reducing the size of the database to facilitate testing.

What is the best way to declutter the database?

# Answer
Best to review the tables which are largest in your DB, and also identify which queries during the upgrade take the longest. This is a chicken-and-egg problem, which means you might review the tables you "lighten" as you work through the upgrade process.

Here's something I was using a few years ago on fairly heavy DB. This would exclude data in those tables from being tested on upgrade, but that was an acceptable tradeoff to test the core upgrade.

**WARNING - this SQL will destroy data in the DB you execute it against.**

```
-- Trim a CiviCRM DB by stripping out the enormous amount of data
-- stored in some tables, especially the ones relating to mailing.
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE civicrm_cache;
TRUNCATE TABLE civicrm_log;
TRUNCATE TABLE civicrm_mailing_event_bounce;
TRUNCATE TABLE civicrm_mailing_event_delivered;
TRUNCATE TABLE civicrm_mailing_event_forward;
TRUNCATE TABLE civicrm_mailing_event_opened;
TRUNCATE TABLE civicrm_mailing_event_reply;
TRUNCATE TABLE civicrm_mailing_event_trackable_url_open;
TRUNCATE TABLE civicrm_mailing_event_unsubscribe;
TRUNCATE TABLE civicrm_mailing_event_queue;
TRUNCATE TABLE civicrm_mailing_recipients;
TRUNCATE TABLE civicrm_mailing_spool;
TRUNCATE TABLE civicrm_subscription_history;
SET FOREIGN_KEY_CHECKS=1;

```

A couple of automated scripts would use the above to reduce a copy of the live DB to a more workable upgrade dataset, then test the upgrade against this reduced DB.

Another set of DB tables you might remove is those prefixed `log_*`. The ARCHIVE table format they use by default has on-the-fly compression, and every DB update will trigger a duplicate query against log. This means you run double the number of DB updates, one of which will also require some compression. Disabling CiviCRM's trigger logging feature should then reduce the size of the database and the amount of work it does for each change.
> 6 votes

---
Tags: database, upgrade, performance
---


title: Confirmation emails not being sent

text:
# Question
Title: Confirmation emails not being sent
Our event confirmation emails are not being sent. The PayPal payment is happening, but the Online Registration Confirmation is not happening. What have I forgotten to enable??? We are using CiviCRM ver 4.7.1. I don't know how to find the version of Joomla. Emails DO go out, but only to those who do not owe any money - who have not gone to PayPal. Those who have paid remain in the "Pending (incomplete transaction)" status. We are NOT using "Pay Later".

# Answer
I've recently had to address this issue.

1) Make sure that the PayPal's "callback" setting is enabled and set to point to your website.

2) Speak with your sysadmin and make sure that calls from PayPal are not being blocked.

3) Look in your CiviCRM logs around the time of the payment to see if there are any errors.

4) Ask your friendly neighbourhood software developer (or me or a CiviCRM partner agency if you don't have one) to add extra logging and debug output to determine if the calls are being received and traced through the system.

5) Check the spam folders - there's a lot of things that you can do if emails end up being sent to spam.

Good luck!
> 1 votes

# Answer
I've experienced a similar issue when for some reason, my hosting environment reverts to an older PHP version (5.3.29). I use SparkPost and it needs 5.4.x so it stops working until I change PHP version. Not sure if it applies to your situation but thought I'd mention.
> 0 votes

---
Tags: civievent, joomla, confirmation
---


title: Missing Civicrm

text:
# Question
Title: Missing Civicrm
Recently, I went back to WordPress and I was surprised to see CIVICRM Installer on the system. I never delete or disable this. I am not sure what was happening. I checked the database and I saw the data is still there. It seem the link between WP and CIVICRM is broken. What would be the best approach to restore rather than reinstall and make a copy to database.

I have another question. If I split two databases (one for WP and One for CIVICRM), will this speed up? I tried to do this but the CIVICRM installer won't let me do this when I installed despite I typed another database name using my account. After I clicked, it went back to WP database information and there was no way. I could not find a script to instruct link between WP and CIVICRM

Thanks. I am waiting for your reply.

# Answer
If you don't have a lot of useful data, I'd suggest to drop the civicrm tables and start fresh, trying to find out what happened and where whatever happened left things in slightly broken state isn't worthwhile the investigative work, download the latest version of civi and start clean

As for having separate databases, it's probably worthwhile if you have a lot of contacts or activities, not so much for speed than for backup restore convenience. but if you have a medium size installation (say less than 30k contacts), I wouldn't bother and put everything in the same database

X+
> 1 votes

---
Tags: wordpress
---


# Question
Title: why is the percentage of successful deliveries greater than the intended recipients in civi mailing report?
I have started experiencing some problems with bulk mailing, for at least 3 mailings the mailing report shows successful deliveries greater than the intended recipients. I have checked the detail report and noticed that some contacts actually show successful deliveries 4 times, while others are double or triple - see attached

In some cases, the contact email is marked as on hold but report shows double or triple successful deliveries.

My Mailer Batch Limit is 750, cron used to run every 15 minutes (\*/15 * * * * wget -O - -q -t 1 'http://mysite.org/sites/all/modules/civicrm/bin/cron.php?name=username&pass=password&key=site-key'), i have changed it to every hour but still get more deliveries. Mailer Throttle Time, Mailer Job Size and Mailer CRON job limit are set to 0. I have had this settings for long and didn't experience this problem until recently.

I have also taken a look at this post here but this doesn't seem to be my case.

What should i be looking at? Civi 4.6.10, Drupal 7

# Answer
> 2 votes
@Kboy - that sounds like it could be a bug; General receipe for this sort of scenario is to update to latest 4.6.x - if this then still persists let us know and file a bug report on JIRA. 4.6.x latest is where you want to be for many other reasons since 4.6.10 - so time well spent. Please keep us posted!

# Answer
> 1 votes
I've got a theory about this, based on my experience with Clickatell.

Members of 'Team Clicka' will occasionally receive inbound text messages twice, and very rarely three times. This is because Clickatell would sometimes tell us about the message, not get a response saying we heard it, and then tell us again.

I bet that something similar is happening with clickthroughs. As you're not throttling, it makes sense that your server would be too busy to send out all its "yes, I heard you" messages, so perhaps they're being resent?

Also, has anyone double checked to make sure that clicking the same message multiple times isn't being counted multiple times? Seems unlikely but it could happen.

# Answer
> 1 votes
We have a similar problem and so where we could find was related with ACLs. Users who sent mailings and had ACLs defined caused this unexpected behaviour. We experimented it with CiviCRM versions 4.7.11 and 4.7.12.

# Answer
> 1 votes
I've been able to reproduce the duplicate deliveries that push the delivery rate over 100% by having 2 cron jobs processing a CiviMail job at the same time.

@scardinius has traced this to some code and we've opened ticket https://issues.civicrm.org/jira/browse/CRM-19809 for the bug.

There's a conversation on MatterMost about this bug. https://chat.civicrm.org/civicrm/pl/168t4i9ac3nu7rwcrpi8dcfnca

In any case, it would be prudent to prevent 2 cron jobs from running at the same time, either by adjusting the Mailer Batch Limit setting under Administer - CiviMail - Mailer Settings to a value less than the number of messages that can be delivered in a single cron run, or by using a lockfile to prevent the cron job from invoking the Scheduled Jobs while another is running.

```
#!/usr/local/bin/bash
if [ ! -f $HOME/civicrm-cron.lock ]
then
  touch $HOME/civicrm-cron.lock
  /usr/bin/wp --user="civicrm_cron" \
    --url=http://www.yoursite.org \
    --path=/home/yoursite/public_html \
    civicrm api job.execute auth=0
  wait
  rm -f $HOME/civicrm-cron.lock
fi

```

Per Xavier's comment, your environment may depend on being able to have 2 instances of the Scheduled Jobs running at the same time, as in the case of doing A/B testing.

---
Tags: civimail, cron-job
---


# Question
Title: Can't administer cividiscount afer upgrade to 4.7.7
I've recently upgraded to 4.7.7 and it seems this has caused me to be unable to administer cividiscount. Current discounts are working, the extension is listed properly, there are/were no errors at any point. It's just when you go to the cividiscount URL you get the main civiCRM dashboard!

Previous version was 4.7.4, cividiscount version in 3.2 running on Drupal 7.43

I have noted a similar question here same sounding problem on a different version, no solutions.

How do I even start finding out what this is? do I need to turn on some sort of debugging and look at lots of logs?

# Answer
> 1 votes
I was having the same issue (Joomla 3.5/CiviCRM 4.7.8) after a tests on my local install, I found that activating the debug (Administer \> System Settings \> Debugging & Error Handling), browsing the CiviDiscount loaded. Turned off debug and loaded. Hope this may help.

# Answer
> 1 votes
I was having the same problem in Drupal until I realized that the menu link was wrong and when I put in the correct URL manually, it would indeed go to the CiviDiscount administration page.

The link that the menu takes me to: https://dev.example.com/civicrm/cividiscount\_reset\_1

The correct link: https://dev.example.com/civicrm/cividiscount?reset=1

Even though I don't know why this happened, it's worth checking out. To fix it, edit the link URL in the menu: Administer \> Custom Data & Screens \> Navigation then right-click menu item and edit. If you are unable to edit it from here, you could create a new link.

---
Tags: cividiscount
---