* revision to the database.
*
* @param $preUpgradeMessage
- * @param $rev string, a version number, e.g. '4.2.alpha1', '4.2.beta3', '4.2.0'
+ * @param $rev
+ * String, a version number, e.g. '4.2.alpha1', '4.2.beta3', '4.2.0'.
* @param null $currentVer
*
* @return void
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
if ($rev == '4.2.alpha1') {
- $tables = array('civicrm_contribution_page','civicrm_event','civicrm_group','civicrm_contact');
- if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)){
+ $tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
+ if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)) {
$errors = ts("The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to %1.", array(1 => CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki")));
CRM_Core_Error::fatal($errors);
return FALSE;
$invalidData = CRM_Core_DAO::executeQuery($query);
if ($invalidData->N) {
$invalidDataMessage = "<br /><strong>" . ts('The upgrade is being aborted due to data integrity issues in your database. There are multiple membership records linked to the same contribution record. This is unexpected, and some of the membership records may be duplicates. The problem record sets are listed below. Refer to <a href="%1">this wiki page for instructions on repairing your database</a> so that you can run the upgrade successfully.
- ', array( 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC42/Repair+database+script+for+4.2+upgrades')) . "</strong>";
+ ', array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC42/Repair+database+script+for+4.2+upgrades')) . "</strong>";
$membershipType = CRM_Member_PseudoConstant::membershipType();
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
$invalidDataMessage .= "<table border=1><tr><th>Contact-ID</th><th>Contribution-ID</th><th>Membership-ID</th><th>Membership Type</th><th>Start Date</th><th>End Date</th><th>Membership Status</th></tr>";
$invalidDataMessage .= "<td>{$invalidData->end_date}</td>";
$invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->status_id, $membershipStatus) . "</td>";
$invalidDataMessage .= "</tr>";
- }
+ }
$invalidDataMessage .= "</table><p>" . ts('If you have reviewed the cleanup script documentation on the wiki and you are ready to run the cleanup now - <a href="%1">click here</a>.', array(1 => CRM_Utils_System::url('civicrm/upgrade/cleanup425', 'reset=1'))) . "</p>";
CRM_Core_Error::fatal($invalidDataMessage);
return FALSE;
- }
}
+ }
if ($rev == '4.2.beta2') {
// note: error conditions are also checked in upgrade_4_2_beta2()
$preUpgradeMessage .= '<br />' . ts('Could not determine path to civicrm.settings.php. Please manually locate it and add these lines at the bottom: <pre>%1</pre>', array(
1 => self::SETTINGS_SNIPPET
));
- } elseif (preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
+ }
+ elseif (preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
// OK, nothing to do
- } elseif (!is_writable(CIVICRM_SETTINGS_PATH)) {
+ }
+ elseif (!is_writable(CIVICRM_SETTINGS_PATH)) {
$preUpgradeMessage .= '<br />' . ts('The settings file (%1) must be updated. Please make it writable or manually add these lines:<pre>%2</pre>', array(
1 => CIVICRM_SETTINGS_PATH,
2 => self::SETTINGS_SNIPPET
INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'default_membership_type_amount' ";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
- $preUpgradeMessage .= "<br /><strong>". ts('We have identified extraneous data in your database that a previous upgrade likely introduced. We STRONGLY recommend making a backup of your site before continuing. We also STRONGLY suggest fixing this issue with unneeded records BEFORE you upgrade. You can find more information about this issue and the way to fix it by visiting <a href="http://forum.civicrm.org/index.php/topic,26181.0.html">http://forum.civicrm.org/index.php/topic,26181.0.html</a>.') ."</strong>";
+ $preUpgradeMessage .= "<br /><strong>" . ts('We have identified extraneous data in your database that a previous upgrade likely introduced. We STRONGLY recommend making a backup of your site before continuing. We also STRONGLY suggest fixing this issue with unneeded records BEFORE you upgrade. You can find more information about this issue and the way to fix it by visiting <a href="http://forum.civicrm.org/index.php/topic,26181.0.html">http://forum.civicrm.org/index.php/topic,26181.0.html</a>.') . "</strong>";
}
}
$errors = ts("We found unexpected data values from an older version of CiviCRM in your database. The upgrade can not be run until this condition is corrected.<br /><br />Details: One or more rows are present in the civicrm_option_group with name like 'civicrm_price_field.amount.%'. <a href='%1'>Check here for information on diagnosing and correcting this problem.</a>", array(1 => 'http://forum.civicrm.org/index.php/topic,27744.msg118748.html#msg118748'));
CRM_Core_Error::fatal($errors);
return FALSE;
- }
+ }
}
}
/**
* Compute any messages which should be displayed after upgrade
*
- * @param $postUpgradeMessage string, alterable
- * @param $rev string, an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs
+ * @param $postUpgradeMessage
+ * String, alterable.
+ * @param $rev
+ * String, an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
* @return void
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
$postUpgradeMessage .= '<br />' . ts('Please <a href="%1" target="_blank">configure the Extension Resource URL</a>.', array(
1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1')
));
- }
+ }
}
if ($rev == '4.2.7') {
$postUpgradeMessage .= '<br />' . ts('If you have configured a report instance to allow anonymous access, you will need to reset the permission to Everyone for that instance (under the Report Settings pane).');
- }
+ }
}
/**
//checking whether the foreign key exists before dropping it
//drop foreign key queries of CRM-9850
$params = array();
- $tables = array('civicrm_contribution_page' =>'FK_civicrm_contribution_page_payment_processor_id',
+ $tables = array(
+ 'civicrm_contribution_page' => 'FK_civicrm_contribution_page_payment_processor_id',
'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
'civicrm_group' => 'FK_civicrm_group_saved_search_id',
);
- foreach($tables as $tableName => $fKey){
- $foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName,$fKey);
- if ($foreignKeyExists){
+ foreach ($tables as $tableName => $fKey) {
+ $foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
+ if ($foreignKeyExists) {
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP INDEX {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
}
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
}
}
- } else {
+ }
+ else {
$query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title'";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
}
}
- public function convertContribution(){
+ public function convertContribution() {
$minContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
$maxContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
for ($startId = $minContributionId; $startId <= $maxContributionId; $startId += self::BATCH_SIZE) {
while ($dao->fetch()) {
$addTo = explode('.', $dao->name);
if (!empty($addTo[2])) {
- $options = array ('optionGroup' => $dao->name);
+ $options = array('optionGroup' => $dao->name);
self::createPriceSet($daoName, $addTo, $options);
}
CRM_Core_OptionGroup::deleteAssoc($dao->name);
$addTo = array('civicrm_contribution_page');
while ($dao->fetch()) {
$addTo[2] = $dao->contribution_page_id;
- $options = array ('otherAmount' =>$dao->is_allow_other_amount,
- 'membership' => $dao->membership_block_id );
+ $options = array(
+ 'otherAmount' => $dao->is_allow_other_amount,
+ 'membership' => $dao->membership_block_id);
self::createPriceSet($daoName, $addTo, $options);
}
* (Queue Task Callback)
*/
public static function task_4_2_x_runSql(CRM_Queue_TaskContext $ctx, $rev) {
- $upgrade = new CRM_Upgrade_Form();
- $upgrade->processSQL($rev);
+ $upgrade = new CRM_Upgrade_Form();
+ $upgrade->processSQL($rev);
- // now rebuild all the triggers
- // CRM-9716
- // FIXME // CRM_Core_DAO::triggerRebuild();
+ // now rebuild all the triggers
+ // CRM-9716
+ // FIXME // CRM_Core_DAO::triggerRebuild();
- return TRUE;
+ return TRUE;
}
/**
*
* create price sets
*/
- public static function createPriceSet($daoName, $addTo, $options = array()) {
+ public static function createPriceSet($daoName, $addTo, $options = array()) {
$query = "SELECT title FROM {$addTo[0]} where id =%1";
$setParams['title'] = CRM_Core_DAO::singleValueQuery($query,
array(1 => array($addTo[2], 'Integer'))
// an event or contrib page has been deleted but left the option group behind - (this may be fixed in later versions?)
// we should probably delete the option group - but at least early exit here as the code following it does not fatal
// CRM-10298
- if ( empty($pageTitle)) {
+ if (empty($pageTitle)) {
return;
}
$optionValue = array();
if (!empty($options['optionGroup'])) {
CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
- if (empty($optionValue))
+ if (empty($optionValue)) {
return;
+ }
}
elseif (empty($options['otherAmount']) && empty($options['membership'])) {
//CRM-12273
return;
}
- if (! CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', true)) {
+ if (! CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
$setParams['name'] = $pageTitle;
}
else {
- $timeSec = explode(".", microtime(true));
+ $timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['extends'] = $daoName[$addTo[0]][1];
* records.
*
* @param CRM_Queue_TaskContext $ctx
- * @param $startId int, the first/lowest contribution ID to convert
- * @param $endId int, the last/highest contribution ID to convert
+ * @param $startId
+ * Int, the first/lowest contribution ID to convert.
+ * @param $endId
+ * Int, the last/highest contribution ID to convert.
*
* @return bool
*/
//CRM-12273
//check if price_set_id is exist, if not use the default contribution amount
- if (isset($result->price_set_id)){
+ if (isset($result->price_set_id)) {
$priceSetId = $result->price_set_id;
}
else{
$defaultPriceSets = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
foreach ($defaultPriceSets as $key => $pSet) {
- if ($pSet['name'] == 'contribution_amount'){
+ if ($pSet['name'] == 'contribution_amount') {
$priceSetId = $pSet['setID'];
}
}
* records.
*
* @param CRM_Queue_TaskContext $ctx
- * @param $startId int, the first/lowest participant ID to convert
- * @param $endId int, the last/highest participant ID to convert
+ * @param $startId
+ * Int, the first/lowest participant ID to convert.
+ * @param $endId
+ * Int, the last/highest participant ID to convert.
*
* @return bool
*/
'price_field_value_id' => $dao->price_field_value_id,
);
$priceSetId = $dao->price_set_id;
- } else {
+ }
+ else {
$lineParams['price_field_id'] = $fieldID;
$priceSetId = $defaultPriceSetId;
}
$contribStatus = CRM_Utils_Array::value($dao->contribution_status_id, $contributionStatus);
$processedRecords[] = array($dao->contact_id, $dao->contribution_id, $contribStatus, $dao->membership_id,
$memType, $dao->start_date, $dao->end_date, $memStatus, $status);
-}
+ }
}
- if ( !empty($processedRecords) ) {
+ if (!empty($processedRecords)) {
CRM_Core_Error::debug_log_message("deleteInvalidPairs() - The following records have been processed. Membership records with action:");
- CRM_Core_Error::debug_log_message( "Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action" );
- foreach ( $processedRecords as $record ) {
+ CRM_Core_Error::debug_log_message("Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action");
+ foreach ($processedRecords as $record) {
CRM_Core_Error::debug_log_message(implode(', ', $record));
}
- } else {
+ }
+ else {
CRM_Core_Error::debug_log_message("deleteInvalidPairs() - Could not find any records to process.");
}
return $processedRecords;