?
avatar PhilETaylor
PhilETaylor
6 Jul 2020

Steps to reproduce the issue

In Joomla 4 (and to a certain extent Joomla 3) when you install, the db doesn't contain all the configuration params that the application uses, and (one assumes) relies on code in PHP to set a default or handle missing params.

This means extensions that rely (correctly) on reading the params direct from the db with code such as below don't get the correct values (such as loggable_api is not in the json array in params for this com_actionlogs extension after installation, unless someone has gone to global config -> User Action Logs and clicked save).

// Joomla 4 Example
$isEnabled = ComponentHelper::getParams('com_actionlogs')->get('loggable_api')
// $isEnabled = null !!! Expected an int, 0 or 1. 

After installation the params for com_actionlogs are

// beautified for ease of reading in GitHub
{
   "ip_logging":0,
   "csv_delimiter":",",
   "loggable_extensions":[
      "com_banners",
      "com_cache",
      "com_categories",
      "com_checkin",
      "com_config",
      "com_contact",
      "com_content",
      "com_installer",
      "com_media",
      "com_menus",
      "com_messages",
      "com_modules",
      "com_newsfeeds",
      "com_plugins",
      "com_redirect",
      "com_tags",
      "com_templates",
      "com_users"
   ]
}

After loading Global Config -> User Action Logs, not changing anything, clicking save, the params in the db are now:

// beautified for ease of reading in GitHub
{
   "ip_logging":0,
   "csv_delimiter":",",
   "loggable_extensions":[
      "com_content",
      "com_banners",
      "com_cache",
      "com_categories",
      "com_checkin",
      "com_config",
      "com_contact",
      "com_installer",
      "com_media",
      "com_menus",
      "com_messages",
      "com_modules",
      "com_newsfeeds",
      "com_plugins",
      "com_redirect",
      "com_tags",
      "com_templates",
      "com_users"
   ],
   "loggable_api":0,
   "loggable_verbs":[
      "GET"
   ]
}

I stress this is just ONE example, there are others, mainly to do with permissions and acl a lot of the time

I appreciate going through and retrospectively finding all these is a HUGE job, however new PR'snew features should also ensure that they are correctly setting the defaults in the db at installation time, as well as working around the fact that they might not exist in the database (i.e a site has upgraded, which now has a new feature, but no one has yet updated the database)

Expected result

The sane defaults for all params should be in the json array in the db from the time of installation and not relying on additional PHP code to set a default if the param is missing.

Actual result

Lots of missing data in the database for configuration params
3pd extensions reading the db directly receive false type-strict params for missing configs (get a null, as its not defined instead of an int 0/1 for example)

avatar PhilETaylor PhilETaylor - open - 6 Jul 2020
avatar joomla-cms-bot joomla-cms-bot - change - 6 Jul 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Jul 2020
avatar PhilETaylor PhilETaylor - change - 6 Jul 2020
The description was changed
avatar PhilETaylor PhilETaylor - edited - 6 Jul 2020
avatar PhilETaylor PhilETaylor - change - 6 Jul 2020
The description was changed
avatar PhilETaylor PhilETaylor - edited - 6 Jul 2020
avatar PhilETaylor
PhilETaylor - comment - 6 Jul 2020

I have PR #30028 for this specific example - this doesnt really close this issue, as there are many more...

avatar PhilETaylor
PhilETaylor - comment - 6 Jul 2020

Another example:

  • Look at your configuration.php right after installation.
  • Go to /administrator/ and go to System -> Global Configuration
  • Click Save
  • Compare the configuration.php file to the one before saving - note loads of additional values.
avatar mbabker
mbabker - comment - 6 Jul 2020

Not every possible parameter needs to be persisted into the database or configuration file the second it is introduced into an XML form definition, this is in part why the expectation is you always provide a same default to fall back to when calling Registry::get().

If it’s your position that everything has to be persisted, then you also need to solve the problem of adding these values to the database or regenerating the configuration file on update, and IMO that’s adding a lot of risk for creating new update failures for something that personally I’d say has very little gain.

avatar PhilETaylor PhilETaylor - change - 6 Jul 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-07-06 12:09:59
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 6 Jul 2020

Add a Comment

Login with GitHub to post a comment