- Issue created by @kanchamk
- Status changed to Downport
6 months ago 1:19pm 9 October 2024 - 🇺🇸United States pearl.liang
Hi kanchamk
I am also installing Opigno 3.2.7. The above patch solves the first error message caused by visiting /private-message:
Error: Call to a member function load() on null in Drupal\opigno_messaging\Services\OpignoPrivateMessageService->getFirstThreadForUser() (line 38 of C:\xampp\htdocs\opigno-composer\web\modules\contrib\opigno_messaging\src\Services\OpignoPrivateMessageService.php).
But, the 2nd error message occurs when I click the particular private message thread (a.k.a "Discussion"). The url is /private-messages/[an integer representing thread id]. For example: /private-messages/6.
TypeError: Drupal\private_message\Form\PrivateMessageForm::__construct(): Argument #11 ($privateMessageBanManager) must be of type Drupal\private_message\Service\PrivateMessageBanManagerInterface, Drupal\Core\Form\FormBuilder given, called in C:\xampp\htdocs\opigno-composer\web\modules\contrib\opigno_messaging\src\Form\PrivateMessageForm.php on line 30 in Drupal\private_message\Form\PrivateMessageForm->__construct() (line 137 of C:\xampp\htdocs\opigno-composer\web\modules\contrib\private_message\src\Form\PrivateMessageForm.php).
Can you look again and see if you can come up with another patch to fix the particular thread by visiting /private-messages/[an integer representing thread id] ? Thank you very much.
- 🇳🇬Nigeria chike Nigeria
The patch here ought to be posted on the issue I referenced as that is the module it is patching.
The patch introduces another issue,
Warning: Undefined variable $thread_id in Drupal\opigno_messaging\Services\OpignoPrivateMessageService->getFirstThreadForUser() (line 38 of /var/www/html/public_html/modules/contrib/opigno_messaging/src/Services/OpignoPrivateMessageService.php)`
This is because the patch removes this line
$thread_id = array_shift($user_threads);
where the variable is declared.I fixed the method this way,
public function getFirstThreadForUser(UserInterface $user) { $uid = (int) $user->id(); $user_threads = $this->msgThreadService->getUserThreads($uid); $thread_id = array_shift($user_threads); $pmThreadManager = $this->entityTypeManager->getStorage('private_message_thread'); return !$thread_id ? FALSE : $pmThreadManager->load($thread_id); }