Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4] Rebuild mod_users_latest with new Joomla 4 structure #40092

Merged
merged 18 commits into from
Mar 17, 2023

Conversation

sandewt
Copy link
Contributor

@sandewt sandewt commented Mar 13, 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

@sandewt
Copy link
Contributor Author

sandewt commented Mar 13, 2023

Related to:

#40066 : mod_footer
#39931 : mod_custom

Delete Factory class
`folder module="mod_users_latest">mod_users_latest.php</folder>`
becomes
`<folder module="mod_articles_latest">services</folder>`
@laoneo
Copy link
Member

laoneo commented Mar 13, 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).

@sandewt
Copy link
Contributor Author

sandewt commented Mar 13, 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.

@toivo
Copy link
Contributor

toivo commented Mar 14, 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>

replace  $user = $app->getIdentity();
@sandewt
Copy link
Contributor Author

sandewt commented Mar 14, 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.]

mod_users_latest system test
@laoneo
Copy link
Member

laoneo commented Mar 15, 2023

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

syntax error
@laoneo
Copy link
Member

laoneo commented Mar 15, 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');
      });
  });
});

laoneo and others added 5 commits March 15, 2023 10:54
create a user for the test
registerDate: '2023-03-01 20:00:00'
params: ''
richard67 added a commit to richard67/joomla-cms that referenced this pull request Mar 29, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Mar 29, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Mar 30, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Apr 4, 2023
@sandewt sandewt deleted the patch-4 branch April 26, 2023 08:58
richard67 added a commit to richard67/joomla-cms that referenced this pull request Apr 30, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request May 9, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request May 22, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request May 23, 2023
laoneo pushed a commit that referenced this pull request May 23, 2023
* Add deleted files from #40066 , #40092 , #40142 and #40146

* Add deleted files from #40180 and #40174

* Add deleted files from #39527 , #39535 , #40169 and #40173

* Add deleted files from #39552 , #39931 , #39628 and #40328

* Add deleted files from #40216

* Add deleted files from #40561 , #40190 and #40205
richard67 added a commit to richard67/joomla-cms that referenced this pull request May 27, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jun 3, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jun 8, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jun 23, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jul 3, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Jul 23, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Aug 12, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Aug 19, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Aug 20, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Aug 22, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Sep 1, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Sep 4, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Sep 4, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Sep 14, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Sep 19, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Sep 26, 2023
richard67 added a commit to richard67/joomla-cms that referenced this pull request Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants