|
14 | 14 | use Joomla\CMS\Access\Access; |
15 | 15 | use Joomla\CMS\Access\Rules; |
16 | 16 | use Joomla\CMS\Component\ComponentHelper; |
| 17 | +use Joomla\CMS\Filesystem\Folder; |
| 18 | +use Joomla\CMS\Filesystem\Path; |
17 | 19 | use Joomla\CMS\MVC\Model\FormModel; |
18 | 20 | use Joomla\CMS\Table\Asset; |
19 | 21 | use Joomla\CMS\Table\Table; |
@@ -315,6 +317,43 @@ public function save($data) |
315 | 317 | } |
316 | 318 | } |
317 | 319 |
|
| 320 | + // Ensure custom session file path exists or try to create it if changed |
| 321 | + if (!empty($data['session_filesystem_path'])) |
| 322 | + { |
| 323 | + $currentPath = $prev['session_filesystem_path'] ?? null; |
| 324 | + |
| 325 | + if ($currentPath) |
| 326 | + { |
| 327 | + $currentPath = Path::clean($currentPath); |
| 328 | + } |
| 329 | + |
| 330 | + $data['session_filesystem_path'] = Path::clean($data['session_filesystem_path']); |
| 331 | + |
| 332 | + if ($currentPath !== $data['session_filesystem_path']) |
| 333 | + { |
| 334 | + if (!Folder::exists($data['session_filesystem_path']) && !Folder::create($data['session_filesystem_path'])) |
| 335 | + { |
| 336 | + try |
| 337 | + { |
| 338 | + \JLog::add( |
| 339 | + \JText::sprintf('COM_CONFIG_ERROR_CUSTOM_SESSION_FILESYSTEM_PATH_NOTWRITABLE_USING_DEFAULT', $data['session_filesystem_path']), |
| 340 | + \JLog::WARNING, |
| 341 | + 'jerror' |
| 342 | + ); |
| 343 | + } |
| 344 | + catch (\RuntimeException $logException) |
| 345 | + { |
| 346 | + $app->enqueueMessage( |
| 347 | + \JText::sprintf('COM_CONFIG_ERROR_CUSTOM_SESSION_FILESYSTEM_PATH_NOTWRITABLE_USING_DEFAULT', $data['session_filesystem_path']), |
| 348 | + 'warning' |
| 349 | + ); |
| 350 | + } |
| 351 | + |
| 352 | + $data['session_filesystem_path'] = $currentPath; |
| 353 | + } |
| 354 | + } |
| 355 | + } |
| 356 | + |
318 | 357 | // Set the shared session configuration |
319 | 358 | if (isset($data['shared_session'])) |
320 | 359 | { |
|
0 commit comments