Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20140830.imagemacrousagebackfill.php
- This file was added.
<?php | |||||
$xaction_classes = id(new PhutilSymbolLoader()) | |||||
->setAncestorClass('PhabricatorApplicationTransactionComment') | |||||
->loadObjects(); | |||||
$engine = PhabricatorMarkupEngine::getEngine('extract'); | |||||
$engine->setConfig('viewer', PhabricatorUser::getOmnipotentUser()); | |||||
PhabricatorEnv::setRequestBaseURI('/'); // Doesn't matter during backfill | |||||
$macro_usage_table = new PhabricatorFileImageMacroUsage(); | |||||
$macro_usage_key = PhabricatorImageMacroRemarkupRule::KEY_MACRO_USAGE; | |||||
/* If I uncomment this, I get the following error. | |||||
Argument 1 passed to PhabricatorApplicationTransactionComment::getTableNameFromTransaction() must be an instance of PhabricatorApplicationTransaction, instance of HarbormasterBuildPlan given, called in /home/vagrant/src/phabricator/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php on line 52 and defined at [<phutil>/src/error/PhutilErrorHandler.php:200] | |||||
#0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phabricator>/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php:56] | |||||
#1 PhabricatorApplicationTransactionComment::getTableNameFromTransaction(HarbormasterBuildPlan) called at [<phabricator>/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php:52] | |||||
#2 PhabricatorApplicationTransactionComment::getTableName() called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:498] | |||||
#3 LiskDAO::loadRawDataWhere(string, integer, integer) | |||||
#4 call_user_func_array(array, array) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:447] | |||||
#5 LiskDAO::loadAllWhere(string, integer, integer) called at [<phabricator>/src/infrastructure/storage/lisk/LiskMigrationIterator.php:41] | |||||
#6 LiskMigrationIterator::loadPage() called at [<phutil>/src/utils/PhutilBufferedIterator.php:129] | |||||
#7 PhutilBufferedIterator::next() called at [<phutil>/src/utils/PhutilBufferedIterator.php:84] | |||||
#8 PhutilBufferedIterator::rewind() called at [<phabricator>/resources/sql/autopatches/20140830.imagemacrousagebackfill.php:16] | |||||
#9 require_once(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:196] | |||||
#10 PhabricatorStorageManagementAPI::applyPatchPHP(string) called at [<phabricator>/src/infrastructure/storage/management/PhabricatorStorageManagementAPI.php:171] | |||||
#11 PhabricatorStorageManagementAPI::applyPatch(PhabricatorStoragePatch) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php:168] | |||||
#12 PhabricatorStorageManagementUpgradeWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:394] | |||||
#13 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:290] | |||||
#14 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:163] | |||||
Looks like some of the PhabricatorApplicationTransactionComment objects work, but some don't. Is this not something we can iterate over? | |||||
*/ | |||||
$xaction_classes = array($xaction_classes['DifferentialTransactionComment']); | |||||
foreach ($xaction_classes as $xaction_class) { | |||||
foreach (new LiskMigrationIterator($xaction_class) as $xaction) { | |||||
$authorPHID = $xaction->getAuthorPHID(); | |||||
$usagePHID = $xaction->getPHID(); | |||||
$block = $xaction->getContent(); | |||||
$engine->markupText($block); | |||||
$macro_usage = $engine->getTextMetadata($macro_usage_key, array()); | |||||
$macro_usage_table->updateUsage($authorPHID, $usagePHID, $macro_usage); | |||||
} | |||||
} |