You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/upgradeguides/glpi-11.0.rst
+73-3Lines changed: 73 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -74,13 +74,83 @@ If you were using the second syntax, you will need to replace as follows:
74
74
75
75
Using raw SQL queries must be replaced with query builder call, among other to prevent syntax issues, and SQL injections; please refer to :doc:devapi/database/dbiterator.
76
76
77
-
Changes related to URLs routing
78
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77
+
Changes related to web requests handling
78
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79
+
80
+
In GLPI 11.0, all the web requests are now handled by a unique entry point, the ``/public/index.php`` script.
81
+
This allowed us to centralize a large number of things, including GLPI's initialization mechanics and error management.
82
+
83
+
Removal of the ``/inc/includes.php`` script
84
+
+++++++++++++++++++++++++++++++++++++++++++
85
+
86
+
All the logic that was executed by the inclusion of the ``/inc/includes.php`` script is now made automatically.
87
+
Therefore, it is no longer necessary to include it, even if it is still present to ease the migration to GLPI 11.0.
88
+
89
+
.. code-block:: diff
90
+
91
+
- include("../../../inc/includes.php");
92
+
93
+
Legacy scripts access policy
94
+
++++++++++++++++++++++++++++
95
+
96
+
By default, the access to any PHP script will be allowed only to authenticated users.
97
+
If you need to change this default policy for some of your PHP scripts, you will need to do this in your plugin ``init`` function,
98
+
using the ``Glpi\Http\Firewall::addPluginFallbackStrategy()`` method.
* ``Firewall::STRATEGY_NO_CHECK``: no check is done, anyone can access your script, even unauthenticated users;
114
+
* ``Firewall::STRATEGY_AUTHENTICATED``: only authenticated users can access your script, it is the default strategy for all PHP scripts;
115
+
* ``Firewall::STRATEGY_CENTRAL_ACCESS``: only users with access to the standard interface can access your script;
116
+
* ``Firewall::STRATEGY_HELPDESK_ACCESS``: only users with access to the simplified interface can access your script;
117
+
* ``Firewall::STRATEGY_FAQ_ACCESS``: only users with a read access to the FAQ will be allowed to access your script, unless the FAQ is configured to be public.
118
+
119
+
Handling of response codes and early script exit
120
+
++++++++++++++++++++++++++++++++++++++++++++++++
121
+
122
+
Usage of the ``exit()``/``die()`` language construct is now discouraged as it prevents the execution of routines that might take place after the request has been executed.
123
+
Also, due to a PHP bug (see https://bugs.php.net/bug.php?id=81451), the usage of the ``http_response_code()`` function will produce unexpected results, depending on the server environment.
124
+
125
+
In the case they were used to exit the script early due to an error, you can replace them by throwing an exception.
126
+
Any exception thrown will now be caught correctly and forwarded to the error handler.
127
+
If this exception is thrown during the execution of a web request, the GLPI error page will be shown, unless this exception is handled by a specific routine.
128
+
129
+
.. code-block:: diff
130
+
131
+
if ($item->getFromDB($_GET['id']) === false) {
132
+
- http_response_code(404);
133
+
- exit();
134
+
+ throw new \Glpi\Exception\Http\NotFoundHttpException();
135
+
}
136
+
137
+
In case the ``exit()``/``die()`` language construct was used to just ignore the following line of code in the script, you can replace it with a ``return`` instruction.
In GLPI 11.0, we changed the way to handle URLs to plugin resources so that they no longer need to reflect the location of the plugin on the file system.
153
+
We changed the way to handle URLs to plugin resources so that they no longer need to reflect the location of the plugin on the file system.
84
154
For instance, the same URL could be used to access a plugin file whether it was installed manually in the ``/plugins`` directory or via the marketplace.
85
155
86
156
To maintain backwards compatibility with previous behavior, we will continue to support URLs using the ``/marketplace`` path prefix.
0 commit comments