code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function setRenderWithImpliedContext($render_with_implied_context) {
$this->renderWithImpliedContext = $render_with_implied_context;
return $this;
} | Render story text using contextual language to identify the object the
story is about, instead of the full object name. For example, without
contextual language a story might render like this:
alincoln created D123: Chop Wood for Log Cabin v2.0
With contextual language, it will render like this instead:
alincoln created this revision.
If the interface where the text will be displayed is specific to an
individual object (like Asana tasks that represent one review or commit
are), it's generally more natural to use language that assumes context.
If the target context may show information about several objects (like
JIRA issues which can have several linked revisions), it's generally
more useful not to assume context.
@param bool $render_with_implied_context True to assume object context
when rendering.
@return $this
@task config | setRenderWithImpliedContext | php | phorgeit/phorge | src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php | https://github.com/phorgeit/phorge/blob/master/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php | Apache-2.0 |
public function getRenderWithImpliedContext() {
return $this->renderWithImpliedContext;
} | Determine if rendering should assume object context. For discussion, see
@{method:setRenderWithImpliedContext}.
@return bool True if rendering should assume object context is implied.
@task config | getRenderWithImpliedContext | php | phorgeit/phorge | src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php | https://github.com/phorgeit/phorge/blob/master/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php | Apache-2.0 |
public function willPublishStory($object) {
return $object;
} | Hook for publishers to mutate the story object, particularly by loading
and attaching additional data. | willPublishStory | php | phorgeit/phorge | src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php | https://github.com/phorgeit/phorge/blob/master/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php | Apache-2.0 |
public function setThrowOnMissingLink($throw) {
$this->throwOnMissingLink = $throw;
return $this;
} | Configure behavior if remote refs can not be retrieved because an
authentication link is missing. | setThrowOnMissingLink | php | phorgeit/phorge | src/applications/doorkeeper/engine/DoorkeeperImportEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/doorkeeper/engine/DoorkeeperImportEngine.php | Apache-2.0 |
function phid_get_type($phid) {
$matches = null;
if (is_string($phid) && preg_match('/^PHID-([^-]{4})-/', $phid, $matches)) {
return $matches[1];
}
return PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
} | Look up the type of a PHID. Returns
PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN if it fails to look up the type
@param string $phid A PHID of anything.
@return string A value from PhabricatorPHIDConstants (ideally) | phid_get_type | php | phorgeit/phorge | src/applications/phid/utils.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/utils.php | Apache-2.0 |
public function setComplete($complete) {
$this->complete = $complete;
return $this;
} | Set whether or not the underlying object is complete. See
@{method:isComplete} for an explanation of what it means to be complete.
@param bool $complete True if the handle represents a complete object.
@return $this | setComplete | php | phorgeit/phorge | src/applications/phid/PhabricatorObjectHandle.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/PhabricatorObjectHandle.php | Apache-2.0 |
public function isComplete() {
return $this->complete;
} | Determine if the handle represents an object which was completely loaded
(i.e., the underlying object exists) vs an object which could not be
completely loaded (e.g., the type or data for the PHID could not be
identified or located).
Basically, @{class:PhabricatorHandleQuery} gives you back a handle for
any PHID you give it, but it gives you a complete handle only for valid
PHIDs.
@return bool True if the handle represents a complete object. | isComplete | php | phorgeit/phorge | src/applications/phid/PhabricatorObjectHandle.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/PhabricatorObjectHandle.php | Apache-2.0 |
public function getHandleIfExists($phid, $default = null) {
if ($this->handles === null) {
$this->loadHandles();
}
return idx($this->handles, $phid, $default);
} | Get a handle from this list if it exists.
This has similar semantics to @{function:idx}. | getHandleIfExists | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function newSublist(array $phids) {
foreach ($phids as $phid) {
if (!isset($this[$phid])) {
throw new Exception(
pht(
'Trying to create a new sublist of an existing handle list, '.
'but PHID "%s" does not appear in the parent list.',
$phid));
}
}
return $this->handlePool->newHandleList($phids);
} | Create a new list with a subset of the PHIDs in this list. | newSublist | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function renderList() {
return id(new PHUIHandleListView())
->setHandleList($this);
} | Return a @{class:PHUIHandleListView} which can render the handles in
this list. | renderList | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function renderHandle($phid) {
if (!isset($this[$phid])) {
throw new Exception(
pht('Trying to render a handle which does not exist!'));
}
return id(new PHUIHandleView())
->setHandleList($this)
->setHandlePHID($phid);
} | Return a @{class:PHUIHandleView} which can render a specific handle. | renderHandle | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function rewind() {
$this->cursor = 0;
} | [\ReturnTypeWillChange] | rewind | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function current() {
return $this->getHandle($this->phids[$this->cursor]);
} | [\ReturnTypeWillChange] | current | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function key() {
return $this->phids[$this->cursor];
} | [\ReturnTypeWillChange] | key | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function next() {
++$this->cursor;
} | [\ReturnTypeWillChange] | next | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function valid() {
return ($this->cursor < $this->count);
} | [\ReturnTypeWillChange] | valid | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function offsetExists($offset) {
// NOTE: We're intentionally not loading handles here so that isset()
// checks do not trigger fetches. This gives us better bulk loading
// behavior, particularly when invoked through methods like renderHandle().
if ($this->map === null) {
$this->map = array_fill_keys($this->phids, true);
}
return isset($this->map[$offset]);
} | [\ReturnTypeWillChange] | offsetExists | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function offsetGet($offset) {
if ($this->handles === null) {
$this->loadHandles();
}
return $this->handles[$offset];
} | [\ReturnTypeWillChange] | offsetGet | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function offsetSet($offset, $value) {
$this->raiseImmutableException();
} | [\ReturnTypeWillChange] | offsetSet | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function offsetUnset($offset) {
$this->raiseImmutableException();
} | [\ReturnTypeWillChange] | offsetUnset | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
public function count() {
return $this->count;
} | [\ReturnTypeWillChange] | count | php | phorgeit/phorge | src/applications/phid/handle/pool/PhabricatorHandleList.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/handle/pool/PhabricatorHandleList.php | Apache-2.0 |
protected function shouldDisablePolicyFiltering() {
$view_capability = PhabricatorPolicyCapability::CAN_VIEW;
if ($this->getRequiredCapabilities() === array($view_capability)) {
return true;
}
return false;
} | This query disables policy filtering if the only required capability is
the view capability.
The view capability is always checked in the subqueries, so we do not need
to re-filter results. For any other set of required capabilities, we do. | shouldDisablePolicyFiltering | php | phorgeit/phorge | src/applications/phid/query/PhabricatorObjectQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/query/PhabricatorObjectQuery.php | Apache-2.0 |
public static function loadInvalidPHIDsForViewer(
PhabricatorUser $viewer,
array $phids) {
if (!$phids) {
return array();
}
$objects = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->withPHIDs($phids)
->execute();
$objects = mpull($objects, null, 'getPHID');
$invalid = array();
foreach ($phids as $phid) {
if (empty($objects[$phid])) {
$invalid[] = $phid;
}
}
return $invalid;
} | Select invalid or restricted PHIDs from a list.
PHIDs are invalid if their objects do not exist or can not be seen by the
viewer. This method is generally used to validate that PHIDs affected by
a transaction are valid.
@param PhabricatorUser $viewer Viewer.
@param list<string> $phids List of ostensibly valid PHIDs.
@return list<string> List of invalid or restricted PHIDs. | loadInvalidPHIDsForViewer | php | phorgeit/phorge | src/applications/phid/query/PhabricatorObjectQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/query/PhabricatorObjectQuery.php | Apache-2.0 |
public function loadObjects(
PhabricatorObjectQuery $query,
array $phids) {
$object_query = $this->buildQueryForObjects($query, $phids)
->setViewer($query->getViewer())
->setParentQuery($query);
// If the user doesn't have permission to use the application at all,
// just mark all the PHIDs as filtered. This primarily makes these
// objects show up as "Restricted" instead of "Unknown" when loaded as
// handles, which is technically true.
if (!$object_query->canViewerUseQueryApplication()) {
$object_query->addPolicyFilteredPHIDs(array_fuse($phids));
return array();
}
return $object_query->execute();
} | Load objects of this type, by PHID. For most PHID types, it is only
necessary to implement @{method:buildQueryForObjects} to get object
loading to work.
@param PhabricatorObjectQuery $query Query being executed.
@param list<string> $phids PHIDs to load.
@return list<wild> Corresponding objects. | loadObjects | php | phorgeit/phorge | src/applications/phid/type/PhabricatorPHIDType.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/type/PhabricatorPHIDType.php | Apache-2.0 |
final public static function getAllTypes() {
return self::newClassMapQuery()
->execute();
} | Get all known PHID types.
To get PHID types a given user has access to, see
@{method:getAllInstalledTypes}.
@return dict<string, PhabricatorPHIDType> Map of type constants to types. | getAllTypes | php | phorgeit/phorge | src/applications/phid/type/PhabricatorPHIDType.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/type/PhabricatorPHIDType.php | Apache-2.0 |
public static function getAllTypesForApplication(
string $application) {
$all_types = self::getAllTypes();
$application_types = array();
foreach ($all_types as $key => $type) {
if ($type->getPHIDTypeApplicationClass() != $application) {
continue;
}
$application_types[$key] = $type;
}
return $application_types;
} | Get all PHID types of an application.
@param string $application Class name of an application
@return dict<string, PhabricatorPHIDType> Map of constants of application | getAllTypesForApplication | php | phorgeit/phorge | src/applications/phid/type/PhabricatorPHIDType.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phid/type/PhabricatorPHIDType.php | Apache-2.0 |
public function addPHPConfigOriginalValue($php_config, $value) {
$this->originalPHPConfigValues[$php_config] = $value;
return $this;
} | Set an explicit value to display when showing the user PHP configuration
values.
If Phabricator has changed a value by the time a config issue is raised,
you can provide the original value here so the UI makes sense. For example,
we alter `memory_limit` during startup, so if the original value is not
provided it will look like it is always set to `-1`.
@param string $php_config PHP configuration option to provide a value for.
@param string $value Explicit value to show in the UI.
@return $this | addPHPConfigOriginalValue | php | phorgeit/phorge | src/applications/config/issue/PhabricatorSetupIssue.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/issue/PhabricatorSetupIssue.php | Apache-2.0 |
public function renderContextualDescription(
PhabricatorConfigOption $option,
AphrontRequest $request) {
return null;
} | Hook to render additional hints based on, e.g., the viewing user, request,
or other context. For example, this is used to show workspace IDs when
configuring `asana.workspace-id`.
@param PhabricatorConfigOption $option Option being rendered.
@param AphrontRequest $request Active request.
@return wild|null Additional contextual description
information. | renderContextualDescription | php | phorgeit/phorge | src/applications/config/option/PhabricatorApplicationConfigOptions.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/option/PhabricatorApplicationConfigOptions.php | Apache-2.0 |
final protected function deformat($string) {
return preg_replace('/(?<=\S)\n(?=\S)/', ' ', $string);
} | Deformat a HEREDOC for use in remarkup by converting line breaks to
spaces. | deformat | php | phorgeit/phorge | src/applications/config/option/PhabricatorApplicationConfigOptions.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/option/PhabricatorApplicationConfigOptions.php | Apache-2.0 |
public function setDescription($description) {
$this->description = $description;
return $this;
} | Set the human Description of this Config
@param string|null $description Description as raw Remarkup
@return self | setDescription | php | phorgeit/phorge | src/applications/config/option/PhabricatorConfigOption.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/option/PhabricatorConfigOption.php | Apache-2.0 |
public function getDescription() {
return $this->description;
} | Get the human Description of this Config
@return string|null Description as raw Remarkup | getDescription | php | phorgeit/phorge | src/applications/config/option/PhabricatorConfigOption.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/option/PhabricatorConfigOption.php | Apache-2.0 |
public static function getAncientConfig() {
$reason_auth = pht(
'This option has been migrated to the "Auth" application. Your old '.
'configuration is still in effect, but now stored in "Auth" instead of '.
'configuration. Going forward, you can manage authentication from '.
'the web UI.');
$auth_config = array(
'controller.oauth-registration',
'auth.password-auth-enabled',
'facebook.auth-enabled',
'facebook.registration-enabled',
'facebook.auth-permanent',
'facebook.application-id',
'facebook.application-secret',
'facebook.require-https-auth',
'github.auth-enabled',
'github.registration-enabled',
'github.auth-permanent',
'github.application-id',
'github.application-secret',
'google.auth-enabled',
'google.registration-enabled',
'google.auth-permanent',
'google.application-id',
'google.application-secret',
'ldap.auth-enabled',
'ldap.hostname',
'ldap.port',
'ldap.base_dn',
'ldap.search_attribute',
'ldap.search-first',
'ldap.username-attribute',
'ldap.real_name_attributes',
'ldap.activedirectory_domain',
'ldap.version',
'ldap.referrals',
'ldap.anonymous-user-name',
'ldap.anonymous-user-password',
'ldap.start-tls',
'disqus.auth-enabled',
'disqus.registration-enabled',
'disqus.auth-permanent',
'disqus.application-id',
'disqus.application-secret',
'phabricator.oauth-uri',
'phabricator.auth-enabled',
'phabricator.registration-enabled',
'phabricator.auth-permanent',
'phabricator.application-id',
'phabricator.application-secret',
);
$ancient_config = array_fill_keys($auth_config, $reason_auth);
$markup_reason = pht(
'Custom remarkup rules are now added by subclassing '.
'%s or %s.',
'PhabricatorRemarkupCustomInlineRule',
'PhabricatorRemarkupCustomBlockRule');
$session_reason = pht(
'Sessions now expire and are garbage collected rather than having an '.
'arbitrary concurrency limit.');
$differential_field_reason = pht(
'All Differential fields are now managed through the configuration '.
'option "%s". Use that option to configure which fields are shown.',
'differential.fields');
$reply_domain_reason = pht(
'Individual application reply handler domains have been removed. '.
'Configure a reply domain with "%s".',
'metamta.reply-handler-domain');
$reply_handler_reason = pht(
'Reply handlers can no longer be overridden with configuration.');
$monospace_reason = pht(
'Global customization of monospaced fonts is no longer supported.');
$public_mail_reason = pht(
'Inbound mail addresses are now configured for each application '.
'in the Applications tool.');
$gc_reason = pht(
'Garbage collectors are now configured with "%s".',
'bin/garbage set-policy');
$aphlict_reason = pht(
'Configuration of the notification server has changed substantially. '.
'For discussion, see T10794.');
$stale_reason = pht(
'The Differential revision list view age UI elements have been removed '.
'to simplify the interface.');
$global_settings_reason = pht(
'The "Re: Prefix" and "Vary Subjects" settings are now configured '.
'in global settings.');
$dashboard_reason = pht(
'This option has been removed, you can use Dashboards to provide '.
'homepage customization. See T11533 for more details.');
$elastic_reason = pht(
'Elasticsearch is now configured with "%s".',
'cluster.search');
$mailers_reason = pht(
'Inbound and outbound mail is now configured with "cluster.mailers".');
$prefix_reason = pht(
'Per-application mail subject prefix customization is no longer '.
'directly supported. Prefixes and other strings may be customized with '.
'"translation.override".');
$phd_reason = pht(
'Use "bin/phd debug ..." to get a detailed daemon execution log.');
$ancient_config += array(
'phid.external-loaders' =>
pht(
'External loaders have been replaced. Extend `%s` '.
'to implement new PHID and handle types.',
'PhabricatorPHIDType'),
'maniphest.custom-task-extensions-class' =>
pht(
'Maniphest fields are now loaded automatically. '.
'You can configure them with `%s`.',
'maniphest.fields'),
'maniphest.custom-fields' =>
pht(
'Maniphest fields are now defined in `%s`. '.
'Existing definitions have been migrated.',
'maniphest.custom-field-definitions'),
'differential.custom-remarkup-rules' => $markup_reason,
'differential.custom-remarkup-block-rules' => $markup_reason,
'auth.sshkeys.enabled' => pht(
'SSH keys are now actually useful, so they are always enabled.'),
'differential.anonymous-access' => pht(
'Global access controls now exist, see `%s`.',
'policy.allow-public'),
'celerity.resource-path' => pht(
'An alternate resource map is no longer supported. Instead, use '.
'multiple maps. See T4222.'),
'metamta.send-immediately' => pht(
'Mail is now always delivered by the daemons.'),
'auth.sessions.conduit' => $session_reason,
'auth.sessions.web' => $session_reason,
'tokenizer.ondemand' => pht(
'Typeahead strategies are now managed automatically.'),
'differential.revision-custom-detail-renderer' => pht(
'Obsolete; use standard rendering events instead.'),
'differential.show-host-field' => $differential_field_reason,
'differential.show-test-plan-field' => $differential_field_reason,
'differential.field-selector' => $differential_field_reason,
'phabricator.show-beta-applications' => pht(
'This option has been renamed to `%s` to emphasize the '.
'unfinished nature of many prototype applications. '.
'Your existing setting has been migrated.',
'phabricator.show-prototypes'),
'notification.user' => pht(
'The notification server no longer requires root permissions. Start '.
'the server as the user you want it to run under.'),
'notification.debug' => pht(
'Notifications no longer have a dedicated debugging mode.'),
'translation.provider' => pht(
'The translation implementation has changed and providers are no '.
'longer used or supported.'),
'config.mask' => pht(
'Use `%s` instead of this option.',
'config.hide'),
'phd.start-taskmasters' => pht(
'Taskmasters now use an autoscaling pool. You can configure the '.
'pool size with `%s`.',
'phd.taskmasters'),
'storage.engine-selector' => pht(
'Storage engines are now discovered automatically at runtime.'),
'storage.upload-size-limit' => pht(
'Arbitrarily large files are now supported. Consult the '.
'documentation for configuration details.'),
'security.allow-outbound-http' => pht(
'This option has been replaced with the more granular option `%s`.',
'security.outbound-blacklist'),
'metamta.reply.show-hints' => pht(
'Reply hints are no longer shown in mail.'),
'metamta.differential.reply-handler-domain' => $reply_domain_reason,
'metamta.diffusion.reply-handler-domain' => $reply_domain_reason,
'metamta.macro.reply-handler-domain' => $reply_domain_reason,
'metamta.maniphest.reply-handler-domain' => $reply_domain_reason,
'metamta.pholio.reply-handler-domain' => $reply_domain_reason,
'metamta.diffusion.reply-handler' => $reply_handler_reason,
'metamta.differential.reply-handler' => $reply_handler_reason,
'metamta.maniphest.reply-handler' => $reply_handler_reason,
'metamta.package.reply-handler' => $reply_handler_reason,
'metamta.precedence-bulk' => pht(
'Transaction mail is now always sent with "Precedence: bulk" to '.
'improve deliverability.'),
'style.monospace' => $monospace_reason,
'style.monospace.windows' => $monospace_reason,
'search.engine-selector' => pht(
'Available search engines are now automatically discovered at '.
'runtime.'),
'metamta.files.public-create-email' => $public_mail_reason,
'metamta.maniphest.public-create-email' => $public_mail_reason,
'metamta.maniphest.default-public-author' => $public_mail_reason,
'metamta.paste.public-create-email' => $public_mail_reason,
'security.allow-conduit-act-as-user' => pht(
'Impersonating users over the API is no longer supported.'),
'feed.public' => pht('The framable public feed is no longer supported.'),
'auth.login-message' => pht(
'This configuration option has been replaced with a modular '.
'handler. See T9346.'),
'gcdaemon.ttl.herald-transcripts' => $gc_reason,
'gcdaemon.ttl.daemon-logs' => $gc_reason,
'gcdaemon.ttl.differential-parse-cache' => $gc_reason,
'gcdaemon.ttl.markup-cache' => $gc_reason,
'gcdaemon.ttl.task-archive' => $gc_reason,
'gcdaemon.ttl.general-cache' => $gc_reason,
'gcdaemon.ttl.conduit-logs' => $gc_reason,
'phd.variant-config' => pht(
'This configuration is no longer relevant because daemons '.
'restart automatically on configuration changes.'),
'notification.ssl-cert' => $aphlict_reason,
'notification.ssl-key' => $aphlict_reason,
'notification.pidfile' => $aphlict_reason,
'notification.log' => $aphlict_reason,
'notification.enabled' => $aphlict_reason,
'notification.client-uri' => $aphlict_reason,
'notification.server-uri' => $aphlict_reason,
'metamta.differential.unified-comment-context' => pht(
'Inline comments are now always rendered with a limited amount '.
'of context.'),
'differential.days-fresh' => $stale_reason,
'differential.days-stale' => $stale_reason,
'metamta.re-prefix' => $global_settings_reason,
'metamta.vary-subjects' => $global_settings_reason,
'ui.custom-header' => pht(
'This option has been replaced with `ui.logo`, which provides more '.
'flexible configuration options.'),
'welcome.html' => $dashboard_reason,
'maniphest.priorities.unbreak-now' => $dashboard_reason,
'maniphest.priorities.needs-triage' => $dashboard_reason,
'mysql.implementation' => pht(
'The best available MYSQL implementation is now selected '.
'automatically.'),
'mysql.configuration-provider' => pht(
'Partitioning and replication are now managed in primary '.
'configuration.'),
'search.elastic.host' => $elastic_reason,
'search.elastic.namespace' => $elastic_reason,
'metamta.mail-adapter' => $mailers_reason,
'amazon-ses.access-key' => $mailers_reason,
'amazon-ses.secret-key' => $mailers_reason,
'amazon-ses.endpoint' => $mailers_reason,
'mailgun.domain' => $mailers_reason,
'mailgun.api-key' => $mailers_reason,
'phpmailer.mailer' => $mailers_reason,
'phpmailer.smtp-host' => $mailers_reason,
'phpmailer.smtp-port' => $mailers_reason,
'phpmailer.smtp-protocol' => $mailers_reason,
'phpmailer.smtp-user' => $mailers_reason,
'phpmailer.smtp-password' => $mailers_reason,
'phpmailer.smtp-encoding' => $mailers_reason,
'sendgrid.api-user' => $mailers_reason,
'sendgrid.api-key' => $mailers_reason,
'celerity.resource-hash' => pht(
'This option generally did not prove useful. Resource hash keys '.
'are now managed automatically.'),
'celerity.enable-deflate' => pht(
'Resource deflation is now managed automatically.'),
'celerity.minify' => pht(
'Resource minification is now managed automatically.'),
'metamta.domain' => pht(
'Mail thread IDs are now generated automatically.'),
'metamta.placeholder-to-recipient' => pht(
'Placeholder recipients are now generated automatically.'),
'metamta.mail-key' => pht(
'Mail object address hash keys are now generated automatically.'),
'phabricator.csrf-key' => pht(
'CSRF HMAC keys are now managed automatically.'),
'metamta.insecure-auth-with-reply-to' => pht(
'Authenticating users based on "Reply-To" is no longer supported.'),
'phabricator.allow-email-users' => pht(
'Public email is now accepted if the associated address has a '.
'default author, and rejected otherwise.'),
'metamta.conpherence.subject-prefix' => $prefix_reason,
'metamta.differential.subject-prefix' => $prefix_reason,
'metamta.diffusion.subject-prefix' => $prefix_reason,
'metamta.files.subject-prefix' => $prefix_reason,
'metamta.legalpad.subject-prefix' => $prefix_reason,
'metamta.macro.subject-prefix' => $prefix_reason,
'metamta.maniphest.subject-prefix' => $prefix_reason,
'metamta.package.subject-prefix' => $prefix_reason,
'metamta.paste.subject-prefix' => $prefix_reason,
'metamta.pholio.subject-prefix' => $prefix_reason,
'metamta.phriction.subject-prefix' => $prefix_reason,
'aphront.default-application-configuration-class' => pht(
'This ancient extension point has been replaced with other '.
'mechanisms, including "AphrontSite".'),
'differential.whitespace-matters' => pht(
'Whitespace rendering is now handled automatically.'),
'phd.pid-directory' => pht(
'Daemons no longer use PID files.'),
'phd.trace' => $phd_reason,
'phd.verbose' => $phd_reason,
);
return $ancient_config;
} | Return a map of deleted config options. Keys are option keys; values are
explanations of what happened to the option. | getAncientConfig | php | phorgeit/phorge | src/applications/config/check/PhabricatorExtraConfigSetupCheck.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php | Apache-2.0 |
protected function executeChecks() {
$engines = PhabricatorFileStorageEngine::loadWritableChunkEngines();
$chunk_engine_active = (bool)$engines;
$this->checkS3();
if (!$chunk_engine_active) {
$doc_href = PhabricatorEnv::getDoclink('Configuring File Storage');
$message = pht(
'Large file storage has not been configured, which will limit '.
'the maximum size of file uploads. See %s for '.
'instructions on configuring uploads and storage.',
phutil_tag(
'a',
array(
'href' => $doc_href,
'target' => '_blank',
),
pht('Configuring File Storage')));
$this
->newIssue('large-files')
->setShortName(pht('Large Files'))
->setName(pht('Large File Storage Not Configured'))
->setMessage($message);
}
$post_max_size = ini_get('post_max_size');
if ($post_max_size && ((int)$post_max_size > 0)) {
$post_max_bytes = phutil_parse_bytes($post_max_size);
$post_max_need = (32 * 1024 * 1024);
if ($post_max_need > $post_max_bytes) {
$summary = pht(
'Set %s in your PHP configuration to at least 32MB '.
'to support large file uploads.',
phutil_tag('tt', array(), 'post_max_size'));
$message = pht(
'Adjust %s in your PHP configuration to at least 32MB. When '.
'set to smaller value, large file uploads may not work properly.',
phutil_tag('tt', array(), 'post_max_size'));
$this
->newIssue('php.post_max_size')
->setName(pht('PHP post_max_size Not Configured'))
->setSummary($summary)
->setMessage($message)
->setGroup(self::GROUP_PHP)
->addPHPConfig('post_max_size');
}
}
// This is somewhat arbitrary, but make sure we have enough headroom to
// upload a default file at the chunk threshold (8MB), which may be
// base64 encoded, then JSON encoded in the request, and may need to be
// held in memory in the raw and as a query string.
$need_bytes = (64 * 1024 * 1024);
$memory_limit = PhabricatorStartup::getOldMemoryLimit();
if ($memory_limit && ((int)$memory_limit > 0)) {
$memory_limit_bytes = phutil_parse_bytes($memory_limit);
$memory_usage_bytes = memory_get_usage();
$available_bytes = ($memory_limit_bytes - $memory_usage_bytes);
if ($need_bytes > $available_bytes) {
$summary = pht(
'Your PHP memory limit is configured in a way that may prevent '.
'you from uploading large files or handling large requests.');
$message = pht(
'When you upload a file via drag-and-drop or the API, chunks must '.
'be buffered into memory before being written to permanent '.
'storage. This server needs memory available to store these '.
'chunks while they are uploaded, but PHP is currently configured '.
'to severely limit the available memory.'.
"\n\n".
'PHP processes currently have very little free memory available '.
'(%s). To work well, processes should have at least %s.'.
"\n\n".
'(Note that the application itself must also fit in available '.
'memory, so not all of the memory under the memory limit is '.
'available for running workloads.)'.
"\n\n".
"The easiest way to resolve this issue is to set %s to %s in your ".
"PHP configuration, to disable the memory limit. There is ".
"usually little or no value to using this option to limit ".
"process memory.".
"\n\n".
"You can also increase the limit or ignore this issue and accept ".
"that you may encounter problems uploading large files and ".
"processing large requests.",
phutil_format_bytes($available_bytes),
phutil_format_bytes($need_bytes),
phutil_tag('tt', array(), 'memory_limit'),
phutil_tag('tt', array(), '-1'));
$this
->newIssue('php.memory_limit.upload')
->setName(pht('Memory Limit Restricts File Uploads'))
->setSummary($summary)
->setMessage($message)
->setGroup(self::GROUP_PHP)
->addPHPConfig('memory_limit')
->addPHPConfigOriginalValue('memory_limit', $memory_limit);
}
}
$local_path = PhabricatorEnv::getEnvConfig('storage.local-disk.path');
if (!$local_path) {
return;
}
if (!Filesystem::pathExists($local_path) ||
!is_readable($local_path) ||
!is_writable($local_path)) {
$message = pht(
'Configured location for storing uploaded files on disk ("%s") does '.
'not exist, or is not readable or writable. Verify the directory '.
'exists and is readable and writable by the webserver.',
$local_path);
$this
->newIssue('config.storage.local-disk.path')
->setShortName(pht('Local Disk Storage'))
->setName(pht('Local Disk Storage Not Readable/Writable'))
->setMessage($message)
->addPhabricatorConfig('storage.local-disk.path');
}
} | @phutil-external-symbol class PhabricatorStartup | executeChecks | php | phorgeit/phorge | src/applications/config/check/PhabricatorStorageSetupCheck.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/check/PhabricatorStorageSetupCheck.php | Apache-2.0 |
public function isPreflightCheck() {
return false;
} | Should this check execute before we load configuration?
The majority of checks (particularly, those checks which examine
configuration) should run in the normal setup phase, after configuration
loads. However, a small set of critical checks (mostly, tests for PHP
setup and extensions) need to run before we can load configuration.
@return bool True to execute before configuration is loaded. | isPreflightCheck | php | phorgeit/phorge | src/applications/config/check/PhabricatorSetupCheck.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/check/PhabricatorSetupCheck.php | Apache-2.0 |
final public static function isInFlight() {
$cache = PhabricatorCaches::getServerStateCache();
return (bool)$cache->getKey('phabricator.in-flight');
} | Test if we've survived through setup on at least one normal request
without fataling.
If we've made it through setup without hitting any fatals, we switch
to render a more friendly error page when encountering issues like
database connection failures. This gives users a smoother experience in
the face of intermittent failures.
@return bool True if we've made it through setup since the last restart. | isInFlight | php | phorgeit/phorge | src/applications/config/check/PhabricatorSetupCheck.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/check/PhabricatorSetupCheck.php | Apache-2.0 |
public static function getLogoURI(PhabricatorUser $viewer) {
$logo_uri = null;
$custom_header = self::getLogoImagePHID();
if ($custom_header) {
$cache = PhabricatorCaches::getImmutableCache();
$cache_key_logo = 'ui.custom-header.logo-phid.v3.'.$custom_header;
$logo_uri = $cache->getKey($cache_key_logo);
if (!$logo_uri) {
// NOTE: If the file policy has been changed to be restrictive, we'll
// miss here and just show the default logo. The cache will fill later
// when someone who can see the file loads the page. This might be a
// little spooky, see T11982.
$files = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($custom_header))
->execute();
$file = head($files);
if ($file) {
$logo_uri = $file->getViewURI();
$cache->setKey($cache_key_logo, $logo_uri);
}
}
}
if (!$logo_uri) {
$logo_uri =
celerity_get_resource_uri('/rsrc/image/logo/project-logo.png');
}
return $logo_uri;
} | Return the full URI of the Phorge logo
@param PhabricatorUser $viewer Current viewer
@return string Full URI of the Phorge logo | getLogoURI | php | phorgeit/phorge | src/applications/config/custom/PhabricatorCustomLogoConfigType.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/custom/PhabricatorCustomLogoConfigType.php | Apache-2.0 |
public static function prettyPrintJSON($value) {
// If the value is an array with keys "0, 1, 2, ..." then we want to
// show it as a list.
// If the value is an array with other keys, we want to show it as an
// object.
// Otherwise, just use the default encoder.
$type = null;
if (is_array($value)) {
$list_keys = range(0, count($value) - 1);
$actual_keys = array_keys($value);
if ($actual_keys === $list_keys) {
$type = 'list';
} else {
$type = 'object';
}
}
switch ($type) {
case 'list':
$result = id(new PhutilJSON())->encodeAsList($value);
break;
case 'object':
$result = id(new PhutilJSON())->encodeFormatted($value);
break;
default:
$result = json_encode($value);
break;
}
// For readability, unescape forward slashes. These are normally escaped
// to prevent the string "</script>" from appearing in a JSON literal,
// but it's irrelevant here and makes reading paths more difficult than
// necessary.
$result = str_replace('\\/', '/', $result);
return $result;
} | Properly format a JSON value.
@param wild $value Any value, but should be a raw value, not a string of
JSON.
@return string | prettyPrintJSON | php | phorgeit/phorge | src/applications/config/json/PhabricatorConfigJSON.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/json/PhabricatorConfigJSON.php | Apache-2.0 |
private function logGitErrorWithPotentialTips($e, $lib) {
// First, detect this specific error message related to [safe] stuff.
$expected_error_msg_part = 'detected dubious ownership in repository';
$stderr = $e->getStderr();
if (strpos($stderr, $expected_error_msg_part) !== false) {
// Found! Let's show a nice resolution tip.
// Complete path of the problematic repository.
$lib_root = dirname(phutil_get_library_root($lib));
phlog(pht(
"Cannot identify the version of the %s repository because ".
"the webserver does not trust it (more info on Task %s).\n".
"Try this system resolution:\n".
"sudo git config --system --add safe.directory %s",
$lib,
'https://we.phorge.it/T15282',
$lib_root));
return;
}
// Second, detect if .git does not exist
// https://we.phorge.it/T16023
$expected_error_msg_part = 'fatal: not a git repository '.
'(or any of the parent directories): .git';
if (strpos($stderr, $expected_error_msg_part) !== false) {
return;
}
// Otherwise show a generic error message
phlog($e);
} | Help in better troubleshooting git errors.
@param CommandException $e Exception
@param string $lib Library name involved | logGitErrorWithPotentialTips | php | phorgeit/phorge | src/applications/config/controller/PhabricatorConfigConsoleController.php | https://github.com/phorgeit/phorge/blob/master/src/applications/config/controller/PhabricatorConfigConsoleController.php | Apache-2.0 |
public function validateCustomDomain($domain_full_uri) {
$example_domain = 'http://blog.example.com/';
$label = pht('Invalid');
// note this "uri" should be pretty busted given the desired input
// so just use it to test if there's a protocol specified
$uri = new PhutilURI($domain_full_uri);
$domain = $uri->getDomain();
$protocol = $uri->getProtocol();
$path = $uri->getPath();
$supported_protocols = array('http', 'https');
if (!in_array($protocol, $supported_protocols)) {
return pht(
'The custom domain should include a valid protocol in the URI '.
'(for example, "%s"). Valid protocols are "http" or "https".',
$example_domain);
}
if (strlen($path) && $path != '/') {
return pht(
'The custom domain should not specify a path (hosting a Phame '.
'blog at a path is currently not supported). Instead, just provide '.
'the bare domain name (for example, "%s").',
$example_domain);
}
if (strpos($domain, '.') === false) {
return pht(
'The custom domain should contain at least one dot (.) because '.
'some browsers fail to set cookies on domains without a dot. '.
'Instead, use a normal looking domain name like "%s".',
$example_domain);
}
if (!PhabricatorEnv::getEnvConfig('policy.allow-public')) {
$href = PhabricatorEnv::getProductionURI(
'/config/edit/policy.allow-public/');
return pht(
'For custom domains to work, this server must be '.
'configured to allow the public access policy. Configure this '.
'setting %s, or ask an administrator to configure this setting. '.
'The domain can be specified later once this setting has been '.
'changed.',
phutil_tag(
'a',
array('href' => $href),
pht('here')));
}
return null;
} | Makes sure a given custom blog uri is properly configured in DNS
to point at this Phabricator instance. If there is an error in
the configuration, return a string describing the error and how
to fix it. If there is no error, return null.
@return string|null | validateCustomDomain | php | phorgeit/phorge | src/applications/phame/storage/PhameBlog.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phame/storage/PhameBlog.php | Apache-2.0 |
public function getFeedURI() {
return '/phame/blog/feed/'.$this->getID().'/';
} | Get relative URI of Phame blog feed.
@return string Relative URI of Phame blog feed | getFeedURI | php | phorgeit/phorge | src/applications/phame/storage/PhameBlog.php | https://github.com/phorgeit/phorge/blob/master/src/applications/phame/storage/PhameBlog.php | Apache-2.0 |
public function setMinimumValue($minimum_value) {
$this->minimumValue = $minimum_value;
return $this;
} | @param int $minimum_value Epoch timestamp of the first input data | setMinimumValue | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartDataQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartDataQuery.php | Apache-2.0 |
public function setMaximumValue($maximum_value) {
$this->maximumValue = $maximum_value;
return $this;
} | @param int $maximum_value Epoch timestamp of the last input data | setMaximumValue | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartDataQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartDataQuery.php | Apache-2.0 |
public function setLimit($limit) {
$this->limit = $limit;
return $this;
} | @param int $limit Maximum amount of data points to handle. If there are
more data points, some in-between data will be ignored. | setLimit | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartDataQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartDataQuery.php | Apache-2.0 |
public function selectInputValues(array $xv) {
$result = array();
$x_min = $this->getMinimumValue();
$x_max = $this->getMaximumValue();
$limit = $this->getLimit();
if ($x_min !== null) {
foreach ($xv as $key => $x) {
if ($x < $x_min) {
unset($xv[$key]);
}
}
}
if ($x_max !== null) {
foreach ($xv as $key => $x) {
if ($x > $x_max) {
unset($xv[$key]);
}
}
}
// If we have too many data points, throw away some of the data.
// TODO: This doesn't work especially well right now.
if ($limit !== null) {
$count = count($xv);
if ($count > $limit) {
$ii = 0;
$every = ceil($count / $limit);
foreach ($xv as $key => $x) {
$ii++;
if (($ii % $every) && ($ii != $count)) {
unset($xv[$key]);
}
}
}
}
return array_values($xv);
} | Filter input data: Remove values lower resp. higher than the minimum
resp. maximum values; remove some data if amount of data above the limit.
@param array<int> $xv Epoch timestamps of unfitlered input data
@return array<int> Epoch timestamps of fitlered input data | selectInputValues | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartDataQuery.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartDataQuery.php | Apache-2.0 |
final public static function getAllFunctions() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getFunctionKey')
->execute();
} | Get all available PhabricatorChartFunction subclasses
@return array<PhabricatorChartFunction> All Phabricator*ChartFunction
classes which implement getFunctionKey() | getAllFunctions | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartFunction.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartFunction.php | Apache-2.0 |
public function newDatapoints(PhabricatorChartDataQuery $query) {
$xv = $this->newInputValues($query);
if ($xv === null) {
$xv = $this->newDefaultInputValues($query);
}
$xv = $query->selectInputValues($xv);
$n = count($xv);
$yv = $this->evaluateFunction($xv);
$points = array();
for ($ii = 0; $ii < $n; $ii++) {
$y = $yv[$ii];
if ($y === null) {
continue;
}
$points[] = array(
'x' => $xv[$ii],
'y' => $y,
);
}
return $points;
} | Return arrays of x,y data points for a two-dimensional chart
@param PhabricatorChartDataQuery $query
@return array<array<int,int>> x => epoch value; y => incremental number | newDatapoints | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartFunction.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartFunction.php | Apache-2.0 |
public function setStacks(array $stacks) {
$this->stacks = $stacks;
return $this;
} | @param array<array> $stacks One or more arrays with
PhabricatorChartFunctionLabel names of each PhabricatorChartFunction,
grouped by stacking
(e.g. [["created","reopened","moved-in"],["closed","moved-out"]]) | setStacks | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartStackedAreaDataset.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartStackedAreaDataset.php | Apache-2.0 |
final public function setFunctions(array $functions) {
assert_instances_of($functions, 'PhabricatorComposeChartFunction');
$this->functions = $functions;
return $this;
} | @param array<PhabricatorComposeChartFunction> $functions | setFunctions | php | phorgeit/phorge | src/applications/fact/chart/PhabricatorChartDataset.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/chart/PhabricatorChartDataset.php | Apache-2.0 |
public function setDimensionPHID($dimension_phid) {
$this->dimensionPHID = $dimension_phid;
return $this;
} | @param string $dimension_phid | setDimensionPHID | php | phorgeit/phorge | src/applications/fact/storage/PhabricatorFactIntDatapoint.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/storage/PhabricatorFactIntDatapoint.php | Apache-2.0 |
public function key() {
return $this->getCursorFromObject($this->current());
} | [\ReturnTypeWillChange] | key | php | phorgeit/phorge | src/applications/fact/extract/PhabricatorFactUpdateIterator.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/extract/PhabricatorFactUpdateIterator.php | Apache-2.0 |
public function loadChart($chart_key) {
$chart = id(new PhabricatorFactChart())->loadOneWhere(
'chartKey = %s',
$chart_key);
if ($chart) {
$this->setChart($chart);
}
return $chart;
} | Load the chart by its key
@param string $chart_key 12-character string identifier of chart to load
@return PhabricatorFactChart | loadChart | php | phorgeit/phorge | src/applications/fact/engine/PhabricatorChartRenderingEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/engine/PhabricatorChartRenderingEngine.php | Apache-2.0 |
public static function getChartURI($chart_key) {
return id(new PhabricatorFactChart())
->setChartKey($chart_key)
->getURI();
} | Get the relative URI of the chart
@param string $chart_key 12-character string identifier of chart to load
@return string Relative URI of the chart, e.g. "fact/chart/a1b2c3d4e5f6/" | getChartURI | php | phorgeit/phorge | src/applications/fact/engine/PhabricatorChartRenderingEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/engine/PhabricatorChartRenderingEngine.php | Apache-2.0 |
public function getStoredChart() {
if (!$this->storedChart) {
$chart = $this->getChart();
$chart_key = $chart->getChartKey();
if (!$chart_key) {
$chart_key = $chart->newChartKey();
$stored_chart = id(new PhabricatorFactChart())->loadOneWhere(
'chartKey = %s',
$chart_key);
if ($stored_chart) {
$chart = $stored_chart;
} else {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
try {
$chart->save();
} catch (AphrontDuplicateKeyQueryException $ex) {
$chart = id(new PhabricatorFactChart())->loadOneWhere(
'chartKey = %s',
$chart_key);
if (!$chart) {
throw new Exception(
pht(
'Failed to load chart with key "%s" after key collision. '.
'This should not be possible.',
$chart_key));
}
}
unset($unguarded);
}
$this->setChart($chart);
}
$this->storedChart = $chart;
}
return $this->storedChart;
} | @return PhabricatorFactChart | getStoredChart | php | phorgeit/phorge | src/applications/fact/engine/PhabricatorChartRenderingEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/engine/PhabricatorChartRenderingEngine.php | Apache-2.0 |
public function newChartView() {
$chart = $this->getStoredChart();
$chart_key = $chart->getChartKey();
$chart_node_id = celerity_generate_unique_node_id();
$chart_view = phutil_tag(
'div',
array(
'id' => $chart_node_id,
'class' => 'chart-hardpoint',
));
$data_uri = urisprintf('/fact/chart/%s/draw/', $chart_key);
Javelin::initBehavior(
'line-chart',
array(
'chartNodeID' => $chart_node_id,
'dataURI' => (string)$data_uri,
));
return $chart_view;
} | @return PhutilSafeHTML | newChartView | php | phorgeit/phorge | src/applications/fact/engine/PhabricatorChartRenderingEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/engine/PhabricatorChartRenderingEngine.php | Apache-2.0 |
final public static function getAllChartEngines() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getChartEngineKey')
->execute();
} | Load all available chart engines.
@return list<PhabricatorChartEngine> All available chart engines. | getAllChartEngines | php | phorgeit/phorge | src/applications/fact/engine/PhabricatorChartEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/engine/PhabricatorChartEngine.php | Apache-2.0 |
public function newFacts() {
return array(
id(new PhabricatorCountFact())
->setKey('tasks.count.create'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.create'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.status'),
id(new PhabricatorCountFact())
->setKey('tasks.count.create.project'),
id(new PhabricatorCountFact())
->setKey('tasks.count.assign.project'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.create.project'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.status.project'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.assign.project'),
id(new PhabricatorCountFact())
->setKey('tasks.count.create.owner'),
id(new PhabricatorCountFact())
->setKey('tasks.count.assign.owner'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.create.owner'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.status.owner'),
id(new PhabricatorCountFact())
->setKey('tasks.open-count.assign.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.create'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.score'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.create'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.status'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.score'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.create.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.assign.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.score.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.create.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.status.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.score.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.assign.project'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.create.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.assign.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.points.score.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.create.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.status.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.score.owner'),
id(new PhabricatorPointsFact())
->setKey('tasks.open-points.assign.owner'),
);
} | @return array<PhabricatorCountFact> All known task related facts | newFacts | php | phorgeit/phorge | src/applications/fact/engine/PhabricatorManiphestTaskFactEngine.php | https://github.com/phorgeit/phorge/blob/master/src/applications/fact/engine/PhabricatorManiphestTaskFactEngine.php | Apache-2.0 |
public function subscribeExplicit(array $phids) {
$this->explicitSubscribePHIDs += array_fill_keys($phids, true);
return $this;
} | Add explicit subscribers. These subscribers have explicitly subscribed
(or been subscribed) to the object, and will be added even if they
had previously unsubscribed.
@param list<string> $phids List of PHIDs to explicitly subscribe.
@return $this | subscribeExplicit | php | phorgeit/phorge | src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php | Apache-2.0 |
public function subscribeImplicit(array $phids) {
$this->implicitSubscribePHIDs += array_fill_keys($phids, true);
return $this;
} | Add implicit subscribers. These subscribers have taken some action which
implicitly subscribes them (e.g., adding a comment) but it will be
suppressed if they've previously unsubscribed from the object.
@param list<string> $phids List of PHIDs to implicitly subscribe.
@return $this | subscribeImplicit | php | phorgeit/phorge | src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php | Apache-2.0 |
public function unsubscribe(array $phids) {
$this->unsubscribePHIDs += array_fill_keys($phids, true);
return $this;
} | Unsubscribe PHIDs and mark them as unsubscribed, so implicit subscriptions
will not resubscribe them.
@param list<string> $phids List of PHIDs to unsubscribe.
@return $this | unsubscribe | php | phorgeit/phorge | src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php | https://github.com/phorgeit/phorge/blob/master/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php | Apache-2.0 |
public function transformResource($path, $data) {
$type = self::getResourceType($path);
switch ($type) {
case 'css':
$data = $this->replaceCSSPrintRules($path, $data);
$data = $this->replaceCSSVariables($path, $data);
$data = preg_replace_callback(
'@url\s*\((\s*[\'"]?.*?)\)@s',
nonempty(
$this->translateURICallback,
array($this, 'translateResourceURI')),
$data);
break;
}
if (!$this->minify) {
return $data;
}
// Some resources won't survive minification (like d3.min.js), and are
// marked so as not to be minified.
if (strpos($data, '@'.'do-not-minify') !== false) {
return $data;
}
switch ($type) {
case 'css':
// Remove comments.
$data = preg_replace('@/\*.*?\*/@s', '', $data);
// Remove whitespace around symbols.
$data = preg_replace('@\s*([{}:;,])\s*@', '\1', $data);
// Remove unnecessary semicolons.
$data = preg_replace('@;}@', '}', $data);
// Replace #rrggbb with #rgb when possible.
$data = preg_replace(
'@#([a-f0-9])\1([a-f0-9])\2([a-f0-9])\3@i',
'#\1\2\3',
$data);
$data = trim($data);
break;
case 'js':
// If `jsxmin` is available, use it. jsxmin is the Javelin minifier and
// produces the smallest output, but is complicated to build.
if (Filesystem::binaryExists('jsxmin')) {
$future = new ExecFuture('jsxmin __DEV__:0');
$future->write($data);
list($err, $result) = $future->resolve();
if (!$err) {
$data = $result;
break;
}
}
// If `jsxmin` is not available, use `JsShrink`, which doesn't compress
// quite as well but is always available.
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root.'/externals/JsShrink/jsShrink.php';
$data = jsShrink($data);
break;
}
return $data;
} | @phutil-external-symbol function jsShrink | transformResource | php | phorgeit/phorge | src/applications/celerity/CelerityResourceTransformer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceTransformer.php | Apache-2.0 |
private function generateDataURI($resource_name) {
$ext = last(explode('.', $resource_name));
switch ($ext) {
case 'png':
$type = 'image/png';
break;
case 'gif':
$type = 'image/gif';
break;
case 'jpg':
$type = 'image/jpeg';
break;
default:
return null;
}
// In IE8, 32KB is the maximum supported URI length.
$maximum_data_size = (1024 * 32);
$data = $this->celerityMap->getResourceDataForName($resource_name);
if (strlen($data) >= $maximum_data_size) {
// If the data is already too large on its own, just bail before
// encoding it.
return null;
}
$uri = 'data:'.$type.';base64,'.base64_encode($data);
if (strlen($uri) >= $maximum_data_size) {
return null;
}
return $uri;
} | Attempt to generate a data URI for a resource. We'll generate a data URI
if the resource is a valid resource of an appropriate type, and is
small enough. Otherwise, this method will return `null` and we'll end up
using a normal URI instead.
@param string $resource_name Resource name to attempt to generate a data
URI for.
@return string|null Data URI, or null if we declined to generate one. | generateDataURI | php | phorgeit/phorge | src/applications/celerity/CelerityResourceTransformer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceTransformer.php | Apache-2.0 |
function require_celerity_resource($symbol, $source_name = 'phabricator') {
$response = CelerityAPI::getStaticResourceResponse();
$response->requireResource($symbol, $source_name);
} | Include a CSS or JS static resource by name. This function records a
dependency for the current page, so when a response is generated it can be
included. You can call this method from any context, and it is recommended
you invoke it as close to the actual dependency as possible so that page
dependencies are minimized.
For more information, see @{article:Adding New CSS and JS}.
@param string $symbol Name of the celerity module to include. This is
whatever you annotated as "@provides" in the file.
@param string $source_name (optional)
@return void | require_celerity_resource | php | phorgeit/phorge | src/applications/celerity/api.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/api.php | Apache-2.0 |
function celerity_get_resource_uri($resource, $source = 'phabricator') {
$resource = ltrim($resource, '/');
$map = CelerityResourceMap::getNamedInstance($source);
$response = CelerityAPI::getStaticResourceResponse();
return $response->getURI($map, $resource);
} | Get the versioned URI for a raw resource, like an image.
@param string $resource Path to the raw image.
@param string $source (optional) Defaults to 'phabricator'
@return string Versioned path to the image, if one is available. | celerity_get_resource_uri | php | phorgeit/phorge | src/applications/celerity/api.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/api.php | Apache-2.0 |
public function getURIForSymbol($symbol) {
$hash = idx($this->symbolMap, $symbol);
return $this->getURIForHash($hash);
} | Return the absolute URI for the resource associated with a symbol. This
method is fairly low-level and ignores packaging.
@param string $symbol Resource symbol to lookup.
@return string|null Resource URI, or null if the symbol is unknown. | getURIForSymbol | php | phorgeit/phorge | src/applications/celerity/CelerityResourceMap.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceMap.php | Apache-2.0 |
public function getURIForName($name) {
$hash = idx($this->nameMap, $name);
return $this->getURIForHash($hash);
} | Return the absolute URI for the resource associated with a resource name.
This method is fairly low-level and ignores packaging.
@param string $name Resource name to lookup.
@return string|null Resource URI, or null if the name is unknown. | getURIForName | php | phorgeit/phorge | src/applications/celerity/CelerityResourceMap.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceMap.php | Apache-2.0 |
private function getURIForHash($hash) {
if ($hash === null) {
return null;
}
return $this->resources->getResourceURI($hash, $this->hashMap[$hash]);
} | Return the absolute URI for a resource, identified by hash.
This method is fairly low-level and ignores packaging.
@param string $hash Resource hash to lookup.
@return string|null Resource URI, or null if the hash is unknown. | getURIForHash | php | phorgeit/phorge | src/applications/celerity/CelerityResourceMap.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceMap.php | Apache-2.0 |
public function getRequiredSymbolsForName($name) {
$hash = idx($this->nameMap, $name);
if ($hash === null) {
return null;
}
return idx($this->requiresMap, $hash, array());
} | Return the resource symbols required by a named resource.
@param string $name Resource name to lookup.
@return list<string>|null List of required symbols, or null if the name
is unknown. | getRequiredSymbolsForName | php | phorgeit/phorge | src/applications/celerity/CelerityResourceMap.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceMap.php | Apache-2.0 |
public function getResourceNameForSymbol($symbol) {
$hash = idx($this->symbolMap, $symbol);
return idx($this->hashMap, $hash);
} | Return the resource name for a given symbol.
@param string $symbol Resource symbol to lookup.
@return string|null Resource name, or null if the symbol is unknown. | getResourceNameForSymbol | php | phorgeit/phorge | src/applications/celerity/CelerityResourceMap.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceMap.php | Apache-2.0 |
private function getProvidesAndRequires($name, $data) {
$parser = new PhutilDocblockParser();
$matches = array();
$ok = preg_match('@/[*][*].*?[*]/@s', $data, $matches);
if (!$ok) {
throw new Exception(
pht(
'Resource "%s" does not have a header doc comment. Encode '.
'dependency data in a header docblock.',
$name));
}
list($description, $metadata) = $parser->parse($matches[0]);
$provides = $this->parseResourceSymbolList(idx($metadata, 'provides'));
$requires = $this->parseResourceSymbolList(idx($metadata, 'requires'));
if (!$provides) {
// Tests and documentation-only JS is permitted to @provide no targets.
return array(null, null);
}
if (count($provides) > 1) {
throw new Exception(
pht(
'Resource "%s" must %s at most one Celerity target.',
$name,
'@provide'));
}
return array(head($provides), $requires);
} | Parse the `@provides` and `@requires` symbols out of a text resource, like
JS or CSS.
@param string $name Resource name.
@param string $data Resource data.
@return pair<string|null, list<string>|null> The `@provides` symbol and
the list of `@requires` symbols. If the resource is not part of the
dependency graph, both are null. | getProvidesAndRequires | php | phorgeit/phorge | src/applications/celerity/CelerityResourceMapGenerator.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/CelerityResourceMapGenerator.php | Apache-2.0 |
private function isLocallyCacheableResourceType($type) {
$types = array(
'js' => true,
'css' => true,
);
return isset($types[$type]);
} | Is it appropriate to cache the data for this resource type in the fast
immutable cache?
Generally, text resources (which are small, and expensive to process)
are cached, while other types of resources (which are large, and cheap
to process) are not.
@param string $type Resource type.
@return bool True to enable caching. | isLocallyCacheableResourceType | php | phorgeit/phorge | src/applications/celerity/controller/CelerityResourceController.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/controller/CelerityResourceController.php | Apache-2.0 |
private function rebuildResources(CelerityPhysicalResources $resources) {
$this->log(
pht(
'Rebuilding resource source "%s" (%s)...',
$resources->getName(),
get_class($resources)));
id(new CelerityResourceMapGenerator($resources))
->setDebug(true)
->generate()
->write();
} | Rebuild the resource map for a resource source.
@param $resources CelerityPhysicalResources Resource source to rebuild.
@return void | rebuildResources | php | phorgeit/phorge | src/applications/celerity/management/CelerityManagementMapWorkflow.php | https://github.com/phorgeit/phorge/blob/master/src/applications/celerity/management/CelerityManagementMapWorkflow.php | Apache-2.0 |
public function getCustomRuleValues($rule_class) {
$values = array();
foreach ($this->getRules() as $rule) {
if ($rule['rule'] == $rule_class) {
$values[] = $rule['value'];
}
}
return $values;
} | Return a list of all values used by a given rule class to implement this
policy. This is used to bulk load data (like project memberships) in order
to apply policy filters efficiently.
@param string $rule_class Policy rule classname.
@return list<wild> List of values used in this policy. | getCustomRuleValues | php | phorgeit/phorge | src/applications/policy/storage/PhabricatorPolicy.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/storage/PhabricatorPolicy.php | Apache-2.0 |
public function isStrongerThan(PhabricatorPolicy $other) {
$this_policy = $this->getPHID();
$other_policy = $other->getPHID();
$strengths = array(
PhabricatorPolicies::POLICY_PUBLIC => -2,
PhabricatorPolicies::POLICY_USER => -1,
// (Default policies have strength 0.)
PhabricatorPolicies::POLICY_NOONE => 1,
);
$this_strength = idx($strengths, $this_policy, 0);
$other_strength = idx($strengths, $other_policy, 0);
return ($this_strength > $other_strength);
} | Return `true` if this policy is stronger (more restrictive) than some
other policy.
Because policies are complicated, determining which policies are
"stronger" is not trivial. This method uses a very coarse working
definition of policy strength which is cheap to compute, unambiguous,
and intuitive in the common cases.
This method returns `true` if the //class// of this policy is stronger
than the other policy, even if the policies are (or might be) the same in
practice. For example, "Members of Project X" is considered a stronger
policy than "All Users", even though "Project X" might (in some rare
cases) contain every user.
Generally, the ordering here is:
- Public
- All Users
- (Everything Else)
- No One
In the "everything else" bucket, we can't make any broad claims about
which policy is stronger (and we especially can't make those claims
cheaply).
Even if we fully evaluated each policy, the two policies might be
"Members of X" and "Members of Y", each of which permits access to some
set of unique users. In this case, neither is strictly stronger than
the other.
@param PhabricatorPolicy $other Other policy.
@return bool `true` if this policy is more restrictive than the other
policy. | isStrongerThan | php | phorgeit/phorge | src/applications/policy/storage/PhabricatorPolicy.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/storage/PhabricatorPolicy.php | Apache-2.0 |
public static function getMostOpenPolicy() {
if (PhabricatorEnv::getEnvConfig('policy.allow-public')) {
return self::POLICY_PUBLIC;
} else {
return self::POLICY_USER;
}
} | Returns the most public policy this install's configuration permits.
This is either "public" (if available) or "all users" (if not).
@return string Most open working policy constant. | getMostOpenPolicy | php | phorgeit/phorge | src/applications/policy/constants/PhabricatorPolicies.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/constants/PhabricatorPolicies.php | Apache-2.0 |
private function buildObject($policy) {
$object = new PhabricatorPolicyTestObject();
$object->setCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
));
$object->setPolicies(
array(
PhabricatorPolicyCapability::CAN_VIEW => $policy,
PhabricatorPolicyCapability::CAN_EDIT => $policy,
));
return $object;
} | Build a test object to spec. | buildObject | php | phorgeit/phorge | src/applications/policy/__tests__/PhabricatorPolicyTestCase.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php | Apache-2.0 |
private function buildUser($spec) {
$user = new PhabricatorUser();
switch ($spec) {
case 'public':
break;
case 'user':
$user->setPHID(1);
break;
case 'admin':
$user->setPHID(1);
$user->setIsAdmin(true);
break;
default:
throw new Exception(pht("Unknown user spec '%s'.", $spec));
}
return $user;
} | Build a test user to spec. | buildUser | php | phorgeit/phorge | src/applications/policy/__tests__/PhabricatorPolicyTestCase.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php | Apache-2.0 |
public function canApplyToObject(PhabricatorPolicyInterface $object) {
return true;
} | Return `true` if this rule can be applied to the given object.
Some policy rules may only operation on certain kinds of objects. For
example, a "task author" rule can only operate on tasks. | canApplyToObject | php | phorgeit/phorge | src/applications/policy/rule/PhabricatorPolicyRule.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php | Apache-2.0 |
public function ruleHasEffect($value) {
return true;
} | Return `true` if the given value creates a rule with a meaningful effect.
An example of a rule with no meaningful effect is a "users" rule with no
users specified.
@return bool True if the value creates a meaningful rule. | ruleHasEffect | php | phorgeit/phorge | src/applications/policy/rule/PhabricatorPolicyRule.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php | Apache-2.0 |
public static function passTransactionHintToRule(
PhabricatorPolicyInterface $object,
PhabricatorPolicyRule $rule,
$hint) {
$cache = PhabricatorCaches::getRequestCache();
$cache->setKey(self::getObjectPolicyCacheKey($object, $rule), $hint);
} | Tell policy rules about upcoming transaction effects.
Before transaction effects are applied, we try to stop users from making
edits which will lock them out of objects. We can't do this perfectly,
since they can set a policy to "the moon is full" moments before it wanes,
but we try to prevent as many mistakes as possible.
Some policy rules depend on complex checks against object state which
we can't set up ahead of time. For example, subscriptions require database
writes.
In cases like this, instead of doing writes, you can pass a hint about an
object to a policy rule. The rule can then look for hints and use them in
rendering a verdict about whether the user will be able to see the object
or not after applying the policy change.
@param PhabricatorPolicyInterface $object Object to pass a hint about.
@param PhabricatorPolicyRule $rule Rule to pass hint to.
@param wild $hint Hint.
@return void | passTransactionHintToRule | php | phorgeit/phorge | src/applications/policy/rule/PhabricatorPolicyRule.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php | Apache-2.0 |
public function getObjectPolicyKey() {
return null;
} | Return a unique string like "maniphest.author" to expose this rule as an
object policy.
Object policy rules, like "Task Author", are more advanced than basic
policy rules (like "All Users") but not as powerful as custom rules.
@return string Unique identifier for this rule.
@task objectpolicy | getObjectPolicyKey | php | phorgeit/phorge | src/applications/policy/rule/PhabricatorPolicyRule.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/rule/PhabricatorPolicyRule.php | Apache-2.0 |
final public function getCapabilityKey() {
return $this->getPhobjectClassConstant('CAPABILITY');
} | Get the unique key identifying this capability. This key must be globally
unique. Application capabilities should be namespaced. For example:
application.create
@return string Globally unique capability key. | getCapabilityKey | php | phorgeit/phorge | src/applications/policy/capability/PhabricatorPolicyCapability.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/capability/PhabricatorPolicyCapability.php | Apache-2.0 |
public function describeCapabilityRejection() {
return null;
} | Return a human-readable string describing what not having this capability
prevents the user from doing. For example:
- You do not have permission to edit this object.
- You do not have permission to create new tasks.
@return string|null Human-readable name describing what failing a check
for this capability prevents the user from doing. | describeCapabilityRejection | php | phorgeit/phorge | src/applications/policy/capability/PhabricatorPolicyCapability.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/capability/PhabricatorPolicyCapability.php | Apache-2.0 |
public function shouldAllowPublicPolicySetting() {
return false;
} | Can this capability be set to "public"? Broadly, this is only appropriate
for view and view-related policies.
@return bool True to allow the "public" policy. Returns false by default. | shouldAllowPublicPolicySetting | php | phorgeit/phorge | src/applications/policy/capability/PhabricatorPolicyCapability.php | https://github.com/phorgeit/phorge/blob/master/src/applications/policy/capability/PhabricatorPolicyCapability.php | Apache-2.0 |
public function userHasAuthorizedClient(array $scope) {
$authorization = id(new PhabricatorOAuthClientAuthorization())
->loadOneWhere(
'userPHID = %s AND clientPHID = %s',
$this->getUser()->getPHID(),
$this->getClient()->getPHID());
if (empty($authorization)) {
return array(false, null);
}
if ($scope) {
$missing_scope = array_diff_key($scope, $authorization->getScope());
} else {
$missing_scope = false;
}
if ($missing_scope) {
return array(false, $authorization);
}
return array(true, $authorization);
} | @task auth
@return tuple <bool hasAuthorized, ClientAuthorization or null> | userHasAuthorizedClient | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function authorizeClient(array $scope) {
$authorization = new PhabricatorOAuthClientAuthorization();
$authorization->setUserPHID($this->getUser()->getPHID());
$authorization->setClientPHID($this->getClient()->getPHID());
$authorization->setScope($scope);
$authorization->save();
return $authorization;
} | @task auth | authorizeClient | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function generateAuthorizationCode(PhutilURI $redirect_uri) {
$code = Filesystem::readRandomCharacters(32);
$client = $this->getClient();
$authorization_code = new PhabricatorOAuthServerAuthorizationCode();
$authorization_code->setCode($code);
$authorization_code->setClientPHID($client->getPHID());
$authorization_code->setClientSecret($client->getSecret());
$authorization_code->setUserPHID($this->getUser()->getPHID());
$authorization_code->setRedirectURI((string)$redirect_uri);
$authorization_code->save();
return $authorization_code;
} | @task auth | generateAuthorizationCode | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function generateAccessToken() {
$token = Filesystem::readRandomCharacters(32);
$access_token = new PhabricatorOAuthServerAccessToken();
$access_token->setToken($token);
$access_token->setUserPHID($this->getUser()->getPHID());
$access_token->setClientPHID($this->getClient()->getPHID());
$access_token->save();
return $access_token;
} | @task token | generateAccessToken | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function validateAuthorizationCode(
PhabricatorOAuthServerAuthorizationCode $test_code,
PhabricatorOAuthServerAuthorizationCode $valid_code) {
// check that all the meta data matches
if ($test_code->getClientPHID() != $valid_code->getClientPHID()) {
return false;
}
if ($test_code->getClientSecret() != $valid_code->getClientSecret()) {
return false;
}
// check that the authorization code hasn't timed out
$created_time = $test_code->getDateCreated();
$must_be_used_by = $created_time + self::AUTHORIZATION_CODE_TIMEOUT;
return (time() < $must_be_used_by);
} | @task token | validateAuthorizationCode | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function authorizeToken(
PhabricatorOAuthServerAccessToken $token) {
$user_phid = $token->getUserPHID();
$client_phid = $token->getClientPHID();
$authorization = id(new PhabricatorOAuthClientAuthorizationQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withUserPHIDs(array($user_phid))
->withClientPHIDs(array($client_phid))
->executeOne();
if (!$authorization) {
return null;
}
$application = $authorization->getClient();
if ($application->getIsDisabled()) {
return null;
}
return $authorization;
} | @task token | authorizeToken | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function assertValidRedirectURI($raw_uri) {
// This covers basics like reasonable formatting and the existence of a
// protocol.
PhabricatorEnv::requireValidRemoteURIForLink($raw_uri);
$uri = new PhutilURI($raw_uri);
$fragment = $uri->getFragment();
if (strlen($fragment)) {
throw new Exception(
pht(
'OAuth application redirect URIs must not contain URI '.
'fragments, but the URI "%s" has a fragment ("%s").',
$raw_uri,
$fragment));
}
$protocol = $uri->getProtocol();
switch ($protocol) {
case 'http':
case 'https':
break;
default:
throw new Exception(
pht(
'OAuth application redirect URIs must only use the "http" or '.
'"https" protocols, but the URI "%s" uses the "%s" protocol.',
$raw_uri,
$protocol));
}
} | See http://tools.ietf.org/html/draft-ietf-oauth-v2-23#section-3.1.2
for details on what makes a given redirect URI "valid". | assertValidRedirectURI | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function validateSecondaryRedirectURI(
PhutilURI $secondary_uri,
PhutilURI $primary_uri) {
// The secondary URI must be valid.
if (!$this->validateRedirectURI($secondary_uri)) {
return false;
}
// Both URIs must point at the same domain.
if ($secondary_uri->getDomain() != $primary_uri->getDomain()) {
return false;
}
// Both URIs must have the same path
if ($secondary_uri->getPath() != $primary_uri->getPath()) {
return false;
}
// Both URIs must have the same port
if ($secondary_uri->getPort() != $primary_uri->getPort()) {
return false;
}
// Any query parameters present in the first URI must be exactly present
// in the second URI.
$need_params = $primary_uri->getQueryParamsAsMap();
$have_params = $secondary_uri->getQueryParamsAsMap();
foreach ($need_params as $key => $value) {
if (!array_key_exists($key, $have_params)) {
return false;
}
if ((string)$have_params[$key] != (string)$value) {
return false;
}
}
// If the first URI is HTTPS, the second URI must also be HTTPS. This
// defuses an attack where a third party with control over the network
// tricks you into using HTTP to authenticate over a link which is supposed
// to be HTTPS only and sniffs all your token cookies.
if (strtolower($primary_uri->getProtocol()) == 'https') {
if (strtolower($secondary_uri->getProtocol()) != 'https') {
return false;
}
}
return true;
} | If there's a URI specified in an OAuth request, it must be validated in
its own right. Further, it must have the same domain, the same path, the
same port, and (at least) the same query parameters as the primary URI. | validateSecondaryRedirectURI | php | phorgeit/phorge | src/applications/oauthserver/PhabricatorOAuthServer.php | https://github.com/phorgeit/phorge/blob/master/src/applications/oauthserver/PhabricatorOAuthServer.php | Apache-2.0 |
public function getRuleExecutionOrderSortKey() {
$rule_type = $this->getRuleType();
switch ($rule_type) {
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
$type_order = 1;
break;
case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
$type_order = 2;
break;
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
$type_order = 3;
break;
default:
throw new Exception(pht('Unknown rule type "%s"!', $rule_type));
}
return sprintf('~%d%010d', $type_order, $this->getID());
} | Get a sortable key for rule execution order.
Rules execute in a well-defined order: personal rules first, then object
rules, then global rules. Within each rule type, rules execute from lowest
ID to highest ID.
This ordering allows more powerful rules (like global rules) to override
weaker rules (like personal rules) when multiple rules exist which try to
affect the same field. Executing from low IDs to high IDs makes
interactions easier to understand when adding new rules, because the newest
rules always happen last.
@return string A sortable key for this rule. | getRuleExecutionOrderSortKey | php | phorgeit/phorge | src/applications/herald/storage/HeraldRule.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/storage/HeraldRule.php | Apache-2.0 |
public function getEditorDisplayName() {
$name = pht('%s %s', $this->getMonogram(), $this->getName());
if ($this->getIsDisabled()) {
$name = pht('%s (Disabled)', $name);
}
return $name;
} | @return string Name of the rule, for example "H123 RuleName (Disabled)" | getEditorDisplayName | php | phorgeit/phorge | src/applications/herald/storage/HeraldRule.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/storage/HeraldRule.php | Apache-2.0 |
final public function getAppliedTransactions() {
return $this->appliedTransactions;
} | Get a list of transactions which just took effect.
When an object is edited normally, transactions are applied and then
Herald executes. You can call this method to examine the transactions
if you want to react to them.
@return list<PhabricatorApplicationTransaction> List of transactions. | getAppliedTransactions | php | phorgeit/phorge | src/applications/herald/adapter/HeraldAdapter.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/adapter/HeraldAdapter.php | Apache-2.0 |
public function getAdapterContentType() {
return get_class($this);
} | NOTE: You generally should not override this; it exists to support legacy
adapters which had hard-coded content types. | getAdapterContentType | php | phorgeit/phorge | src/applications/herald/adapter/HeraldAdapter.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/adapter/HeraldAdapter.php | Apache-2.0 |
public function isSingleEventAdapter() {
return false;
} | Does this adapter's event fire only once?
Single use adapters (like pre-commit and diff adapters) only fire once,
so fields like "Is new object" don't make sense to apply to their content.
@return bool | isSingleEventAdapter | php | phorgeit/phorge | src/applications/herald/adapter/HeraldAdapter.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/adapter/HeraldAdapter.php | Apache-2.0 |
protected function applyStandardEffect(HeraldEffect $effect) {
$action = $effect->getAction();
$rule_type = $effect->getRule()->getRuleType();
$impl = $this->getActionImplementation($action);
if (!$impl) {
return new HeraldApplyTranscript(
$effect,
false,
array(
array(
HeraldAction::DO_STANDARD_INVALID_ACTION,
$action,
),
));
}
if (!$impl->supportsRuleType($rule_type)) {
return new HeraldApplyTranscript(
$effect,
false,
array(
array(
HeraldAction::DO_STANDARD_WRONG_RULE_TYPE,
$rule_type,
),
));
}
$impl->applyEffect($this->getObject(), $effect);
return $impl->getApplyTranscript($effect);
} | @task apply | applyStandardEffect | php | phorgeit/phorge | src/applications/herald/adapter/HeraldAdapter.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/adapter/HeraldAdapter.php | Apache-2.0 |
public function getObjectPHID() {
return $this->objectPHID;
} | @return string PHID of the object that Herald is applied on | getObjectPHID | php | phorgeit/phorge | src/applications/herald/engine/HeraldEffect.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/engine/HeraldEffect.php | Apache-2.0 |
public function getAction() {
return $this->action;
} | @return string ACTIONCONST of the HeraldAction | getAction | php | phorgeit/phorge | src/applications/herald/engine/HeraldEffect.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/engine/HeraldEffect.php | Apache-2.0 |
public function getTarget() {
return $this->target;
} | @return array|null | getTarget | php | phorgeit/phorge | src/applications/herald/engine/HeraldEffect.php | https://github.com/phorgeit/phorge/blob/master/src/applications/herald/engine/HeraldEffect.php | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.