1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-23 03:59:25 +01:00

Unbreak the creation of Packages Versions

Summary:
Allow the creation of versions in Packages
by specifying a dummy Package to allow the
extended policy checks to pass. Versions
require that the package they're a version
of be accessible to the viewer, but that
means a package is required during creation.

This also initializes the attached package
property to the un-attached state, which
was missing. This should make it easier to
fix when misused.

Currently trying to create versions in Packages throws:
```
EXCEPTION: (Error) Call to a member function getPHID() on null at [<phorge>/src/applications/policy/filter/PhabricatorPolicyFilter.php:404]
```

Test Plan:
* Visit /applications/view/PhabricatorPackagesApplication/ and enable the Packages prototype application
* Visit /packages/version/edit/form/default
* Observe an edit form instead of an exception

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25882
This commit is contained in:
mainframe98 2025-02-15 22:04:21 +01:00
parent 6ea09aa82c
commit ebbe83c394
2 changed files with 6 additions and 2 deletions

View file

@ -19,7 +19,11 @@ final class PhabricatorPackagesVersionEditEngine
protected function newEditableObject() {
$viewer = $this->getViewer();
return PhabricatorPackagesVersion::initializeNewVersion($viewer);
return PhabricatorPackagesVersion::initializeNewVersion($viewer)
// Attach a dummy package to have the policy checks pass for this object
// during creation.
->attachPackage(
PhabricatorPackagesPackage::initializeNewPackage($viewer));
}
protected function newObjectQuery() {

View file

@ -15,7 +15,7 @@ final class PhabricatorPackagesVersion
protected $name;
protected $packagePHID;
private $package;
private $package = self::ATTACHABLE;
public static function initializeNewVersion(PhabricatorUser $actor) {
return id(new self());