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

2392 commits

Author SHA1 Message Date
Valerio Bozzolan
6142fcd526 Fix Subversion "commit" support in PHP 8.1
Summary:
Premising that "arc commit" is a beautiful Workflow dedicated to svn repositories,
I tried it at work, causing the usual PHP 8.1 deprecation warning:

    $ arc diff
    $ arc commit
    ERROR 8192: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated at [arcanist/src/workflow/ArcanistWorkflow.php:1520]
    arcanist(head=master, ref.master=e46025f7a914)
      #0 preg_replace(string, string, NULL) called at [<arcanist>/src/workflow/ArcanistWorkflow.php:1520]
      #1 ArcanistWorkflow::normalizeRevisionID(NULL) called at [<arcanist>/src/workflow/ArcanistCommitWorkflow.php:68]
      #2 ArcanistCommitWorkflow::run() called at [<arcanist>/scripts/arcanist.php:427]
    Usage Exception: Unable to identify the revision in the working copy. Use '--revision <revision_id>' to select a revision.

This bug happens at least when Arcanist does not find any related Revision ID.

It seems there is a method that always normalizes the Revision ID, but sometime that is unknown (null).
And so, NULL ends inside a preg_replace(). It's probably OK to have a normalize method that accept wild
things, including NULL. So, fixed that specific method.

Closes T15693

Test Plan:
This revision was tested in production in my company.

Take a random Subversion repository. Edit a line. Run "arc diff". Then run "arc commit". No warnings.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15693

Differential Revision: https://we.phorge.it/D25498
2023-12-18 11:37:41 +01:00
Andre Klapper
e46025f7a9 Fix PHP 8.1 "urlencode(null)" exception blocking account registration redirect for custom OAuth provider
Summary:
It seems that a `tokenSecret` is not always passed at this stage, and that PHP's `urlencode()` does not accept passing a `null` string since PHP 8.1 (I could not find any upstream note about this but bug reports across the web seem to confirm this).

Thus do not try to `urlencode($this->tokenSecret)` if it is `null`.

```
EXCEPTION: (RuntimeException) urlencode(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(), ava(), phorge(), wmf-ext-misc()
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  #1 <#2> urlencode(NULL) called at [<arcanist>/src/future/oauth/PhutilOAuth1Future.php:232]
```

Closes T15589

Test Plan:
* As an admin, set up custom "MediaWiki" OAuth provider from from https://gitlab.wikimedia.org/-/ide/project/repos/phabricator/extensions/edit/wmf/stable/-/src/oauth/
* As an admin, apply D25373
* As a user, go to `/auth/login/mediawiki:whatever/`
* Select login button

Redirect now works as expected: The URL redirect to allow access on
http://mediawiki.localhost/index.php?title=Special%3AOAuth%2Fauthorize&oauth_token=1234567890abcdef1234567890abcdef&oauth_consumer_key=1234567890abcdef1234567890abcdef works as expected, instead of showing a raw error page about `urlencode()` not accepting passing `null`. (After allowing authorization there are more issues in Phorge code but they are out of scope for this Arcanist patch.)

Reviewers: O1 Blessed Committers, valerio.bozzolan, speck

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

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

Maniphest Tasks: T15589

Differential Revision: https://we.phorge.it/D25374
2023-12-04 19:28:25 -08:00
Bartosz Dziewoński
16a412b108 Fix ArcanistExternalLinter on Windows
Summary:
When using `proc_open()` with `'bypass_shell' => true` on Windows,
file extensions other than .exe will not be resolved. Various linters
therefore don't work, such as `jshint`, which is actually `jshint.cmd`.

The problem was already observed and fixed in some places (e.g.
ArcanistGitAPI trying to run `git`), but not in ArcanistExternalLinter.

Changes:
* Fix `Filesystem::resolveBinary()` to actually only resolve executable
  files on Windows, and not any other files with no extension or with
  an extension listed in %PATHEXT%. Those files can be executed by
  typing their name in the cmd.exe shell, but not directly by low-level
  Windows functions, and we're using `'bypass_shell'` to bypass the
  shell.
* Fix `ArcanistExternalLinter::getBinary()` to call
  `Filesystem::resolveBinary()` on Windows.

Test Plan:
Run `arc lint` on the Phorge repository while on Windows.
Observe no errors related to jshint.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15544

Differential Revision: https://we.phorge.it/D25341
2023-12-04 22:44:29 +01:00
Aviv Eyal
25611ba24a PhutilErrorHandler: support multiple error listeners
Summary: Ref T15554. The plan is to add a new listener that will only listen to DEPRECATED events, and do something useful with them.

Test Plan: Test script in P26 shows registering 2 handlers and getting both invoked.

Reviewers: O1 Blessed Committers, Matthew

Reviewed By: O1 Blessed Committers, Matthew

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

Maniphest Tasks: T15554

Differential Revision: https://we.phorge.it/D25388
2023-11-27 20:32:12 +02:00
sten
5bc53cfe53 Update PhutilCowsay.php to work for small cows
Summary:
Update PhutilCowsay.php to work for small cows.

In doing so, we also simplify the code to just use multiline regexps rather than trying to parse a line at a time.

cowsay(cow='small'){{{What about me?}}}

Test Plan:
Check cowsay works for the built in non-perl cow:
```
cowsay(cow='companion'){{{Built in}}}
```

Test all the perl cows:
```
cowsay(cow='bunny'){{{Testing bunny}}}
cowsay(cow='cower'){{{Testing cower}}}
cowsay(cow='daemon'){{{Testing daemon}}}
cowsay(cow='default'){{{Testing default}}}
cowsay(cow='dragon-and-cow'){{{Testing dragon-and-cow}}}
cowsay(cow='dragon'){{{Testing dragon}}}
cowsay(cow='elephant'){{{Testing elephant}}}
cowsay(cow='eyes'){{{Testing eyes}}}
cowsay(cow='flaming-sheep'){{{Testing flaming-sheep}}}
cowsay(cow='head-in'){{{Testing head-in}}}
cowsay(cow='kitty'){{{Testing kitty}}}
cowsay(cow='koala'){{{Testing koala}}}
cowsay(cow='meow'){{{Testing meow}}}
cowsay(cow='moofasa'){{{Testing moofasa}}}
cowsay(cow='moose'){{{Testing moose}}}
cowsay(cow='mutilated'){{{Testing mutilated}}}
cowsay(cow='satanic'){{{Testing satanic}}}
cowsay(cow='sheep'){{{Testing sheep}}}
cowsay(cow='skeleton'){{{Testing skeleton}}}
cowsay(cow='small'){{{Testing small}}}
cowsay(cow='squirrel'){{{Testing squirrel}}}
cowsay(cow='stegosaurus'){{{Testing stegosaurus}}}
cowsay(cow='supermilker'){{{Testing supermilker}}}
cowsay(cow='surgery'){{{Testing surgery}}}
cowsay(cow='turkey'){{{Testing turkey}}}
cowsay(cow='turtle'){{{Testing turtle}}}
cowsay(cow='tux'){{{Testing tux}}}
cowsay(cow='www'){{{Testing www}}}
```

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/D25436
2023-11-14 15:05:33 +00:00
Aviv Eyal
98d16d27cf only update cache file if something changed
Summary:
See Q77. When installing in a read-only location, updating the file is both redundant (nothing changed) and fails.

Make sure to only save the updated file if anything changed.

Test Plan: Run `arc lint` somewhere, make `.phutil_module_cache` and `src/` read-only, run `arc lint` again - it should avoid crashing.

Reviewers: fgaz, O1 Blessed Committers, valerio.bozzolan

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

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25446
2023-10-12 19:21:56 +03:00
sten
ba42b63704 Update ArcanistComposerLinter.php to check content-hash instead of hash
Summary:
The 'hash' key in composer.json files was removed by composer version 1.3.0 in December 2016, in favour of the 'content-hash' key.

Update the code to validate the content-hash instead.

Fixes T15647

Test Plan:
* Update a composer.json file, without running 'composer update'
* Run 'arc lint' and confirm it warns you that the composer.lock file is out of date
* Run 'composer update'
* Run 'arc lint' and confirm it returns OKAY

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15647

Differential Revision: https://we.phorge.it/D25442
2023-09-28 09:12:29 +01:00
sten
35e127da57 Fix rendering of cowsay sheep.cow
Summary:
In the templates of the external cowsay library, most replaceable tokens are specified as $var_name.
However, the sheep.cow and flaming-sheep.cow use the ${eyes} syntax instead. This is not recognised by PhutilCowsay.php resulting in incorrect rendering of the template.

This change updates PhutilCowsay.php to handle ${var_name} tokens as well as $var_name

cowsay(cow='sheep'){{{My eyes, my eyes!}}}

Test Plan:
In a Remarkup comment or document, add
```
cowsay(cow='sheep'){{{How do my eyes look now?}}}
```

When testing in differential, you don't even need to submit the comment.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Differential Revision: https://we.phorge.it/D25435
2023-09-12 15:57:15 +01:00
Aviv Eyal
d343be5926 Error handling: send Deprecation messages as explicit Event
Summary:
Ref T15554. When a deprecation warning is captured here, mark it as such and send using the same channel as error messages.
Error Handlers will generally ignore it now, so they'll need to be updated, e.g. D25386

Test Plan:
Hitting a `strlen(null)` before This Change:

- Web:
    - PhutilAggregateException - white boxes with red border.
- Daemons:
    - trace in daemon log, task fails. Daemon sleeps for 5 seconds.
- Arcanist and Scripts in phorge/bin/ and phorge/scripts:
    - execution blows up with error trace.
- SSH server-side scripts (ssh-auth and ssh-exec):
    - trace in configured log, execution fails
- SSH client-side scripts (ssh-connect):
    - execution blows up with error trace.

After this change:

- Web:
    - Before `D25386`: Nothing on screen, errors show in log.
    - With `D25386`: logs + dark console.
- Daemons:
    - trace in daemon log, task completes successfully.
- Arcanist and Scripts in phorge/bin/ and phorge/scripts/ :
    - Error trace printed to STDERR, execution continues.
- SSH server-side scripts (ssh-auth and ssh-exec):
    - trace in configured log, execution continues.
- SSH client-side scripts (ssh-connect):
    - Error trace printed to STDERR, execution continues.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15554

Differential Revision: https://we.phorge.it/D25387
2023-08-31 08:14:16 -07:00
sten
8b907d7716 Fix PHP 8.1 arc patch strlen(null) binary file error
Summary:
Fix issue in arcanist whereby when doing an arc patch involving adding or removing a binary file, it falls over with strlen(null) errors.

Fixes T15617

Test Plan: arc patch Dxxxx

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15617

Differential Revision: https://we.phorge.it/D25409
2023-08-18 14:57:54 +01:00
bob
df6c315ace Fix a PHP 8.1/8.2 deprecated use of strlen deprecated call with a NULL argument
Summary:
This strlen call triggering an exception if an user tried to call the patch command without an authentication token
Indeed, strlen() was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1, we use phutil_nonempty_string() as a replacement.

Fix T15599

Test Plan:
Remove your arcanist authentication token file (if you have one) and try to call the patch command in a repository.
You should get an error message suggesting you to call the install-certificate command instead of an exception.

Reviewers: O1 Blessed Committers, Matthew

Reviewed By: O1 Blessed Committers, Matthew

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

Maniphest Tasks: T15599

Differential Revision: https://we.phorge.it/D25383
2023-08-14 10:58:01 +02:00
Aviv Eyal
6832afc300 Fix jshint tests
Summary:
The linter's behavior was changed in https://github.com/jshint/jshint/issues/3444: "warnings" are no longer counted for `maxerr`.

Updating the test to match...

Test Plan: `arc unit src/lint/linter/__tests__/ArcanistJSHintLinterTestCase.php` with a recent-ish (2.13.6) jshint.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Differential Revision: https://we.phorge.it/D25355
2023-08-12 08:43:46 -07:00
Aviv Eyal
726b148afc Rebrand: Add "path" entries to PlatformSymbols
Summary: Ref T15006. Required for D25343

Test Plan: See D25343.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15006

Differential Revision: https://we.phorge.it/D25349
2023-08-12 08:41:53 -07:00
Andre Klapper
788098096e Fix PHP 8.0 ValueError calling mb_convert_encoding() with an invalid encoding
Summary:
Per https://www.php.net/manual/en/function.mb-convert-encoding.php, as of PHP 8.0.0, a ValueError is thrown if the value of `to_encoding` or `from_encoding` is an invalid encoding but a ValueError is not suppressed by the stfu operator ("@").

Origin of the function:

https://secure.phabricator.com/rPHU72ad8fd0f05b0d84f7d8efd7db62ad0b3ba4431f

Premising that Arcanist elevates warnings to exception, now we just try-catch.

Closes T15423

Test Plan:
On `/diffusion/edit/1/page/encoding/`,
* enter a valid encoding, such as "7bit", successfully changed encoding
* enter a valid encoding with random capitalization, such as "7biT", successfully changed encoding
* enter a valid alias encoding, such as "ISO-10646-UCS-2", successfully changed encoding
* enter a valid alias encoding with random capitalization, such as "isO-10646-uCS-2", successfully changed encoding
* enter an invalid encoding, such as "whatever", get error message "Repository encoding "whatever" is not valid: String conversion from encoding 'UTF-8' to encoding 'whatever' failed: mb_convert_encoding(): Argument #2 ($to_encoding) must be a valid encoding, "whatever" given"
In any case, no exception is shown anymore.

Reviewers: O1 Blessed Committers, valerio.bozzolan, speck

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

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

Maniphest Tasks: T15423

Differential Revision: https://we.phorge.it/D25249
2023-07-29 12:20:40 +03:00
Aviv Eyal
6c6f47bf9c (arc) Unify type-checking for setHref() type methods
Summary:
Introduce `PhutilURI::checkHrefType` to unify type-check of some PHUI objects (See D25357).

Ref T15316

Test Plan:
Run this script:

```
#!/usr/bin/env php
<?php

require_once './arcanist/scripts/__init_script__.php';

$valid_inputs = array(
  'foo',
  null,
  new PhutilURI('http://0@domain.com/'),
);

$invalid_inputs = array(
  9,
  new Filesystem(),
  array(),
);

echo "Valid inputs: \n";
foreach ($valid_inputs as $v) {
  echo("Checking ".gettype($v)." \n");
  PhutilURI::checkHrefType($v);
}

echo "\nError inputs: \n";
foreach ($invalid_inputs as $v) {
  echo("Checking ".gettype($v)." \n");
  PhutilURI::checkHrefType($v);
}

echo "\n";
```

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15316

Differential Revision: https://we.phorge.it/D25356
2023-07-24 12:33:47 -07:00
Aviv Eyal
8a2cb75d63 Fix tab complete in php 8
Summary: Ref T15064

Test Plan: run `arc shell-complete`; `arc shell-complete arc shell`; Should suggest completions, not crash.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15064

Differential Revision: https://we.phorge.it/D25350
2023-07-21 09:45:55 -07:00
Valerio Bozzolan
b996b4799b phutil_nonempty_scalar(): don't throw when receiving a boolean scalar
Summary:
Note that booleans are scalars. Full stop.

| is_scalar($v)    | Result |
|------------------|--------|
| `"foo"`          | true   |
| `""`             | true   |
| `null`           | true   |
| `0`              | true   |
| `0.5`            | true   |
| `true`           | true   |
| `false`          | true   |
| `new stdclass()` | false  |
| `array()`        | false  |

Note that phutil_nonempty_scalar() was designed just to tell
whenever a scalar is "empty" or not. So it must not explode
when receiving a valid scalar.

So the question is not whenever a boolean is a scalar or not,
but whenever is empty or not. But also this is a clear fact:

| `$v`    | `is_scalar($v)` | `!is_empty($v)` | `if(strlen($v))`|
|---------|-----------------|-----------------|-----------------|
| `true`  | `true`          | `true`          | `true`          |
| `false` | `true`          | `false`         | `false`         |

In short, now the function does not explode anymore with bool
values. Instead, it says whenever are empty or not.

In bold the exact changes:

| Value             |`phutil_nonempty_scalar($v)`|
|-------------------|----------------------------|
| `"foo"`           | true                       |
| `""`              | false                      |
| `null`            | false                      |
| `0`               | true                       |
| `0.5`             | true                       |
|`obj` with tostring| true                       |
|`obj` withno tostr.| Exception                  |
| `array()`         | Exception                  |
| `true`            | ~~Exception~~ **true**     |
| `false`           | ~~Exception~~ **false**    |

Closes T15239

Test Plan:
- check if it makes sense to you
- check the few usages

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15239

Differential Revision: https://we.phorge.it/D25117
2023-07-18 12:41:43 +02:00
Aviv Eyal
6e4947b55f Improve arc-browse for php 8.1
Summary: Ref T15064.

Test Plan: ran some `arc browse` commands in php 8.1, got no exceptions.

Reviewers: O1 Blessed Committers, valerio.bozzolan, Sten

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

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

Maniphest Tasks: T15064

Differential Revision: https://we.phorge.it/D25339
2023-07-07 09:16:59 -07:00
Aviv Eyal
152ba1f02a Add explicit tests for phutil_string_cast
Summary: Test (and document) what phutil_string_cast actually does to some things.

Test Plan: `arc unit`

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

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

Differential Revision: https://we.phorge.it/D25326
2023-07-03 13:43:07 -07:00
Aviv Eyal
8426ebc053 Fix arc browse for php 8.x
Summary: Ref T15064

Test Plan: Run `arc browse <filename>`, get a browser and no exception.

Reviewers: O1 Blessed Committers, valerio.bozzolan, chris

Reviewed By: O1 Blessed Committers, chris

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15064

Differential Revision: https://we.phorge.it/D25309
2023-06-26 12:18:07 -07:00
Steve Campbell
8130241a11 Add resources/ssl/custom.pem to .gitignore
Summary:
When arcanist connects to a phorge site which uses an SSL certificate signed by a local CA, then the client needs to have a resources/ssl/custom.pem file as per resources/ssl/README

As this is client specific it should be in the .gitignore file.

Also update resources/ssl/README to replace [Pp]habricator with [Pp]horge.

Test Plan:
```
touch resources/ssl/custom.pem
git status
```
The 'git status' should show no changes.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Differential Revision: https://we.phorge.it/D25304
2023-06-21 19:56:55 +01:00
Steve Campbell
677e117b97 Fix strlen() being passed a null in ArcanistUnitConsoleRenderer.php
Summary:
Fix the following error in ArcanistUnitConsoleRenderer.php under PHP 8.1:

```
strlen(): Passing null to parameter #1 ($string) of type string is deprecated
```

Stack trace:

```
EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=97e163187418, custom=4)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/unit/renderer/ArcanistUnitConsoleRenderer.php:15]
  #1 ArcanistUnitConsoleRenderer::renderUnitResult(ArcanistUnitTestResult) called at [<arcanist>/src/workflow/ArcanistUnitWorkflow.php:190]
  #2 ArcanistUnitWorkflow::run() called at [<arcanist>/scripts/arcanist.php:427]
```

Ref T15187

Test Plan: arc unit

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15187

Differential Revision: https://we.phorge.it/D25300
2023-06-19 14:55:49 +01:00
Andre Klapper
97e1631874 Fix PHP 8.1 "strlen(null)" exception which blocks creating a project with an empty Description field
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_stringlike()` as a replacement for string-alike variables.

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

Closes first half of T15331

Test Plan: Applied these two changes (one in Arcanist, one in Phorge). Project with empty Description field was created and `/project/view/projectid/` rendered in web browser.

Reviewers: O1 Blessed Committers, valerio.bozzolan, speck

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

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

Maniphest Tasks: T15331

Differential Revision: https://we.phorge.it/D25176
2023-06-10 16:35:18 +02:00
Andre Klapper
b325304b6e Fix PHP 8.1 null exceptions which block rendering tab panels on dashboards
Summary:
Passing null as input strings to `substr()` and `preg_match()` is deprecated in PHP 8.
Thus do not call `substr()` when input is `null` and pass an empty string instead of `null` to `preg_match()`. (Not calling `preg_match()` at all here would lead to `Exception: Lexical error on line 1. Unrecognized text. ^`).

Closes T15346

Test Plan: After applying these three changes and following the steps in T15346, tab on the dashboard displays "This tab panel does not have any tabs yet." as expected instead of the previous RuntimeException.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15346

Differential Revision: https://we.phorge.it/D25250
2023-06-02 18:30:58 +02:00
Valerio Bozzolan
8eda766990 Update the extracted cURL SSL CA bundle
Summary: Updated the default CA bundle file to the 2022-07-19 file from https://curl.se/ca/cacert-2022-07-19.pem

Test Plan:
Confirmed the hash matches the published hash:

```
$ openssl dgst -sha256 resources/ssl/default.pem
SHA256(resources/ssl/default.pem)= 6ed95025fba2aef0ce7b647607225745624497f876d74ef6ec22b26e73e9de77
```

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Tags: #arcanist_archived

Differential Revision: https://we.phorge.it/D25049
2023-06-02 17:06:13 +02:00
Valerio Bozzolan
444bb60d43 Fix PHP 8.1 "strlen(null)" exception from ArcanistRefView which blocks "arc look remotes"
Summary:
This change fixes the command `arc look remotes` for PHP 8.1.

Without this change, the null value bubbles up to PhutilUTF8StringTruncator, reaching a strlen().

This control probably does not need to be done at this low level inside PhutilUTF8StringTruncator,
but it is right to be at this high level from the caller in ArcanistRefView.

Closes T15368

Test Plan:
- run "arc look remotes"
- still works in "old PHP" like 7.4
- start to work in recent PHP 8.1+

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15368

Differential Revision: https://we.phorge.it/D25206
2023-06-01 18:20:24 +02:00
Andre Klapper
18554ea76c Correct spelling mistake in PhutilLock
Summary: Closes T15268

Test Plan: Only changes to spelling.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15268

Differential Revision: https://we.phorge.it/D25253
2023-05-29 10:29:05 +02:00
jkim
0e32dbc1ac Correct a PHP8 compatibility issue when running "arc diff" with no active branch
Summary:
When there is no active branch name, arc diff currently fails under PHP8 when we try to strlen(null).

This change is also credited to Evan from upstream Phabricator that applied the same change:

https://secure.phabricator.com/rARCc39ab20eb3717a15aed2467842bd77d9addce96a

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.

Closes T15412

Test Plan: Under PHP 8.1: ran git checkout <hash of head>, then arc diff to generate this revision.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15412

Differential Revision: https://we.phorge.it/D25237
2023-05-24 20:06:26 +01:00
Andre Klapper
e4fd31ec02 Fix PHP 8.1 exception in Conduit: Make "array_fuse(array $list)" accept null as parameter
Summary:
`array_fuse` in Arcanist is a wrapper for calling `array_combine($list, $list)`.
The latter doesn't accept passing `null` in PHP 8.2.
Going to `/conduit/method/project.create/`, entering a `name` but nothing as `members` (so we pass `null`), and calling this method, an exception is thrown.

Thus make `array_fuse` accept null and return an empty list in such cases.

Closes T15393

Test Plan: Applied this change; afterwards "Method Call Result" page at `/api/project.create`  correctly displayed in the web browser.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15393

Differential Revision: https://we.phorge.it/D25228
2023-05-21 00:07:13 +02:00
Christopher Speck
5cdafa4002 Update the arc-hg.py extension to work with mercurial 6.4
Summary:
Mercurial 6.4 was recently released and showing up in package managers. With
the update to 6.4 using `arc land` would result in an exception indicating that
`expandpath` function does not exist.

The `ui.expandpath` function was deprecated in 5.8 and now removed in 6.4. The
functionality has been moved to `utils.urlutil.get_` functions (they are split
between getting pull, push, and clone paths).

This updates the script to try `utils.urlutil.get_clone_path` function if the
`ui.expandpath` function is not present.

Imported from:

https://secure.phabricator.com/rARC0fc22183e796fb8ac2e3a0a3f3f37aa964c6d7fa

Test Plan:
I updated my latest mercurial install to 6.4 and verified with `hg --version`.

I created a diff in a mercurial repo and used `arc land` to successfully land
the revision without any exceptions.

Closes T15288

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15288

Differential Revision: https://we.phorge.it/D25143
2023-05-17 20:44:37 -04:00
Valerio Bozzolan
c14785c379 Fix PHP 8.1 "strpos(null)" exception from PhutilCommandString which blocks arc patch
Summary:
For some reason it may happen that a specific command line argument receives a null argument
from PHP, instead of just an empty string.

Nowadays, this null value probably breaks almost whatever GNU/Linux or FreeBSD or Microsoft Windows
etc. implementations since everyone expect to receive a string.

This used to work in the past since functions like strpos() or strlen() accepted null, but not
anymore. This generate a deprecation warning since PHP 8.1, that is elevated as exception from
Phabricator/Phorge and breaking features.

Without getting into implementation logics (which doesn't make sense to fix all of them) the
calling function should just be kind. So we normalize nonsense null values to an empty string.

Note: this was the expected behavior prior to PHP 8.1.

Now we do that normalization explicitly, in this early point.

After this fix, also T15368 should probably be fixed.

Closes T15367

Test Plan:
- run "arc patch <something valid>"
- to you it must continue to work
- (to @ton it starts working right now)

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: speck, tobiaswiese, Matthew, Cigaryno, ton

Maniphest Tasks: T15367

Differential Revision: https://we.phorge.it/D25205
2023-05-09 08:29:00 +02:00
Andre Klapper
d472896226 Fix PHP 8.1 "rawurlencode(null)" exception which blocks rendering a project page
Summary:
After PHP 8.1 the function `rawurlencode()` does not accept anymore the `null` value.

Thus return an empty string when the input parameter is null instead of passing the input parameter to `rawurlencode()`.

Closes T15263

Test Plan:
Applied this change on top of D25144, D25145, D25146, D25147, D25151,
D25152, D25153 and D25163 and already existing Workboard located at
`/project/view/1/` finally rendered in web browser.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15263

Differential Revision: https://we.phorge.it/D25164
2023-05-04 13:14:24 +02:00
Andre Klapper
f7d5614ca1 Do not pass a null string to mb_convert_case() for PHP 8.1 compatibility
Summary:
Passing `null` to the `$string` parameter of `mb_convert_case()` is deprecated in PHP 8.1.
This is one of the exceptions which block rendering the "Browse Projects" overlay dialog.

Closes part of T15335

Test Plan: Applied this change in Arcanist (plus the four changes in D25179 in Phorge) and the `Browse Projects` overlay dialog finally rendered in web browser and listed existing projects.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15335

Differential Revision: https://we.phorge.it/D25180
2023-05-04 12:39:17 +02:00
Andre Klapper
084303cd5f Fix PHP 8.1 "preg_match()" exception when pasting malformed Raw Diff into "Create Diff"
Summary:
Entering a malformed string (like `"pHoRgE rOcKs!!"`) into the "Raw Diff" field, Arcanist's `tryMatchHeader()` function is first called in `$ok = $this->tryMatchHeader($patterns, $line, $match)` with a non-null `$line` value (the first line entered in the "Raw Diff" field) being passed.

Afterwards, `tryMatchHeader()` is called for a second time after assigning `$line = $this->nextLineThatLooksLikeDiffStart()`.
This time `$line` is null and a RuntimeException is thrown, as `tryMatchHeader()` calls `preg_match()` which does not accept passing null as the $subject string parameter in PHP 8.1.

Thus add a `phutil_nonempty_string()` check if the `$subject` parameter (in this case, `$line`) is a non-empty string.

Arcanist's `tryMatchHeader()` function is not called outside of the file in which it is defined.
Thus catch the exception in the second call to `tryMatchHeader()` and not in the code of the `tryMatchHeader()` function itself.

Closes T15338

Test Plan: After adding the additional check, `/differential/diff/create/` showed the expected `Diff Parse Exception` instead.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15338

Differential Revision: https://we.phorge.it/D25183
2023-05-04 10:56:23 +02:00
Chris Novakovic
12484acfc8 Handle ERR-INVALID-AUTH responses from Conduit in patch workflow
Summary:
Conduit responds to requests with either `ERR-INVALID-SESSION` or `ERR-INVALID-AUTH` if the request wasn't sufficiently authenticated. Arcanist's `patch` workflow can automatically attempt to recover from situations in which Conduit responds to unauthenticated requests with `ERR-INVALID-SESSION` (by resending an authenticated version of the request), but not `ERR-INVALID-AUTH` - recover from `ERR-INVALID-AUTH` in the same way.

Closes T15333

Test Plan: The company I work for has been running a local clone of Arcanist containing this change in production for over 18 months now with no problems.

Reviewers: #blessed_committers, O1 Blessed Committers, valerio.bozzolan, avivey

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

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

Maniphest Tasks: T15333

Differential Revision: https://we.phorge.it/D25178
2023-05-03 14:48:55 +01:00
Andre Klapper
82d1abd4ed Fix PHP 8.1 "strlen(null)" exception in PhutilOpaqueEnvelope.php
Summary:
This change fixes a RuntimeException for passing null to strlen() when setting up the DB host parameter

Closes T15260

Test Plan: I was able to run "./bin/config set mysql.host "localhost"" successfully

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Maniphest Tasks: T15260

Differential Revision: https://we.phorge.it/D25129
2023-04-25 15:40:02 +02:00
rgodden
ca5f5cd152 Fix idx default empty string in ArcanistWorkflow
Summary:
Another fix for PHP 8.1 deprecations.

Closes T15259
Ref T15190

Test Plan: Run arc patch with certificate uninstalled

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15259, T15190

Differential Revision: https://we.phorge.it/D25128
2023-04-20 11:17:58 +01:00
rgodden
75af13abe9 Fix early exit from getMatchSeverity on null severity
Summary:
In PHP 8.1, the strtolower() function no longer accepts NULL.

Without this change, getMatchSeverity() exits early if there is no severity found.

Closes T15257
Ref T15190

Test Plan: I ran this with an arc linter on a private repository which doesn't have a regex to match severity

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15257, T15190

Differential Revision: https://we.phorge.it/D25126
2023-04-19 17:21:07 +01:00
Valerio Bozzolan
f4a639944d Fix a PHP 8.1 issue related to preg_match() and null subject
Summary:
This change fixes 'arc patch' in some circumstances.

Closes T15254

Test Plan: I was able to run "arc patch D25111" without issues

Reviewers: O1 Blessed Committers, Matthew

Reviewed By: O1 Blessed Committers, Matthew

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15187, T15254

Differential Revision: https://we.phorge.it/D25123
2023-04-14 22:13:04 +02:00
Valerio Bozzolan
08dfffd5ca Replace function utf8_decode() - deprecated since PHP 8.2
Summary:
The function utf8_decode() was a shortcut to convert strings
encoded from UTF-8 to ISO-8859-1 ("Latin 1").

This function was deprecated since PHP 8.2 and will be dropped
in PHP 9:

https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode

As mentioned in the RFC, if a $string is a valid UTF-8 string,
so this could be used to count the number of code points:

    strlen(utf8_decode($string))

It works because any unmappable code point is replaced with the
single byte '?' in the output. But, the correct native approach
should be this one:

    mb_strlen($string, 'UTF-8');

Also, another good approach is this one:

    iconv_strlen($string, 'UTF-8')

Note that mb_strlen() was introduced in PHP 4, so, there
are no compatibility issues in using that.

Note that the mbstring extension is already required in the installation
documentation, so this should not change anything for any person.

https://we.phorge.it/T15188

https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode

https://www.php.net/manual/en/function.utf8-decode

https://www.php.net/manual/en/function.mb-convert-encoding.php

https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#utf8decodeencodetombconvertencodingrector

Closes T15188

Test Plan:
- I was able to execute "arc lint" from PHP 8.2
- I was able to execute this "arc diff" from PHP 8.2
- With this patch you can still run "arc lint" with your local version

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15188

Differential Revision: https://we.phorge.it/D25092
2023-03-25 11:57:32 +01:00
k__nard
9e1bb955fa updating twitch to latest api (Helix)
Summary:
api doc : https://dev.twitch.tv/docs/api/reference
oauth2 doc : https://dev.twitch.tv/docs/authentication

Test Plan: I have successfully setup OAuth2 authentication against Twitch

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

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

Tags: #auth

Maniphest Tasks: T15122

Differential Revision: https://we.phorge.it/D25056
2022-12-08 15:39:25 -07:00
Aviv Eyal
0c0b9644a6 Rebrand: Change Server name
Summary:
Use the name "Phorge" as the defined platform.

Also prepare to rename the core library "phorge" rather then "phabricator" - see next diff.

T15006

Test Plan: Deployed change, tooltip for "Config" shows "Configure Phorge"

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew

Maniphest Tasks: T15006

Differential Revision: https://we.phorge.it/D25046
2022-08-25 01:24:41 -07:00
Aviv Eyal
9b4bcc8349 Merge Phacility/master into phorge 2022-07-25 11:39:47 -07:00
epriestley
85c953ebe4 Fix a PHP 8.1 repository marker issue in Mercurial
Summary:
Ref T13588. "arc-ls-markers" emits a "branch-state" marker so callers can identify which branch is active in the working copy.

This marker doesn't have an associated commit, so trying to generate a display name fails under stricter PHP 8.1 rules when we try to `substr(null, ...)`.

Don't attempt to generate a display name for markers with no commit hash.

Test Plan:
  - Ran `arc branches` under PHP 8.1 in a Mercurial repository.
  - Before: fatal.
  - After: sensible output.

Maniphest Tasks: T13588

Differential Revision: https://secure.phabricator.com/D21825
2022-05-17 16:20:14 -07:00
epriestley
942b54a697 Straggling fixes for PhutilURI under PHP 8.1
Summary: Ref T13588. Additional PhutilURI fixes for PHP 8.1.

Test Plan: Ran "arc unit --everything" in Phabricator.

Maniphest Tasks: T13588

Differential Revision: https://secure.phabricator.com/D21822
2022-05-17 16:08:48 -07:00
epriestley
3cc486d5c1 Add "pht_list()", a translation wrapper for lists of items
Summary: Ref T13603. This is just a small piece of cleanup I've wanted to do for a while: different languages might have different list separators and repeating this implosion manually all over the place is a bit ugly even if the beahvior is never a function of translation language.

Test Plan: See next change.

Maniphest Tasks: T13603

Differential Revision: https://secure.phabricator.com/D21814
2022-05-12 10:57:39 -07:00
epriestley
fc5b228db5 Return STDIN, STDOUT, and STDERR file descriptors from parent process
Summary:
Ref T13675. When a process daemonizes, it needs to close these actual file descriptors, so the calling context must provide them.

Elsewhere, modify the embedded "arc" to provide them. Then use them in place of reopening the streams.

Test Plan: Ran locally with embedded "arc", will deploy for production hangs.

Maniphest Tasks: T13675

Differential Revision: https://secure.phabricator.com/D21804
2022-05-05 10:27:22 -07:00
epriestley
2969f24961 Add an ArgumentParser helper for integers
Summary:
Ref T13676. With increased PHP8.1 strictness around null, it seems reasonable to add some convenience parsing to "PhutilArgumentParser".

Add a helper function for parsing integers.

Test Plan:
See next change. Tried these arguments:

```
--count ''
--count asdf
--count 0
--count -3
--count 999999999999999999999999999999999999999999999234
--count 5
```

Got sensible parsing and appropriate feedback in all cases.

Maniphest Tasks: T13676

Differential Revision: https://secure.phabricator.com/D21799
2022-05-03 15:57:06 -07:00
epriestley
e5b92735c6 Fix more PHP 8.1 "strlen(null)" callsites in PhutilURI
Summary: Ref T13676. Ref T13588. These properties on PhutilURI have flexible types, just wrap them.

Test Plan: Built a new Drydock working copy with an HTTPS URI under PHP 8.1, see T13676.

Maniphest Tasks: T13676, T13588

Differential Revision: https://secure.phabricator.com/D21798
2022-05-03 13:42:02 -07:00
epriestley
8d487ed770 Mostly remove "STDERR" and "STDOUT" constants from Arcanist
Summary:
Ref T13675. Ref T13556. The "STDOUT" and "STDERR" constants are defined by the PHP CLI SAPI, in `cli_register_file_handles()`.

The "native arc" embedded PHP wrapper doesn't define these, and there's no real reason to define them, since they're just defined in terms of the PHP stream wrappers ("php://stdin", etc) anyway.

This patch isn't exhaustive (and a subsequent change should add lint, rejecting these magic constants) but is just trying to make native `arc` functional.

Test Plan: Created this revision with a standalone native `arc` binary.

Subscribers: cspeckmim

Maniphest Tasks: T13675, T13556

Differential Revision: https://secure.phabricator.com/D21794
2022-05-03 11:58:45 -07:00