? ? Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
29 Jun 2020

Pull Request for Issue #29819 .

Summary of Changes

added confirmation step before delete a user

Testing Instructions

php cli/joomla.php user:delete

Actual result BEFORE applying this Pull Request

User deleted without confirmation

Expected result AFTER applying this Pull Request

a confirmation is required

Documentation Changes Required

? probably yes

avatar alikon alikon - open - 29 Jun 2020
avatar alikon alikon - change - 29 Jun 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 Jun 2020
Category Libraries
avatar brianteeman
brianteeman - comment - 29 Jun 2020

Would it not be better to check if the response is "yes" before deleting.

avatar brianteeman brianteeman - test_item - 29 Jun 2020 - Tested unsuccessfully
avatar brianteeman
brianteeman - comment - 29 Jun 2020

I have tested this item ? unsuccessfully on b4856f2

The question is asked but it doesn't wait for a response

C:\htdocs\joomla-cms\cli>php joomla.php user:delete --username test

Delete users

Are you sure you want to delete this user? [yes/no]:

[OK] User test deleted!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29827.
avatar alikon alikon - change - 29 Jun 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-06-29 10:12:22
Closed_By alikon
Labels Added: ?
avatar alikon alikon - close - 29 Jun 2020
avatar alikon alikon - change - 29 Jun 2020
Status Closed New
Closed_Date 2020-06-29 10:12:22
Closed_By alikon
avatar alikon alikon - change - 29 Jun 2020
Status New Pending
avatar alikon alikon - reopen - 29 Jun 2020
avatar alikon
alikon - comment - 29 Jun 2020

implemented the tip #29819 (comment) (1st part only)

avatar brianteeman
brianteeman - comment - 29 Jun 2020

Maybe its me but none of the interactive parts of the cli are working for me. After typing the command I am immediately exited as below

image

image

avatar mbabker
mbabker - comment - 29 Jun 2020

That's the bit I mentioned in #29819 (comment)

It seems like your shell session is being detected as non-interactive and that's causing the issues you're seeing. Whether that's a piece missing in Joomla\Console\Application compared to Symfony\Component\Console\Application or there's some environment missing support, I couldn't tell you, but the fact you're getting abort messages in what appears to be detected as a non-interactive environment is at least correct behavior for that part of the system.

avatar mbabker
mbabker - comment - 29 Jun 2020

@brianteeman See if when you run php cli/joomla.php if either https://github.com/joomla-framework/console/blob/master/src/Application.php#L270 or https://github.com/joomla-framework/console/blob/master/src/Application.php#L276 are being triggered. They shouldn't be based on the screenshots you have, but those are the only spots which flip the console input to a non-interactive state in the Joomla application class (symfony/symfony@87bd741 was never ported from Symfony so the env var that added support for isn't a factor here). Otherwise, you're going to need to add something like a var_dump(debug_backtrace());die; inside Symfony\Component\Console\Input\Input::setInteractive() to see what's flipping the switch; the input API defaults to interactive so something is forcing it to non-interactive, it'd be good to figure out what that something is.

avatar toivo toivo - test_item - 29 Jun 2020 - Tested successfully
avatar toivo
toivo - comment - 29 Jun 2020

I have tested this item successfully on 4dd4edb

Tested successfully in Beta2-dev of 29 June.

Wampserver 3.2.2 Apache 2.4.43 MySQL 8.0.20 PHP 7.4.7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29827.

avatar brianteeman
brianteeman - comment - 29 Jun 2020

@mbabker looks like it may be a php bug with 7.4.0 symfony/symfony#34702

avatar brianteeman
brianteeman - comment - 30 Jun 2020

I can confirm my problem was a bug in php 7.4.0 and its all good in 7.4.7

just needs the non-interactive thing @wilsonge requires


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29827.

avatar pabloarias pabloarias - test_item - 9 Jul 2020 - Tested successfully
avatar pabloarias
pabloarias - comment - 9 Jul 2020

I have tested this item successfully on 4dd4edb

Works fine with PHP version 7.3.19 and Joomla beta3-dev.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29827.

avatar richard67
richard67 - comment - 20 Jul 2020

@alikon Could you check @wilsonge 's suggestion above? If so, let me know if you will modify this PR here further. I'll wait with RTC a bit.

avatar alikon
alikon - comment - 20 Jul 2020

@richard67 i hope i've understood correctly @wilsonge
using the non-interactive flag -n, --no-interaction Flag to disable interacting with the user

php cli/joomla.php user:delete --username aaaa -n

delete the user in a non interactive way

avatar richard67
richard67 - comment - 20 Jul 2020

@alikon Your last change looks wrong to me: First you check for the confirmation and then if it's running interactive. That's the wrong order, if I'm not wrong, because as far as I know PHP checks from left to right.

avatar alikon
alikon - comment - 20 Jul 2020

ok let me change the order then

avatar Quy
Quy - comment - 20 Jul 2020

@alikon OK to close #29819?

avatar alikon
alikon - comment - 20 Jul 2020

yes i think so now

avatar particthistle particthistle - test_item - 25 Jul 2020 - Tested successfully
avatar particthistle
particthistle - comment - 25 Jul 2020

I have tested this item successfully on e695e5d

Tested on PHP 7.4.8, Joomla 4.0.0-beta3-dev

avatar astridx
astridx - comment - 25 Jul 2020

i created a user (super user) with the name te. The user admin is active.
My test before applying this patch

$ php cli/joomla.php user:delete

 Please enter a username:
 > admin

Delete users
============

                                                                                
 [ERROR] You can't delete the last active Super User                            
                                                                                

$ php cli/joomla.php user:delete

 Please enter a username:
 > test

Delete users
============

                                                                                
 [ERROR] test does not exist!                                                   
                                                                                

$ php cli/joomla.php user:delete

 Please enter a username:
 > te

Delete users
============

                                                                                
 [OK] User te deleted!     

Then I applied the path via
git fetch origin pull/29827/head:patch-117
git checkout patch-117
i created a user (super user) with the name te. The user admin is active.

After that

$ php cli/joomla.php user:delete

 Please enter a username:
 > admin

Delete users
============

 Are you sure you want to delete this user? (yes/no) [no]:
 > yes

                                                                                                       
 [ERROR] You can't delete the last active Super User                                                   
                                                                                                       

$ php cli/joomla.php user:delete

 Please enter a username:
 > testt

Delete users
============

                                                                                                       
 [ERROR] testt does not exist!                                                                         
                                                                                                       

$ php cli/joomla.php user:delete

 Please enter a username:
 > te

Delete users
============

 Are you sure you want to delete this user? (yes/no) [no]:
 > jsdklfjdslfls

 ! [NOTE] User not deleted                                                                             

$ php cli/joomla.php user:delete

 Please enter a username:
 > te

Delete users
============

 Are you sure you want to delete this user? (yes/no) [no]:
 > no

 ! [NOTE] User not deleted                                                                             

$ php cli/joomla.php user:delete

 Please enter a username:
 > te

Delete users
============

 Are you sure you want to delete this user? (yes/no) [no]:
 > yes

                                                                                                       
 [OK] User te deleted!                                                                                 
                                                                                                       
avatar astridx astridx - test_item - 25 Jul 2020 - Tested successfully
avatar astridx
astridx - comment - 25 Jul 2020

I have tested this item successfully on e695e5d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29827.

avatar alikon alikon - change - 25 Jul 2020
Status Pending Ready to Commit
avatar alikon
alikon - comment - 25 Jul 2020

rtc


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29827.

avatar wilsonge wilsonge - change - 25 Jul 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-07-25 22:57:35
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 25 Jul 2020
avatar wilsonge wilsonge - merge - 25 Jul 2020
avatar wilsonge
wilsonge - comment - 25 Jul 2020

Thanks!

Add a Comment

Login with GitHub to post a comment