Monday, September 30, 2024

Restore Joomla 4 Manually

This post has info on manually restoring a Joomla 4.3.4 set-up across two servers. While both are Linux systems the configuration differ slightly including the OS, Php , DB, etc. Various issues were faced & overcome in doing the restoration.

Background info:

- Source:
Ubuntu 22.04, Php 8.2, Joomla 4.3.4, Apache, Maria DB, Addon Plugins (AddToAny, LazyDb, Komento, SexyPolling)

- Destination:
Ubuntu 20.04, Php 7.4, Joomla 4.3.4, Apache, MySql 8.0

- Latest DB dump & htdocs folder (including all files, modules, plugins, media, images etc.) from Source was transferred to Destination server via Ftp before hand.

Steps:

1) DB Import

    1.1) Create user, db, grant all permission to user. 

    1.2) Import data to the created db from the latest DB dump of the source.
 
        1.2.1) ERROR 1366 (HY000) at line 2273: Incorrect integer value: '' for column 'checked_out' at row 1. Solution is to set NO_ENGINE_SUBSTITUTION & then import:

            SET @@GLOBAL.sql_mode= 'NO_ENGINE_SUBSTITUTION';

    1.3) ERROR 1101 (42000) at line 10692: BLOB, TEXT, GEOMETRY or JSON column 'country' can't have a default value

        - Using the solution found online & the DB dump sql import script was changed to set DEFAULT values for the problematic text columns country, city, etc
    

         // 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;

2) Download Joomla_4.3.4-Stable-Full_Package.zip from joomla.org
    2.1) Unzip Joomla_4.3.4-Stable-Full_Package.zip to /var/www/html & rename folder to <site_name>

    2.2) Set up site configuration.php (/var/www/html/<site_name>/configuration.php)
        - Add db, username, password
        - Add tmp_path & log_path in

        public $log_path = '/var/www/html/<site_name>/administrator/logs';
          public $tmp_path = '/var/www/html/<site_name>/tmp';


3) Restore Joomla modules, plugins, languages, etc from file system Ftp backup location of Source.

4) Additional system settings on Destination


    4.1) Add missing Php modules: "Call to undefined function" error

        4.1.1) simplexml_load_file()
            sudo apt-get install php7.4-xml

        4.1.2) "IntlTimeZone" module missing
            sudo apt-get install php7.4-intl

    4.2) Increase Php upload limit (/etc/php/7.4/apache2/php.ini)

          post_max_size = 38M
            upload_max_filesize = 32M


    4.3) Restart apache
          sudo systemctl reload apache2
 

5) Recovering from J4 Red Error Page of death

    5.1) Redirection to installation/index.php:

    - With an error "500 - Whoops, looks like something went wrong".
    - Needed to delete the installation folder, to stop the redirection.

    5.2) Next, 404 Component not found error on the home page: 
 

    ---
        404 **Component not found.**

        Call stack
        #     Function     Location
        1     ()     JROOT/libraries/src/Component/ComponentHelper.php:296
        2     Joomla\CMS\Component\ComponentHelper::renderComponent()     JROOT/libraries/src/Application/SiteApplication.php:210
        3     Joomla\CMS\Application\SiteApplication->dispatch()     JROOT/libraries/src/Application/SiteApplication.php:251
        4     Joomla\CMS\Application\SiteApplication->doExecute()     JROOT/libraries/src/Application/CMSApplication.php:293
        5     Joomla\CMS\Application\CMSApplication->execute()     JROOT/includes/app.php:61
        6     require_once()     JROOT/index.php:32
    ---
 

    5.3) Checked DB connections using a custom php script:

No issues connecting to DB with username/ password!

    5.4) Enable Debugging/ Logging:
        

        5.4.1) Logging in php.ini (/etc/php/7.4/apache2/php.ini)
            ----Turn on logging-----
               display_errors = On
               html_errors = On
               display_startup_errors = On
               log_errors = On
               error_log = /var/log/apache2/php_errors.log


        5.4.2) Logging in configuration.php (/var/www/html/<site_name>/configuration.php)
            // Change to true from false
                public $debug = true;
                public $debug_lang = true;

                // Change to 'maximum' from 'default'
                public $error_reporting = 'maximum';
    
                // Change to 1 from 0
                public $log_everything = 1;


    With those J! Info started showing up in the browser along with the error stack trace & queries.

    5.5) Root cause analysis

        5.5.1) Checked the specific php libraries:
            libraries/src/Component/ComponentHelper.php:296
            libraries/src/Application/SiteApplication.php:210, etc..

    - Using var_dump($component), on SiteApplication.php:210 found: 

           $component = NULL

        - The same '$component = "com_content"' on the home page of a default Joomla application (unzip Joomla 4.3.4 zip & install & check value on Joomla home page).

        - Test with hard coded $component = "com_content" in libraries/src/Application/SiteApplication.php:210

                if(empty($component)){
                     $component = "com_content";
         
       }


        - With this 404 was gone & a broken site home page came up with a few Category links listed out

        - Clicking on Category link was showing that "No Article linked to Category", despite there being several Articles imported from source db dump.

        5.5.2) Localizing issue with Content/ Article loading:
        - Hit the direct Article url:
            http://<site_name>/index.php?option=com_content&view=article&id=<article_id>

        - This gave another error"404 Article not found", though the specific <article_id> was present in the database.

        - J! Info provided the corresponding php file and db query used to fetch article by id which was giving no result

    5.5.3) Issue with imports of all "datetime DEFAULT NULL" fields

    - On exploring the query further, it was seen to have checks for publish_up & publish_down dates. These needed to be either NULL or set to a date earlier (/later) than date NOW for publish_up (/publish_down).

    - In the "#_content" table publish_up & publish_down dates values were showing as "0000-00-00 00:00:00" (i.e. were imported as 0) in place of NULL.
This was causing all records being filtered out.

    - It also meant that wherever the "datetime default NULL" fields were imported the same issue was happening. 

        - A check revealed 30 other J! tables with the same issue.
 
        - Prepared a script to update each of these datetime fields to NULL in the 30 tables.
            UPDATE `#_content` SET `checked_out_time` = NULL, `publish_up` = NULL, `publish_down` = NULL;

            UPDATE `#_categories` SET `checked_out_time` = NULL;
                                                                     .... 
for all the affected tables!

With that the issue was resolved & site home page became functional!

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.

 

Monday, August 19, 2024

Pygradle for Python-3

Gradle, the build workhorse from the Java ecosystem, extends its support to Python through Pygradle. A recent attempt to build a Python-3.x project using Pygradle though did't work as expected. 

The delta between the supported Python-2.x vs Python-3.x is hard to reconcile with many issues like:

  • Need for a specific, old version of Java (ver.8), Gradle (ver. 5.0), etc
  • Dependencies on old versions of Python modules without backwards compatibility
    • Hard to figure out which exact version will work
    • A rule of thumb is to pick the highest version dependency module around some cut-off year like 2018/19, post which they don't seem to build
  • Downloading of the correct dependencies & creating ivy files
    • Includes identifying the right version, name, dependencies-within-dependencies (that no longer work on Python-3.x), etc.
  • Using a local file system based repo to download & build modules & ivy files

With some effort though, have been able to complete a successful build on a Python-3.8 on an Ubuntu-20.04 with Java-8 & Gradle-5.0. More details are available on the pygradle_python3_example repo. Hope this helps!

Monday, July 22, 2024

Cloudera - Streaming Data Platform

Cloudera has a significantly mature streaming offering on their Data Platform. Data from varied sources such as rich media, text, chat, message queues, etc is brought in to their unified DataFlow platform using Nifi or other ETL/ ELT. After processing these can be directed to one or more of the Op./ App DB, Data Lake (Iceberg), Vector DB post embedding (for AI/ ML), etc.

Streaming in AI/ ML apps help to provide a real-time context that can be leveraged by the apps. Things like feedback mechanism, grounding of outputs, avoiding hallucinations, model evolution, etc all of them require real-time data to be available. So with a better faster data, MLOPs platform Cloudera is looking to improve the quality of the ML apps itself running on them.

Cloudera has also made it easy to get stared with ML with their cloud based Accelarators (AMP). AMPs have support for not just Cloudera built modules, but even those from others like Pinecode, AWS, Hugging Face, etc & the ML community. Apps for Chats, Text summarization, Image analysis, Time series, LLMs, etc are available for use off the shelf. As always, Cloudera continues to offer all deployment options like on-premise, cloud & hybrid as per customer's needs.

 

Monday, April 1, 2024

Gurobi Optimizer

Gurobi stack consists of various modules in Python (Gurobipy) & other languages for solving Optimization problems. Think of scheduling, routing, cost minimization, profit maximization, flow decision, OR, assignment and so on. They have all the classical Linear Programming, ILP, Greedy, Constrained Optimization type algos properly implemented & ready for use at scale.

Off late they are fusing Mathematical Optimizations with AI to yield much better modules. Their stack includes Neural Nets, DNN, Differential Programming, Simulators, Reinforcement Learning and all the other tools required to fuse ML & Optimization. They also have hardware & cloud offerings now. These can be good places to start of by uploading modules that need to be optimized on demand. The output results can be integrated within applications/ workflows.   

Monday, March 25, 2024

VR Movies

Watching movies on VR headset was an experience like none other. Thanks to the organizers from Goethe Institute & IHC for hosting such a unique event for the viewers.

Immersive movies & 360 filmmaking is a rather new development taking place in the world of cinema. International events like the VRHAM Film Festival is exclusively being organized since 2018 for VR movies makers. All the biggies from the tech world are in on it with VR headsets catering to the growing demands. So the action is hotting up on the AR/ VR front.

Going back the movies, there were about ten of them on display. These were short ones of about 15 min each curated by U. Schauth.  I got the opportunity to watch:

Each movie was remarkable. Distinct stories, providing an immersive experience to our connected pasts. Highly recommend the experience to all.


Sunday, March 10, 2024

Gaming World

Recently got an opportunity to attend the India Gaming Summit 2024 in person. This was truly an insightful first peek into the world of the gamers!

All kinds of gaming professions have been gaining traction over the last few years. On the one end of the spectrum are the elite ESport Atheletes who compete on national & international forums. On the other there are Casual Gamers, playing games on their mobiles & computers for fun, entertainment, and as a recreational pass time. 

On a slightly different tangent are the gamers playing Real Money Games (RMG). They play games (like poker, etc) with actual monetary bets & rewards (losses). There is a wide age profile mix among all the different kinds of gamers. From teenagers to senior citizens to home makers to professionals it seems the whole world is busy playing games, not just in their free time. Though preferences for different types of games vary across demographics.

Those considerations and more are the lookout of the other kind of gaming professionals - the game developers. These are the tech & biz folks building gaming companies & startups. They are busy coming up with newer and popular games which appeals to their audiences. Issues of profits, growth, user-base, market capture, freshness & appeal, newer products, marketing, recruitment, etc. are among many of the organizational concerns on their minds.

Fluidity on the taxation front is giving gitters to the whole industry. A consistent and steady policy from the government is the need of the hour. At the same time social & heath issues like addiction, isolation, mental health issue are also serious concerns of the entire gaming industry. 

Several technological interventions like compulsory lay off time after a certain period of playing, etc are being brought in. As well as education & health interventions. While there seems to be a general acknowledgement of the issues, individual solutions may differ yielding varying results. A regulatory/ governance model is also needed here. Self-regulatory models while promising may/ may not work. Better is to institute a proper governance framework with checks & balances in place.

Finally, for what makes gaming worthwhile look at the success of Monopoly Go, a digitized version of the children's board game. The game is so popular that it  touched $1 Bn in revenues within 7 months of release & doubled that over the next 3 months. With that in mind, keep an eye out on all the action from the gaming world!