1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-13 04:44:53 +01:00
phorge-phorge/src/applications/files/conduit
Andre Klapper 108cbcd09b Fix PHP 8.1 "base64_decode(null)" exception calling Conduit's file.upload with no data passed
Summary:
Since PHP 8.1, `base64_decode()` does not accept passing null as a parameter. Thus first check that `data !== null` before calling `decodeBase64($data)` (which then calls PHP's `base64_decode()`), and throw an exception if it is.

```
EXCEPTION: (RuntimeException) base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=18554ea76ceb), phorge(head=conduitDashboardPanelEdit, ref.master=0d81da590923, ref.conduitDashboardPanelEdit=ab4391b30465)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  #1 <#2> base64_decode(NULL, boolean) called at [<phorge>/src/applications/files/conduit/FileConduitAPIMethod.php:84]
```

Closes T15426

Test Plan: Applied this change; afterwards `/api/file.upload` under "Method Result", "error_info" shows "Unable to decode base64 data!" instead of "base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated" which is more descriptive.

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

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

Maniphest Tasks: T15426

Differential Revision: https://we.phorge.it/D25258
2023-06-11 16:34:16 +02:00
..
FileAllocateConduitAPIMethod.php Remove SHA1 file content hashing and make Files work without any hashing 2017-04-04 16:22:10 -07:00
FileConduitAPIMethod.php phtize all the things 2015-05-22 21:16:39 +10:00
FileDownloadConduitAPIMethod.php phtize all the things 2015-05-22 21:16:39 +10:00
FileInfoConduitAPIMethod.php Provide a modern ("v3") API for querying files ("file.search") 2017-04-04 16:15:36 -07:00
FileQueryChunksConduitAPIMethod.php Give Conduit params/return/errors protected visibility 2015-04-13 11:58:35 -07:00
FileUploadChunkConduitAPIMethod.php Stop trying to assess the image dimensions of large files and file chunks 2017-12-18 09:17:32 -08:00
FileUploadConduitAPIMethod.php Fix PHP 8.1 "base64_decode(null)" exception calling Conduit's file.upload with no data passed 2023-06-11 16:34:16 +02:00
FileUploadHashConduitAPIMethod.php Deprecate "file.uploadhash" 2017-04-04 16:18:26 -07:00
PhabricatorFileSearchConduitAPIMethod.php Provide a modern ("v3") API for querying files ("file.search") 2017-04-04 16:15:36 -07:00