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

Do not decorate the CLI output if it's explicitly turned off #31877

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

ChristophWurst
Copy link
Member

Fixes #29023

If you look at https://github.com/nextcloud/3rdparty/blob/fd0d5d72f48315cc4f51342dc2d9e82d1dafe0e8/symfony/console/Helper/ProgressBar.php#L496-L497 then you see that it uses the formatter to figure out how "long" the progress character is. In our verbose upgrade procedure this gives a wrong result because our formatter prepends the character with a timestamp and that screws up the length calculation. In the end we get something like -2 or worse for str_repeat's $times argument.

This patch turns off the prepended timestamp if decoration is off. So at https://github.com/nextcloud/3rdparty/blob/fd0d5d72f48315cc4f51342dc2d9e82d1dafe0e8/symfony/console/Helper/Helper.php#L133-L138 it only gives the raw message and nothing more.

This comes with a small downside that the output is not prepended with a timestamp for progress bar lines. IMO that's an acceptable trade-off.

Example

$ php occ maintenance:repair -v
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2022-04-07T12:40:19+00:00  - Repair MySQL collation
2022-04-07T12:40:19+00:00      - All tables already have the correct collation -> nothing to do
2022-04-07T12:40:19+00:00  - Repair mime types
2022-04-07T12:40:19+00:00  - Clean tags and favorites
2022-04-07T12:40:19+00:00      - 0 tags of deleted users have been removed.
2022-04-07T12:40:19+00:00      - 0 tags for delete files have been removed.
2022-04-07T12:40:19+00:00      - 0 tag entries for deleted tags have been removed.
2022-04-07T12:40:19+00:00      - 0 tags with no entries have been removed.
2022-04-07T12:40:19+00:00  - Repair invalid shares
2022-04-07T12:40:19+00:00  - Move .step file of updater to backup location
2022-04-07T12:40:19+00:00  - Add move avatar background job
2022-04-07T12:40:19+00:00      - Repair step already executed
2022-04-07T12:40:19+00:00  - Add preview cleanup background jobs
2022-04-07T12:40:19+00:00  - Migrate oauth2_clients table to nextcloud schema
2022-04-07T12:40:19+00:00      - Update the oauth2_access_tokens table schema.
2022-04-07T12:40:20+00:00      - Update the oauth2_clients table schema.
2022-04-07T12:40:22+00:00  - Fix potential broken mount points
2022-04-07T12:40:22+00:00      - No mounts updated
2022-04-07T12:40:22+00:00  - Repair language codes
2022-04-07T12:40:22+00:00  - Install new core bundle components
2022-04-07T12:40:22+00:00  - Add log rotate job
2022-04-07T12:40:22+00:00  - Clear frontend caches
2022-04-07T12:40:22+00:00      - Image cache cleared
2022-04-07T12:40:22+00:00      - SCSS cache cleared
2022-04-07T12:40:22+00:00      - JS cache cleared
2022-04-07T12:40:22+00:00  - Clear every generated avatar on major updates
2022-04-07T12:40:22+00:00  - Add preview background cleanup job
2022-04-07T12:40:22+00:00  - Queue a one-time job to cleanup old backups of the updater
2022-04-07T12:40:22+00:00  - Cleanup invalid photocache files for carddav
2022-04-07T12:40:22+00:00  - Add background job to cleanup login flow v2 tokens
2022-04-07T12:40:22+00:00  - Remove potentially over exposing share links
2022-04-07T12:40:22+00:00      - No need to remove link shares.
2022-04-07T12:40:22+00:00  - Clear access cache of projects
2022-04-07T12:40:22+00:00  - Reset generated avatar flag
2022-04-07T12:40:22+00:00  - Keep legacy encryption enabled
2022-04-07T12:40:22+00:00  - Check encryption key format
2022-04-07T12:40:22+00:00  - Remove old dashboard app config data
2022-04-07T12:40:22+00:00  - Add job to cleanup the bruteforce entries
2022-04-07T12:40:22+00:00  - Queue a one-time job to check for user uploaded certificates
2022-04-07T12:40:22+00:00  - Repair DAV shares
2022-04-07T12:40:22+00:00  - Add background job to set the lookup server share state for users
2022-04-07T12:40:22+00:00  - Update name of the stored view
2022-04-07T12:40:22+00:00  - Fix component of birthday calendars
2022-04-07T12:40:22+00:00      - 2 birthday calendars updated.
2022-04-07T12:40:22+00:00  - Regenerating birthday calendars to use new icons and fix old birthday events without year
2022-04-07T12:40:22+00:00      - Repair step already executed
2022-04-07T12:40:22+00:00  - Fix broken values of calendar objects
    0 [->--------------------------] < 1 sec2022-04-07T12:40:22+00:00 
2022-04-07T12:40:22+00:00  - Registering building of calendar search index as background job
2022-04-07T12:40:22+00:00      - Repair step already executed
2022-04-07T12:40:22+00:00  - Register building of social profile search index as background job
2022-04-07T12:40:22+00:00      - Repair step already executed
2022-04-07T12:40:22+00:00  - Registering background jobs to update cache for webcal calendars
2022-04-07T12:40:22+00:00      - Added 0 background jobs to update webcal calendars
2022-04-07T12:40:22+00:00  - Registering building of calendar reminder index as background job
2022-04-07T12:40:22+00:00      - Repair step already executed
2022-04-07T12:40:22+00:00  - Clean up orphan event and contact data
2022-04-07T12:40:22+00:00      - 0 events without a calendar have been cleaned up
2022-04-07T12:40:22+00:00      - 0 properties without an events have been cleaned up
2022-04-07T12:40:22+00:00      - 0 changes without a calendar have been cleaned up
2022-04-07T12:40:22+00:00      - 0 cached events without a calendar subscription have been cleaned up
2022-04-07T12:40:22+00:00      - 0 changes without a calendar subscription have been cleaned up
2022-04-07T12:40:22+00:00      - 0 contacts without an addressbook have been cleaned up
2022-04-07T12:40:22+00:00      - 0 properties without a contact have been cleaned up
2022-04-07T12:40:22+00:00      - 0 changes without an addressbook have been cleaned up
2022-04-07T12:40:22+00:00  - Remove activity entries of private events
2022-04-07T12:40:22+00:00      - Removed 0 activity entries
2022-04-07T12:40:22+00:00  - Clean up old calendar subscriptions from deleted users that were not cleaned-up
    0 [----->----------------------] < 1 sec2022-04-07T12:40:22+00:00 
2022-04-07T12:40:22+00:00      - 0 calendar subscriptions without an user have been cleaned up
2022-04-07T12:40:22+00:00  - Fix the share type of guest shares when migrating from ownCloud
2022-04-07T12:40:22+00:00  - Copy the share password into the dedicated column
2022-04-07T12:40:22+00:00  - Set existing shares as accepted
2022-04-07T12:40:22+00:00  - Restore default tags that are missing
2022-04-07T12:40:22+00:00      - Looking up default tags
2022-04-07T12:40:22+00:00      - 136 accounts to check found
 136/136 [============================] 100% < 1 sec2022-04-07T12:40:22+00:00 
2022-04-07T12:40:22+00:00  - Add a generated message-id to all Mail messages that have none
2022-04-07T12:40:22+00:00      - Looking up messages without a message-id
2022-04-07T12:40:22+00:00  - Purify and migrate collected mail addresses
 2/2 [============================] 100% < 1 sec2022-04-07T12:40:22+00:00 
2022-04-07T12:40:22+00:00  - Insert background jobs for all accounts
 136/136 [============================] 100%  1 sec2022-04-07T12:40:23+00:00 
2022-04-07T12:40:23+00:00  - Make Mail itinerary extractor executable
2022-04-07T12:40:23+00:00  - Create or update provisioned Mail accounts
2022-04-07T12:40:23+00:00      - 0 accounts provisioned
2022-04-07T12:40:23+00:00  - Repair Broken Threads for all mail accounts
2022-04-07T12:40:23+00:00      - Repaired threads, 0 messages updated
2022-04-07T12:40:23+00:00  - Update OAuth token expiration times
2022-04-07T12:40:23+00:00  - Create help command
2022-04-07T12:40:23+00:00  - Invalidate access cache for projects conversation provider
2022-04-07T12:40:23+00:00      - Invalidation not required
2022-04-07T12:40:23+00:00  - Cache the user display names
2022-04-07T12:40:23+00:00  - Add background job to check for backup codes
2022-04-07T12:40:23+00:00  - Repair provider registrations
2022-04-07T12:40:23+00:00  - Insert UUIDFix background job for user and group in batches
2022-04-07T12:40:23+00:00  - Remove deprecated refresh time markers for LDAP user records
2022-04-07T12:40:23+00:00  - Populating added database structures for workflows

How to test

  1. Download fake-cli-formatter-error.txt
  2. Apply the patch
  3. Run occ maintenance:repair

On master: 💥
Here: ⛵

@ChristophWurst ChristophWurst added this to the Nextcloud 24 milestone Apr 7, 2022
@ChristophWurst ChristophWurst requested review from st3iny, miaulalala and a team April 7, 2022 12:45
@ChristophWurst ChristophWurst self-assigned this Apr 7, 2022
@ChristophWurst ChristophWurst requested review from ArtificialOwl, vanpertsch and come-nc and removed request for a team April 7, 2022 12:45
@ChristophWurst
Copy link
Member Author

/backport to stable23

@ChristophWurst
Copy link
Member Author

/backport to stable22

@blizzz blizzz mentioned this pull request Apr 7, 2022
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

Upgrade Error - ValueError: str_repeat(): Argument #2 ($times) must be greater than or equal to 0
3 participants