A patch towards a final Drupal 10 Juicebox

Created on 16 January 2024, 10 months ago
Updated 22 January 2024, 10 months ago

Problem/Motivation

We have made great progress towards a "stable" Drupal 10 version of Juicebox.
The patch in this issue was developed in PHPstorm locally and incorporates a number of proposed fixes including
- many "nits" suggested by PHPstorm that will fix spelling and cosmetic issues that have been embedded in Juicebox code for years.
- some "nits" suggested by PHPstorm relating to putting return types into functions or documenting variable types. These will not have any operational impact but move the code quality forward
- fixes for the deprecated watchdog function (in three of the Juicebox programs). These could use review.

Let's see how testing goes.

I've tried to make my Windows git version compliant with recommended Drupal git standards. This could be a work in progress, no way to know without testing it live.

πŸ“Œ Task
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States fkelly

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fkelly
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 10 months ago
    Patch Failed to Apply
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 10 months ago
    Patch Failed to Apply
  • πŸ‡ΊπŸ‡ΈUnited States fkelly
  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Obviously the first version of the patch failed miserably. Need a good version of the code up on the repository to apply to 4.0.x. Probably a week before I get to it because of other priorities.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Hopefully this corrects the errors in the storm.patch file uploaded previously.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 10 months ago
    Patch Failed to Apply
  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    The "only" patch failures on this iteration were the overall info.yml and 8 of the programs in the tests directory, which I believe may not even be in the 4.0.x directory.

    I will need help on the next steps: I could modify the patch to not include the failing programs but that is just avoiding the issue. I think that, substantively the patches are needed (though some may need further review) but not sure how to proceed. There doesn't seem to be a "branch" that I can use reliably to run the patch against .... if that's even needed. Or do I need to run a merge of some sort.

    Many of the patches are "innocuous" things. A few, such as the ones getting rid of the deprecated watchdog function, do need review.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    Review needed code:

    Phpstorm frequently kicks off "error" messages that may or may not have an effect on the operation of the Juicebox code. Since I am not the most expert PHP coder, I'm reluctant to just "blindly" make changes that I don't fully understand.

    Juicebox_load_js is once program that PHPSTORM has "reservations about". Here is an article that explains the issue(s).

    https://www.linkedin.com/pulse/var-vs-let-const-easiest-explanation-ever....

    Here is replacement code based on PHPstorm's suggestions. I'm not ready to promote it as a patch but rather to submit it for review.

    /**
     * @file
     * Attaches the behaviors for the Juicebox module.
     */
    
    class juicebox {
      constructor(newGallery) {
        
      }
    
    }
    
    (function ($, Drupal) {
      Drupal.behaviors.juicebox = {
        attach: function (context, settings) {
          if (typeof settings['juicebox'] !== 'undefined') {
            const galleries = settings['juicebox'];
            // Loop-through galleries that were added during this request.
            for (const key in galleries) {
              if (galleries.hasOwnProperty(key) && document.getElementById(key)) {
                // Instantiate each new gallery via the library. Take a copy to be
                // safe as we will delete the original settings reference after.
                const newGallery = $.extend({}, galleries[key]);
                new juicebox(newGallery);
                // We only want to hold on to the settings for this gallery long
                // enough to pass it on as a proper Juicebox object. In fact,
                // holding on longer can cause problems on sequential AJAX updates
                // of the same gallery, so it's probably best to delete it.
                delete galleries[key];
              }
            }
          }
        }
      };
    })(jQuery, Drupal);
    
  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    The function watchdog_exception was deprecated for Drupal 10. In pre-Drupal 10 Juicebox code this function was used in 3 programs:

    JuiceBoxXmlControllerField.php
    JuiceBoxXmlControllerBase.php
    JuiceBoxFieldFormatter.php

    In my patch in #5 I provided tentative replacements. The code "works" on my 10.2.2 test and production systems using the bleeding edge Juicebox Code with many of Luke's fixes in it. I'm not sure how to test further to see if issues that would have caused a watchdog exception to occur would be handled properly by my replacements. I could "quote" the code here but a more detailed review would be a better idea.

  • πŸ‡ΊπŸ‡ΈUnited States fkelly

    filtermarkup ...

    JuiceBoxGallery.php contains a function that attempts to make sure that only html codes that are valid are allowed in a JuiceboxGallery.

    protected function filterMarkup(string $markup): string {
    // Set inline html5 elements that are safe in a Juicebox gallery. Ref:
    // https://www.w3.org/html/wg/drafts/html/master/single-page.html#phrasing-content
    $valid_elements = "

Production build 0.71.5 2024