@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

Modularize content sources

Summary:
Ref T10537. For Nuance, I want to introduce new sources (like "GitHub" or "GitHub via Nuance" or something) but this needs to modularize eventually.

Split ContentSource apart so applications can add new content sources.

Test Plan:
This change has huge surface area, so I'll hold it until post-release. I think it's fairly safe (and if it does break anything, the breaks should be fatals, not anything subtle or difficult to fix), there's just no reason not to hold it for a few hours.

- Viewed new module page.
- Grepped for all removed functions/constants.
- Viewed some transactions.
- Hovered over timestamps to get content source details.
- Added a comment via Conduit.
- Added a comment via web.
- Ran `bin/storage upgrade --namespace XXXXX --no-quickstart -f` to re-run all historic migrations.
- Generated some objects with `bin/lipsum`.
- Ran a bulk job on some tasks.
- Ran unit tests.

{F1190182}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10537

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

+495 -265
+1 -2
resources/sql/autopatches/20140211.dx.2.migcommenttext.php
··· 4 4 $rows = new LiskRawMigrationIterator($conn_w, 'differential_comment'); 5 5 6 6 $content_source = PhabricatorContentSource::newForSource( 7 - PhabricatorContentSource::SOURCE_LEGACY, 8 - array())->serialize(); 7 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 9 8 10 9 echo pht('Migrating Differential comment text to modern storage...')."\n"; 11 10 foreach ($rows as $row) {
+1 -2
resources/sql/autopatches/20140212.dx.1.armageddon.php
··· 4 4 $rows = new LiskRawMigrationIterator($conn_w, 'differential_comment'); 5 5 6 6 $content_source = PhabricatorContentSource::newForSource( 7 - PhabricatorContentSource::SOURCE_LEGACY, 8 - array())->serialize(); 7 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 9 8 10 9 echo pht('Migrating Differential comments to modern storage...')."\n"; 11 10 foreach ($rows as $row) {
+1 -2
resources/sql/autopatches/20140722.audit.3.miginlines.php
··· 10 10 echo pht('Migrating Audit inline comments to new format...')."\n"; 11 11 12 12 $content_source = PhabricatorContentSource::newForSource( 13 - PhabricatorContentSource::SOURCE_LEGACY, 14 - array())->serialize(); 13 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 15 14 16 15 $rows = new LiskRawMigrationIterator($conn_w, $src_table); 17 16 foreach ($rows as $row) {
+1 -2
resources/sql/autopatches/20140722.audit.4.migtext.php
··· 4 4 $rows = new LiskRawMigrationIterator($conn_w, 'audit_comment'); 5 5 6 6 $content_source = PhabricatorContentSource::newForSource( 7 - PhabricatorContentSource::SOURCE_LEGACY, 8 - array())->serialize(); 7 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 9 8 10 9 echo pht('Migrating Audit comment text to modern storage...')."\n"; 11 10 foreach ($rows as $row) {
+1 -2
resources/sql/autopatches/20140725.audit.1.migxactions.php
··· 4 4 $rows = new LiskRawMigrationIterator($conn_w, 'audit_comment'); 5 5 6 6 $content_source = PhabricatorContentSource::newForSource( 7 - PhabricatorContentSource::SOURCE_LEGACY, 8 - array())->serialize(); 7 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 9 8 10 9 echo pht('Migrating Audit comments to modern storage...')."\n"; 11 10 foreach ($rows as $row) {
+2 -3
resources/sql/patches/20130715.votecomments.php
··· 46 46 PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST, 47 47 PhabricatorSlowvotePollPHIDType::TYPECONST); 48 48 49 - $source = PhabricatorContentSource::newForSource( 50 - PhabricatorContentSource::SOURCE_LEGACY, 51 - array())->serialize(); 49 + $content_source = PhabricatorContentSource::newForSource( 50 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 52 51 53 52 queryfx( 54 53 $conn_w,
+2 -4
resources/sql/patches/20130728.ponderxcomment.php
··· 49 49 1, 50 50 $row['content'], 51 51 PhabricatorContentSource::newForSource( 52 - PhabricatorContentSource::SOURCE_LEGACY, 53 - array())->serialize(), 52 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(), 54 53 0, 55 54 $row['dateCreated'], 56 55 $row['dateModified']); ··· 73 72 'null', 74 73 'null', 75 74 PhabricatorContentSource::newForSource( 76 - PhabricatorContentSource::SOURCE_LEGACY, 77 - array())->serialize(), 75 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(), 78 76 '[]', 79 77 $row['dateCreated'], 80 78 $row['dateModified']);
+1 -2
resources/sql/patches/20130801.pastexactions.php
··· 34 34 'null', 35 35 $row['filePHID'], 36 36 PhabricatorContentSource::newForSource( 37 - PhabricatorContentSource::SOURCE_LEGACY, 38 - array())->serialize(), 37 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(), 39 38 '[]', 40 39 $row['dateCreated'], 41 40 $row['dateCreated'],
+1 -2
resources/sql/patches/20130926.dinline.php
··· 10 10 echo pht('Migrating Differential inline comments to new format...')."\n"; 11 11 12 12 $content_source = PhabricatorContentSource::newForSource( 13 - PhabricatorContentSource::SOURCE_LEGACY, 14 - array())->serialize(); 13 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 15 14 16 15 $rows = new LiskRawMigrationIterator($conn_w, $src_table); 17 16 foreach ($rows as $row) {
+1 -2
resources/sql/patches/20131020.pxactionmig.php
··· 10 10 echo pht('Migrating Project transactions to new format...')."\n"; 11 11 12 12 $content_source = PhabricatorContentSource::newForSource( 13 - PhabricatorContentSource::SOURCE_LEGACY, 14 - array())->serialize(); 13 + PhabricatorOldWorldContentSource::SOURCECONST)->serialize(); 15 14 16 15 $rows = new LiskRawMigrationIterator($conn_w, $src_table); 17 16 foreach ($rows as $row) {
+30 -2
src/__phutil_library_map__.php
··· 1919 1919 'PhabricatorBotWhatsNewHandler' => 'infrastructure/daemon/bot/handler/PhabricatorBotWhatsNewHandler.php', 1920 1920 'PhabricatorBritishEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorBritishEnglishTranslation.php', 1921 1921 'PhabricatorBuiltinPatchList' => 'infrastructure/storage/patch/PhabricatorBuiltinPatchList.php', 1922 + 'PhabricatorBulkContentSource' => 'infrastructure/daemon/contentsource/PhabricatorBulkContentSource.php', 1922 1923 'PhabricatorBusyUIExample' => 'applications/uiexample/examples/PhabricatorBusyUIExample.php', 1923 1924 'PhabricatorCacheDAO' => 'applications/cache/storage/PhabricatorCacheDAO.php', 1924 1925 'PhabricatorCacheGeneralGarbageCollector' => 'applications/cache/garbagecollector/PhabricatorCacheGeneralGarbageCollector.php', ··· 1993 1994 'PhabricatorConduitCertificateToken' => 'applications/conduit/storage/PhabricatorConduitCertificateToken.php', 1994 1995 'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/PhabricatorConduitConnectionLog.php', 1995 1996 'PhabricatorConduitConsoleController' => 'applications/conduit/controller/PhabricatorConduitConsoleController.php', 1997 + 'PhabricatorConduitContentSource' => 'infrastructure/contentsource/PhabricatorConduitContentSource.php', 1996 1998 'PhabricatorConduitController' => 'applications/conduit/controller/PhabricatorConduitController.php', 1997 1999 'PhabricatorConduitDAO' => 'applications/conduit/storage/PhabricatorConduitDAO.php', 1998 2000 'PhabricatorConduitEditField' => 'applications/transactions/editfield/PhabricatorConduitEditField.php', ··· 2080 2082 'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php', 2081 2083 'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php', 2082 2084 'PhabricatorConsoleApplication' => 'applications/console/application/PhabricatorConsoleApplication.php', 2083 - 'PhabricatorContentSource' => 'applications/metamta/contentsource/PhabricatorContentSource.php', 2084 - 'PhabricatorContentSourceView' => 'applications/metamta/contentsource/PhabricatorContentSourceView.php', 2085 + 'PhabricatorConsoleContentSource' => 'infrastructure/contentsource/PhabricatorConsoleContentSource.php', 2086 + 'PhabricatorContentSource' => 'infrastructure/contentsource/PhabricatorContentSource.php', 2087 + 'PhabricatorContentSourceModule' => 'infrastructure/contentsource/PhabricatorContentSourceModule.php', 2088 + 'PhabricatorContentSourceView' => 'infrastructure/contentsource/PhabricatorContentSourceView.php', 2085 2089 'PhabricatorContributedToObjectEdgeType' => 'applications/transactions/edges/PhabricatorContributedToObjectEdgeType.php', 2086 2090 'PhabricatorController' => 'applications/base/controller/PhabricatorController.php', 2087 2091 'PhabricatorCookies' => 'applications/auth/constants/PhabricatorCookies.php', ··· 2138 2142 'PhabricatorDaemonBulkJobMonitorController' => 'applications/daemon/controller/PhabricatorDaemonBulkJobMonitorController.php', 2139 2143 'PhabricatorDaemonBulkJobViewController' => 'applications/daemon/controller/PhabricatorDaemonBulkJobViewController.php', 2140 2144 'PhabricatorDaemonConsoleController' => 'applications/daemon/controller/PhabricatorDaemonConsoleController.php', 2145 + 'PhabricatorDaemonContentSource' => 'infrastructure/daemon/contentsource/PhabricatorDaemonContentSource.php', 2141 2146 'PhabricatorDaemonController' => 'applications/daemon/controller/PhabricatorDaemonController.php', 2142 2147 'PhabricatorDaemonDAO' => 'applications/daemon/storage/PhabricatorDaemonDAO.php', 2143 2148 'PhabricatorDaemonEventListener' => 'applications/daemon/event/PhabricatorDaemonEventListener.php', ··· 2302 2307 'PhabricatorElasticFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php', 2303 2308 'PhabricatorElasticSearchSetupCheck' => 'applications/config/check/PhabricatorElasticSearchSetupCheck.php', 2304 2309 'PhabricatorEmailAddressesSettingsPanel' => 'applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php', 2310 + 'PhabricatorEmailContentSource' => 'applications/metamta/contentsource/PhabricatorEmailContentSource.php', 2305 2311 'PhabricatorEmailFormatSettingsPanel' => 'applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php', 2306 2312 'PhabricatorEmailLoginController' => 'applications/auth/controller/PhabricatorEmailLoginController.php', 2307 2313 'PhabricatorEmailPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php', ··· 2347 2353 'PhabricatorFactSimpleSpec' => 'applications/fact/spec/PhabricatorFactSimpleSpec.php', 2348 2354 'PhabricatorFactSpec' => 'applications/fact/spec/PhabricatorFactSpec.php', 2349 2355 'PhabricatorFactUpdateIterator' => 'applications/fact/extract/PhabricatorFactUpdateIterator.php', 2356 + 'PhabricatorFaxContentSource' => 'infrastructure/contentsource/PhabricatorFaxContentSource.php', 2350 2357 'PhabricatorFeedApplication' => 'applications/feed/application/PhabricatorFeedApplication.php', 2351 2358 'PhabricatorFeedBuilder' => 'applications/feed/builder/PhabricatorFeedBuilder.php', 2352 2359 'PhabricatorFeedConfigOptions' => 'applications/feed/config/PhabricatorFeedConfigOptions.php', ··· 2476 2483 'PhabricatorHelpKeyboardShortcutController' => 'applications/help/controller/PhabricatorHelpKeyboardShortcutController.php', 2477 2484 'PhabricatorHelpMainMenuBarExtension' => 'applications/help/extension/PhabricatorHelpMainMenuBarExtension.php', 2478 2485 'PhabricatorHeraldApplication' => 'applications/herald/application/PhabricatorHeraldApplication.php', 2486 + 'PhabricatorHeraldContentSource' => 'applications/herald/contentsource/PhabricatorHeraldContentSource.php', 2479 2487 'PhabricatorHighSecurityRequestExceptionHandler' => 'aphront/handler/PhabricatorHighSecurityRequestExceptionHandler.php', 2480 2488 'PhabricatorHomeApplication' => 'applications/home/application/PhabricatorHomeApplication.php', 2481 2489 'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php', ··· 2524 2532 'PhabricatorLibraryTestCase' => '__tests__/PhabricatorLibraryTestCase.php', 2525 2533 'PhabricatorLinkProfilePanel' => 'applications/search/profilepanel/PhabricatorLinkProfilePanel.php', 2526 2534 'PhabricatorLipsumArtist' => 'applications/lipsum/image/PhabricatorLipsumArtist.php', 2535 + 'PhabricatorLipsumContentSource' => 'infrastructure/contentsource/PhabricatorLipsumContentSource.php', 2527 2536 'PhabricatorLipsumGenerateWorkflow' => 'applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php', 2528 2537 'PhabricatorLipsumManagementWorkflow' => 'applications/lipsum/management/PhabricatorLipsumManagementWorkflow.php', 2529 2538 'PhabricatorLipsumMondrianArtist' => 'applications/lipsum/image/PhabricatorLipsumMondrianArtist.php', ··· 2737 2746 'PhabricatorObjectSelectorDialog' => 'view/control/PhabricatorObjectSelectorDialog.php', 2738 2747 'PhabricatorObjectUsesCredentialsEdgeType' => 'applications/transactions/edges/PhabricatorObjectUsesCredentialsEdgeType.php', 2739 2748 'PhabricatorOffsetPagedQuery' => 'infrastructure/query/PhabricatorOffsetPagedQuery.php', 2749 + 'PhabricatorOldWorldContentSource' => 'infrastructure/contentsource/PhabricatorOldWorldContentSource.php', 2740 2750 'PhabricatorOneTimeTriggerClock' => 'infrastructure/daemon/workers/clock/PhabricatorOneTimeTriggerClock.php', 2741 2751 'PhabricatorOpcodeCacheSpec' => 'applications/cache/spec/PhabricatorOpcodeCacheSpec.php', 2742 2752 'PhabricatorOwnerPathQuery' => 'applications/owners/query/PhabricatorOwnerPathQuery.php', ··· 2871 2881 'PhabricatorPholioConfigOptions' => 'applications/pholio/config/PhabricatorPholioConfigOptions.php', 2872 2882 'PhabricatorPholioMockTestDataGenerator' => 'applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php', 2873 2883 'PhabricatorPhortuneApplication' => 'applications/phortune/application/PhabricatorPhortuneApplication.php', 2884 + 'PhabricatorPhortuneContentSource' => 'applications/phortune/contentsource/PhabricatorPhortuneContentSource.php', 2874 2885 'PhabricatorPhortuneManagementInvoiceWorkflow' => 'applications/phortune/management/PhabricatorPhortuneManagementInvoiceWorkflow.php', 2875 2886 'PhabricatorPhortuneManagementWorkflow' => 'applications/phortune/management/PhabricatorPhortuneManagementWorkflow.php', 2876 2887 'PhabricatorPhragmentApplication' => 'applications/phragment/application/PhabricatorPhragmentApplication.php', ··· 3471 3482 'PhabricatorUIExampleRenderController' => 'applications/uiexample/controller/PhabricatorUIExampleRenderController.php', 3472 3483 'PhabricatorUIExamplesApplication' => 'applications/uiexample/application/PhabricatorUIExamplesApplication.php', 3473 3484 'PhabricatorUSEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php', 3485 + 'PhabricatorUnitTestContentSource' => 'infrastructure/contentsource/PhabricatorUnitTestContentSource.php', 3474 3486 'PhabricatorUnitsTestCase' => 'view/__tests__/PhabricatorUnitsTestCase.php', 3487 + 'PhabricatorUnknownContentSource' => 'infrastructure/contentsource/PhabricatorUnknownContentSource.php', 3475 3488 'PhabricatorUnsubscribedFromObjectEdgeType' => 'applications/transactions/edges/PhabricatorUnsubscribedFromObjectEdgeType.php', 3476 3489 'PhabricatorUser' => 'applications/people/storage/PhabricatorUser.php', 3477 3490 'PhabricatorUserBlurbField' => 'applications/people/customfield/PhabricatorUserBlurbField.php', ··· 3511 3524 'PhabricatorVeryWowEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorVeryWowEnglishTranslation.php', 3512 3525 'PhabricatorViewerDatasource' => 'applications/people/typeahead/PhabricatorViewerDatasource.php', 3513 3526 'PhabricatorWatcherHasObjectEdgeType' => 'applications/transactions/edges/PhabricatorWatcherHasObjectEdgeType.php', 3527 + 'PhabricatorWebContentSource' => 'infrastructure/contentsource/PhabricatorWebContentSource.php', 3514 3528 'PhabricatorWordPressAuthProvider' => 'applications/auth/provider/PhabricatorWordPressAuthProvider.php', 3515 3529 'PhabricatorWorker' => 'infrastructure/daemon/workers/PhabricatorWorker.php', 3516 3530 'PhabricatorWorkerActiveTask' => 'infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php', ··· 6274 6288 'PhabricatorBotWhatsNewHandler' => 'PhabricatorBotHandler', 6275 6289 'PhabricatorBritishEnglishTranslation' => 'PhutilTranslation', 6276 6290 'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList', 6291 + 'PhabricatorBulkContentSource' => 'PhabricatorContentSource', 6277 6292 'PhabricatorBusyUIExample' => 'PhabricatorUIExample', 6278 6293 'PhabricatorCacheDAO' => 'PhabricatorLiskDAO', 6279 6294 'PhabricatorCacheGeneralGarbageCollector' => 'PhabricatorGarbageCollector', ··· 6369 6384 'PhabricatorConduitCertificateToken' => 'PhabricatorConduitDAO', 6370 6385 'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO', 6371 6386 'PhabricatorConduitConsoleController' => 'PhabricatorConduitController', 6387 + 'PhabricatorConduitContentSource' => 'PhabricatorContentSource', 6372 6388 'PhabricatorConduitController' => 'PhabricatorController', 6373 6389 'PhabricatorConduitDAO' => 'PhabricatorLiskDAO', 6374 6390 'PhabricatorConduitEditField' => 'PhabricatorEditField', ··· 6469 6485 'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorSettingsPanel', 6470 6486 'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType', 6471 6487 'PhabricatorConsoleApplication' => 'PhabricatorApplication', 6488 + 'PhabricatorConsoleContentSource' => 'PhabricatorContentSource', 6472 6489 'PhabricatorContentSource' => 'Phobject', 6490 + 'PhabricatorContentSourceModule' => 'PhabricatorConfigModule', 6473 6491 'PhabricatorContentSourceView' => 'AphrontView', 6474 6492 'PhabricatorContributedToObjectEdgeType' => 'PhabricatorEdgeType', 6475 6493 'PhabricatorController' => 'AphrontController', ··· 6535 6553 'PhabricatorDaemonBulkJobMonitorController' => 'PhabricatorDaemonController', 6536 6554 'PhabricatorDaemonBulkJobViewController' => 'PhabricatorDaemonController', 6537 6555 'PhabricatorDaemonConsoleController' => 'PhabricatorDaemonController', 6556 + 'PhabricatorDaemonContentSource' => 'PhabricatorContentSource', 6538 6557 'PhabricatorDaemonController' => 'PhabricatorController', 6539 6558 'PhabricatorDaemonDAO' => 'PhabricatorLiskDAO', 6540 6559 'PhabricatorDaemonEventListener' => 'PhabricatorEventListener', ··· 6726 6745 'PhabricatorElasticFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine', 6727 6746 'PhabricatorElasticSearchSetupCheck' => 'PhabricatorSetupCheck', 6728 6747 'PhabricatorEmailAddressesSettingsPanel' => 'PhabricatorSettingsPanel', 6748 + 'PhabricatorEmailContentSource' => 'PhabricatorContentSource', 6729 6749 'PhabricatorEmailFormatSettingsPanel' => 'PhabricatorSettingsPanel', 6730 6750 'PhabricatorEmailLoginController' => 'PhabricatorAuthController', 6731 6751 'PhabricatorEmailPreferencesSettingsPanel' => 'PhabricatorSettingsPanel', ··· 6773 6793 'PhabricatorFactSimpleSpec' => 'PhabricatorFactSpec', 6774 6794 'PhabricatorFactSpec' => 'Phobject', 6775 6795 'PhabricatorFactUpdateIterator' => 'PhutilBufferedIterator', 6796 + 'PhabricatorFaxContentSource' => 'PhabricatorContentSource', 6776 6797 'PhabricatorFeedApplication' => 'PhabricatorApplication', 6777 6798 'PhabricatorFeedBuilder' => 'Phobject', 6778 6799 'PhabricatorFeedConfigOptions' => 'PhabricatorApplicationConfigOptions', ··· 6935 6956 'PhabricatorHelpKeyboardShortcutController' => 'PhabricatorHelpController', 6936 6957 'PhabricatorHelpMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension', 6937 6958 'PhabricatorHeraldApplication' => 'PhabricatorApplication', 6959 + 'PhabricatorHeraldContentSource' => 'PhabricatorContentSource', 6938 6960 'PhabricatorHighSecurityRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 6939 6961 'PhabricatorHomeApplication' => 'PhabricatorApplication', 6940 6962 'PhabricatorHomeController' => 'PhabricatorController', ··· 6983 7005 'PhabricatorLibraryTestCase' => 'PhutilLibraryTestCase', 6984 7006 'PhabricatorLinkProfilePanel' => 'PhabricatorProfilePanel', 6985 7007 'PhabricatorLipsumArtist' => 'Phobject', 7008 + 'PhabricatorLipsumContentSource' => 'PhabricatorContentSource', 6986 7009 'PhabricatorLipsumGenerateWorkflow' => 'PhabricatorLipsumManagementWorkflow', 6987 7010 'PhabricatorLipsumManagementWorkflow' => 'PhabricatorManagementWorkflow', 6988 7011 'PhabricatorLipsumMondrianArtist' => 'PhabricatorLipsumArtist', ··· 7218 7241 'PhabricatorObjectSelectorDialog' => 'Phobject', 7219 7242 'PhabricatorObjectUsesCredentialsEdgeType' => 'PhabricatorEdgeType', 7220 7243 'PhabricatorOffsetPagedQuery' => 'PhabricatorQuery', 7244 + 'PhabricatorOldWorldContentSource' => 'PhabricatorContentSource', 7221 7245 'PhabricatorOneTimeTriggerClock' => 'PhabricatorTriggerClock', 7222 7246 'PhabricatorOpcodeCacheSpec' => 'PhabricatorCacheSpec', 7223 7247 'PhabricatorOwnerPathQuery' => 'Phobject', ··· 7375 7399 'PhabricatorPholioConfigOptions' => 'PhabricatorApplicationConfigOptions', 7376 7400 'PhabricatorPholioMockTestDataGenerator' => 'PhabricatorTestDataGenerator', 7377 7401 'PhabricatorPhortuneApplication' => 'PhabricatorApplication', 7402 + 'PhabricatorPhortuneContentSource' => 'PhabricatorContentSource', 7378 7403 'PhabricatorPhortuneManagementInvoiceWorkflow' => 'PhabricatorPhortuneManagementWorkflow', 7379 7404 'PhabricatorPhortuneManagementWorkflow' => 'PhabricatorManagementWorkflow', 7380 7405 'PhabricatorPhragmentApplication' => 'PhabricatorApplication', ··· 8094 8119 'PhabricatorUIExampleRenderController' => 'PhabricatorController', 8095 8120 'PhabricatorUIExamplesApplication' => 'PhabricatorApplication', 8096 8121 'PhabricatorUSEnglishTranslation' => 'PhutilTranslation', 8122 + 'PhabricatorUnitTestContentSource' => 'PhabricatorContentSource', 8097 8123 'PhabricatorUnitsTestCase' => 'PhabricatorTestCase', 8124 + 'PhabricatorUnknownContentSource' => 'PhabricatorContentSource', 8098 8125 'PhabricatorUnsubscribedFromObjectEdgeType' => 'PhabricatorEdgeType', 8099 8126 'PhabricatorUser' => array( 8100 8127 'PhabricatorUserDAO', ··· 8150 8177 'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation', 8151 8178 'PhabricatorViewerDatasource' => 'PhabricatorTypeaheadDatasource', 8152 8179 'PhabricatorWatcherHasObjectEdgeType' => 'PhabricatorEdgeType', 8180 + 'PhabricatorWebContentSource' => 'PhabricatorContentSource', 8153 8181 'PhabricatorWordPressAuthProvider' => 'PhabricatorOAuth2AuthProvider', 8154 8182 'PhabricatorWorker' => 'Phobject', 8155 8183 'PhabricatorWorkerActiveTask' => 'PhabricatorWorkerTask',
+1 -2
src/applications/almanac/management/AlmanacManagementWorkflow.php
··· 3 3 abstract class AlmanacManagementWorkflow 4 4 extends PhabricatorManagementWorkflow { 5 5 6 - 7 6 protected function loadServices(array $names) { 8 7 if (!$names) { 9 8 return array(); ··· 37 36 $editor = id(new AlmanacServiceEditor()) 38 37 ->setActor($this->getViewer()) 39 38 ->setActingAsPHID($almanac_phid) 40 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 39 + ->setContentSource($this->newContentSource()) 41 40 ->setContinueOnMissingFields(true); 42 41 43 42 $editor->applyTransactions($service, array($xaction));
+1 -2
src/applications/audit/storage/PhabricatorAuditInlineComment.php
··· 34 34 35 35 public function getTransactionCommentForSave() { 36 36 $content_source = PhabricatorContentSource::newForSource( 37 - PhabricatorContentSource::SOURCE_LEGACY, 38 - array()); 37 + PhabricatorOldWorldContentSource::SOURCECONST); 39 38 40 39 $this->proxy 41 40 ->setViewPolicy('public')
+5
src/applications/conduit/protocol/ConduitAPIRequest.php
··· 57 57 return $this->isClusterRequest; 58 58 } 59 59 60 + public function newContentSource() { 61 + return PhabricatorContentSource::newForSource( 62 + PhabricatorConduitContentSource::SOURCECONST); 63 + } 64 + 60 65 }
+2 -2
src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php
··· 147 147 148 148 id(new ConpherenceEditor()) 149 149 ->setActor($creator) 150 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 150 + ->setContentSource($this->newContentSource()) 151 151 ->setContinueOnNoEffect(true) 152 152 ->applyTransactions($conpherence, $xactions); 153 153 ··· 166 166 167 167 id(new ConpherenceEditor()) 168 168 ->setActor($actor) 169 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 169 + ->setContentSource($this->newContentSource()) 170 170 ->setContinueOnNoEffect(true) 171 171 ->applyTransactions($room, $xactions); 172 172 }
+3 -3
src/applications/conpherence/__tests__/ConpherenceTestCase.php
··· 14 14 ); 15 15 $editor = id(new ConpherenceEditor()) 16 16 ->setActor($actor) 17 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 17 + ->setContentSource($this->newContentSource()) 18 18 ->applyTransactions($conpherence, $xactions); 19 19 20 20 } ··· 31 31 ); 32 32 $editor = id(new ConpherenceEditor()) 33 33 ->setActor($actor) 34 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 34 + ->setContentSource($this->newContentSource()) 35 35 ->applyTransactions($conpherence, $xactions); 36 36 } 37 37 ··· 45 45 46 46 $editor = id(new ConpherenceEditor()) 47 47 ->setActor($actor) 48 - ->setContentSource(PhabricatorContentSource::newConsoleSource()); 48 + ->setContentSource($this->newContentSource()); 49 49 50 50 $xactions = $editor->generateTransactionsFromText( 51 51 $actor,
+1 -1
src/applications/conpherence/conduit/ConpherenceCreateThreadConduitAPIMethod.php
··· 42 42 $participant_phids, 43 43 $title, 44 44 $message, 45 - PhabricatorContentSource::newFromConduitRequest($request)); 45 + $request->newContentSource()); 46 46 47 47 if ($errors) { 48 48 foreach ($errors as $error_code) {
+1 -1
src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php
··· 58 58 throw new ConduitException('ERR_USAGE_ROOM_NOT_FOUND'); 59 59 } 60 60 61 - $source = PhabricatorContentSource::newFromConduitRequest($request); 61 + $source = $request->newContentSource(); 62 62 $editor = id(new ConpherenceEditor()) 63 63 ->setContentSource($source) 64 64 ->setActor($user);
+1 -5
src/applications/conpherence/mail/ConpherenceReplyHandler.php
··· 48 48 $conpherence->attachParticipants($participants); 49 49 } 50 50 51 - $content_source = PhabricatorContentSource::newForSource( 52 - PhabricatorContentSource::SOURCE_EMAIL, 53 - array( 54 - 'id' => $mail->getID(), 55 - )); 51 + $content_source = $mail->newContentSource(); 56 52 57 53 $editor = id(new ConpherenceEditor()) 58 54 ->setActor($user)
+2 -4
src/applications/differential/conduit/DifferentialCloseConduitAPIMethod.php
··· 45 45 ->setTransactionType(DifferentialTransaction::TYPE_ACTION) 46 46 ->setNewValue(DifferentialAction::ACTION_CLOSE); 47 47 48 - $content_source = PhabricatorContentSource::newForSource( 49 - PhabricatorContentSource::SOURCE_CONDUIT, 50 - array()); 48 + $content_source = $request->newContentSource(); 51 49 52 50 $editor = id(new DifferentialTransactionEditor()) 53 51 ->setActor($viewer) 54 - ->setContentSourceFromConduitRequest($request) 52 + ->setContentSource($request->newContentSource()) 55 53 ->setContinueOnMissingFields(true) 56 54 ->setContinueOnNoEffect(true); 57 55
+1 -1
src/applications/differential/conduit/DifferentialConduitAPIMethod.php
··· 138 138 139 139 $editor = id(new DifferentialTransactionEditor()) 140 140 ->setActor($viewer) 141 - ->setContentSourceFromConduitRequest($request) 141 + ->setContentSource($request->newContentSource()) 142 142 ->setContinueOnNoEffect(true) 143 143 ->setContinueOnMissingFields(true); 144 144
+1 -1
src/applications/differential/conduit/DifferentialCreateCommentConduitAPIMethod.php
··· 77 77 $editor = id(new DifferentialTransactionEditor()) 78 78 ->setActor($viewer) 79 79 ->setDisableEmail($request->getValue('silent')) 80 - ->setContentSourceFromConduitRequest($request) 80 + ->setContentSource($request->newContentSource()) 81 81 ->setContinueOnNoEffect(true) 82 82 ->setContinueOnMissingFields(true); 83 83
+1 -1
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
··· 144 144 145 145 id(new DifferentialDiffEditor()) 146 146 ->setActor($viewer) 147 - ->setContentSourceFromConduitRequest($request) 147 + ->setContentSource($request->newContentSource()) 148 148 ->setContinueOnNoEffect(true) 149 149 ->applyTransactions($diff, $xactions); 150 150
+1 -1
src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
··· 85 85 86 86 id(new DifferentialDiffEditor()) 87 87 ->setActor($viewer) 88 - ->setContentSourceFromConduitRequest($request) 88 + ->setContentSource($request->newContentSource()) 89 89 ->setContinueOnNoEffect(true) 90 90 ->setLookupRepository(false) // respect user choice 91 91 ->applyTransactions($diff, $xactions);
+1 -3
src/applications/differential/management/PhabricatorDifferentialAttachCommitWorkflow.php
··· 68 68 ->setViewer($viewer) 69 69 ->setAuthorPHID($differential_phid); 70 70 71 - $content_source = PhabricatorContentSource::newForSource( 72 - PhabricatorContentSource::SOURCE_CONSOLE, 73 - array()); 71 + $content_source = $this->newContentSource(); 74 72 75 73 $extraction_engine->updateRevisionWithCommit( 76 74 $revision,
+1 -2
src/applications/differential/storage/DifferentialInlineComment.php
··· 18 18 19 19 public function getTransactionCommentForSave() { 20 20 $content_source = PhabricatorContentSource::newForSource( 21 - PhabricatorContentSource::SOURCE_LEGACY, 22 - array()); 21 + PhabricatorOldWorldContentSource::SOURCECONST); 23 22 24 23 $this->proxy 25 24 ->setViewPolicy('public')
+1 -1
src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php
··· 95 95 96 96 id(new PhabricatorAuditEditor()) 97 97 ->setActor($request->getUser()) 98 - ->setContentSourceFromConduitRequest($request) 98 + ->setContentSource($request->newContentSource()) 99 99 ->setDisableEmail($request->getValue('silent')) 100 100 ->setContinueOnMissingFields(true) 101 101 ->applyTransactions($commit, $xactions);
+1 -2
src/applications/harbormaster/engine/HarbormasterBuildEngine.php
··· 458 458 ->getPHID(); 459 459 460 460 $daemon_source = PhabricatorContentSource::newForSource( 461 - PhabricatorContentSource::SOURCE_DAEMON, 462 - array()); 461 + PhabricatorDaemonContentSource::SOURCECONST); 463 462 464 463 $editor = $object->getApplicationTransactionEditor() 465 464 ->setActor($viewer)
+16
src/applications/herald/contentsource/PhabricatorHeraldContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorHeraldContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'herald'; 7 + 8 + public function getSourceName() { 9 + return pht('Herald'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Changes triggered by Herald rules.'); 14 + } 15 + 16 + }
+3 -2
src/applications/herald/field/HeraldContentSourceField.php
··· 24 24 } 25 25 26 26 public function getHeraldFieldValueType($condition) { 27 - $map = PhabricatorContentSource::getSourceNameMap(); 27 + $map = PhabricatorContentSource::getAllContentSources(); 28 + $map = mpull($map, 'getSourceName'); 28 29 asort($map); 29 30 30 31 return id(new HeraldSelectFieldValue()) 31 32 ->setKey(self::FIELDCONST) 32 - ->setDefault(PhabricatorContentSource::SOURCE_WEB) 33 + ->setDefault(PhabricatorWebContentSource::SOURCECONST) 33 34 ->setOptions($map); 34 35 } 35 36
+1 -2
src/applications/lipsum/generator/PhabricatorTestDataGenerator.php
··· 56 56 57 57 protected function getLipsumContentSource() { 58 58 return PhabricatorContentSource::newForSource( 59 - PhabricatorContentSource::SOURCE_LIPSUM, 60 - array()); 59 + PhabricatorLipsumContentSource::SOURCECONST); 61 60 } 62 61 63 62 /**
+1 -1
src/applications/maniphest/__tests__/ManiphestTaskTestCase.php
··· 207 207 ManiphestTask $task, 208 208 array $xactions) { 209 209 210 - $content_source = PhabricatorContentSource::newConsoleSource(); 210 + $content_source = $this->newContentSource(); 211 211 212 212 $editor = id(new ManiphestTransactionEditor()) 213 213 ->setActor($viewer)
+1 -3
src/applications/maniphest/conduit/ManiphestConduitAPIMethod.php
··· 192 192 return; 193 193 } 194 194 195 - $content_source = PhabricatorContentSource::newForSource( 196 - PhabricatorContentSource::SOURCE_CONDUIT, 197 - array()); 195 + $content_source = $request->newContentSource(); 198 196 199 197 $editor = id(new ManiphestTransactionEditor()) 200 198 ->setActor($request->getUser())
+1 -3
src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
··· 15 15 ->setSubPriority($this->generateTaskSubPriority()) 16 16 ->setTitle($this->generateTitle()); 17 17 18 - $content_source = PhabricatorContentSource::newForSource( 19 - PhabricatorContentSource::SOURCE_UNKNOWN, 20 - array()); 18 + $content_source = $this->getLipsumContentSource(); 21 19 22 20 $template = new ManiphestTransaction(); 23 21 // Accumulate Transactions
-104
src/applications/metamta/contentsource/PhabricatorContentSource.php
··· 1 - <?php 2 - 3 - final class PhabricatorContentSource extends Phobject { 4 - 5 - const SOURCE_UNKNOWN = 'unknown'; 6 - const SOURCE_WEB = 'web'; 7 - const SOURCE_EMAIL = 'email'; 8 - const SOURCE_CONDUIT = 'conduit'; 9 - const SOURCE_MOBILE = 'mobile'; 10 - const SOURCE_TABLET = 'tablet'; 11 - const SOURCE_FAX = 'fax'; 12 - const SOURCE_CONSOLE = 'console'; 13 - const SOURCE_HERALD = 'herald'; 14 - const SOURCE_LEGACY = 'legacy'; 15 - const SOURCE_DAEMON = 'daemon'; 16 - const SOURCE_LIPSUM = 'lipsum'; 17 - const SOURCE_PHORTUNE = 'phortune'; 18 - const SOURCE_BULK = 'bulk'; 19 - 20 - private $source; 21 - private $params = array(); 22 - 23 - private function __construct() { 24 - // <empty> 25 - } 26 - 27 - public static function newForSource($source, array $params) { 28 - $obj = new PhabricatorContentSource(); 29 - $obj->source = $source; 30 - $obj->params = $params; 31 - 32 - return $obj; 33 - } 34 - 35 - public static function newFromSerialized($serialized) { 36 - $dict = json_decode($serialized, true); 37 - if (!is_array($dict)) { 38 - $dict = array(); 39 - } 40 - 41 - $obj = new PhabricatorContentSource(); 42 - $obj->source = idx($dict, 'source', self::SOURCE_UNKNOWN); 43 - $obj->params = idx($dict, 'params', array()); 44 - 45 - return $obj; 46 - } 47 - 48 - public static function newConsoleSource() { 49 - return self::newForSource( 50 - self::SOURCE_CONSOLE, 51 - array()); 52 - } 53 - 54 - public static function newFromRequest(AphrontRequest $request) { 55 - return self::newForSource( 56 - self::SOURCE_WEB, 57 - array()); 58 - } 59 - 60 - public static function newFromConduitRequest(ConduitAPIRequest $request) { 61 - return self::newForSource( 62 - self::SOURCE_CONDUIT, 63 - array()); 64 - } 65 - 66 - public static function getSourceNameMap() { 67 - return array( 68 - self::SOURCE_WEB => pht('Web'), 69 - self::SOURCE_EMAIL => pht('Email'), 70 - self::SOURCE_CONDUIT => pht('Conduit'), 71 - self::SOURCE_MOBILE => pht('Mobile'), 72 - self::SOURCE_TABLET => pht('Tablet'), 73 - self::SOURCE_FAX => pht('Fax'), 74 - self::SOURCE_CONSOLE => pht('Console'), 75 - self::SOURCE_LEGACY => pht('Legacy'), 76 - self::SOURCE_HERALD => pht('Herald'), 77 - self::SOURCE_DAEMON => pht('Daemons'), 78 - self::SOURCE_LIPSUM => pht('Lipsum'), 79 - self::SOURCE_UNKNOWN => pht('Old World'), 80 - self::SOURCE_PHORTUNE => pht('Phortune'), 81 - self::SOURCE_BULK => pht('Bulk Edit'), 82 - ); 83 - } 84 - 85 - public function serialize() { 86 - return json_encode(array( 87 - 'source' => $this->getSource(), 88 - 'params' => $this->getParams(), 89 - )); 90 - } 91 - 92 - public function getSource() { 93 - return $this->source; 94 - } 95 - 96 - public function getParams() { 97 - return $this->params; 98 - } 99 - 100 - public function getParam($key, $default = null) { 101 - return idx($this->params, $key, $default); 102 - } 103 - 104 - }
+4 -11
src/applications/metamta/contentsource/PhabricatorContentSourceView.php src/infrastructure/contentsource/PhabricatorContentSourceView.php
··· 10 10 } 11 11 12 12 public function getSourceName() { 13 - $map = PhabricatorContentSource::getSourceNameMap(); 14 - $source = $this->contentSource->getSource(); 15 - return idx($map, $source, null); 16 - 13 + return $this->contentSource->getSourceName(); 17 14 } 18 15 19 16 public function render() { 20 17 require_celerity_resource('phabricator-content-source-view-css'); 21 18 22 - $map = PhabricatorContentSource::getSourceNameMap(); 23 - 24 - $source = $this->contentSource->getSource(); 25 - $type = idx($map, $source, null); 26 - 27 - if (!$type) { 19 + $name = $this->getSourceName(); 20 + if ($name === null) { 28 21 return null; 29 22 } 30 23 ··· 33 26 array( 34 27 'class' => 'phabricator-content-source-view', 35 28 ), 36 - pht('Via %s', $type)); 29 + pht('Via %s', $name)); 37 30 } 38 31 39 32 }
+16
src/applications/metamta/contentsource/PhabricatorEmailContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorEmailContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'email'; 7 + 8 + public function getSourceName() { 9 + return pht('Email'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Content sent by electronic mail, also known as e-mail.'); 14 + } 15 + 16 + }
+8
src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php
··· 371 371 ->saveAndSend(); 372 372 } 373 373 374 + public function newContentSource() { 375 + return PhabricatorContentSource::newForSource( 376 + PhabricatorEmailContentSource::SOURCECONST, 377 + array( 378 + 'id' => $this->getID(), 379 + )); 380 + } 381 + 374 382 }
+2 -3
src/applications/nuance/item/NuanceGitHubEventItemType.php
··· 323 323 324 324 // TODO: Preserve the item's original source. 325 325 $source = PhabricatorContentSource::newForSource( 326 - PhabricatorContentSource::SOURCE_DAEMON, 327 - array()); 326 + PhabricatorDaemonContentSource::SOURCECONST); 328 327 329 - // TOOD: This should really be the external source. 328 + // TODO: This should really be the external source. 330 329 $acting_phid = $nuance_phid; 331 330 332 331 $editor = id(new ManiphestTransactionEditor())
+1 -2
src/applications/nuance/item/NuanceItemType.php
··· 119 119 120 120 // TODO: Maybe preserve the actor's original content source? 121 121 $source = PhabricatorContentSource::newForSource( 122 - PhabricatorContentSource::SOURCE_DAEMON, 123 - array()); 122 + PhabricatorDaemonContentSource::SOURCECONST); 124 123 125 124 $editor = id(new NuanceItemEditor()) 126 125 ->setActor($viewer)
+1 -1
src/applications/paste/conduit/PasteCreateConduitAPIMethod.php
··· 61 61 $editor = id(new PhabricatorPasteEditor()) 62 62 ->setActor($viewer) 63 63 ->setContinueOnNoEffect(true) 64 - ->setContentSourceFromConduitRequest($request); 64 + ->setContentSource($request->newContentSource()); 65 65 66 66 $xactions = $editor->applyTransactions($paste, $xactions); 67 67
+2 -5
src/applications/paste/mail/PasteCreateMailReceiver.php
··· 37 37 38 38 $paste = PhabricatorPaste::initializeNewPaste($sender); 39 39 40 - $content_source = PhabricatorContentSource::newForSource( 41 - PhabricatorContentSource::SOURCE_EMAIL, 42 - array( 43 - 'id' => $mail->getID(), 44 - )); 40 + $content_source = $mail->newContentSource(); 45 41 46 42 $editor = id(new PhabricatorPasteEditor()) 47 43 ->setActor($sender) ··· 68 64 ->setBody($body->render()) 69 65 ->saveAndSend(); 70 66 } 67 + 71 68 72 69 }
+2 -3
src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php
··· 13 13 ->loadOneWhere('phid = %s', $author_phid); 14 14 $mock = PholioMock::initializeNewMock($author); 15 15 16 - $content_source = PhabricatorContentSource::newForSource( 17 - PhabricatorContentSource::SOURCE_UNKNOWN, 18 - array()); 16 + $content_source = $this->getLipsumContentSource(); 17 + 19 18 $template = id(new PholioTransaction()) 20 19 ->setContentSource($content_source); 21 20
+16
src/applications/phortune/contentsource/PhabricatorPhortuneContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorPhortuneContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'phortune'; 7 + 8 + public function getSourceName() { 9 + return pht('Phortune'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Updates from subscriptions and payment processors.'); 14 + } 15 + 16 + }
+1 -2
src/applications/phortune/product/PhortuneProductImplementation.php
··· 12 12 13 13 protected function getContentSource() { 14 14 return PhabricatorContentSource::newForSource( 15 - PhabricatorContentSource::SOURCE_PHORTUNE, 16 - array()); 15 + PhabricatorPhortuneContentSource::SOURCECONST); 17 16 } 18 17 19 18 public function getPurchaseName(
+1 -2
src/applications/phortune/storage/PhortuneCart.php
··· 431 431 ->setNewValue(true); 432 432 433 433 $content_source = PhabricatorContentSource::newForSource( 434 - PhabricatorContentSource::SOURCE_PHORTUNE, 435 - array()); 434 + PhabricatorPhortuneContentSource::SOURCECONST); 436 435 437 436 $editor = id(new PhortuneCartEditor()) 438 437 ->setActor($omnipotent_user)
+1 -2
src/applications/phortune/worker/PhortuneSubscriptionWorker.php
··· 96 96 ->setNewValue(true); 97 97 98 98 $content_source = PhabricatorContentSource::newForSource( 99 - PhabricatorContentSource::SOURCE_PHORTUNE, 100 - array()); 99 + PhabricatorPhortuneContentSource::SOURCECONST); 101 100 102 101 $acting_phid = id(new PhabricatorPhortuneApplication())->getPHID(); 103 102 $editor = id(new PhortuneCartEditor())
+1 -1
src/applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php
··· 55 55 56 56 $editor = id(new PhrictionTransactionEditor()) 57 57 ->setActor($request->getUser()) 58 - ->setContentSourceFromConduitRequest($request) 58 + ->setContentSource($request->newContentSource()) 59 59 ->setContinueOnNoEffect(true) 60 60 ->setDescription($request->getValue('description')); 61 61
+1 -1
src/applications/phriction/conduit/PhrictionEditConduitAPIMethod.php
··· 50 50 51 51 $editor = id(new PhrictionTransactionEditor()) 52 52 ->setActor($request->getUser()) 53 - ->setContentSourceFromConduitRequest($request) 53 + ->setContentSource($request->newContentSource()) 54 54 ->setContinueOnNoEffect(true) 55 55 ->setDescription($request->getValue('description')); 56 56
+4 -4
src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
··· 1087 1087 1088 1088 $editor = id(new ManiphestTransactionEditor()) 1089 1089 ->setActor($viewer) 1090 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 1090 + ->setContentSource($this->newContentSource()) 1091 1091 ->setContinueOnNoEffect(true) 1092 1092 ->applyTransactions($task, $xactions); 1093 1093 } ··· 1203 1203 1204 1204 $editor = id(new ManiphestTransactionEditor()) 1205 1205 ->setActor($viewer) 1206 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 1206 + ->setContentSource($this->newContentSource()) 1207 1207 ->setContinueOnNoEffect(true) 1208 1208 ->applyTransactions($task, $xactions); 1209 1209 } ··· 1239 1239 1240 1240 $editor = id(new ManiphestTransactionEditor()) 1241 1241 ->setActor($viewer) 1242 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 1242 + ->setContentSource($this->newContentSource()) 1243 1243 ->setContinueOnNoEffect(true) 1244 1244 ->applyTransactions($task, $xactions); 1245 1245 ··· 1464 1464 1465 1465 $editor = id(new PhabricatorProjectTransactionEditor()) 1466 1466 ->setActor($user) 1467 - ->setContentSource(PhabricatorContentSource::newConsoleSource()) 1467 + ->setContentSource($this->newContentSource()) 1468 1468 ->setContinueOnNoEffect(true) 1469 1469 ->applyTransactions($project, $xactions); 1470 1470 }
+1 -1
src/applications/project/conduit/ProjectCreateConduitAPIMethod.php
··· 71 71 $editor = id(new PhabricatorProjectTransactionEditor()) 72 72 ->setActor($user) 73 73 ->setContinueOnNoEffect(true) 74 - ->setContentSourceFromConduitRequest($request); 74 + ->setContentSource($request->newContentSource()); 75 75 76 76 $editor->applyTransactions($project, $xactions); 77 77
+1 -4
src/applications/releeph/conduit/ReleephRequestConduitAPIMethod.php
··· 144 144 $editor = id(new ReleephRequestTransactionalEditor()) 145 145 ->setActor($user) 146 146 ->setContinueOnNoEffect(true) 147 - ->setContentSource( 148 - PhabricatorContentSource::newForSource( 149 - PhabricatorContentSource::SOURCE_CONDUIT, 150 - array())); 147 + ->setContentSource($request->newContentSource()); 151 148 152 149 $editor->applyTransactions($releeph_request, $xactions); 153 150 }
+1 -4
src/applications/releeph/conduit/work/ReleephWorkRecordConduitAPIMethod.php
··· 65 65 $editor = id(new ReleephRequestTransactionalEditor()) 66 66 ->setActor($request->getUser()) 67 67 ->setContinueOnNoEffect(true) 68 - ->setContentSource( 69 - PhabricatorContentSource::newForSource( 70 - PhabricatorContentSource::SOURCE_CONDUIT, 71 - array())); 68 + ->setContentSource($request->newContentSource()); 72 69 73 70 $editor->applyTransactions($releeph_request, $xactions); 74 71 }
+1 -4
src/applications/releeph/conduit/work/ReleephWorkRecordPickStatusConduitAPIMethod.php
··· 64 64 $editor = id(new ReleephRequestTransactionalEditor()) 65 65 ->setActor($request->getUser()) 66 66 ->setContinueOnNoEffect(true) 67 - ->setContentSource( 68 - PhabricatorContentSource::newForSource( 69 - PhabricatorContentSource::SOURCE_CONDUIT, 70 - array())); 67 + ->setContentSource($request->newContentSource()); 71 68 72 69 $xactions = array(); 73 70
+1 -2
src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php
··· 301 301 ->setContinueOnNoEffect(true) 302 302 ->setContentSource( 303 303 PhabricatorContentSource::newForSource( 304 - PhabricatorContentSource::SOURCE_UNKNOWN, 305 - array())); 304 + PhabricatorUnknownContentSource::SOURCECONST)); 306 305 307 306 $editor->applyTransactions($releeph_request, $xactions); 308 307 }
+1 -1
src/applications/repository/management/PhabricatorRepositoryManagementEditWorkflow.php
··· 117 117 pht('Specify one or more fields to edit!')); 118 118 } 119 119 120 - $content_source = PhabricatorContentSource::newConsoleSource(); 120 + $content_source = $this->newContentSource(); 121 121 122 122 $editor = id(new PhabricatorRepositoryEditor()) 123 123 ->setActor($actor)
+1 -3
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
··· 30 30 31 31 $commit->attachRepository($repository); 32 32 33 - $content_source = PhabricatorContentSource::newForSource( 34 - PhabricatorContentSource::SOURCE_DAEMON, 35 - array()); 33 + $content_source = $this->newContentSource(); 36 34 37 35 $committer_phid = $data->getCommitDetail('committerPHID'); 38 36 $author_phid = $data->getCommitDetail('authorPHID');
+2 -6
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 221 221 ->setViewer($actor) 222 222 ->setAuthorPHID($acting_as_phid); 223 223 224 - $content_source = PhabricatorContentSource::newForSource( 225 - PhabricatorContentSource::SOURCE_DAEMON, 226 - array()); 224 + $content_source = $this->newContentSource(); 227 225 228 226 $update_data = $extraction_engine->updateRevisionWithCommit( 229 227 $revision, ··· 337 335 338 336 $xactions[] = $edge_xaction; 339 337 340 - $content_source = PhabricatorContentSource::newForSource( 341 - PhabricatorContentSource::SOURCE_DAEMON, 342 - array()); 338 + $content_source = $this->newContentSource(); 343 339 344 340 $editor = id(new ManiphestTransactionEditor()) 345 341 ->setActor($actor)
+1 -1
src/applications/spaces/__tests__/PhabricatorSpacesTestCase.php
··· 215 215 ->setNewValue($is_default); 216 216 } 217 217 218 - $content_source = PhabricatorContentSource::newConsoleSource(); 218 + $content_source = $this->newContentSource(); 219 219 220 220 $editor = id(new PhabricatorSpacesNamespaceEditor()) 221 221 ->setActor($actor)
+1 -1
src/applications/tokens/conduit/TokenGiveConduitAPIMethod.php
··· 22 22 } 23 23 24 24 protected function execute(ConduitAPIRequest $request) { 25 - $content_source = PhabricatorContentSource::newFromConduitRequest($request); 25 + $content_source = $request->newContentSource(); 26 26 27 27 $editor = id(new PhabricatorTokenGivenEditor()) 28 28 ->setActor($request->getUser())
+2 -2
src/applications/transactions/controller/PhabricatorApplicationTransactionCommentRawController.php
··· 37 37 $addendum = null; 38 38 if ($request->getExists('email')) { 39 39 $content_source = $xaction->getContentSource(); 40 - $source_email = PhabricatorContentSource::SOURCE_EMAIL; 40 + $source_email = PhabricatorEmailContentSource::SOURCECONST; 41 41 if ($content_source->getSource() == $source_email) { 42 - $source_id = $content_source->getParam('id'); 42 + $source_id = $content_source->getContentSourceParameter('id'); 43 43 if ($source_id) { 44 44 $message = id(new PhabricatorMetaMTAReceivedMail())->loadOneWhere( 45 45 'id = %d',
+1 -1
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1684 1684 1685 1685 $editor = $object->getApplicationTransactionEditor() 1686 1686 ->setActor($viewer) 1687 - ->setContentSourceFromConduitRequest($request) 1687 + ->setContentSource($request->newContentSource()) 1688 1688 ->setContinueOnNoEffect(true); 1689 1689 1690 1690 if (!$this->getIsCreate()) {
+1 -12
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 733 733 PhabricatorContentSource::newFromRequest($request)); 734 734 } 735 735 736 - public function setContentSourceFromConduitRequest( 737 - ConduitAPIRequest $request) { 738 - 739 - $content_source = PhabricatorContentSource::newForSource( 740 - PhabricatorContentSource::SOURCE_CONDUIT, 741 - array()); 742 - 743 - return $this->setContentSource($content_source); 744 - } 745 - 746 736 public function getContentSource() { 747 737 return $this->contentSource; 748 738 } ··· 979 969 // out from transcripts, but it would be cleaner if you didn't have to. 980 970 981 971 $herald_source = PhabricatorContentSource::newForSource( 982 - PhabricatorContentSource::SOURCE_HERALD, 983 - array()); 972 + PhabricatorHeraldContentSource::SOURCECONST); 984 973 985 974 $herald_editor = newv(get_class($this), array()) 986 975 ->setContinueOnNoEffect(true)
+1 -5
src/applications/transactions/replyhandler/PhabricatorApplicationTransactionReplyHandler.php
··· 18 18 } 19 19 20 20 private function newEditor(PhabricatorMetaMTAReceivedMail $mail) { 21 - $content_source = PhabricatorContentSource::newForSource( 22 - PhabricatorContentSource::SOURCE_EMAIL, 23 - array( 24 - 'id' => $mail->getID(), 25 - )); 21 + $content_source = $mail->newContentSource(); 26 22 27 23 $editor = $this->getMailReceiver() 28 24 ->getApplicationTransactionEditor()
+1 -3
src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
··· 62 62 PhabricatorApplicationTransactionInterface $object) { 63 63 $data = $this->getTaskData(); 64 64 65 - $daemon_source = PhabricatorContentSource::newForSource( 66 - PhabricatorContentSource::SOURCE_DAEMON, 67 - array()); 65 + $daemon_source = $this->newContentSource(); 68 66 69 67 $viewer = PhabricatorUser::getOmnipotentUser(); 70 68 $editor = $object->getApplicationTransactionEditor()
+16
src/infrastructure/contentsource/PhabricatorConduitContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorConduitContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'conduit'; 7 + 8 + public function getSourceName() { 9 + return pht('Conduit'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Content from the Conduit API.'); 14 + } 15 + 16 + }
+16
src/infrastructure/contentsource/PhabricatorConsoleContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorConsoleContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'console'; 7 + 8 + public function getSourceName() { 9 + return pht('Console'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Content generated by CLI administrative tools.'); 14 + } 15 + 16 + }
+92
src/infrastructure/contentsource/PhabricatorContentSource.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorContentSource extends Phobject { 4 + 5 + private $source; 6 + private $params = array(); 7 + 8 + abstract public function getSourceName(); 9 + abstract public function getSourceDescription(); 10 + 11 + final public function getSourceTypeConstant() { 12 + return $this->getPhobjectClassConstant('SOURCECONST', 32); 13 + } 14 + 15 + final public static function getAllContentSources() { 16 + return id(new PhutilClassMapQuery()) 17 + ->setAncestorClass(__CLASS__) 18 + ->setUniqueMethod('getSourceTypeConstant') 19 + ->execute(); 20 + } 21 + 22 + /** 23 + * Construct a new content source object. 24 + * 25 + * @param const The source type constant to build a source for. 26 + * @param array Source parameters. 27 + * @param bool True to suppress errors and force construction of a source 28 + * even if the source type is not valid. 29 + * @return PhabricatorContentSource New source object. 30 + */ 31 + final public static function newForSource( 32 + $source, 33 + array $params = array(), 34 + $force = false) { 35 + 36 + $map = self::getAllContentSources(); 37 + if (isset($map[$source])) { 38 + $obj = clone $map[$source]; 39 + } else { 40 + if ($force) { 41 + $obj = new PhabricatorUnknownContentSource(); 42 + } else { 43 + throw new Exception( 44 + pht( 45 + 'Content source type "%s" is not known to Phabricator!', 46 + $source)); 47 + } 48 + } 49 + 50 + $obj->source = $source; 51 + $obj->params = $params; 52 + 53 + return $obj; 54 + } 55 + 56 + public static function newFromSerialized($serialized) { 57 + $dict = json_decode($serialized, true); 58 + if (!is_array($dict)) { 59 + $dict = array(); 60 + } 61 + 62 + $source = idx($dict, 'source'); 63 + $params = idx($dict, 'params'); 64 + if (!is_array($params)) { 65 + $params = array(); 66 + } 67 + 68 + return self::newForSource($source, $params, true); 69 + } 70 + 71 + public static function newFromRequest(AphrontRequest $request) { 72 + return self::newForSource( 73 + PhabricatorWebContentSource::SOURCECONST); 74 + } 75 + 76 + final public function serialize() { 77 + return phutil_json_encode( 78 + array( 79 + 'source' => $this->getSource(), 80 + 'params' => $this->params, 81 + )); 82 + } 83 + 84 + final public function getSource() { 85 + return $this->source; 86 + } 87 + 88 + final public function getContentSourceParameter($key, $default = null) { 89 + return idx($this->params, $key, $default); 90 + } 91 + 92 + }
+51
src/infrastructure/contentsource/PhabricatorContentSourceModule.php
··· 1 + <?php 2 + 3 + final class PhabricatorContentSourceModule 4 + extends PhabricatorConfigModule { 5 + 6 + public function getModuleKey() { 7 + return 'contentsource'; 8 + } 9 + 10 + public function getModuleName() { 11 + return pht('Content Sources'); 12 + } 13 + 14 + public function renderModuleStatus(AphrontRequest $request) { 15 + $viewer = $request->getViewer(); 16 + 17 + $sources = PhabricatorContentSource::getAllContentSources(); 18 + ksort($sources); 19 + 20 + $rows = array(); 21 + foreach ($sources as $source) { 22 + $rows[] = array( 23 + $source->getSourceTypeConstant(), 24 + get_class($source), 25 + $source->getSourceName(), 26 + $source->getSourceDescription(), 27 + ); 28 + } 29 + 30 + $table = id(new AphrontTableView($rows)) 31 + ->setHeaders( 32 + array( 33 + pht('Key'), 34 + pht('Class'), 35 + pht('Source'), 36 + pht('Description'), 37 + )) 38 + ->setColumnClasses( 39 + array( 40 + null, 41 + null, 42 + 'pri', 43 + 'wide', 44 + )); 45 + 46 + return id(new PHUIObjectBoxView()) 47 + ->setHeaderText(pht('Content Sources')) 48 + ->setTable($table); 49 + } 50 + 51 + }
+16
src/infrastructure/contentsource/PhabricatorFaxContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorFaxContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'fax'; 7 + 8 + public function getSourceName() { 9 + return pht('Fax'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Content received via fax (telefacsimile).'); 14 + } 15 + 16 + }
+16
src/infrastructure/contentsource/PhabricatorLipsumContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorLipsumContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'lipsum'; 7 + 8 + public function getSourceName() { 9 + return pht('Lipsum'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Test data created with bin/lipsum.'); 14 + } 15 + 16 + }
+17
src/infrastructure/contentsource/PhabricatorOldWorldContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorOldWorldContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'legacy'; 7 + 8 + public function getSourceName() { 9 + return pht('Old World'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht( 14 + 'Content from the distant past, before content sources existed.'); 15 + } 16 + 17 + }
+16
src/infrastructure/contentsource/PhabricatorUnitTestContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorUnitTestContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'unittest'; 7 + 8 + public function getSourceName() { 9 + return pht('Unit Test'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Content created by unit tests.'); 14 + } 15 + 16 + }
+21
src/infrastructure/contentsource/PhabricatorUnknownContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorUnknownContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'unknown'; 7 + 8 + public function getSourceName() { 9 + $source = $this->getSource(); 10 + if (strlen($source)) { 11 + return pht('Unknown ("%s")', $source); 12 + } else { 13 + return pht('Unknown'); 14 + } 15 + } 16 + 17 + public function getSourceDescription() { 18 + return pht('Content with no known source.'); 19 + } 20 + 21 + }
+16
src/infrastructure/contentsource/PhabricatorWebContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorWebContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'web'; 7 + 8 + public function getSourceName() { 9 + return pht('Web'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Content created from the web UI.'); 14 + } 15 + 16 + }
+16
src/infrastructure/daemon/contentsource/PhabricatorBulkContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorBulkContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'bulk'; 7 + 8 + public function getSourceName() { 9 + return pht('Bulk Update'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Changes made by bulk update.'); 14 + } 15 + 16 + }
+16
src/infrastructure/daemon/contentsource/PhabricatorDaemonContentSource.php
··· 1 + <?php 2 + 3 + final class PhabricatorDaemonContentSource 4 + extends PhabricatorContentSource { 5 + 6 + const SOURCECONST = 'daemon'; 7 + 8 + public function getSourceName() { 9 + return pht('Daemon'); 10 + } 11 + 12 + public function getSourceDescription() { 13 + return pht('Updates from background processing in daemons.'); 14 + } 15 + 16 + }
+5
src/infrastructure/daemon/workers/PhabricatorWorker.php
··· 305 305 $epoch_ago); 306 306 } 307 307 308 + protected function newContentSource() { 309 + return PhabricatorContentSource::newForSource( 310 + PhabricatorDaemonContentSource::SOURCECONST); 311 + } 312 + 308 313 }
+1 -3
src/infrastructure/daemon/workers/bulk/PhabricatorWorkerBulkJobWorker.php
··· 121 121 ->setTransactionType($type_status) 122 122 ->setNewValue($status); 123 123 124 - $daemon_source = PhabricatorContentSource::newForSource( 125 - PhabricatorContentSource::SOURCE_DAEMON, 126 - array()); 124 + $daemon_source = $this->newContentSource(); 127 125 128 126 $app_phid = id(new PhabricatorDaemonsApplication())->getPHID(); 129 127
+1 -1
src/infrastructure/daemon/workers/storage/PhabricatorWorkerBulkJob.php
··· 102 102 103 103 public function newContentSource() { 104 104 return PhabricatorContentSource::newForSource( 105 - PhabricatorContentSource::SOURCE_BULK, 105 + PhabricatorBulkContentSource::SOURCECONST, 106 106 array( 107 107 'jobID' => $this->getID(), 108 108 ));
+5
src/infrastructure/management/PhabricatorManagementWorkflow.php
··· 26 26 return $epoch; 27 27 } 28 28 29 + protected function newContentSource() { 30 + return PhabricatorContentSource::newForSource( 31 + PhabricatorConsoleContentSource::SOURCECONST); 32 + } 33 + 29 34 }
+4
src/infrastructure/testing/PhabricatorTestCase.php
··· 229 229 } 230 230 } 231 231 232 + protected function newContentSource() { 233 + return PhabricatorContentSource::newForSource( 234 + PhabricatorUnitTestContentSource::SOURCECONST); 235 + } 232 236 233 237 }
+2 -2
src/view/phui/PHUITimelineEventView.php
··· 622 622 )); 623 623 624 624 $content_source = $this->getContentSource(); 625 - $source_email = PhabricatorContentSource::SOURCE_EMAIL; 625 + $source_email = PhabricatorEmailContentSource::SOURCECONST; 626 626 if ($content_source->getSource() == $source_email) { 627 - $source_id = $content_source->getParam('id'); 627 + $source_id = $content_source->getContentSourceParameter('id'); 628 628 if ($source_id) { 629 629 $items[] = id(new PhabricatorActionView()) 630 630 ->setIcon('fa-envelope-o')