SMF 2.1 renamed the icon column
authorAlexander Ebert <ebert@woltlab.com>
Thu, 27 Jul 2023 16:05:07 +0000 (18:05 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 27 Jul 2023 16:05:07 +0000 (18:05 +0200)
See https://github.com/SimpleMachines/SMF/blob/7f6d318352751d7ae8131557b4dd7c642903a67c/other/upgrade_2-1_mysql.sql#L1293-L1294

files/lib/system/exporter/SMF2xExporter.class.php

index f6550bc86af4852a4e4e3cb3652c36e07c693fd9..483eb09520a9ce91ee6977d928ecd6479dac5e20 100644 (file)
@@ -512,10 +512,15 @@ class SMF2xExporter extends AbstractExporter
      */
     public function countUserRanks()
     {
+        $fieldName = 'stars';
+        if (\version_compare($this->readOption('smfVersion'), '2.1.0', '>')) {
+            $fieldName = 'icons';
+        }
+
         $sql = "SELECT  COUNT(*) AS count
                 FROM    " . $this->databasePrefix . "membergroups
                 WHERE   min_posts <> ?
-                    AND stars <> ?";
+                    AND {$fieldName} <> ?";
         $statement = $this->database->prepareStatement($sql);
         $statement->execute([-1, '']);
         $row = $statement->fetchArray();
@@ -531,15 +536,20 @@ class SMF2xExporter extends AbstractExporter
      */
     public function exportUserRanks($offset, $limit)
     {
+        $fieldName = 'stars';
+        if (\version_compare($this->readOption('smfVersion'), '2.1.0', '>')) {
+            $fieldName = 'icons';
+        }
+
         $sql = "SELECT      *
                 FROM        " . $this->databasePrefix . "membergroups
                 WHERE       min_posts <> ?
-                        AND stars <> ?
+                        AND {$fieldName} <> ?
                 ORDER BY    id_group";
         $statement = $this->database->prepareStatement($sql, $limit, $offset);
         $statement->execute([-1, '']);
         while ($row = $statement->fetchArray()) {
-            [$repeatImage, $rankImage] = \explode('#', $row['stars'], 2);
+            [$repeatImage, $rankImage] = \explode('#', $row[$fieldName], 2);
 
             $groupID = $row['id_group'] == self::GROUP_USER ? self::GROUP_USER_FAKE : $row['id_group'];