Skip to content

Conversation

@alikon
Copy link
Contributor

@alikon alikon commented Jan 10, 2022

Create a console plugin that boot the com_content component and run it from terminal

ie. something like

$content = Factory::getApplication()->bootComponent('com_content')->getMVCFactory();
$model = $content->createModel('Article', 'Administrator',['ignore_request' => true]);
$result = $model->save($article);

Summary of Changes

  • added the getUserState() method to the ConsoleApplication.php
  • don't check session from cli
  • early return from Webauthn plugin when from console

Testing Instructions

Actual result BEFORE applying this Pull Request

image

Expected result AFTER applying this Pull Request

no error in console and article created

References

#36568, #36332, #35818

cc: @wilsonge @laoneo @anibalsanchez

@wilsonge
Copy link
Contributor

Ok so webauthn looks fine. But where else is the user state being used - i don't particularly like having to implement that in the consoleapplication class

@alikon
Copy link
Contributor Author

alikon commented Jan 10, 2022

the main point is we want the console app like 1st citizen ?
we want the console application able to re-use existing CMS code or not ?

i've shared the plugin console code already maybe i've made something wrong there ??
https://github.com/alikon/testcom/blob/main/plugins/console/lorem/src/Extension/LoremIpsumCommand.php

@laoneo
Copy link
Member

laoneo commented Jan 10, 2022

If you have 'ignore_request' => true then the populateState function should not be called. On other places the userstate should not be called.

@wilsonge
Copy link
Contributor

I don't have the ability to test right now - I'll give it a test when I get home but @laoneo is right about the theory of how this should work

@alikon
Copy link
Contributor Author

alikon commented Jan 10, 2022

as you can see i already have set ['ignore_request' => true]

$content = Factory::getApplication()->bootComponent('com_content')->getMVCFactory();
$model = $content->createModel('Article', 'Administrator',['ignore_request' => true]);
$result = $model->save($article);

@laoneo
Copy link
Member

laoneo commented Jan 10, 2022

And where is the user state requested?

@alikon
Copy link
Contributor Author

alikon commented Jan 10, 2022

even then the setUserState() is not a method of ConsoleApplication what i'm missing ?

@chmst chmst changed the base branch from 4.0-dev to 4.1-dev January 31, 2022 18:11
@alikon
Copy link
Contributor Author

alikon commented Feb 14, 2022

let's see what kind of thumb i'll collect cc: @SharkyKZ

@alikon
Copy link
Contributor Author

alikon commented Mar 21, 2022

closed by mistake i suppose

@alikon alikon reopened this Mar 21, 2022
@alikon alikon closed this May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants