? PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar sandewt
sandewt
13 Mar 2023

Pull Request for Issue # .

Summary of Changes

Rebuild mod_users_latest with new Joomla 4 structure

Testing Instructions

  • Code review
  • Just try to use it as usual

Actual result BEFORE applying this Pull Request

  • Module works

Expected result AFTER applying this Pull Request

  • Module works

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar joomla-cms-bot joomla-cms-bot - change - 13 Mar 2023
Category Modules Front End
avatar sandewt sandewt - open - 13 Mar 2023
avatar sandewt sandewt - change - 13 Mar 2023
Status New Pending
avatar sandewt
sandewt - comment - 13 Mar 2023

Related to:

#40066 : mod_footer
#39931 : mod_custom

avatar sandewt sandewt - change - 13 Mar 2023
Labels Added: PR-4.4-dev
avatar laoneo
laoneo - comment - 13 Mar 2023

I worked today on system tests and I'm on a point now where it is relative easy to write one for front end modules. It would be cool if you can also write one for the converted module here. It is not that much of code to write. An example can be found here #40102 (ignore the changes in the db file).

avatar sandewt
sandewt - comment - 13 Mar 2023

It would be cool if you can also write one for the converted module here. It is not that much of code to write.

Sounds interesting. I'm going to check it out. But don't promise anything yet. Come back to it.

avatar toivo toivo - test_item - 14 Mar 2023 - Tested successfully
avatar toivo
toivo - comment - 14 Mar 2023

I have tested this item successfully on d3ad059

Tested successfully in Joomla 4.4.0-dev of 14 March using PHP 8.1.10.

The following Deprecated message was reported from the back end when creating the front tne module, with or without the PR:

[14-Mar-2023 02:09:13 UTC] PHP Deprecated:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in C:\www\joomla44\libraries\src\Table\Module.php on line 152
[14-Mar-2023 02:09:13 UTC] PHP Stack trace:
[14-Mar-2023 02:09:13 UTC] PHP   1. {main}() C:\www\joomla44\administrator\index.php:0
[14-Mar-2023 02:09:13 UTC] PHP   2. require_once() C:\www\joomla44\administrator\index.php:32
[14-Mar-2023 02:09:13 UTC] PHP   3. Joomla\CMS\Application\CMSApplication->execute() C:\www\joomla44\administrator\includes\app.php:61
[14-Mar-2023 02:09:13 UTC] PHP   4. Joomla\CMS\Application\AdministratorApplication->doExecute() C:\www\joomla44\libraries\src\Application\CMSApplication.php:293
[14-Mar-2023 02:09:13 UTC] PHP   5. Joomla\CMS\Application\AdministratorApplication->dispatch($component = *uninitialized*) C:\www\joomla44\libraries\src\Application\AdministratorApplication.php:186
[14-Mar-2023 02:09:13 UTC] PHP   6. Joomla\CMS\Component\ComponentHelper::renderComponent($option = 'com_modules', $params = *uninitialized*) C:\www\joomla44\libraries\src\Application\AdministratorApplication.php:143
[14-Mar-2023 02:09:13 UTC] PHP   7. Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() C:\www\joomla44\libraries\src\Component\ComponentHelper.php:355
[14-Mar-2023 02:09:13 UTC] PHP   8. Joomla\CMS\MVC\Controller\BaseController->execute($task = 'save') C:\www\joomla44\libraries\src\Dispatcher\ComponentDispatcher.php:143
[14-Mar-2023 02:09:13 UTC] PHP   9. Joomla\Component\Modules\Administrator\Controller\ModuleController->save($key = *uninitialized*, $urlVar = *uninitialized*) C:\www\joomla44\libraries\src\MVC\Controller\BaseController.php:672
[14-Mar-2023 02:09:13 UTC] PHP  10. Joomla\CMS\MVC\Controller\FormController->save($key = NULL, $urlVar = NULL) C:\www\joomla44\administrator\components\com_modules\src\Controller\ModuleController.php:241
[14-Mar-2023 02:09:13 UTC] PHP  11. Joomla\Component\Modules\Administrator\Model\ModuleModel->save($data = ['id' => '0', 'title' => 'Latest Users 2', 'note' => '', 'module' => 'mod_users_latest', 'showtitle' => '1', 'published' => '1', 'publish_up' => '', 'publish_down' => '', 'client_id' => '0', 'position' => 'sidebar-right', 'access' => 1, 'ordering' => '1', 'language' => '*', 'assignment' => '0', 'assigned' => [0 => '101'], 'rules' => ['core.delete' => [...], 'core.edit' => [...], 'core.edit.state' => [...], 'module.edit.frontend' => [...]], 'params' => ['shownumber' => 5, 'filter_groups' => 0, 'layout' => '_:default', 'moduleclass_sfx' => '', 'cache' => 1, 'cache_time' => 900, 'cachemode' => 'static', 'module_tag' => 'div', 'bootstrap_size' => '0', 'header_tag' => 'h3', 'header_class' => '', 'style' => '0'], 'tags' => []]) C:\www\joomla44\libraries\src\MVC\Controller\FormController.php:675
[14-Mar-2023 02:09:13 UTC] PHP  12. Joomla\CMS\Table\Module->check() C:\www\joomla44\administrator\components\com_modules\src\Model\ModuleModel.php:934
```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/40092">issues.joomla.org/tracker/joomla-cms/40092</a>.</sub>
avatar sandewt
sandewt - comment - 14 Mar 2023

strlen(): Passing null to parameter #1 ($string) of type string is deprecated in C:\www\joomla44\libraries\src\Table\Module.php on line 152

As far as I can see this is a PHP 8.1 error: strlen() and is unrelated to this pr. I think a separate PR is needed to solve this. Also because this error occurs before and after this pr.

[EDIT adding !empty($this->content) to line 152 (Module.php) solves the error message issue.]

avatar joomla-cms-bot joomla-cms-bot - change - 15 Mar 2023
Category Modules Front End Modules Front End JavaScript Unit Tests
avatar laoneo
laoneo - comment - 15 Mar 2023

You have a syntax code style error in the test https://ci.joomla.org/joomla/joomla-cms/63196/1/29.

avatar sandewt sandewt - change - 15 Mar 2023
Labels Added: ?
avatar laoneo
laoneo - comment - 15 Mar 2023

You need to create a user in your test, add the following code to the file tests/cypress/support/commands/db.js after line 61:

Cypress.Commands.add('db_createUser', (user) => {
  const defaultUserOptions = {
    name: 'test user',
    username: 'test',
    email: 'test@example.com',
    password: '098f6bcd4621d373cade4e832627b4f6', // Is the md5 of the word 'test'
    block: 0
  };
  user = { ...defaultUserOptions, ...user };

  const groupId = user.group_id ?? 2; // Default the group id to registered
  delete user.group_id;

  return cy.task('queryDB', createInsertQuery('users', user)).then((info) => {
    cy.task('queryDB', "INSERT INTO #__user_usergroup_map (user_id, group_id) VALUES ('" + info.insertId + "', '" + groupId + "')").then(() => info);
  });
});

And then replace your test with:

describe('Test that the users latest module', () => {
  it('can load in frontend and displays the latest registered users', () => {
    cy.db_createUser({ username: 'automatedtestuser' })
      .then(() => cy.db_createModule({ module: 'mod_users_latest' }))
      .then(() => {
        cy.visit('/');

        cy.contains('automatedtestuser');
      });
  });
});
avatar laoneo laoneo - change - 17 Mar 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-03-17 13:41:19
Closed_By laoneo
avatar laoneo laoneo - close - 17 Mar 2023
avatar laoneo laoneo - merge - 17 Mar 2023
avatar laoneo
laoneo - comment - 17 Mar 2023

Thanks!

avatar joomdonation
joomdonation - comment - 17 Mar 2023

@laoneo @sandewt On other modules which we converted so far, we usually keep the static method in Helper class for backward compatible purpose, like this one https://github.com/joomla/joomla-cms/blob/4.2-dev/modules/mod_articles_latest/src/Helper/ArticlesLatestHelper.php#L161-L164

Look like you forgot that in this OR ?

avatar sandewt
sandewt - comment - 17 Mar 2023

Look like you forgot that in this OR ?

Does this mean this module will not work in J4.2 and J4.3 ?

avatar laoneo
laoneo - comment - 17 Mar 2023

@joomdonation is right, can somebody make a followup pr?

Does this mean this module will not work in J4.2 and J4.3 ?

It means when we ship this code it can break other extensions or templates. So you need to leave the old function name and signature in place.

avatar sandewt
sandewt - comment - 17 Mar 2023

@joomdonation Glad you discovered this error. ? A teaching moment for me.

avatar laoneo
laoneo - comment - 17 Mar 2023

@sandewt can you make sure that the other module pr's will also be backwards compatible?

avatar sandewt
sandewt - comment - 17 Mar 2023

@sandewt can you make sure that the other module pr's will also be backwards compatible?

Good question.

mod_footer #40066 has/had no static method (in Helper class). This is the other module I modified.

Add a Comment

Login with GitHub to post a comment