1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00
Commit graph

13737 commits

Author SHA1 Message Date
Andre Klapper
58f1c83a5a Fix PHP 8.1 "strlen(null)" exception in DivinerFindController
Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/diviner/controller/DivinerFindController.php:40]
```

Closes T15910

Test Plan:
Go to this (or any other Diviner Find URL not passing a `type` URI parameter): now it works:

http://phorge.localhost/diviner/find/?name=PhutilSafeHTML

Go to this (or any other Diviner Find URL passing a `type` URI parameter): it still works:

http://phorge.localhost/diviner/find/?name=PhutilSafeHTML&type=class

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15910

Differential Revision: https://we.phorge.it/D25768
2024-08-11 22:36:44 +02:00
Dylan F
2b7c0ec92f Destroy file attachments when file is deleted, or object is deleted
Summary:
Adds file attachment deletion logics:

- PhabricatorFile: delete the attachment if file is deleted
- destruction engine extension: delete attachment if object is deleted
- SQL patch: delete existing leftover attachments from deleted files

To apply the cleanup, as usual, run:

    ./bin/storage upgrade

This cleanup may take some time, proportionally to the size of these tables:

    phabricator_file.file
    phabricator_file.file_attachment

Just as an indication: the storage upgrade, in a Phorge with `file` count 1.3M rows and `file_attachment` consisting in 9K rows, it may delete 170K rows in less than 1 second on average hardware.

Closes T15110

Test Plan:
Apply the patch, run `./bin/storage/upgrade`:

- no "Unknown Object" in any "Referenced Files" curtain of any object.

Have phd daemon running.

Upload file, attach the file to a task, delete the file from the web interface:

- no "Unknown Object" in "Referenced Files" curtain of that task.
- the query `SELECT * FROM file_attachment WHERE filePHID = '<file phid>'` returns empty result

Upload file, attach the file to a task, delete the task from the `./bin/remove destroy` workflow:

- the query `SELECT * FROM file_attachment WHERE objectPHID = '<task phid>'` returns empty result

Reviewers: O1 Blessed Committers, avivey, valerio.bozzolan

Reviewed By: O1 Blessed Committers, avivey, valerio.bozzolan

Subscribers: Ekubischta, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Tags: #files

Maniphest Tasks: T15110

Differential Revision: https://we.phorge.it/D25051
2024-08-10 22:16:53 +02:00
Andre Klapper
b74f1ad519 Fix 404 link in Diviner to "Configuring File Storage" article
Summary: Fix a broken link in documentation.

Test Plan:
1. Go to https://we.phorge.it/book/dev/class/PhabricatorFileStorageEngine/
2. Click link "For more information, see File Storage Technical Documentation."
3. Get a 404 via https://we.phorge.it/diviner/find/?name=File_Storage_Technical_Documentation&type=article&jump=1 beforehand; get an article via https://we.phorge.it/diviner/find/?name=Configuring_File_Storage&type=article&jump=1 afterhand.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25762
2024-08-07 17:40:55 +02:00
Andre Klapper
88225b99f2 Fix PHP 8.1 "strlen(null)" exception in ManiphestTaskPointsTransaction
Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/maniphest/xaction/ManiphestTaskPointsTransaction.php:85]
```

Closes T15902

Test Plan: Unclear due to lack of steps to reproduce.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15902

Differential Revision: https://we.phorge.it/D25765
2024-08-07 13:57:07 +02:00
Andre Klapper
89778dc9e6 Add Open Graph protocol meta tags to Maniphest task pages
Summary:
Add OGP <meta> tags to Maniphest task pages when the task is publicly accessible and anonymously accessed. See https://ogp.me/

Based on rP2c72c2b924ffa3f8a49dbec636a2cdca3bae004f reverted in rP49b57eae7df52c189aef1d973823c697fc97fd4b.

Closes T15472

Test Plan:
* Use the default Phorge logo, open a Maniphest task, look at the headers in its HTML.
* Set a custom Phorge logo via `config/edit/ui.logo/`.
* Access a task with "View Policy: All Users" while logged in: No OGP headers included.
* Access a task with "View Policy: Public" while logged in: No OGP headers included.
* Access a task with "View Policy: All Users" while logged out: No OGP headers included; "Access Denied: Restricted Maniphest Task" displayed.
* Access a task with "View Policy: Public" while logged out: OGP headers included.
* Access a task with "View Policy: Public" while logged out with a task description and a task without a task description: OGP headers included.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15472

Differential Revision: https://we.phorge.it/D25668
2024-08-07 13:54:11 +02:00
Andre Klapper
ec6ba69666 Add Copy file path button to file header bar in Differential/Diffusion
Summary:
When looking at a commit/revision, allow to copy the path of a file to the clipboard, so you can quickly open that file in your local code checkout from the command line.

Closes T15897

Test Plan:
Open a proposed commit in Differential or a merged commit in Diffusion. Click the "Copy file path" button, paste that clipboard content.
Change the width of the viewport and see that the button is not rendered when in phone mode.
Run `./bin/celerity map` again and no changes.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15897

Differential Revision: https://we.phorge.it/D25757
2024-08-04 11:53:24 +02:00
Andre Klapper
0bfe9ca88f Log Herald rules with invalid actions via phlog()
Summary:
When Herald rules fail unexpectedly due to relying on a (now) invalid action, allow Phorge administrators to get aware by creating an entry in the error log via `phlog()` instead of crossing fingers that someone may from time to time get the idea to open and read Herald transcripts.

Refs T15887

Test Plan: See steps in T15887; check error log.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15887

Differential Revision: https://we.phorge.it/D25737
2024-08-04 11:35:55 +02:00
Andre Klapper
71615f4b99 Log Herald rules having disabled Herald rules as condition via phlog()
Summary:
Do not silently fail when a Herald rule refers in its conditions to a disabled rule.
Allow Phorge administrators to get aware by creating an entry in the error log via phlog() instead of crossing fingers that someone may from time to time get the idea to open and read Herald transcripts.

This is similar to T15885 / D25735.

Refs T15869

Test Plan:
1. Phorge at `0873b36569bfcf502a092870d7d5f4d088ed9003`
2. Set up a Herald rule and disable it
3. Set up a second Herald rule with several conditions, the first condition being "Another Herald rule matches" on the disabled first Herald rule
4. Go to http://phorge.localhost/herald/test/ to apply the Herald rule on a corresponding object
5. See an exception in the resulting transcript at http://phorge.localhost/herald/transcript/123456/
6. After applying this patch, also find that exception in the error log

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15869

Differential Revision: https://we.phorge.it/D25736
2024-08-04 11:35:31 +02:00
Andre Klapper
f6302c7ee3 Log Herald rules with invalid keys via phlog()
Summary:
When Herald rules fail unexpectedly due to relying on a (now) invalid key, allow Phorge administrators to get aware by creating an entry in the error log via `phlog()` instead of crossing fingers that someone may from time to time get the idea to open and read Herald transcripts.

Refs T15885

Test Plan: See steps in T15885; check error log.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15885

Differential Revision: https://we.phorge.it/D25735
2024-08-04 11:35:05 +02:00
Andre Klapper
93c9afd2f3 Do not add actor as subscriber when removing a comment
Summary:
When an admin removes a comment (e.g. spam), the admin gets subscribed to the task. This is usually unwanted as the removal action does not imply that the admin is interested in receiving future notifications about the task, in contrast to e.g. adding a comment to a discussion in the task.

Any transaction of a comment (add, edit, remove) is a `"core:comment"` action. The code calls `applyImplicitCC()` which calls `shouldImplyCC()` which returns the bool `$xaction->isCommentTransaction()`. Expand this bool to `$xaction->isCommentTransaction() && !($xaction->getComment()->getIsRemoved())`.

Closes T15899

Test Plan:
* As an admin, go to a task which has comments and to which you are not subscribed
* Click the dropdown for the comment, select Remove comment
* See that you did not get subscribed to the task

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15899

Differential Revision: https://we.phorge.it/D25760
2024-08-04 11:30:03 +02:00
Andre Klapper
62aaa0fcbe Restrict maximum task title length to 255 characters
Summary:
A task title is supposed to summarize a task. For long novels, there is the task description.

Closes T15898

Test Plan: Go to http://phorge.localhost/maniphest/task/edit/form/default/ and enter a task title with multi-byte characters above the threshold, press "Enter".

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15898

Differential Revision: https://we.phorge.it/D25759
2024-08-04 01:43:51 +02:00
Andre Klapper
d8b94dd87d Misc PHPDoc additions to PhabricatorFile
Summary: Add some PHPDoc comments to the `PhabricatorFile` class as I was playing with calling some of its methods.

Test Plan: Call those methods and see what they do and return.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25763
2024-08-03 14:19:49 +02:00
Andre Klapper
81ffe4f8b1 Fix PHP 8.1 "strlen(null)" exception in PhabricatorAuthAccountView
Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/view/PhabricatorAuthAccountView.php:66]
```

Closes T15900

Test Plan: Try to register an account via LDAP.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15900

Differential Revision: https://we.phorge.it/D25761
2024-08-02 21:26:58 +02:00
Andre Klapper
a110aa471e Suppress PHP 8.1 warnings "Return type mixed is not covariant with tentative return type mixed of method Iterator::key()"
Summary:
PHP 8.1 requires classes which implement `Iterator` to have all `Iterator` methods declared with appropriate return types or annotated with `#[\ReturnTypeWillChange]`. In my (limited) understanding we cannot declare return types while remaining backward-compatible, thus annotate.

Closes T15835

Test Plan: Run PHPStan static code analyzer, see no warnings anymore.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15835

Differential Revision: https://we.phorge.it/D25711
2024-08-02 11:44:25 +02:00
jesse
721d5ed64b fix PHP8 array_slice($results, null) which cause diffusion pattern search broken
Test Plan: check diffusion pattern search if working

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25756
2024-07-31 09:51:18 +08:00
Andre Klapper
e2919211f3 Avoid PhabricatorApplicationTransactionStructureException on editors not supporting Mute Notifications
Summary:
Do not expose the "Mute Notifications" sidebar menu entry when the underlying Editor for that object type does not support muting notifications (means: creating a transaction of type "core:edge") at all.
This avoids a disappointing `PhabricatorApplicationTransactionStructureException` after two clicks.

Disabling the menu entry while still exposing it makes no sense here as the user could never get it enabled anyway.

```
EXCEPTION: (PhabricatorApplicationTransactionStructureException) Attempting to apply a transaction (of class "PhabricatorFileTransaction", with type "core:edge") which has not been constructed correctly: Transaction has type "core:edge", but that transaction type is not supported by this editor (PhabricatorFileEditor). at [<phorge>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1830]
```

```
EXCEPTION: (PhabricatorApplicationTransactionStructureException) Attempting to apply a transaction (of class "LegalpadTransaction", with type "core:edge") which has not been constructed correctly: Transaction has type "core:edge", but that transaction type is not supported by this editor (LegalpadDocumentEditor). at [<phorge>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1830]
```

Closes T15378

Test Plan:
* Open various different object types:
** Files: http://phorge.localhost/F1 (not implemented)
** Legalpad: http://phorge.localhost/legalpad/view/1/ (not implemented)
** Maniphest: http://phorge.localhost/T1 (implemented)
* Click "Subscribe" on these various types of objects.
* Click "Mute Notifications" on these various types of objects, remember which objects throw an exception.
* Apply this patch.
* Check that "Mute Notifications" is not exposed for those types of objects that threw an exception.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15378

Differential Revision: https://we.phorge.it/D25730
2024-07-30 10:52:07 +02:00
Andre Klapper
8793bdbaa8 Disallow awarding a badge without selecting recipient
Summary:
Do not continue on missing fields (in this case: the badge recipient) in `PhabricatorBadgesEditRecipientsController`.

Closes T15827

Test Plan: See steps in T15827.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15827

Differential Revision: https://we.phorge.it/D25740
2024-07-30 10:50:28 +02:00
jesse
f75b66b27a fix PHP8 array_slice($results, null) which cause diffusion locate file broken
Test Plan: check diffusion locate file if works

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Differential Revision: https://we.phorge.it/D25750
2024-07-30 09:03:16 +08:00
Andre Klapper
59678094fb Refactor PhabricatorBadgesEditRecipientsController to remove dead code
Summary: `$form` in `$dialog = id(new AphrontDialogView())->appendForm($form)` is only defined when `if ($can_edit)` was `true` beforehand. But that was always true. Thus add a variable definition (and remove some unused variables like `$form_box`).

Test Plan:
Visit the page /badges/recipients/1/ or also directly /badges/recipients/1/add/ and add some recipients. It still works as before.

Visit the page without enough permissions. It does not allow to edit them, as before.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25744
2024-07-27 17:23:44 +02:00
Andre Klapper
7909f6a919 Fix PHP 8.1 "strlen(null)" exception on LDAP login without password
Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

Note: This patch also corrects two further `strlen()` occurrences with the same pattern.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/provider/PhabricatorLDAPAuthProvider.php:145]
```

Closes T15893

Test Plan: Create an LDAP user without setting their password; try to log into Phabricator with that user via the LDAP auth provider.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15893

Differential Revision: https://we.phorge.it/D25748
2024-07-27 06:47:21 +02:00
Andre Klapper
903015312a Remove unused parameter from PhabricatorDaemonController::buildSideNavView() call
Summary:
`Method PhabricatorDaemonController::buildSideNavView() invoked with 1 parameter, 0 required.`
Thus remove the parameter from its call in the same class.

Test Plan: Read the code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25746
2024-07-26 13:48:44 +02:00
Andre Klapper
c5c2b8ce5a Remove unused parameter from PhabricatorMailEmailEngine::newEmailThreadingHeaders() call
Summary:
`Method PhabricatorMailEmailEngine::newEmailThreadingHeaders() invoked with 1 parameter, 0 required.`
Thus remove the parameter from its call in the same class.
The called private function does `$mailer = $this->getMailer()` anyway.

Test Plan: Read the code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25747
2024-07-26 12:06:42 +02:00
Andre Klapper
4e31cadb54 Remove unused parameter from PhabricatorConfigConsoleController::newLibraryVersionTable() call
Summary:
`Method PhabricatorConfigConsoleController::newLibraryVersionTable() invoked with 1 parameter, 0 required.`
Thus remove the parameter from its only call across the codebase.

Test Plan: Read the code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25745
2024-07-26 10:24:26 +02:00
Andre Klapper
0b93685cc9 Fix undefined variable in HeraldAction
Summary: `$no_permission` is only defined within `if ($object instanceof PhabricatorPolicyInterface)`, thus move the check for `if ($no_permission)` into that clause.

Test Plan: Read the code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25741
2024-07-25 14:41:01 +02:00
Andre Klapper
a039c4952f Remove call to undefined method DoorkeeperDAO::getObjectKey()
Summary: Remove call to undefined static method `DoorKeeperDAO::getObjectKey()` in the `DoorkeeperExternalObject` class. `getObjectKey()` does not exist (and never existed) in any of its parent classes (`DoorkeeperDAO`, `PhabricatorLiskDAO`, `LiskDAO`).

Test Plan: Run static code analysis. Grep the source code and check the git history of parent classes.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25734
2024-07-22 17:28:00 +02:00
Andre Klapper
c3aa581f84 Removed unused renderStatus() from PhabricatorProjectSubprojectsController
Summary:
rPfc9db6e2a2ee929f56eb40530bb6f1fc1b75f563 introduced `private function renderStatus()`.
All calls to this method were removed in rP29cfcc82ef7f84580e798aebeb2abcb8ffec57d7.
Thus remove this unused method.

Test Plan: Read/grep the code in `PhabricatorProjectSubprojectsController`.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25717
2024-07-20 11:55:31 +02:00
Andre Klapper
03092ca422 Removed unused loadGitLocalRefs() from PhabricatorRepositoryPullEngine
Summary:
rP2b0ad243d179f81baad24ccd9748a4ba59017d25 introduced `private function loadGitLocalRefs()`.
In rPe910c76e65e54a439a0af4735ae89c70076673d5, the only call to `loadGitLocalRefs()` was removed, using `loadGitRemoteRefs()` to load (and compare) both remote and local refs. Thus remove this unused method.

Test Plan: Read/grep the code in `PhabricatorRepositoryPullEngine`.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25718
2024-07-15 08:28:20 +02:00
Andre Klapper
5a454cef8a Set ActionName to "Created" for PhabricatorTransactions::TYPE_CREATE
Summary:
Explicitly set "Created" as ActionName (to be used as a mail subject line vary prefix) when the transaction type is `PhabricatorTransactions::TYPE_CREATE` to avoid falling back to a generic "Updated" prefix.

Closes T15865

Test Plan: Either create a new task and check the mail subject line prefix (if you have a mail setup in your Phorge instance), or use the debug patch in P45 and check the order of action strengths.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15865

Differential Revision: https://we.phorge.it/D25732
2024-07-15 00:45:23 +02:00
Andre Klapper
877ac8a873 Fix property name typo in PhabricatorPDFIterator
Summary: `$framgentKey` has a typo.

Test Plan: Slowly spell the word "fragmentKey"; compare with the top of the file.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25715
2024-07-12 12:20:19 +02:00
Andre Klapper
941b769aba Declare missing class property in PhabricatorTimelineEngine
Summary: `setRequest()` and `getRequest` in this class access the undefined property `$request`. Thus define this property.

Test Plan: Run PHPStan static code analysis; grep the code in this class.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25716
2024-07-10 14:54:31 +02:00
Andre Klapper
d9592e0348 Removed unused validateNavigationMenuItem() from PhabricatorProfileMenuEngine
Summary:
The commit rP7bde92b9c9806c5967df617fb4e843dea315ecf7 (2016) introduced `private function validateNavigationMenuItem()`.
The only call to this method was removed in rP950e9d085b482bc3484e2066591ac07c20154c9a.
Thus remove this unused method.

Test Plan:
Read/grep the code in `PhabricatorProfileMenuEngine`.

Run also `grep -RF 'validateNavigationMenuItem' --include="*.php" .` to verify that this is an orphan method.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25719
2024-07-10 13:32:53 +02:00
Andre Klapper
ff7be2cf14 Fix invalid logic in PhabricatorEmailPreferencesSettingsPanel::processRequest()
Summary:
The expression `$all_tags[$tag]['count']` does not do anything. Reading the surrounding code, intention is to display a "Common" section on `/settings/panel/emailpreferences/` listing MailTags defined by at least two different applications. (This is currently not the case anyway as Phorge prefixes all MailTags with their corresponding application but might be a future use case.)
This change fixes the logic accordingly.

Closes T15874

Test Plan: Apply the patch; replace the value of a random `const MAILTAG_*` line in the codebase with the value of another random `const MAILTAG_*` line in the codebase to make it "common", now see that `/settings/panel/emailpreferences/` displays this MailTag in a "Common" section on top of the options.

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15874

Differential Revision: https://we.phorge.it/D25727
2024-07-10 08:38:33 +02:00
Andre Klapper
290883b2a9 Set specific timeline title for form creation
Summary:
The timeline for an EditEngine form says `created this object`. It should say `created this form`.

Closes T15880

Test Plan: Go to http://phorge.localhost/transactions/editengine/maniphest.task/ and create an EditEngine form, scroll down to its timeline.

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15880

Differential Revision: https://we.phorge.it/D25726
2024-07-10 08:18:37 +02:00
Andre Klapper
1b5d2f83c3 Fix property name typo in DrydockResource
Summary: `$capbilities` has a typo.

Test Plan: Slowly spell the word "capabilities"; compare with the top of the file.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25714
2024-07-07 15:52:42 +02:00
Merula Turdus
136091ecd0 Fix missing file attachment in Conpherence
Summary:
When you drag and drop a file in a Conpherence chat,
the file was only visible by the author.

Now the file is also attached to that chat, making it visible.

This is a follow-up from:

https://we.phorge.it/D25705?id=2178

Refs T15106

Test Plan:
1) open a Conpherence chat or create a new one
2) drag and drop file in it and send the message
3) verify file is attached to the chat

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15106

Differential Revision: https://we.phorge.it/D25709
2024-07-05 18:20:40 +02:00
Andre Klapper
b0bba4d142 Remove unused methods in PhabricatorEditorExtension
Summary:
The methods `newRequiredTransasctionError()` [sic!] and `newInvalidTransactionError()` are not called anywhere in the codebase. Both are `final protected`, thus remove them.

Incidentally, speedup Diviner generation by at least 0.000000000000000000000001 milliseconds.

Test Plan: Grep the code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25643
2024-07-02 17:55:25 +02:00
Andre Klapper
9a44a81e79 Remove unused save() method in PhabricatorUserCache
Summary: Seems to be unused. Plus it calls `Filesystem::digestForIndex()` which does not exist. So if this method was ever called then it would through an exception and not reach the `parent::save()` call either in the line after.

Test Plan:
Grep and read the codebase.

Tried things that may use cache and they still work, including:

- running `./bin/cache purge --caches user` successfully shows `Purging "user" cache...`
- the button "Purge cache" in /config/cache/ still work.
- editing a user
- changing user picture using default one
- uploading new user picture
- creating Calendar event and inviting yourself
- visiting user settings
- changing a user setting, including Timezone, Display preferences

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25645
2024-07-02 12:12:43 +02:00
Valerio Bozzolan
118f989366 Fix missing file attachment in Phriction
Summary:
When you drag and drop a file in the Phriction editor and then save the
corresponding wiki document, the file was only visible by the author.

Now the file is also attached to that document, making it visible.

Refs T15106

Test Plan:
1) open the Phriction editor to edit an existing or create a new wiki document
2) drag and drop file in it
3) save wiki document
4) verify file is attached to wiki document (other user can see file in wiki page)

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15106

Differential Revision: https://we.phorge.it/D25705
2024-07-01 18:41:55 +02:00
Andre Klapper
43d3fd9eac Fix exception awarding empty badge to user
Summary:
When awarding a badge to a user without having actually selected a batch to award, do not fail on running a database query with no parameter. Instead, silently fail without an error and reload the page, similar to the behavior of `Add Recipients` on `/badges/recipients/1/` in this case.
Do not throw an Aphront404Response as it would make the `Award Badge` button in the dialog inaccessible and keep the dysfunctional overlay dialog displayed.

```
EXCEPTION: (AphrontParameterQueryException) Array for %Ls conversion is empty. Query: badges.phid IN (%Ls) at [<phorge>/src/infrastructure/storage/xsprintf/qsprintf.php:383]
```

Closes T15825

Test Plan: Go to a user's badges, click the `Award Badge` button, in the dialog do not select any Badge and click the `Award` button.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15825

Differential Revision: https://we.phorge.it/D25636
2024-06-28 14:37:55 +02:00
Andre Klapper
899abf7a2b Redirect back to object after clicking "Log In to Comment" and login
Summary:
`PhabricatorApplicationTransactionCommentView` performs `$uri = id(new PhutilURI('/login/'))->replaceQueryParam('next', (string)$this->getRequestURI())` but the constructor call in `PhabricatorEditEngine` does not set any `RequestURI` so the `Log In to Comment` button at the bottom of an object view does not redirect back to the object URI after login.

Thus pass a `RequestURI` to `PhabricatorApplicationTransactionCommentView` in the constructor call in `PhabricatorEditEngine`.

Closes T15837

Test Plan: As a Phorge admin, set `policy.allow-public` to true and create a Maniphest task with `Public` view policy.  As an anonymous user, visit the task and click the `Log In to Comment` button at the bottom of the single task view, log in, and see that you get redirected to the task.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15837

Differential Revision: https://we.phorge.it/D25667
2024-06-27 10:14:43 +02:00
Andre Klapper
c769125e90 Correct rendering of workboard column move feed stories when a single transaction performs moves on multiple boards
Summary:
If a single transaction performs column moves on multiple different boards (which is permitted in the API), the rendering logic in the feed currently fails. Make it render properly.

Same fix as rPa3f4cbd7484b591425e83bbfc7642bccb04d0d57 for `getTitle()` which left out also fixing `getTitleForFeed()`.

Test Plan: Carefully read the if/else logic.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Differential Revision: https://we.phorge.it/D25646
2024-06-27 10:12:18 +02:00
Valerio Bozzolan
8825a09f67 Fix legacy crash when visiting Motivator backend as anon
Summary:
Now anonymous people can visit this page:

http://phorge.localhost/home/menu/new/custom/motivator/

And you do not see anymore this crash:

    Undefined variable $custom_phid
    phorge	applications/search/engine/PhabricatorProfileMenuEngine.php : 61	PhutilErrorHandler::handleError()
    phorge	applications/search/engine/PhabricatorProfileMenuEngine.php : 916	PhabricatorProfileMenuEngine::getEditModeCustomPHID()
    phorge	applications/search/engine/PhabricatorProfileMenuEngine.php : 269	PhabricatorProfileMenuEngine::buildItemNewContent()
    phorge	applications/home/controller/PhabricatorHomeMenuItemController.php : 39	PhabricatorProfileMenuEngine::buildResponse()
    phorge	aphront/configuration/AphrontApplicationConfiguration.php : 284	PhabricatorHomeMenuItemController::handleRequest()
    phorge	aphront/configuration/AphrontApplicationConfiguration.php : 203	AphrontApplicationConfiguration::processRequest()

Closes T15867

Test Plan:
Visit the mentioned page as logged-in. It still works.

Visit the mentioned page as logged-out. No crash anymore. You are redirected to the login page.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15867

Differential Revision: https://we.phorge.it/D25700
2024-06-26 23:22:51 +02:00
Merula Turdus
f52bc07321 Make the Remarkup Help Page Extensible
Summary:
The Remarkup Help page is currently pointing to a HTML page on we.phorge.it.
Because of this it can not be customized/extended by custom extensions.
This diff allows you to implement a `RemarkupSyntaxDocumentationProvider` interface
to your custom class, which will implement a getDocumentation method.
This getDocumentation should return the custom help text in Remarkup format.
This diff also contains some extra help for the cowsay and figlet interpreters.
The local URLs for the local references are:
* /reference/remarkup/
* /reference/cowsay/
* /reference/figlet/

Closes T15401

Test Plan: Open the Phriction wiki editor and click on the Book (Remarkup Reference) icon in the toolbar and validate URL afterwards

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15401

Differential Revision: https://we.phorge.it/D25698
2024-06-26 22:11:44 +02:00
Andre Klapper
5a9cf81ae5 Fix PHP 8.1 "strlen(null)" exceptions handling empty comment metadata in PhabricatorEditEngine
Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/transactions/editengine/PhabricatorEditEngine.php:1923]
```

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/transactions/editengine/PhabricatorEditEngine.php:2023]
```

Closes T15864

Test Plan: See steps in https://we.phorge.it/T15864

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15864

Differential Revision: https://we.phorge.it/D25699
2024-06-25 10:13:12 +02:00
Valerio Bozzolan
68762e8204 Drydock and Almanac: add welcome pages
Summary:
Premising that I still consider Almanac, Drydock and Harbormaster as dark magic, and premising that all my knowledge about these components is here:

https://en.wikibooks.org/wiki/Phabricator_Administrator%27s_Handbook/Continuous_integration

(Above guide linked from [[Community Resources]])

Hoping to be useful, I've added some welcome pages, precious to newcomers, with the goal to lower a bit the learning barrier to these tricky components.

## Drydock Blueprints

Screenshot of the new welcome page in {nav Drydock > Blueprints}:

{F2243109}

Since Drydock Blueprints are deeply dependent to {nav Almanac}, we added an extra blue button to see its homepage.

So, you are then 2-clicks away from...

## Almanac Services

Screenshot of the new welcome page in {nav Almanac > Services}:

{F2243110}

Since Almanac Services are deeply dependent to {nav Almanac > Devices}, we added an extra blue button to see them.

So, you are then 1-click away from...

## Almanac Devices

Screenshot of the new welcome page in {nav Almanac > Devices}:

{F2243112}

Since Almanac Devices are deeply dependent to {nav Almanac > Networks}, we added an extra blue button to see them.

So, you are then 1-click away from...

## Almanac Networks

Screenshot of the new welcome page in {nav Almanac Networks}:

{F2243111}

And, that's it.

## Notes

Ref T15018

----

After this change, at least 1 newcomer will love Phorge at the maximum level. and they will never again be able to use the proprietary GitHub.

bwahaha

Test Plan:
Visit all the following pages, forcing the welcome "new user interface" mode:

http://phorge.localhost/drydock/blueprint/?nux=1

http://phorge.localhost/almanac/service/?nux=1

http://phorge.localhost/almanac/device/?nux=1

http://phorge.localhost/almanac/network/?nux=1

Test all action buttons.

Write a comment with "yesyes" or "bwahaha" or "chadyes" in production too.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15018

Differential Revision: https://we.phorge.it/D25675
2024-06-25 09:37:01 +02:00
Andre Klapper
f8b8d8876d Fix call to non-existing newEmptyValue() in PhabricatorDashboardPortalProfileMenuEngine
Summary:
`PhabricatorDashboardPortalProfileMenuEngine` calls `$this->newEmptyValue()` but neither `PhabricatorDashboardPortalProfileMenuEngine` nor its parent `PhabricatorProfileMenuEngine` define a `newEmptyValue()` method.
Thus use existing `newNoContentView()` in parent `PhabricatorProfileMenuEngine` (which according to its string output is supposed to cover this case).

Test Plan:
Go to a Portal with no content. Before applying the patch, Phorge shows the message defined in the parent class `PhabricatorProfileMenuEngine`: `No Content`; `No visible menu items can render content.`
After applying this change, it correctly shows the message defined in `PhabricatorDashboardPortalProfileMenuEngine`: `No Portal Content`; `None of the visible menu items in this portal can render any content.`

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

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

Differential Revision: https://we.phorge.it/D25648
2024-06-24 08:56:02 +02:00
Andre Klapper
ed9d212013 Warn in comment field if task is closed as duplicate
Summary:
Display a placeholder text in the text comment field of a Maniphest task if the task status has been set to Duplicate.
This makes it clearer to users (who may have not checked the task status at the top of the page) not to fragment conversations.

Closes T15749

Test Plan:
* Be logged in and go to a task which is closed as a duplicate and see the placeholder text in the field to add a comment.
* Be logged in and go to tasks which are not closed as a duplicate and see no placeholder text in the field to add a comment.
* Go to other places whose code calls a `PhabricatorApplicationTransactionCommentView` constructor and check that it still renders correctly, for example Ponder in http://phorge.localhost/Q1, Slowvote in http://phorge.localhost/V1, Differential in http://phorge.localhost/D1

Reviewers: O1 Blessed Committers, valerio.bozzolan, avivey

Reviewed By: O1 Blessed Committers, valerio.bozzolan, avivey

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

Maniphest Tasks: T15749

Differential Revision: https://we.phorge.it/D25546
2024-06-23 15:29:17 +02:00
Andre Klapper
ddcdd6eaf2 Fix "Undefined offset: 1" exception in Diviner when @task value in PHPDoc is a single word
Summary:
The PHPDoc in https://we.phorge.it/source/phorge/browse/master/src/infrastructure/storage/lisk/LiskMigrationIterator.php$14 defines `* @task storage`.
That means the value of `$task` in the DivinerAtomController class is the single string `storage` and there is no whitespace to `explode` on and there is no second key in the array to set as `$title`.
Thus only call `explode` when `$task` contains a whitespace.

```
EXCEPTION: (RuntimeException) Undefined array key 1 at [<arcanist>/src/error/PhutilErrorHandler.php:273]
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/diviner/controller/DivinerAtomController.php:450]
```

Closes T15854

Test Plan: Go to https://we.phorge.it/book/contrib/article/database/#primary-keys and click the `LiskMigrationIterator` link pointing to https://we.phorge.it/book/dev/class/LiskMigrationIterator/

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

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

Maniphest Tasks: T15854

Differential Revision: https://we.phorge.it/D25690
2024-06-22 18:10:23 +02:00
Merula Turdus
1f5c54c35a Conduit API: allow phriction.edit to modify viewPolicy and editPolicy
Summary: Closes T15858

Test Plan: See T15858

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15858

Differential Revision: https://we.phorge.it/D25693
2024-06-21 18:10:30 +02:00
Andre Klapper
5d479556c3 Display same items in mobile menu on User Profile page as on desktop
Summary:
Display same items in mobile menu on User Profile page as on desktop. (The code did not make too much sense anyway here?)

Also remove special but dysfunctional "Calendar" item in mobile view: The resulting URI does not work even if the calendar application is installed. If it ever worked, it should be moved to the default desktop sidebar anyway and not be a mobile-only menu item.

Closes T15224

Test Plan: Open http://phorge.localhost/people/ and http://phorge.localhost/p/username and http://phorge.localhost/people/manage/1/, change screen width to less and more than 920px, check at menu items in left bar (>920px) and right upper corner (<920px).

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

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

Maniphest Tasks: T15224

Differential Revision: https://we.phorge.it/D25687
2024-06-18 20:00:53 +02:00