mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Fix old image macros and memes for logged out users
Summary: Fixes T6013. Old image macros/memes never had the file edge written. We also never wrote file edges for audio. Finally, the meme controller didn't allow public access. Write edges for images and audio, perform a migration to populate the historic ones, and make the Editor keep them up to date going forward. Test Plan: - Updated image, saw new image attach and old image detach. - Updated audio, saw new audio attach and old audio detach. - Ran migration. - Viewed memes as a logged-out user. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6013 Differential Revision: https://secure.phabricator.com/D10411
This commit is contained in:
parent
2e0361bd98
commit
8038af4bd5
4 changed files with 70 additions and 20 deletions
|
@ -8,7 +8,7 @@
|
|||
return array(
|
||||
'names' => array(
|
||||
'core.pkg.css' => '974635bb',
|
||||
'core.pkg.js' => '4e529147',
|
||||
'core.pkg.js' => 'cebacb31',
|
||||
'darkconsole.pkg.js' => 'df001cab',
|
||||
'differential.pkg.css' => '36884139',
|
||||
'differential.pkg.js' => '73337d1d',
|
||||
|
@ -438,7 +438,7 @@ return array(
|
|||
'rsrc/js/application/uiexample/notification-example.js' => '7a9677fc',
|
||||
'rsrc/js/core/Busy.js' => '6453c869',
|
||||
'rsrc/js/core/DragAndDropFileUpload.js' => '8c49f386',
|
||||
'rsrc/js/core/DraggableList.js' => '98d13594',
|
||||
'rsrc/js/core/DraggableList.js' => '2a6a1041',
|
||||
'rsrc/js/core/FileUpload.js' => 'a4ae61bf',
|
||||
'rsrc/js/core/Hovercard.js' => '7e8468ae',
|
||||
'rsrc/js/core/KeyboardShortcut.js' => '1ae869f2',
|
||||
|
@ -713,7 +713,7 @@ return array(
|
|||
'phabricator-crumbs-view-css' => 'a49339de',
|
||||
'phabricator-dashboard-css' => 'a2bfdcbf',
|
||||
'phabricator-drag-and-drop-file-upload' => '8c49f386',
|
||||
'phabricator-draggable-list' => '98d13594',
|
||||
'phabricator-draggable-list' => '2a6a1041',
|
||||
'phabricator-fatal-config-template-css' => '25d446d6',
|
||||
'phabricator-feed-css' => '7bfc6f12',
|
||||
'phabricator-file-upload' => 'a4ae61bf',
|
||||
|
@ -987,6 +987,14 @@ return array(
|
|||
'javelin-install',
|
||||
'javelin-util',
|
||||
),
|
||||
'2a6a1041' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-util',
|
||||
'javelin-vector',
|
||||
'javelin-magical-init',
|
||||
),
|
||||
'2b228192' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
|
@ -1437,14 +1445,6 @@ return array(
|
|||
'javelin-dom',
|
||||
'javelin-reactor-dom',
|
||||
),
|
||||
'98d13594' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
'javelin-stratcom',
|
||||
'javelin-util',
|
||||
'javelin-vector',
|
||||
'javelin-magical-init',
|
||||
),
|
||||
'9c2623f4' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
|
|
26
resources/sql/autopatches/20140904.macroattach.php
Normal file
26
resources/sql/autopatches/20140904.macroattach.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
$table = new PhabricatorFileImageMacro();
|
||||
foreach (new LiskMigrationIterator($table) as $macro) {
|
||||
$name = $macro->getName();
|
||||
|
||||
echo "Linking macro '{$name}'...\n";
|
||||
|
||||
$editor = new PhabricatorEdgeEditor();
|
||||
|
||||
$phids[] = $macro->getFilePHID();
|
||||
$phids[] = $macro->getAudioPHID();
|
||||
$phids = array_filter($phids);
|
||||
|
||||
if ($phids) {
|
||||
foreach ($phids as $phid) {
|
||||
$editor->addEdge(
|
||||
$macro->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE,
|
||||
$phid);
|
||||
}
|
||||
$editor->save();
|
||||
}
|
||||
}
|
||||
|
||||
echo "Done.\n";
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorMacroMemeController
|
||||
extends PhabricatorMacroController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$macro_name = $request->getStr('macro');
|
||||
|
|
|
@ -82,19 +82,39 @@ final class PhabricatorMacroEditor
|
|||
protected function applyCustomExternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected function extractFilePHIDsFromCustomTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorMacroTransactionType::TYPE_FILE:
|
||||
return array($xaction->getNewValue());
|
||||
}
|
||||
case PhabricatorMacroTransactionType::TYPE_AUDIO:
|
||||
// When changing a macro's image or audio, attach the underlying files
|
||||
// to the macro (and detach the old files).
|
||||
$old = $xaction->getOldValue();
|
||||
$new = $xaction->getNewValue();
|
||||
$all = array();
|
||||
if ($old) {
|
||||
$all[] = $old;
|
||||
}
|
||||
if ($new) {
|
||||
$all[] = $new;
|
||||
}
|
||||
|
||||
return array();
|
||||
$files = id(new PhabricatorFileQuery())
|
||||
->setViewer($this->requireActor())
|
||||
->withPHIDs($all)
|
||||
->execute();
|
||||
$files = mpull($files, null, 'getPHID');
|
||||
|
||||
$old_file = idx($files, $old);
|
||||
if ($old_file) {
|
||||
$old_file->detachFromObject($object->getPHID());
|
||||
}
|
||||
|
||||
$new_file = idx($files, $new);
|
||||
if ($new_file) {
|
||||
$new_file->attachToObject($this->requireActor(), $object->getPHID());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function mergeTransactions(
|
||||
|
|
Loading…
Reference in a new issue