Saturday, September 28, 2024

Sexy Polling Reloaded Extension (Plugin) on J4 with MySql 8

For anyone installing the plugin SexyPolling 4.1.7 on a Joomla 4.3.4 with a MySql 8.0 db on an Ubuntu system there may be issues with default value for Text fields. More specifically error in setting default value for country, city, etc TEXT fields:

    "BLOB, TEXT, GEOMETRY or JSON column 'country' can't have a default value"

1) There is a solution for MySql 8.0 to set DEFAULT values for TEXT fields. The CREATE statement for table `#_sexy_votes` needs to be changed to:

         // Modify the sexypolling plugin CREATE TABLE script:
            CREATE TABLE `#_sexy_votes` (
              `id_vote` int(10) unsigned NOT NULL AUTO_INCREMENT,
                  ....
              `country` text NOT NULL DEFAULT (_utf8mb4'Unknown'),
              `city` text NOT NULL DEFAULT (_utf8mb4'Unknown'),
              `region` text NOT NULL DEFAULT (_utf8mb4'Unknown'),
              `countrycode` text NOT NULL DEFAULT (_utf8mb4'Unknown'),
              PRIMARY KEY (`id_vote`),
                  .....
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;


Further, in order for the CREATE table changes to take effect & not get dropped/ altered, a few of the plugin's installer scripts needs to be modified. The installation then needs to be done from a folder (or a modified zip file) in which the modified plugin installer scripts are present (instead of the downloaded joomla_plugin_sexypolling_reloaded_v4.1.7.zip file), as explained next.

2) Installation of plugin from /tmp folder 

2.1) Unzip the downloaded joomla_plugin_sexypolling_reloaded_v4.1.7.zip file to the site /tmp folder as mentioned in the site configuration.php file (e.g. /var/www/html/<site_name>/tmp). Give the folder proper read/write permissions.

2.2) Change CREATE TABLE `#_sexy_votes` command  in /tmp/com_sexypolling/admin/install/sql/install.sql:

Set the DEFAULT value for country, city, region, countrycode to  "DEFAULT (_utf8mb4'Unknown')" as mentioned above.
 
2.3) Remove ALTER TABLE `#_sexy_votes` command from /tmp/com_sexypolling/scriptfile.php. 

     Put an invalid condition check on line 235 of the script to stop ALTER TABLE for `#_sexy_votes` to run:

         $alterSexyVotes=false;

         if($alterSexyVotes && is_array($columns_titles)) { 

            ...

2.4) Finally, install:

  • Option A: Install from modified com_sexypolling folder: Install the extension from the folder /tmp/com_sexypolling from the J! "Admin" > "System" > "Install Extensions" > "Install from Folder" page.
  • Option B: Zip & Install modified com_sexypolling folder: Another option could be to manually zip the folder with the modifications (/tmp/com_sexypolling) & install using this zip file from the standard J! "Admin" > "System" > "Install Extensions" > "Upload Package File" page.

 

No comments:

Post a Comment