@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix two issues with creating Conpherence threads via mail on some configurations

Summary:
Ref T4107. Two issues:

- With strict MySQL settings, we try to insert `null` into the non-nullable `messageCount` field. Add an `initializeNew...` method.
- If we don't create a new conpherence (for example, because the message body is empty), we fatal on `getPHID()` right now.

Also, make this stuff a little easier to test.

Test Plan: Used `mail_handler.php` to receive empty conpherence mail, and new-thread conpherence mail.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4107

Differential Revision: https://secure.phabricator.com/D7760

+40 -3
+30 -1
scripts/mail/mail_handler.php
··· 1 1 #!/usr/bin/env php 2 2 <?php 3 3 4 + // NOTE: This script is very oldschool and takes the environment as an argument. 5 + // Some day, we could take a shot at cleaning this up. 4 6 if ($argc > 1) { 5 - $_SERVER['PHABRICATOR_ENV'] = $argv[1]; 7 + foreach (array_slice($argv, 1) as $arg) { 8 + if (!preg_match('/^-/', $arg)) { 9 + $_SERVER['PHABRICATOR_ENV'] = $arg; 10 + break; 11 + } 12 + } 6 13 } 7 14 8 15 $root = dirname(dirname(dirname(__FILE__))); 9 16 require_once $root.'/scripts/__init_script__.php'; 10 17 require_once $root.'/externals/mimemailparser/MimeMailParser.class.php'; 11 18 19 + $args = new PhutilArgumentParser($argv); 20 + $args->parseStandardArguments(); 21 + $args->parse( 22 + array( 23 + array( 24 + 'name' => 'process-duplicates', 25 + 'help' => pht( 26 + "Process this message, even if it's a duplicate of another message. ". 27 + "This is mostly useful when debugging issues with mail routing."), 28 + ), 29 + array( 30 + 'name' => 'env', 31 + 'wildcard' => true, 32 + ), 33 + )); 34 + 12 35 $parser = new MimeMailParser(); 13 36 $parser->setText(file_get_contents('php://stdin')); 14 37 ··· 27 50 $headers = $parser->getHeaders(); 28 51 $headers['subject'] = iconv_mime_decode($headers['subject'], 0, "UTF-8"); 29 52 $headers['from'] = iconv_mime_decode($headers['from'], 0, "UTF-8"); 53 + 54 + if ($args->getArg('process-duplicates')) { 55 + $headers['message-id'] = Filesystem::readRandomCharacters(64); 56 + } 30 57 31 58 $received = new PhabricatorMetaMTAReceivedMail(); 32 59 $received->setHeaders($headers); ··· 62 89 $received 63 90 ->setMessage('EXCEPTION: '.$e->getMessage()) 64 91 ->save(); 92 + 93 + throw $e; 65 94 } 66 95 67 96
+4 -2
src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php
··· 53 53 $phids = mpull($users, 'getPHID'); 54 54 55 55 $conpherence = id(new ConpherenceReplyHandler()) 56 - ->setMailReceiver(new ConpherenceThread()) 56 + ->setMailReceiver(ConpherenceThread::initializeNewThread($sender)) 57 57 ->setMailAddedParticipantPHIDs($phids) 58 58 ->setActor($sender) 59 59 ->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs()) 60 60 ->processEmail($mail); 61 61 62 - $mail->setRelatedPHID($conpherence->getPHID()); 62 + if ($conpherence) { 63 + $mail->setRelatedPHID($conpherence->getPHID()); 64 + } 63 65 } 64 66 65 67 }
+6
src/applications/conpherence/storage/ConpherenceThread.php
··· 18 18 private $widgetData = self::ATTACHABLE; 19 19 private $images = array(); 20 20 21 + public function initializeNewThread(PhabricatorUser $sender) { 22 + return id(new ConpherenceThread()) 23 + ->setMessageCount(0) 24 + ->setTitle(''); 25 + } 26 + 21 27 public function getConfiguration() { 22 28 return array( 23 29 self::CONFIG_AUX_PHID => true,