Account created on 7 December 2006, over 17 years ago
#

Recent comments

🇬🇧United Kingdom fonant

Hmm... another difference I've found:

The maps that fail to open popups contain an additional command in the AJAX returned:

    {
        "command": "add_css",
        "data": [
            {
                "rel": "stylesheet",
                "media": "all",
                "href": "\/core\/themes\/claro\/css\/classy\/components\/node.css?sfkw3v"
            }
        ]
    },

whereas the maps the work only contain the popup HTML insert command:

    {
        "command": "insert",
        "method": "replaceWith",
        "selector": "[data-leaflet-popup-ajax-entity=\u0022node-2294-map_popup_balloon-en\u0022]",
        "data": "<pop-up-html-here>",
        "settings": null
    }
🇬🇧United Kingdom fonant

Could it be that the AJAX mechanism needs the page to be for a node?

The other maps that break with "< node entity via ajax >" are those for a View that's not embedded in a node display.

These views used to work in previous versions of Leaflet and Drupal. Only broke in the last few days.

🇬🇧United Kingdom fonant

More information, although I haven't narrowed down the symptoms enough yet:

I have a map that has working popups in the node view page (it's a View Reference field), that fails in exactly the same way when I edit the View (without making any changes) and try to get the popups in the View Preview.

Working:

  • Leaflet map view, added to Node display as a View Reference.
  • Map displays entity references from four different Node reference fields from the current node.
  • Four contextual filters using "Content ID from URL" defaults for "When the filter value is NOT available".
  • Popups loading content using "< node entity via ajax >".

Fails:

  • Edit the above View.
  • Enter the NID four times in the Preview arguments (e.g. 1234/1234/1234/1234).
  • Click on a marker in the Preview: popup appears for an instant then disappears. Same error as in summary.
🇬🇧United Kingdom fonant

Patch in #12 works nicely here to fix the problems with facet selections and the browser's Back button. Thanks!

🇬🇧United Kingdom fonant

Patch from https://git.drupalcode.org/project/drupal/-/merge_requests/5391.diff still works here to fix the problem:

patching file core/modules/views/src/Plugin/views/filter/NumericFilter.php
Hunk #1 succeeded at 420 (offset 16 lines).
🇬🇧United Kingdom fonant

Patch #18 works for me to stop the watchdog logs filling up with deprecation warnings. Thanks @gurvindersingh!

🇬🇧United Kingdom fonant

Yes, the code works for me as it now stands, thanks!

As a bonus example, I managed to add the Arctic Circle to my maps using this additional code:

        let points = [
          [66.564, -180],
          [66.564, 180],
        ];
        L.polyline(points, { color: '#0003', weight: 1.5 }).addTo(map);

I was quite surprised that "L" was defined :)

🇬🇧United Kingdom fonant

Unclear about JS filename: "map-script.js" or "js/map.js"?

Should this line:

lMap.bounds = [],

read:

lMap.bounds = [];

 

🇬🇧United Kingdom fonant

Doh! Of course the other way to fix this is to edit each email definition at /admin/commerce/config/emails and just re-save each one.

🇬🇧United Kingdom fonant

I've hacked a workaround for line 111 of commerce_email/src/EmailSender.php, which I think will fix the problem:

'reply-to' => $this->replaceTokens(($email->getReplyTo() ?? ''), $replacements),

Maybe we need an update function to add empty ReplyTo strings for older orders?

🇬🇧United Kingdom fonant

@a.dmitriiev thanks, I was wondering how @djg_tram had managed with his method.

I now have this working with the patch and a custom module with a hook. Needs a bit more work and some tidying before I post it here.

🇬🇧United Kingdom fonant

Phew, this one is still fun to fix if you install geocoder before composer-requiring the providers. I was using just geocoder, and none of the other modules (using the geocoder field in Leaflet maps).

I think the method that finally worked for me was:

  1. drush pm:uninstall geocoder
  2. drush cr
  3. Restart Webserver and PHP processes (Apache, php-fpm, OpenLitespeed, lsphp, etc.)
  4. drush pm:enable geocoder
🇬🇧United Kingdom fonant

@djg_tram - I can managed to get the derived image written to the public filesystem, but how do I tell Drupal to use the public URL for this image, rather than the private /system/files/... one?

🇬🇧United Kingdom fonant

I'd find this useful for a couple of customer sites.

Uploaded full-scale unwatermarked images: private
Derived small-scale and/or watermarked images: public

It's possible to modify the permissions system to give anonymous users access to private derived images for certain styles, but for a site with lots of images it's process-intensive to check permissions for every image. Much better to store the derived images in the public filesystem, so they can be served direct by the web server without needing to bootstrap Drupal for every one.

🇬🇧United Kingdom fonant

Workaround:

Edit configuration to remove non-existent permissions, contained in user.role.*.yml configuration files.

🇬🇧United Kingdom fonant

Patch #2 works to fix the problem for me, too.

🇬🇧United Kingdom fonant

Hi there, development stopped while the Rules module, which this module depends on, was ready for Drupal 8 and later.

Looks like that's nearly the case, I'll have a look at what changes are needed here.

🇬🇧United Kingdom fonant

For what it's worth, the patch in #38 applies with a few small offsets to Drupal 10.1.7 and fixes the problem of active-trail not being applied to menus for View pages.

🇬🇧United Kingdom fonant

Patch #7 fixes the problem for me, but for a different situation: migration source is a CSV file with no headers, and PHP 8.1.26.

🇬🇧United Kingdom fonant

Have just contacted andriuzss and thelmer via their Drupal contact forms, offering to help and pointing to this issue.

🇬🇧United Kingdom fonant

Patch in #26 applies cleanly to 3.x-dev and fixes the problem, Drupal 10. Thanks @MukhtarM!

🇬🇧United Kingdom fonant

Thanks for the speedy update! There's one other link to change, though, in the Description section.

🇬🇧United Kingdom fonant

#8 worked nicely here, too. Thanks @sebasgd

🇬🇧United Kingdom fonant

Using plain diff from MR 2 as a patch works to make the button work here :)

🇬🇧United Kingdom fonant

@PhilY I don't think that's possible, since we don't have direct access to the view in the query alter.

🇬🇧United Kingdom fonant

Patch #12 works to fix the problem for me.

🇬🇧United Kingdom fonant

Patch #5 applies but doesn't make any difference to me, this error appearing when upgrading from migrate_tools 8.x-5.x to 6.x

🇬🇧United Kingdom fonant

An Apache security update causes spaces in filenames to trigger "AH10411: Rewritten query string contains control characters or spaces" errors in the error log, and "Permission denied".

This is because the spaces get double-encoded during the rewrite process. I find that a fix is to change the index.php rewrite rule from

RewriteRule ^(.*)$ index.php?q=$1 "[L]"

to

RewriteRule ^(.*)$ index.php?q=$1 "[B= ?,L,QSA]"

The "B" flag says to not encode spaces and question marks during the rewrite, and QSA allows any itok= URL parameters to be appended to the query string.

🇬🇧United Kingdom fonant

Thanks @weseze for that code!

I found that it duplicated the existing "random seed" sort I had added to the View, calling it random_order_field_2.

That made the think that might be better to look for such a filter already existing, and to modify it, rather than adding a new filter to the view "behind the scenes".

Here's my version of the code:

/**
 * Implements hook_query_alter().
 */
function random_seed_sort_db_query_alter(Drupal\Core\Database\Query\AlterableInterface $query) {
  // Modify any existing random_order_field sort.
  /** @var \Drupal\Core\Database\Driver\mysql\Select $query */
  $order_by = $query->getOrderBy();
  $needs_seed = (array_key_exists('random_order_field', $order_by));
  if ($needs_seed) {
    // Add random sorting with seed by manually calling the service.
    $options = [
      'id' => 'random_seed',
      'table' => 'views',
      'field' => 'random_seed',
      'relationship' => 'none',
      'group_type' => 'group',
      'admin_label' => NULL,
      'order' => 'ASC',
      'exposed' => NULL,
      'expose' => [
        'label' => NULL,
      ],
      'reuse_seed' => NULL,
      'user_seed_type' => 'same_per_user',
      'anonymous_session' => NULL,
      'reset_seed_int' => 0,
      'reset_seed_custom' => 3600, // time in seconds for the seed renewal.
      'plugin_id' => 'views_random_seed_random',
    ];

    /* @var $random_sort \Drupal\views_random_seed\Plugin\views\sort\ViewsRandomSeedRandom */
    $seed = \Drupal::service('views_random_seed.seed_calculator')
      ->calculateSeed(
        $options,
        'MYVIEWNAME', // This is not correct, but only important for cache tag naming.
        'MYDISPLAYNAME', // This is not correct, but only important for cache tag naming.
        \Drupal::database()->driver()
      );
    // Replace rand() with rand(seed).
    $expressions =& $query->getExpressions();
    $expressions['random_order_field']['expression'] = 'rand(' . $seed . ')';
  }
}

This works with MariaDB/MySQL, not sure if it's reliable for all databases.

🇬🇧United Kingdom fonant

Update: spelling should be "Cloudflare" not "Cloudlare" in "Additional CAPTCHA Modules" section of the captcha project page.

🇬🇧United Kingdom fonant

The code is working as designed.

Be careful if you want to modify order data using PayPalEvents::CHECKOUT_CREATE_ORDER_REQUEST => 'addCatnums' and PayPalEvents::CHECKOUT_UPDATE_ORDER_REQUEST, the data is in different places in each.

🇬🇧United Kingdom fonant

Found the problem!

It was my own custom code, that modified the order line item titles sent to PayPal using PayPalEvents::CHECKOUT_CREATE_ORDER_REQUEST and PayPalEvents::CHECKOUT_UPDATE_ORDER_REQUEST.

For the first event, CREATE, the line item titles are stored in $params['purchase_units'][0]['items'].

For the second event, UPDATE, the line item titles are stored in $params[0]['value']['items'].

🇬🇧United Kingdom fonant

Don't know if this is related, but a site I migrated from Drupal 7 to Drupal 9 was failing to display shipping panes for orders.

Turns out I was missing the order shipments field configuration. It seems this is added pragmatically on installing the commerce_shipping module, and I wasn't including it in my site configuration.

Adding these two configuration files re-instated the field and shipping works!

field.storage.commerce_order.shipments.yml
field.field.commerce_order.default.shipments.yml

🇬🇧United Kingdom fonant

Same issue here, copying search_api.settings.yml into the configuration sync directory fixed the issue.

🇬🇧United Kingdom fonant

Most odd. I now catch the Guzzle exception, and log the details. This allows the PayPal orders that fail in the PATCH to continue anyway.

GuzzleHttp\Exception\ClientException

Client error: `PATCH https://api.paypal.com/v2/checkout/orders/xxxxxxxxxxxxxxxxxxxxx` resulted in a `400 Bad Request` response:
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id (truncated...)

{"0":{"op":"replace","path":"\/purchase_units\/@reference_id=='default'","value":{"reference_id":"default","custom_id":"1234","invoice_id":"1234-1234567890","amount":{"currency_code":"GBP","value":"7.5","breakdown":{"item_total":{"currency_code":"GBP","value":"7.5"}}},"items":[{"name":"1296px \u00d7 864px JPEG download","unit_amount":{"currency_code":"GBP","value":"1.25"},"quantity":1,"sku":"DD1296x864"},{"name":"1296px \u00d7 864px JPEG download","unit_amount":{"currency_code":"GBP","value":"1.25"},"quantity":1,"sku":"DD1296x864"},{"name":"1296px \u00d7 864px JPEG download","unit_amount":{"currency_code":"GBP","value":"1.25"},"quantity":1,"sku":"DD1296x864"},{"name":"1296px \u00d7 864px JPEG download","unit_amount":{"currency_code":"GBP","value":"1.25"},"quantity":1,"sku":"DD1296x864"},{"name":"1296px \u00d7 864px JPEG download","unit_amount":{"currency_code":"GBP","value":"1.25"},"quantity":1,"sku":"DD1296x864"},{"name":"1296px \u00d7 864px JPEG download","unit_amount":{"currency_code":"GBP","value":"1.25"},"quantity":1,"sku":"DD1296x864"}]}},"purchase_units":[{"items":[{"name":"AGc19877, 1296px \u00d7 864px JPEG download"},{"name":"AG19650, 1296px \u00d7 864px JPEG download"},{"name":"AB00516, 1296px \u00d7 864px JPEG download"},{"name":"AG06613, 1296px \u00d7 864px JPEG download"},{"name":"AG06615, 1296px \u00d7 864px JPEG download"},{"name":"AG01394, 1296px \u00d7 864px JPEG download"}]}]}

(some possibly-sensitive data replaced with equivalent random text)

This was a shorter order, so nothing to do with the length of the JSON.

According to PhpStorm the JSON is valid.

🇬🇧United Kingdom fonant

My best guess is that the problem occurs when the JSON body is more than 2,040 characters, so for an order with a LOT of line items. I'll do some more testing when I get a spare moment, using an order with a huge JSON description.

🇬🇧United Kingdom fonant

Works for me with Drupal 9 if I patch with #3 then #18.

🇬🇧United Kingdom fonant

I might have found a possible problem, but can't see what is causing it.

Emailing myself the json_encode() of the data, for one order the JSON is broken into two lines, with "! " at the end of the first line and a space at the start of the second line. The first line is 2040 characters long.

This makes the JSON invalid, causing the problem.

Is this a red-herring, caused by emailing the JSON? I don't think so, but could be.

If this is a real symptom, what is inserting "! \n " into the JSON text?

🇬🇧United Kingdom fonant

Added description to Comments.

🇬🇧United Kingdom fonant

Added brief descriptions to the Comments column.

🇬🇧United Kingdom fonant

Added summary comments for each library.

Production build 0.69.0 2024