Be sure to checkout our newest add-on Reading Time Pro!

EE4 compatibility updates:

  • Publisher is EE4 and EE5 compatible, but it does not currently support the Fluid field (it's in the works).
  • Reel is EE4 and EE5 compatible, but it does not currently support the Fluid field.

Ticket: Exception when sending for approval in function getMemberData

Status Resolved
Add-on / Version Publisher Lite 2.10.2
Severity
EE Version 4.3.6

David Clough

Oct 29, 2018

There it a bug I have notices when trying to submit a draft for approval. When retrieving member data with your utility function an exception is thrown where you attempt to look at a member_data table that has been restructured in recent EE releases. Here is a diff which uses inbuilt EE ORM functions to more reliably achieve the same task.

--- a/system/user/addons/publisher/Service/Member.php
+++ b/system/user/addons/publisher/Service/Member.php
@@ -205,55 +205,22 @@ class Member
      */
     public function getMemberData($memberId)
     {
-        $memberData = array();
-        $cacheKey = 'member_custom_fields';
-        $db = ee('db');
-
-        // Get all CUSTOM member fields
-        if (!$this->requestCache->get($cacheKey))
-        {
-            $prefix = $db->dbprefix;
-            $result = $db->query("SELECT m_field_id AS field_id, m_field_name AS field_name, m_field_label AS field_label FROM {$prefix}member_fields");
-
-            $this->requestCache->set('member_custom_fields', $result);
-        }
-
-        /** @var \CI_DB_result $fields */
-        $fields = $this->requestCache->get($cacheKey);
-        $field_ids = array();
-
-        foreach($fields->result_array() as $row) {
-            // Create our select of which fields to get
-            $field_ids[] = 'md.m_field_id_'. $row['field_id'] .' AS "'. $row['field_name'].'"';
-        }
-
         // Normal case, but not if used in Channel:Form/Zoo Visitor registration
         // and user requires admin verification, they don't have a member_id,
         // so look up the user via email.
         if (is_numeric($memberId)) {
-            $where = array('m.member_id' => $memberId);
+            $member = ee('Model')->get('Member')->filter('member_id', $memberId)->first();
         }
         // If a non-integer value is sent, assume its an email address
         else {
-            $where = array('m.email' => $memberId);
-        }
-
-        /** @var \CI_DB_result $qry */
-        $qry = $db->select(implode(',', $field_ids) .', m.*')
-            ->from('members m')
-            ->join('member_data md', 'md.member_id = m.member_id')
-            ->where($where)
-            ->get();
-
-        if ($qry->num_rows() === 0) {
-            return false;
+            $member = ee('Model')->get('Member')->filter('email', $memberId)->first();
         }
 
-        foreach($qry->row() as $key => $value) {
-            $value = is_array($value) ? implode(', ', $value) : $value;
-            $memberData[$key] = $value;
+        if(empty($member))
+        {
+          return false;
         }
 
-        return (object) $memberData;
+        return $member;
     }
 }
#1

BoldMinded (Brian)

Oct 29, 2018

Thanks for spotting this, and bigger thanks for sending the diff. I’ll take a look at getting this included in the next release.

#2

BoldMinded (Brian)

Oct 30, 2018

Added this change to the next release. Thanks!

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.