protected function loadPage() { $table = new ConpherenceThread(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT thread.* FROM %T thread %Q %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), $this->buildGroupClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); $conpherences = $table->loadAllFromArray($data); if ($conpherences) { $conpherences = mpull($conpherences, null, 'getPHID'); $this->loadParticipantsAndInitHandles($conpherences); if ($this->needParticipantCache) { $this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs'); } if ($this->needParticipants) { $this->loadCoreHandles($conpherences, 'getParticipantPHIDs'); } if ($this->needTransactions) { $this->loadTransactionsAndHandles($conpherences); } if ($this->needOrigPics || $this->needCropPics) { $this->initImages($conpherences); } if ($this->needOrigPics) { $this->loadOrigPics($conpherences); } if ($this->needCropPics) { $this->loadCropPics($conpherences); } } return $conpherences; }
protected function loadPage() { $table = new ConpherenceThread(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT thread.* FROM %T thread %Q %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), $this->buildGroupClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); $conpherences = $table->loadAllFromArray($data); if ($conpherences) { $conpherences = mpull($conpherences, null, 'getPHID'); $this->loadParticipantsAndInitHandles($conpherences); if ($this->needParticipantCache) { $this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs'); } if ($this->needParticipants) { $this->loadCoreHandles($conpherences, 'getParticipantPHIDs'); } if ($this->needTransactions) { $this->loadTransactionsAndHandles($conpherences); } if ($this->needProfileImage) { $default = null; $file_phids = mpull($conpherences, 'getProfileImagePHID'); $file_phids = array_filter($file_phids); if ($file_phids) { $files = id(new PhabricatorFileQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($file_phids)->execute(); $files = mpull($files, null, 'getPHID'); } else { $files = array(); } foreach ($conpherences as $conpherence) { $file = idx($files, $conpherence->getProfileImagePHID()); if (!$file) { if (!$default) { $default = PhabricatorFile::loadBuiltin($this->getViewer(), 'conpherence.png'); } $file = $default; } $conpherence->attachProfileImageFile($file); } } } return $conpherences; }
<?php echo pht("Migrating data from conpherence transactions to conpherence 'cache'...\n"); $table = new ConpherenceThread(); $table->openTransaction(); $conn_w = $table->establishConnection('w'); $participant_table = new ConpherenceParticipant(); $conpherences = new LiskMigrationIterator($table); foreach ($conpherences as $conpherence) { echo pht('Migrating conpherence #%d', $conpherence->getID()) . "\n"; $participants = id(new ConpherenceParticipant())->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID()); $transactions = id(new ConpherenceTransaction())->loadAllWhere('objectPHID = %s', $conpherence->getPHID()); $participation_hash = mgroup($participants, 'getBehindTransactionPHID'); $message_count = 0; $participants_to_cache = array(); foreach ($transactions as $transaction) { $participants_to_cache[] = $transaction->getAuthorPHID(); if ($transaction->getTransactionType() == PhabricatorTransactions::TYPE_COMMENT) { $message_count++; } $participants_to_update = idx($participation_hash, $transaction->getPHID(), array()); if ($participants_to_update) { queryfx($conn_w, 'UPDATE %T SET seenMessageCount = %d ' . 'WHERE conpherencePHID = %s AND participantPHID IN (%Ls)', $participant_table->getTableName(), $message_count, $conpherence->getPHID(), mpull($participants_to_update, 'getParticipantPHID')); } } $participants_to_cache = array_slice(array_unique(array_reverse($participants_to_cache)), 0, 10); queryfx($conn_w, 'UPDATE %T ' . 'SET recentParticipantPHIDs = %s, ' . 'messageCount = %d ' . 'WHERE phid = %s', $table->getTableName(), json_encode($participants_to_cache), $message_count, $conpherence->getPHID()); } $table->saveTransaction(); echo "\n" . pht('Done.') . "\n";
<?php // Rebuild all Conpherence Room images to profile standards // $table = new ConpherenceThread(); $conn = $table->establishConnection('w'); $table_name = 'conpherence_thread'; foreach (new LiskRawMigrationIterator($conn, $table_name) as $row) { $images = phutil_json_decode($row['imagePHIDs']); if (!$images) { continue; } $file_phid = idx($images, 'original'); $file = id(new PhabricatorFileQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs(array($file_phid))->executeOne(); $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE); $xformed = $xform->executeTransform($file); $new_phid = $xformed->getPHID(); queryfx($conn, 'UPDATE %T SET profileImagePHID = %s WHERE id = %d', $table->getTableName(), $new_phid, $row['id']); }