From 4233c3d9dc870884b7fbd43faafd6b3920ca2f10 Mon Sep 17 00:00:00 2001
From: Kevin Cristiano <kcristiano@kcristiano.com>
Date: Sun, 28 Apr 2019 10:44:29 -0400
Subject: [PATCH] civicrm 5.12.4: release

---
 civicrm.php                                   |  2 +-
 .../CRM/ACL/Form/WordPress/Permissions.php    |  2 +-
 civicrm/CRM/Contribute/Form/Task/Invoice.php  |  8 +++-
 civicrm/CRM/Mailing/BAO/Mailing.php           |  2 +-
 .../Upgrade/Incremental/sql/5.12.4.mysql.tpl  |  1 +
 civicrm/CRM/Utils/System/WordPress.php        | 10 ++---
 civicrm/Civi/Install/Requirements.php         |  3 +-
 civicrm/civicrm-version.php                   |  2 +-
 civicrm/release-notes/5.12.4.md               | 39 +++++++++++++++++++
 civicrm/sql/civicrm_data.mysql                |  2 +-
 civicrm/sql/civicrm_generated.mysql           |  2 +-
 civicrm/vendor/autoload.php                   |  2 +-
 civicrm/vendor/composer/autoload_real.php     | 14 +++----
 civicrm/vendor/composer/autoload_static.php   | 12 +++---
 civicrm/xml/version.xml                       |  2 +-
 15 files changed, 74 insertions(+), 29 deletions(-)
 create mode 100644 civicrm/CRM/Upgrade/Incremental/sql/5.12.4.mysql.tpl
 create mode 100644 civicrm/release-notes/5.12.4.md

diff --git a/civicrm.php b/civicrm.php
index 90994bf520..b8cb9b4406 100644
--- a/civicrm.php
+++ b/civicrm.php
@@ -2,7 +2,7 @@
 /*
 Plugin Name: CiviCRM
 Description: CiviCRM - Growing and Sustaining Relationships
-Version: 5.12.3
+Version: 5.12.4
 Author: CiviCRM LLC
 Author URI: https://civicrm.org/
 Plugin URI: https://wiki.civicrm.org/confluence/display/CRMDOC/Installing+CiviCRM+for+WordPress
diff --git a/civicrm/CRM/ACL/Form/WordPress/Permissions.php b/civicrm/CRM/ACL/Form/WordPress/Permissions.php
index bff39194d0..24e63eaa60 100644
--- a/civicrm/CRM/ACL/Form/WordPress/Permissions.php
+++ b/civicrm/CRM/ACL/Form/WordPress/Permissions.php
@@ -54,7 +54,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
     }
     foreach ($wp_roles->role_names as $role => $name) {
       // Don't show the permissions options for administrator, as they have all permissions
-      if ( is_multisite() OR $role !== 'administrator') {
+      if ($role !== 'administrator') {
         $roleObj = $wp_roles->get_role($role);
         if (!empty($roleObj->capabilities)) {
           foreach ($roleObj->capabilities as $ckey => $cname) {
diff --git a/civicrm/CRM/Contribute/Form/Task/Invoice.php b/civicrm/CRM/Contribute/Form/Task/Invoice.php
index d6e4758d4b..865f91b5a1 100644
--- a/civicrm/CRM/Contribute/Form/Task/Invoice.php
+++ b/civicrm/CRM/Contribute/Form/Task/Invoice.php
@@ -298,7 +298,13 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
       $invoiceDate = date("F j, Y");
       $dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $prefixValue['due_date'] . "" . $prefixValue['due_date_period']));
 
-      $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID);
+      if ($input['component'] == 'contribute') {
+        $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID);
+      }
+      else {
+        $eid = $contribution->_relatedObjects['participant']->id;
+        $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, 'participant', NULL, TRUE, FALSE, TRUE);
+      }
 
       $resultPayments = civicrm_api3('Payment', 'get', array(
             'sequential' => 1,
diff --git a/civicrm/CRM/Mailing/BAO/Mailing.php b/civicrm/CRM/Mailing/BAO/Mailing.php
index a109c35f6d..bd6e8a0fc9 100644
--- a/civicrm/CRM/Mailing/BAO/Mailing.php
+++ b/civicrm/CRM/Mailing/BAO/Mailing.php
@@ -1750,7 +1750,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
    */
   public static function getMailingHash($id) {
     $hash = NULL;
-    if (Civi::settings()->get('hash_mailing_url')) {
+    if (Civi::settings()->get('hash_mailing_url') && !empty($id)) {
       $hash = CRM_Core_DAO::getFieldValue('CRM_Mailing_BAO_Mailing', $id, 'hash', 'id');
     }
     return $hash;
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.12.4.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.12.4.mysql.tpl
new file mode 100644
index 0000000000..68f3b7d7de
--- /dev/null
+++ b/civicrm/CRM/Upgrade/Incremental/sql/5.12.4.mysql.tpl
@@ -0,0 +1 @@
+{* file to handle db changes in 5.12.4 during upgrade *}
diff --git a/civicrm/CRM/Utils/System/WordPress.php b/civicrm/CRM/Utils/System/WordPress.php
index 27fffe2af7..f450056bdb 100644
--- a/civicrm/CRM/Utils/System/WordPress.php
+++ b/civicrm/CRM/Utils/System/WordPress.php
@@ -810,13 +810,11 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     $contactCreated = 0;
     $contactMatching = 0;
 
-    // previously used $wpdb - which means WordPress *must* be bootstrapped
-    $wpUsers = get_users(array(
-      'blog_id' => get_current_blog_id(),
-      'number' => -1,
-    ));
+    global $wpdb;
+    $wpUserIds = $wpdb->get_col("SELECT $wpdb->users.ID FROM $wpdb->users");
 
-    foreach ($wpUsers as $wpUserData) {
+    foreach ($wpUserIds as $wpUserId) {
+      $wpUserData = get_userdata($wpUserId);
       $contactCount++;
       if ($match = CRM_Core_BAO_UFMatch::synchronizeUFMatch($wpUserData,
         $wpUserData->$id,
diff --git a/civicrm/Civi/Install/Requirements.php b/civicrm/Civi/Install/Requirements.php
index 4d2d3f72d4..df7a60a900 100644
--- a/civicrm/Civi/Install/Requirements.php
+++ b/civicrm/Civi/Install/Requirements.php
@@ -609,6 +609,7 @@ class Requirements {
       return $results;
     }
 
+    mysqli_query($conn, 'DROP TABLE IF EXISTS civicrm_utf8mb4_test');
     $r = mysqli_query($conn, 'CREATE TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
     if (!$r) {
       $results['severity'] = $this::REQUIREMENT_WARNING;
@@ -616,7 +617,7 @@ class Requirements {
       mysqli_close($conn);
       return $results;
     }
-    mysqli_query('DROP TABLE civicrm_utf8mb4_test');
+    mysqli_query($conn, 'DROP TABLE civicrm_utf8mb4_test');
 
     // Ensure that the MySQL driver supports utf8mb4 encoding.
     $version = mysqli_get_client_info($conn);
diff --git a/civicrm/civicrm-version.php b/civicrm/civicrm-version.php
index 13aa8e3f74..2623bec7ed 100644
--- a/civicrm/civicrm-version.php
+++ b/civicrm/civicrm-version.php
@@ -1,7 +1,7 @@
 <?php
 /** @deprecated */
 function civicrmVersion( ) {
-  return array( 'version'  => '5.12.3',
+  return array( 'version'  => '5.12.4',
                 'cms'      => 'Wordpress',
                 'revision' => '' );
 }
diff --git a/civicrm/release-notes/5.12.4.md b/civicrm/release-notes/5.12.4.md
new file mode 100644
index 0000000000..dfc9c2a113
--- /dev/null
+++ b/civicrm/release-notes/5.12.4.md
@@ -0,0 +1,39 @@
+# CiviCRM 5.12.4
+
+Released April 25, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Bugs resolved](#bugs)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?*                                         |         |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities?                                   |   no    |
+| Change the database schema?                                     |   no    |
+| Alter the API?                                                  |   no    |
+| Require attention to configuration options?                     |   no    |
+| Fix problems installing or upgrading to a previous version?     |   no    |
+| Introduce features?                                             |   no    |
+| **Fix bugs?**                                                   | **yes** |
+
+## <a name="bugs"></a>Bugs resolved
+
+- **CiviMail - Fix "Preview" action when using `viewUrl` tokens and mailing hashes. ([dev/core#891](https://lab.civicrm.org/dev/core/issues/891): [14124](https://github.com/civicrm/civicrm-core/pull/14124))**
+
+- **Installer - Fix diagnostic for MySQL `utf8mb4` support. ([dev/core#880](https://lab.civicrm.org/dev/core/issues/880): [14129](https://github.com/civicrm/civicrm-core/pull/14129))**
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following authors and reviewers:
+
+Wikimedia Foundation - Eileen McNaughton; Australian Greens - Seamus Lee;
+Lighthouse Design and Consulting - Brian Shaughnessy; Electronic Frontier Foundation - Mark Burdett
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Tim Otten and Andrew Hunt.  If you'd like to
+provide feedback on them, please login to https://chat.civicrm.org/civicrm and
+contact `@agh1`.
diff --git a/civicrm/sql/civicrm_data.mysql b/civicrm/sql/civicrm_data.mysql
index 9eca358cfb..46f32c630b 100644
--- a/civicrm/sql/civicrm_data.mysql
+++ b/civicrm/sql/civicrm_data.mysql
@@ -24035,4 +24035,4 @@ INSERT INTO `civicrm_report_instance`
     ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
 VALUES
     (  @domainID, 'Survey Details', 'survey/detail', 'Detailed report for canvassing, phone-banking, walk lists or other surveys.', 'access CiviReport', 'a:39:{s:6:"fields";a:2:{s:9:"sort_name";s:1:"1";s:6:"result";s:1:"1";}s:22:"assignee_contact_id_op";s:2:"eq";s:25:"assignee_contact_id_value";s:0:"";s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:17:"street_number_min";s:0:"";s:17:"street_number_max";s:0:"";s:16:"street_number_op";s:3:"lte";s:19:"street_number_value";s:0:"";s:14:"street_name_op";s:3:"has";s:17:"street_name_value";s:0:"";s:15:"postal_code_min";s:0:"";s:15:"postal_code_max";s:0:"";s:14:"postal_code_op";s:3:"lte";s:17:"postal_code_value";s:0:"";s:7:"city_op";s:3:"has";s:10:"city_value";s:0:"";s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:12:"survey_id_op";s:2:"in";s:15:"survey_id_value";a:0:{}s:12:"status_id_op";s:2:"eq";s:15:"status_id_value";s:1:"1";s:11:"custom_1_op";s:2:"in";s:14:"custom_1_value";a:0:{}s:11:"custom_2_op";s:2:"in";s:14:"custom_2_value";a:0:{}s:17:"custom_3_relative";s:1:"0";s:13:"custom_3_from";s:0:"";s:11:"custom_3_to";s:0:"";s:11:"description";s:75:"Detailed report for canvassing, phone-banking, walk lists or other surveys.";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:17:"access CiviReport";s:6:"groups";s:0:"";s:9:"domain_id";i:1;}');
-UPDATE civicrm_domain SET version = '5.12.3';
+UPDATE civicrm_domain SET version = '5.12.4';
diff --git a/civicrm/sql/civicrm_generated.mysql b/civicrm/sql/civicrm_generated.mysql
index a042971b34..5282e9d65e 100644
--- a/civicrm/sql/civicrm_generated.mysql
+++ b/civicrm/sql/civicrm_generated.mysql
@@ -399,7 +399,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_domain` WRITE;
 /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.12.3',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.12.4',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
 /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
 UNLOCK TABLES;
 
diff --git a/civicrm/vendor/autoload.php b/civicrm/vendor/autoload.php
index a2b0f6b12c..9bd94634b0 100644
--- a/civicrm/vendor/autoload.php
+++ b/civicrm/vendor/autoload.php
@@ -4,4 +4,4 @@
 
 require_once __DIR__ . '/composer/autoload_real.php';
 
-return ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318::getLoader();
+return ComposerAutoloaderInit7f6acb755f5ca824ad1c9525def6d342::getLoader();
diff --git a/civicrm/vendor/composer/autoload_real.php b/civicrm/vendor/composer/autoload_real.php
index 8857ec5bca..d476405e3e 100644
--- a/civicrm/vendor/composer/autoload_real.php
+++ b/civicrm/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
 
 // autoload_real.php @generated by Composer
 
-class ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318
+class ComposerAutoloaderInit7f6acb755f5ca824ad1c9525def6d342
 {
     private static $loader;
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318
             return self::$loader;
         }
 
-        spl_autoload_register(array('ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInit7f6acb755f5ca824ad1c9525def6d342', 'loadClassLoader'), true, true);
         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
-        spl_autoload_unregister(array('ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318', 'loadClassLoader'));
+        spl_autoload_unregister(array('ComposerAutoloaderInit7f6acb755f5ca824ad1c9525def6d342', 'loadClassLoader'));
 
         $includePaths = require __DIR__ . '/include_paths.php';
         $includePaths[] = get_include_path();
@@ -31,7 +31,7 @@ class ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318
         if ($useStaticLoader) {
             require_once __DIR__ . '/autoload_static.php';
 
-            call_user_func(\Composer\Autoload\ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::getInitializer($loader));
+            call_user_func(\Composer\Autoload\ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::getInitializer($loader));
         } else {
             $map = require __DIR__ . '/autoload_namespaces.php';
             foreach ($map as $namespace => $path) {
@@ -52,19 +52,19 @@ class ComposerAutoloaderInit5c497419c84e5a596c5f14fa124a8318
         $loader->register(true);
 
         if ($useStaticLoader) {
-            $includeFiles = Composer\Autoload\ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::$files;
+            $includeFiles = Composer\Autoload\ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::$files;
         } else {
             $includeFiles = require __DIR__ . '/autoload_files.php';
         }
         foreach ($includeFiles as $fileIdentifier => $file) {
-            composerRequire5c497419c84e5a596c5f14fa124a8318($fileIdentifier, $file);
+            composerRequire7f6acb755f5ca824ad1c9525def6d342($fileIdentifier, $file);
         }
 
         return $loader;
     }
 }
 
-function composerRequire5c497419c84e5a596c5f14fa124a8318($fileIdentifier, $file)
+function composerRequire7f6acb755f5ca824ad1c9525def6d342($fileIdentifier, $file)
 {
     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
         require $file;
diff --git a/civicrm/vendor/composer/autoload_static.php b/civicrm/vendor/composer/autoload_static.php
index 3b638fd751..a36301761f 100644
--- a/civicrm/vendor/composer/autoload_static.php
+++ b/civicrm/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
 
 namespace Composer\Autoload;
 
-class ComposerStaticInit5c497419c84e5a596c5f14fa124a8318
+class ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342
 {
     public static $files = array (
         '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@@ -418,11 +418,11 @@ class ComposerStaticInit5c497419c84e5a596c5f14fa124a8318
     public static function getInitializer(ClassLoader $loader)
     {
         return \Closure::bind(function () use ($loader) {
-            $loader->prefixLengthsPsr4 = ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::$prefixLengthsPsr4;
-            $loader->prefixDirsPsr4 = ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::$prefixDirsPsr4;
-            $loader->prefixesPsr0 = ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::$prefixesPsr0;
-            $loader->fallbackDirsPsr0 = ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::$fallbackDirsPsr0;
-            $loader->classMap = ComposerStaticInit5c497419c84e5a596c5f14fa124a8318::$classMap;
+            $loader->prefixLengthsPsr4 = ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::$prefixLengthsPsr4;
+            $loader->prefixDirsPsr4 = ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::$prefixDirsPsr4;
+            $loader->prefixesPsr0 = ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::$prefixesPsr0;
+            $loader->fallbackDirsPsr0 = ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::$fallbackDirsPsr0;
+            $loader->classMap = ComposerStaticInit7f6acb755f5ca824ad1c9525def6d342::$classMap;
 
         }, null, ClassLoader::class);
     }
diff --git a/civicrm/xml/version.xml b/civicrm/xml/version.xml
index 0808c9aba6..d43dcbb660 100644
--- a/civicrm/xml/version.xml
+++ b/civicrm/xml/version.xml
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
 <version>
-  <version_no>5.12.3</version_no>
+  <version_no>5.12.4</version_no>
 </version>
-- 
GitLab