0

[original post - I have now established it is a bug] A strange quirk. Using Joomla 5 my install script for a component is designed to show some information to the user after update. It renders the expected text during postflight() if I upload the file to the com_installer install view - it correctly detects that it is an update and displays my update welcome text.

However if the update is run by the com_installer update view after detecting an update is available it successfully does the update but the completion text from the script is not displayed. However messages using enqueueMessage() are displayed as in the example below.

I have seen another component correctly display a message, but I can't see any functional difference between it's postflight() function and mine - we are both simply echoing text.

Here's a script file that doesn't work:

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Installer\Installer;
use Joomla\Filesystem\Path;

class com_xbarticlemanInstallerScript {

    protected $oldver = 'v0.0.0';
    protected $olddate = '32nd January 2024';

    function preflight($type, $parent) {
        // if we are updating then get the old version and date from component xml before it gets overwritten.
        if ($type=='update') {
            $componentXML = Installer::parseXMLInstallFile(Path::clean(JPATH_ADMINISTRATOR . '/components/com_xbarticleman/xbarticleman.xml'));
            $this->oldver = $componentXML['version'];
            $this->olddate = $componentXML['creationDate'];
            Factory::getApplication()->enqueueMessage('Updating from '.$this->oldver.' '.$this->olddate.' to '.$parent->getManifest()->version);
        }
    }
    
    function postflight($type, $parent) {
        if ($type == 'update') {
            Factory::getApplication()->enqueueMessage('updated xbArticleMan component to version '.$parent->getManifest()->version);
//and here's some text that should be displayed on the install/update page after update
            echo '<div><p>The <b>xbArticleMan</b> component has been updated'; 
            echo ' to <b>'.$parent->getManifest()->version.'</b>';
            echo ' from '.$this->oldver.'</p></div>';          
        }
    }

The message displays ok, but the text is not displayed when using the updater but is displayed when using the installer. Any ideas why?

1
  • The code above has been cut down to the minimum that shows the problem and tried with this exact code. The fulll install script does other stuff as well.
    – RogerCO
    Mar 8 at 12:40

1 Answer 1

0

This is a BUG in com_installer. If there is more than one extension to be updated and you only mark one checkbox to update the the script extension_message (ie the html output during postflight() IS displayed.

If, however, there is only one extension in the list and you update it, OR if there is more than one extension in the list and your check 2 or more to be updated then the extension_message for the script(s) is NOT displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.