Problem/Motivation

If a comment contains a forward slash, for example, in a path or URL, it will be stripped when displayed at update.php or using drush updb.

A comment like this (from media_library_post_update_default_administrative_list_to_table_display()):

/**
 * Sets /admin/content/media to the table display of the 'media' view.
 */

Gets converted to this:

8705 - Sets admincontentmedia to the table display of the 'media' view.

The code doing this is this (line 339 of update.inc):

$description = str_replace(["\n", '*', '/'], '', $func->getDocComment());

This same code is also in UpdateRegistry.php, which affects how it's displayed when running drush updb.

Media Library Updates are missing some characters such as the forward slash for '/admin/content/media' when using update.php

stripped characters

Proposed resolution

Remove the single character replacements, which are too "greedy" or just ill-conceived and strip the start and end of the comment first, then any instance of "\n *" (i.e. a new line, a space and an asterisk, which happens on each new comment line).

-          $description = str_replace(["\n", '*', '/'], '', $func->getDocComment());
+          $description = rtrim($func->getDocComment(), "\n */");
+          $description = ltrim($description, "/**\n * ");
+          $description = trim(str_replace("\n *", "", $description), ' ');

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

oknate created an issue. See original summary.

oknate’s picture

See media_library_post_update_default_administrative_list_to_table_display(). Maybe the URL needs quotes?

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

oknate’s picture

Title: Media Library Updates have stripped characters at update.php » URLs not supported in update comments when using update.php
Issue summary: View changes
oknate’s picture

Title: URLs not supported in update comments when using update.php » URLs stripped of forward slashes in update comments when using update.php
oknate’s picture

Status: Active » Needs review
StatusFileSize
new848 bytes
oknate’s picture

Issue summary: View changes
oknate’s picture

This is also an issue with drush updb:

  media_library   defau       post-update     Sets admincontentmedia to the table   
                  lt_ad                       display of the 'media' view.   
oknate’s picture

StatusFileSize
new1.73 KB

This fixes it for drush updb as well.

oknate’s picture

Issue summary: View changes

The last submitted patch, 6: 3087184-5.patch, failed testing. View results

oknate’s picture

StatusFileSize
new961 bytes
new2.67 KB

Adding test coverage for the update.php portion. I'm not sure how to test drush comment output yet.

The last submitted patch, 9: 3087184-9.patch, failed testing. View results

oknate’s picture

StatusFileSize
new3.72 KB
new4.63 KB

Adding test coverage for UpdateRegistry.php, which is what drush uses.

oknate’s picture

StatusFileSize
new3.29 KB
new4.72 KB
new6.48 KB

This should fix test failures.

oknate’s picture

Title: URLs stripped of forward slashes in update comments when using update.php » Update comments display improperly due to str_replace
oknate’s picture

Title: Update comments display improperly due to str_replace » Update comments display improperly due to poor usage of str_replace
oknate’s picture

Issue summary: View changes
oknate’s picture

Issue summary: View changes

The last submitted patch, 12: 3087184-11--FAIL.patch, failed testing. View results

The last submitted patch, 12: 3087184-11.patch, failed testing. View results

The last submitted patch, 14: 3087184-12.patch, failed testing. View results

The last submitted patch, 14: 3087184-12--FAIL.patch, failed testing. View results

oknate’s picture

Title: Update comments display improperly due to poor usage of str_replace » Update.php comments display improperly due to poor usage of str_replace

The last submitted patch, 15: 3087184-15--FAIL.patch, failed testing. View results

effulgentsia’s picture

Priority: Minor » Normal

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Component: media system » update.module
Issue summary: View changes
Status: Needs work » Closed (outdated)
Issue tags: +Bug Smash Initiative
StatusFileSize
new16.89 KB

This has been fixed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.