Skip to content

Commit e4d141f

Browse files
authored
Merge branch 'develop' into fix/2071
2 parents e903d4c + 7b75e7a commit e4d141f

File tree

165 files changed

+5498
-4143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+5498
-4143
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ indent_size = 4
88
charset = utf-8
99
trim_trailing_whitespace = true
1010

11+
[.*yml]
12+
indent_size = 2
13+
1114
[*.md]
1215
trim_trailing_whitespace = false

.env.travis renamed to .env.ci

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ APP_ENV=testing
22
APP_DEBUG=true
33
APP_KEY=SomeRandomString3232RandomString
44
APP_THEME=pterodactyl
5-
APP_TIMEZONE=UTC
5+
APP_TIMEZONE=America/Los_Angeles
66
APP_URL=http://localhost/
77

88
TESTING_DB_HOST=127.0.0.1
9-
TESTING_DB_DATABASE=travis
9+
TESTING_DB_DATABASE=panel_test
1010
TESTING_DB_USERNAME=root
11-
TESTING_DB_PASSWORD=""
11+
TESTING_DB_PASSWORD=
1212

1313
CACHE_DRIVER=array
1414
SESSION_DRIVER=array

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#github: [DaneEveritt]
2+
custom: ["https://paypal.me/PterodactylSoftware"]

.github/workflows/tests.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: tests
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
integration_tests:
7+
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"
8+
runs-on: ubuntu-latest
9+
services:
10+
mysql:
11+
image: mysql:5.7
12+
env:
13+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
14+
MYSQL_DATABASE: panel_test
15+
ports:
16+
- 3306
17+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
18+
strategy:
19+
fail-fast: true
20+
matrix:
21+
php: [7.3, 7.4]
22+
name: PHP ${{ matrix.php }}
23+
steps:
24+
- name: checkout
25+
uses: actions/checkout@v2
26+
- name: get cache directory
27+
id: composer-cache
28+
run: |
29+
echo "::set-output name=dir::$(composer config cache-files-dir)"
30+
- name: cache dependencies
31+
uses: actions/cache@v2
32+
with:
33+
path: |
34+
~/.php_cs.cache
35+
${{ steps.composer-cache.outputs.dir }}
36+
key: ${{ runner.os }}-cache-${{ matrix.php }}-${{ hashFiles('**.composer.lock') }}
37+
restore-keys: |
38+
${{ runner.os }}-cache-${{ matrix.php }}-
39+
- name: setup
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: ${{ matrix.php }}
43+
extensions: cli, openssl, gd, mysql, pdo, mbstring, tokenizer, bcmath, xml, curl, zip
44+
tools: composer:v1
45+
coverage: none
46+
- name: configure
47+
run: cp .env.ci .env
48+
- name: install dependencies
49+
run: composer install --prefer-dist --no-interaction --no-progress
50+
- name: run cs-fixer
51+
run: vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format=udiff
52+
continue-on-error: true
53+
- name: execute unit tests
54+
run: vendor/bin/phpunit --bootstrap bootstrap/app.php tests/Unit
55+
if: ${{ always() }}
56+
env:
57+
DB_CONNECTION: testing
58+
TESTING_DB_HOST: UNIT_NO_DB
59+
- name: execute integration tests
60+
run: vendor/bin/phpunit tests/Integration
61+
if: ${{ always() }}
62+
env:
63+
TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }}
64+
TESTING_DB_USERNAME: root

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ coverage.xml
3232
resources/lang/locales.js
3333
resources/assets/pterodactyl/scripts/helpers/ziggy.js
3434
resources/assets/scripts/helpers/ziggy.js
35+
.phpunit.result.cache

app/Console/Commands/Migration/CleanOrphanedApiKeysCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(ApiKeyRepositoryInterface $repository)
3838
/**
3939
* Delete all orphaned API keys from the database when upgrading from 0.6 to 0.7.
4040
*
41-
* @return null|void
41+
* @return void|null
4242
*/
4343
public function handle()
4444
{

app/Contracts/Repository/SessionRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function getUserSessions(int $user): Collection;
1919
*
2020
* @param int $user
2121
* @param string $session
22-
* @return null|int
22+
* @return int|null
2323
*/
2424
public function deleteUserSession(int $user, string $session);
2525
}

app/Contracts/Repository/TaskRepositoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getTaskForJobProcess(int $id): Task;
2121
*
2222
* @param int $schedule
2323
* @param int $index
24-
* @return null|\Pterodactyl\Models\Task
24+
* @return \Pterodactyl\Models\Task|null
2525
*/
2626
public function getNextTask(int $schedule, int $index);
2727
}

app/Exceptions/Handler.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Pterodactyl\Exceptions;
44

55
use Exception;
6+
use Throwable;
67
use PDOException;
78
use Psr\Log\LoggerInterface;
89
use Swift_TransportException;
@@ -72,12 +73,12 @@ class Handler extends ExceptionHandler
7273
* services such as AWS Cloudwatch or other monitoring you can replace the
7374
* contents of this function with a call to the parent reporter.
7475
*
75-
* @param \Exception $exception
76+
* @param \Throwable $exception
7677
* @return mixed
7778
*
78-
* @throws \Exception
79+
* @throws \Throwable
7980
*/
80-
public function report(Exception $exception)
81+
public function report(Throwable $exception)
8182
{
8283
if (! config('app.exceptions.report_all', false) && $this->shouldntReport($exception)) {
8384
return null;
@@ -103,7 +104,7 @@ public function report(Exception $exception)
103104
return $logger->error($exception);
104105
}
105106

106-
private function generateCleanedExceptionStack(Exception $exception)
107+
private function generateCleanedExceptionStack(Throwable $exception)
107108
{
108109
$cleanedStack = '';
109110
foreach ($exception->getTrace() as $index => $item) {
@@ -133,12 +134,12 @@ class_basename($exception),
133134
* Render an exception into an HTTP response.
134135
*
135136
* @param \Illuminate\Http\Request $request
136-
* @param \Exception $exception
137+
* @param \Throwable $exception
137138
* @return \Symfony\Component\HttpFoundation\Response
138139
*
139-
* @throws \Exception
140+
* @throws \Throwable
140141
*/
141-
public function render($request, Exception $exception)
142+
public function render($request, Throwable $exception)
142143
{
143144
$connections = Container::getInstance()->make(Connection::class);
144145

@@ -200,11 +201,11 @@ public function invalidJson($request, ValidationException $exception)
200201
/**
201202
* Return the exception as a JSONAPI representation for use on API requests.
202203
*
203-
* @param \Exception $exception
204+
* @param \Throwable $exception
204205
* @param array $override
205206
* @return array
206207
*/
207-
public static function convertToArray(Exception $exception, array $override = []): array
208+
public static function convertToArray(Throwable $exception, array $override = []): array
208209
{
209210
$error = [
210211
'code' => class_basename($exception),
@@ -259,10 +260,10 @@ protected function unauthenticated($request, AuthenticationException $exception)
259260
* Converts an exception into an array to render in the response. Overrides
260261
* Laravel's built-in converter to output as a JSONAPI spec compliant object.
261262
*
262-
* @param \Exception $exception
263+
* @param \Throwable $exception
263264
* @return array
264265
*/
265-
protected function convertExceptionToArray(Exception $exception)
266+
protected function convertExceptionToArray(Throwable $exception)
266267
{
267268
return self::convertToArray($exception);
268269
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Pterodactyl\Exceptions\Service;
4+
5+
use Throwable;
6+
use Pterodactyl\Exceptions\DisplayException;
7+
8+
class ServiceLimitExceededException extends DisplayException
9+
{
10+
/**
11+
* Exception thrown when something goes over a defined limit, such as allocated
12+
* ports, tasks, databases, etc.
13+
*
14+
* @param string $message
15+
* @param \Throwable|null $previous
16+
*/
17+
public function __construct(string $message, Throwable $previous = null)
18+
{
19+
parent::__construct($message, $previous, self::LEVEL_WARNING);
20+
}
21+
}

0 commit comments

Comments
 (0)