Skip to content

Commit

Permalink
Remove specific AJAX handling based on manual declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne authored and trasher committed Feb 10, 2025
1 parent 2a84937 commit d9acbd0
Show file tree
Hide file tree
Showing 54 changed files with 30 additions and 246 deletions.
6 changes: 0 additions & 6 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2305,12 +2305,6 @@
'count' => 2,
'path' => __DIR__ . '/src/Glpi/Controller/ApiController.php',
];
$ignoreErrors[] = [
'message' => '#^Method Glpi\\\\Controller\\\\LegacyFileLoadController\\:\\:getRequest\\(\\) never returns null so it can be removed from the return type\\.$#',
'identifier' => 'return.unusedType',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Controller/LegacyFileLoadController.php',
];
$ignoreErrors[] = [
'message' => '#^Expression on left side of \\?\\? is not nullable\\.$#',
'identifier' => 'nullCoalesce.expr',
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ The present file will list all changes made to the project; according to the
- Usage of the `/marketplace` path for plugins URLs. All plugins URLs should now start with `/plugins`.
- Usage of `GLPI_PLUGINS_PATH` javascript variable.
- Usage of `MAIL_SMTPSSL` and `MAIL_SMTPTLS` constants.
- `$AJAX_INCLUDE` global variable usage. Use `$this->setAjax()` in legacy `/ajax/` and `/front` scripts or `Html::setAjax()` and `Session::setAjax()`.
- Usage of `name` and `users_id_validate` parameter in `ajax/dropdownValidator.php`.
- Usage of `users_id_validate` parameter in `front/commonitilvalidation.form.php`.
- `front/ticket_ticket.form.php` script usage.
Expand Down Expand Up @@ -307,6 +306,7 @@ The present file will list all changes made to the project; according to the
- `GLPI_DEMO_MODE` constant.
- `GLPI_DUMP_DIR` constant.
- `GLPI_SQL_DEBUG` constant.
- `$AJAX_INCLUDE` global variable.
- `$CFG_GLPI_PLUGINS` global variable.
- `$DBCONNECTION_REQUIRED` and `$USEDBREPLICATE` global variables. Use `DBConnection::getReadConnection()` to get the most apporpriate connection for read only operations.
- `$dont_check_maintenance_mode` and `$skip_db_check` global variables.
Expand Down
3 changes: 0 additions & 3 deletions ajax/2fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

if (isset($_POST['regenerate_backup_codes'])) {
$totp = new \Glpi\Security\TOTPManager();
$codes = $totp->regenerateBackupCodes(Session::getLoginUserID());
Expand Down
2 changes: 0 additions & 2 deletions ajax/actorinformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/actors.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

switch ($_REQUEST['action']) {
case "getActors":
header("Content-Type: application/json; charset=UTF-8");
Expand Down
3 changes: 0 additions & 3 deletions ajax/agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
use Glpi\Exception\Http\AccessDeniedHttpException;
use Glpi\Exception\Http\NotFoundHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/asset/assetdefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
use Glpi\Exception\Http\BadRequestHttpException;
use Glpi\Exception\Http\NotFoundHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

Session::checkRight(AssetDefinition::$rightname, READ);
Session::writeClose();

Expand Down
3 changes: 0 additions & 3 deletions ajax/asset/customfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
use Glpi\Asset\CustomFieldDefinition;
use Glpi\Exception\Http\BadRequestHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

Session::checkRight(CustomFieldDefinition::$rightname, READ);

if (isset($_POST['action'])) {
Expand Down
4 changes: 0 additions & 4 deletions ajax/central.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@

use Glpi\Exception\Http\BadRequestHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */

$this->setAjax();

// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Expand Down
3 changes: 0 additions & 3 deletions ajax/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
*/
global $CFG_GLPI;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Expand Down
3 changes: 0 additions & 3 deletions ajax/common.tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
*/
global $CFG_GLPI;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/commonitilsatisfaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
use Glpi\Application\View\TemplateRenderer;
use Glpi\Exception\Http\AccessDeniedHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/displayMessageAfterRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

Html::header_nocache();

if (isset($_GET['get_raw']) && filter_var(($_GET['display_container'] ?? true), FILTER_VALIDATE_BOOLEAN)) {
Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownConnectNetworkPort.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
*/
global $DB;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownInstallVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
*/
global $DB;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownMassiveActionAddActor.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownMassiveActionAddValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
*/
global $CFG_GLPI;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownMassiveActionAuthMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownRubDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
*/
global $DB;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownSoftwareLicense.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
*/
global $DB;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/dropdownValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
*/
global $CFG_GLPI;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/entitytreesons.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
*/
global $CFG_GLPI, $GLPI_CACHE;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/fuzzysearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/genericdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Expand Down
3 changes: 0 additions & 3 deletions ajax/getDropdownUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
* @since 0.85
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/getFileTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
* @since 0.85
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header('Content-type: application/json; charset=UTF-8');
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/getUserPicture.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@

use Glpi\Exception\Http\BadRequestHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/impact.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
const DELTA_ACTION_UPDATE = 2;
const DELTA_ACTION_DELETE = 3;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

/**
* @var array $CFG_GLPI
*/
Expand Down
3 changes: 0 additions & 3 deletions ajax/itilfollowup.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

use Glpi\Exception\Http\BadRequestHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/itilvalidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

use Glpi\Exception\Http\BadRequestHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/kanban.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
use Glpi\Features\Kanban;
use Glpi\Features\Teamwork;

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/mailcollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Expand Down
3 changes: 0 additions & 3 deletions ajax/notificationmailingsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

Session::checkRight("config", UPDATE);

if (isset($_POST["test_smtp_send"])) {
Expand Down
3 changes: 0 additions & 3 deletions ajax/planningend.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Expand Down
3 changes: 0 additions & 3 deletions ajax/projecttask.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
* @since 9.2
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

header("Content-Type: application/json; charset=UTF-8");
Html::header_nocache();

Expand Down
4 changes: 0 additions & 4 deletions ajax/rack.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
use Glpi\Exception\Http\AccessDeniedHttpException;
use Glpi\Exception\Http\BadRequestHttpException;

/** @var \Glpi\Controller\LegacyFileLoadController $this */

$this->setAjax();

header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();

Expand Down
3 changes: 0 additions & 3 deletions ajax/resaperiod.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
* @since 0.84
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Expand Down
3 changes: 0 additions & 3 deletions ajax/rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
* ---------------------------------------------------------------------
*/

/** @var \Glpi\Controller\LegacyFileLoadController $this */
$this->setAjax();

switch ($_REQUEST['action']) {
case "move_rule":
$rule_collection = getItemForItemtype($_POST['collection_classname']);
Expand Down
Loading

0 comments on commit d9acbd0

Please sign in to comment.