Browse Source

upgrade packages and add doc

Olivier Massot 2 years ago
parent
commit
3351f9be6b

+ 43 - 0
doc/historic/upgrade_v11.md

@@ -0,0 +1,43 @@
+# Upgrade v10 -> v11
+
+Mise à jour de l'instance typo3 de la 10.4.36 vers la 11.5.29 LTS
+
+Pour cette mise à jour, on reste en PHP 7.4.1
+
+## Analyse
+
+### Mise à niveau des extensions Opentalent
+
+L'analyse des fichiers des extensions signale deux extensions "maison" comme incompatibles : ot_admin et ot_connect.
+
+Au total, ce sont trois méthodes qui sont concernées par les dépréciations.
+
+Un ticket est créé pour la mise à niveau : [V8-4761](https://assistance.opentalent.fr/browse/V8-4761)
+
+
+
+### Mise à niveau des extensions tiers
+
+| Extension                       | Version actuelle | Dernière version | Compatibilité Typo3 11 | Compat. PHP |
+|---------------------------------|------------------|------------------|------------------------|-------------|
+| fluidtypo3/flux                 | 9.7.2            | 9.7.4            | ^11                    | ^7.4.0 - ^8 |
+| fluidtypo3/vhs                  | 6.1.2            | 6.1.3            | ^11                    | ^7.4.0 - ^8 |
+| georgringer/news                | 9.0              | 11.1.2           | ^11.5.24               | 7.4 -> 8.3  |
+| helhum/typo3-console            | 6.6              | 7.1.6            | ^11.5.26               | >=7.4.1     |
+| causal/image_autoresize         | 2.1              | 2.2.0            | ^11                    | ^7.4   - ^8 |
+| friendsoftypo3/frontend-editing | 2.0              | 3.1.1            | ^11.5                  | ?           |
+| sgalinski/lfeditor              | 6.0              | 7.1.11           | ^11.5                  | ?           |
+| waldhacker/hcaptcha             | 2.0              | 2.1.1            | ^11.5                  | ^7.2 - ^8   |
+| guzzle/guzzle                   | 6.x              | 7.7              |                        | ^7.2 - ^8   |
+| nimut/testing-framework         | 5.2              | 6.0.1            | ^11.5.3                | ^7.2 - ^8.0 |
+
+A priori pas de blocage, la mise à jour des extensions sera à faire en même temps que celle de typo3
+
+
+### Réaliser l'upgrade
+
+1. Faire un snapshot du serveur
+2. Maj tous les packages Typo3 de la version ^10.4 à la version ^11.5 dans le composer.json
+3. Maj les dépendances à leur dernière version compatible (voir paragraphe précédent)
+4. Aller à la page /setup de typo3, et faire passer les différentes opérations de mise à jour
+5. Tester

+ 41 - 0
ot_connect/Classes/Service/OtAuthenticationService.php

@@ -11,6 +11,8 @@ use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\Service\OpentalentApiService;
 use TYPO3\CMS\Core\Crypto\Random;
 use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryHelper;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use \TYPO3\CMS\Core\Authentication\AbstractAuthenticationService;
@@ -470,4 +472,43 @@ class OtAuthenticationService extends AbstractAuthenticationService
         setcookie($name, '', 1, '/', $_SERVER['HTTP_HOST']); // for custom domains (not in .opentalent.fr)
         setcookie($name, '', 1, '/', self::COOKIE_DOMAIN);   // for opentalent.fr subdomains
     }
+
+    /**
+     * Get a user from DB by username
+     *
+     * @param string $username User name
+     * @param string $extraWhere Additional WHERE clause: " AND ...
+     * @param array|string $dbUserSetup User db table definition, or empty string for $this->db_user
+     * @return mixed User array or FALSE
+     */
+    public function fetchUserRecordTemp($username, $extraWhere = '', $dbUserSetup = '')
+    {
+        $dbUser = is_array($dbUserSetup) ? $dbUserSetup : $this->db_user;
+        $user = false;
+        if ($username || $extraWhere) {
+            $query = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($dbUser['table']);
+            $query->getRestrictions()->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+            $constraints = array_filter([
+                QueryHelper::stripLogicalOperatorPrefix($dbUser['check_pid_clause']),
+                QueryHelper::stripLogicalOperatorPrefix($dbUser['enable_clause']),
+                QueryHelper::stripLogicalOperatorPrefix($extraWhere),
+            ]);
+            if (!empty($username)) {
+                array_unshift(
+                    $constraints,
+                    $query->expr()->eq(
+                        $dbUser['username_column'],
+                        $query->createNamedParameter($username, \PDO::PARAM_STR)
+                    )
+                );
+            }
+            $user = $query->select('*')
+                ->from($dbUser['table'])
+                ->where(...$constraints)
+                ->execute()
+                ->fetch();
+        }
+        return $user;
+    }
 }

+ 5 - 3
ot_core/Classes/Controller/SelectedSiteController.php

@@ -4,6 +4,8 @@ namespace Opentalent\OtCore\Controller;
 
 use Opentalent\OtCore\Exception\NoSiteSelected;
 use Opentalent\OtCore\Website\OtPageRepository;
+use Psr\Http\Message\ResponseInterface;
+use TYPO3\CMS\Extbase\Mvc\RequestInterface;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 
 /**
@@ -42,7 +44,7 @@ class SelectedSiteController extends ActionController
      * @throws \Opentalent\OtCore\Exception\NoSuchWebsiteException
      * @throws \Exception
      */
-    protected function callActionMethod() {
+    protected function callActionMethod(RequestInterface $request): ResponseInterface {
 
         // Check if the current be-user has a db_mountpoint, and only has one.
         // If so, this will be considered as the selected site (since its the only one available)
@@ -69,7 +71,7 @@ class SelectedSiteController extends ActionController
         }
 
         // [TESTS ONLY]
-        if ($this->preventPropagation) { return; }
+        if ($this->preventPropagation) { return parent::callActionMethod($request); }
 
         // No site is selected, redirect to the warning page
         if ($this->actionMethodName != 'displayNoSelectedPageWarningAction' && $this->currentRootUid == null) {
@@ -78,7 +80,7 @@ class SelectedSiteController extends ActionController
             // $this->forward('displayNoSelectedPageWarning', 'SelectedSite', 'OtCore');
         }
 
-        parent::callActionMethod();
+        return parent::callActionMethod($request);
     }
 
     protected function displayNoSelectedPageWarningAction() {}

+ 6 - 5
ot_core/Classes/Middleware/OtBackendUserAuthenticator.php

@@ -3,6 +3,7 @@ namespace Opentalent\OtCore\Middleware;
 
 use PHPUnit\Exception;
 use TYPO3\CMS\Backend\Middleware\BackendUserAuthenticator;
+use TYPO3\CMS\Backend\Routing\Route;
 
 /**
  * Overrides (XClass) the core BackendUserAuthenticator middleware to extend
@@ -16,14 +17,14 @@ class OtBackendUserAuthenticator extends BackendUserAuthenticator
      * Check if the user is required for the request
      * If we're trying to do a login or an ajax login, don't require a user
      *
-     * @param string $routePath the Route path to check against
+     * @param Route $route
      * @return bool whether the request can proceed without a login required
      */
-    protected function isLoggedInBackendUserRequired(string $routePath): bool
+    protected function isLoggedInBackendUserRequired(Route $route): bool
     {
         if (class_exists('\Opentalent\OtAdmin\Http\ApiController')) {
             // The routes defined in the ot-admin extension are limited to some ips
-            if (preg_match('/\/otadmin\/.+/', $routePath)) {
+            if (preg_match('/\/otadmin\/.+/', $route->getPath())) {
                 if (\Opentalent\OtAdmin\Http\ApiController::isIpAllowed($_SERVER['REMOTE_ADDR'])) {
                     return true;
                 } else {
@@ -34,10 +35,10 @@ class OtBackendUserAuthenticator extends BackendUserAuthenticator
         }
 
         // The routes defined in the ot-core extension are public
-        if (preg_match('/\/otcore\/.+/', $routePath)) {
+        if (preg_match('/\/otcore\/.+/', $route->getPath())) {
             return true;
         }
 
-        return parent::isLoggedInBackendUserRequired($routePath);
+        return parent::isLoggedInBackendUserRequired($route->getPath());
     }
 }

+ 5 - 5
ot_core/composer.json

@@ -9,12 +9,12 @@
         }
     ],
     "require": {
-        "typo3/cms-core": "^10.4",
-        "fluidtypo3/vhs": "^6.0",
-        "fluidtypo3/flux": "^9.5",
+        "typo3/cms-core": "^11.5",
+        "fluidtypo3/vhs": "^6.1",
+        "fluidtypo3/flux": "^9.7",
         "guzzlehttp/guzzle": "^6",
-        "nimut/typo3-complete": "10.4",
-        "nimut/testing-framework": "^5.2"
+        "nimut/typo3-complete": "11.5",
+        "nimut/testing-framework": "^6.0"
     },
     "replace": {
         "opentalent/ot_core": "self.version",

+ 4 - 4
ot_core/ext_emconf.php

@@ -18,12 +18,12 @@ $EM_CONF[$_EXTKEY] = [
     'uploadfolder' => 0,
     'createDirs' => '',
     'clearCacheOnLoad' => 0,
-    'version' => '0.6.6',
+    'version' => '0.7',
     'constraints' => [
         'depends' => [
-            'typo3' => '8.7.0-10.4.99',
-            'flux'  => '9.3.0-9.4.99',
-            'vhs'  => '6.0.0-6.0.99',
+            'typo3' => '10.4.0-11.5.99',
+            'flux'  => '9.3.0-9.7.99',
+            'vhs'  => '6.0.0-6.1.99',
         ],
         'conflicts' => [],
         'suggests' => [],

+ 2 - 3
ot_stats/composer.json

@@ -9,10 +9,9 @@
         }
     ],
     "require": {
-        "typo3/cms-core": "^9.5 || ^10.4",
+        "typo3/cms-core": "^11.5",
         "fluidtypo3/vhs": "^6",
-        "fluidtypo3/flux": "^9",
-        "fluidtypo3/fluidpages": "^5"
+        "fluidtypo3/flux": "^9"
     },
     "replace": {
         "ot_stats": "self.version",

+ 3 - 3
ot_stats/ext_emconf.php

@@ -21,9 +21,9 @@ $EM_CONF[$_EXTKEY] = [
     'version' => '1.0.0',  //see ot_core/ext_emconf.php to get the current ot extensions version
     'constraints' => [
         'depends' => [
-            'typo3' => '8.7.0-10.4.99',
-            'flux'  => '9.3.0-9.4.99',
-            'vhs'  => '6.0.0-6.0.99',
+            'typo3' => '10.4.00-11.5.99',
+            'flux'  => '9.3.0-9.7.99',
+            'vhs'  => '6.0.0-6.1.99',
             'ot_core' => '*'
         ],
         'conflicts' => [],

+ 4 - 5
ot_templating/composer.json

@@ -9,14 +9,13 @@
         }
     ],
     "require": {
-        "typo3/cms-core": "^9.5 || ^10.4",
+        "typo3/cms-core": "^11.5",
         "fluidtypo3/vhs": "^6",
         "fluidtypo3/flux": "^9",
-        "fluidtypo3/fluidpages": "^5",
-        "co-stack/logs": "",
-        "guzzlehttp/guzzle": "^6",
+        "co-stack/logs": "*",
+        "guzzlehttp/guzzle": "^7",
         "ext-json": "^1.6",
-        "sgalinski/lfeditor": "^6"
+        "sgalinski/lfeditor": "^7"
     },
     "replace": {
         "ot_templating": "self.version",