-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate cronjob log clear to modern code
- Loading branch information
Showing
7 changed files
with
95 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Deletes all entries of the cronjob log. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.2 | ||
* @woltlabExcludeBundle tiny | ||
*/ | ||
|
||
import { prepareRequest } from "WoltLabSuite/Core/Ajax/Backend"; | ||
import { ApiResult, apiResultFromError, apiResultFromValue } from "../../Result"; | ||
|
||
export async function clearLogs(): Promise<ApiResult<[]>> { | ||
try { | ||
await prepareRequest(`${window.WSC_RPC_API_URL}core/cronjobs/logs`).delete().fetchAsJson(); | ||
} catch (e) { | ||
return apiResultFromError(e); | ||
} | ||
|
||
return apiResultFromValue([]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
wcfsetup/install/files/js/WoltLabSuite/Core/Api/Cronjobs/Logs/ClearLogs.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/logs/ClearLogs.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace wcf\system\endpoint\controller\core\cronjobs\logs; | ||
|
||
use Laminas\Diactoros\Response\JsonResponse; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use wcf\data\cronjob\log\CronjobLogEditor; | ||
use wcf\system\endpoint\DeleteRequest; | ||
use wcf\system\endpoint\IController; | ||
use wcf\system\WCF; | ||
|
||
/** | ||
* API endpoint for the deletion of all entries of the cronjob log. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.2 | ||
*/ | ||
#[DeleteRequest('/core/cronjobs/logs')] | ||
final class ClearLogs implements IController | ||
{ | ||
#[\Override] | ||
public function __invoke(ServerRequestInterface $request, array $variables): ResponseInterface | ||
{ | ||
WCF::getSession()->checkPermissions(['admin.management.canManageCronjob']); | ||
|
||
CronjobLogEditor::clearLogs(); | ||
|
||
return new JsonResponse([]); | ||
} | ||
} |