protected function loadPage() { $table = new PhabricatorPaste(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT paste.* FROM %T paste %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); $pastes = $table->loadAllFromArray($data); return $pastes; }
public function loadPage() { $table = new PhabricatorPaste(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT paste.* FROM %T paste %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); $pastes = $table->loadAllFromArray($data); if ($pastes && $this->needContent) { $file_phids = mpull($pastes, 'getFilePHID'); $files = id(new PhabricatorFile())->loadAllWhere('phid IN (%Ls)', $file_phids); $files = mpull($files, null, 'getPHID'); foreach ($pastes as $paste) { $file = idx($files, $paste->getFilePHID()); if ($file) { $paste->attachContent($file->loadFileData()); } else { $paste->attachContent(''); } } } return $this->processResults($pastes); }
<?php echo "Populating pastes with mail keys...\n"; $table = new PhabricatorPaste(); $table->openTransaction(); $conn_w = $table->establishConnection('w'); foreach (new LiskMigrationIterator($table) as $paste) { $id = $paste->getID(); echo "P{$id}: "; if (!$paste->getMailKey()) { queryfx($conn_w, 'UPDATE %T SET mailKey = %s WHERE id = %d', $paste->getTableName(), Filesystem::readRandomCharacters(20), $id); echo "Generated Key\n"; } else { echo "-\n"; } } $table->saveTransaction(); echo "Done.\n";