🇬🇧United Kingdom @newaytech

Account created on 27 August 2014, almost 10 years ago
#

Recent comments

🇬🇧United Kingdom newaytech

Thanks kaszarobert - I've applied your patch via composer.json - works a treat - and we're now tracking promo codes in GA4 via GTM - fantastic!

🇬🇧United Kingdom newaytech

Thanks kaszarobert - can I add your commit into my composer.json - or do we need a .patch file for that?

🇬🇧United Kingdom newaytech

I've just noticed that all of the tracking on on of my sites has gone dark since implementing the consent code.

I ticked the box in the module - hoping that the cookieless GA4 machine learning would have our back. Only on deeper diving into the pre-reqs of the cookieless GA4 world - do I then read that you need a minimum of 1000 users per day in order for the model to "learn". See here: https://support.google.com/analytics/answer/11161109?hl=en-GB&utm_id=ad

I've had to turn the consent settings off for now for my client - as all his reports went dark - due to the Behavioural Modelling having insufficient data to fill in the gaps - which kinda sucks for the smaller GA4 users...

I guess the only alternative for the smaller user is to have consent banner - and then only gain insight on the users that actually says yes to analytics_storage...

Anybody else seeing this - I've seen another comment over on another issue here that talks of their reports going dark after ticking the box - and I guess this is the reason.

I personally think that the tick box should be off by default - as unless we make the pre-reqs clear - a lot of smaller users may lose tracking altogether.

🇬🇧United Kingdom newaytech

maybe set the order using dependencies in the libraries.yml?

seeing this:

🇬🇧United Kingdom newaytech

Entry in services.yml

  neway_lintels.breadcrumb:
    class: Drupal\neway_lintels\BreadcrumbBuilder
    arguments: [ '@entity_type.manager', '@entity.repository' ]
    tags:
      - { name: breadcrumb_builder, priority: 1004 }
<?php
namespace Drupal\neway_lintels;

use Drupal;
use Drupal\commerce_product\Entity\Product;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Link;
use Drupal\Core\Routing\LinkGeneratorTrait;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

class BreadcrumbBuilder implements BreadcrumbBuilderInterface {

  use StringTranslationTrait;

  public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityRepositoryInterface $entity_repository) {

    $this->entityTypeManager = $entity_type_manager;
    $this->entityRepository = $entity_repository;

  }

  /**
   * By advent of there being a breadcrumb_builder name in the services.yml file - the Symphony framework runs
   * the below - to see if it is applicable - if it is - the bigger weight wins
   * 
   * Code by Wayne Foster, Neway Technology Ltd, UK
   * 
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match): bool {
    $allowedRoutes = [
      "entity.commerce_product.canonical",
    ];
    $routeName = $route_match->getRouteName();
    //dump("bread applies termID: " . $termID . ", routeName:" . $routeName);
    return (in_array($routeName, $allowedRoutes));
  }

  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match): Breadcrumb {
    $breadcrumb = new Breadcrumb();
    /** @var Product $entityProduct */
    $entityProduct = $route_match->getParameter('commerce_product');
    $termID = Drupal::request()->get('term');
    /** @var \Drupal\taxonomy\TermStorageInterface $parents */
    $parents;

    // We have found a term ID on the URL - use it
    if ($termID && $termID > 0) {
      $parents = $this->entityTypeManager->getStorage('taxonomy_term')
        ->loadAllParents($termID);
    } // if not - then get the first entry on the product category list of taxonomies
    else {
      $taxonomy_field_name = 'product_category';
      /** @var  \Drupal\taxonomy\Entity\Term $productCategory */
      $productCategory = $entityProduct->$taxonomy_field_name->entity;
      //dump("firstCategory", $productCategory);
      $parents = $this->entityTypeManager->getStorage('taxonomy_term')
        ->loadAllParents($productCategory->id());
    }

    // Add a home page link to the start of the breadcrumb render array
    $links[] = Link::createFromRoute(t("Home"), '<front>');
    $linksTax = [];
    // iterate up the taxonomy parents
    foreach ($parents as $parent) {
      $parent = $this->entityRepository->getTranslationFromContext($parent);
      $linksTax[] = $parent->toLink();
    }
    $links = array_merge($links, array_reverse($linksTax));
    $links[] = Link::createFromRoute($entityProduct->getTitle(), '<none>');
    $breadcrumb->setLinks($links);
    $breadcrumb->addCacheContexts(['route', 'url.path','url.query_args']);

    return $breadcrumb;
  }

}
🇬🇧United Kingdom newaytech

Hey Greg, thanks for the tip around the custom code. I ended up using the new BreadcrumbBuilderInterface approach - and pulling the taxonomy ID either from the URL - or the first entry in the list of taxonomies I have on the product. Works a treat - thanks for the hint!

🇬🇧United Kingdom newaytech

Hi folks - just updated to the latest version - and can see that the consent event is fired after the container loaded event. Any further config / GTM config required?

🇬🇧United Kingdom newaytech

I have a requirement here where a commerce product can be reached via several paths. I want to have a URL per taxonomy term - so need to be able to have multiple URL aliases per Commerce Product - all with a single canonical. Does this patch work with Commerce Products - I saw in a note that there was an issue? Thanks for the work here - really enjoying D8/9/10...

🇬🇧United Kingdom newaytech

Fantastic @Berdir - thanks for the contrib...

🇬🇧United Kingdom newaytech

For anyone else landing here - for what it's worth - I rewrote a few GTM triggers and am now using the Google Tag module. I thought that updating the module with the versions numbers would work (thanks for the patch) - but the composer.json file looks at the GIT repo for compatibility.

🇬🇧United Kingdom newaytech

Thanks for the great module folks and support in bringing up to date for D10. Do we have an ETA for a new release with D10 support baked in?

🇬🇧United Kingdom newaytech

Hey @brandon - thanks for checking in. Our setup is:

10:10 AM root@web2:#~ php -v

PHP 8.1.2-1ubuntu2.13 (cli) (built: Jun 28 2023 14:01:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.13, Copyright (c), by Zend Technologies

10:11 AM root@web2:#~ apachectl status

Apache Server Status for localhost (via 127.0.0.1)

Server Version: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2
Server MPM: prefork
Server Built: 2023-03-01T22:43:55
__________________________________________________________________

Current Time: Friday, 07-Jul-2023 10:11:14 BST
Restart Time: Wednesday, 05-Jul-2023 13:36:40 BST
Parent Server Config. Generation: 11
Parent Server MPM Generation: 10
Server uptime: 1 day 20 hours 34 minutes 33 seconds
Server load: 0.05 0.07 0.08
Total accesses: 98105 - Total Traffic: 636.4 MB - Total Duration:
5193991

CPU Usage: u264.91 s114.04 cu6035.18 cs1408.11 - 4.87% CPU load
.611 requests/sec - 4158 B/second - 6.6 kB/request - 52.9432 ms/request

1 requests currently being processed, 6 idle workers

I did try php-fpm - but on the apache bench performance tests I ran - it was slower than out of the box PHP - so kept the install simple.

🇬🇧United Kingdom newaytech

I've been running Ubuntu 22.04.06 for several months now - with the stock PHP running - and our log files are all clear. Could it be something else causing the error @artem_sylchuk ?

🇬🇧United Kingdom newaytech

Arrived here after getting: EntityMetadataWrapperException: Unknown data property commerce_line_items. in EntityStructureWrapper->getPropertyInfo() (line 360 of /etc/apache2/htdocs/drupal-7/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

Ran the commerce repair module but to no avail.

Patch @ #6 fixed for me - thanks folks!

🇬🇧United Kingdom newaytech

In light of the PHP version lock > PHP8.1.2 in Ubuntu 22.04 LTS - what is the recommended approach here? Trust in the backported patches from Ubuntu - or add in "ppa:ondrej/php" - and use 8.1 latest?

🇬🇧United Kingdom newaytech

Just been caught by this too. Upgraded from Ubuntu 20.04.06 LTS > 22.04.2 LTS - then was greeted by the warning on the status page.

My php reports:

HP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies

Hoping that by now the bug has been fixed by the Ubuntu team - and made it into the release number 11.

How do we check for the opcache error in question - log files?

🇬🇧United Kingdom newaytech

same here folks. I added the following to my subthemes variables.scss

// New image variable introduced on 5.5.1
$barrio_path_images: "../images/";

but as others have said - would have expected this to be in the newly introduced variables scss file - for sub themes to then override if required?

🇬🇧United Kingdom newaytech

Hope I'm not breaking the rules by raising this issue again - but the code that was running perfectly (DestructableInterface to run cron) - alas is now throwing an error:

RuntimeException: Failed to start the session because headers have already been sent by "C:\xampp\apache\htdocs\drupal-8\neway-drupal-project\vendor\symfony\http-foundation\Response.php" at line 1239. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 152 of C:\xampp\apache\htdocs\drupal-8\neway-drupal-project\vendor\symfony\http-foundation\Session\Storage\NativeSessionStorage.php).

I've even disabled every other cron task to try and isolate - but to no avail.

I can get this working again by rolling back my code base back to prior to Feb (Upgrading drupal/core (9.5.2 => 9.5.3))

Is there a better way to invoke an immediate queue processing run - whilst still having the securiyy of any failures getting picked up by cron (and also having the item only processed once?)

🇬🇧United Kingdom newaytech

Further discussion here - thanks for the CSP tip!

🇬🇧United Kingdom newaytech

I've implemented a workaround by creating a subdomain, media.mydomain.com - pointing to the same IP as my main site - which still gets served the same Drupal instance by way of domain matching.  I've then implemented a rule (Cloudflare - other solutions work too) - that for incoming requests with "media" in the hostname - adds a header of: 

Content-Security-Policy = frame-ancestors https://*.mydomain.com (this works for uat / www)

The iFrame domain is then set to "https://media.mydomain.com"

Seems to work OK - feels a bit risky to expose a further subdomain to the public - but I'll see how it fairs...

🇬🇧United Kingdom newaytech

I too have just created a subdomain to clean up my status page warning message (using Cloudflare).  Reloaded the page - and the iFramed Vimeo content no longer appears;

Refused to display 'https://mediatest.mydomain.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

Any advice?

🇬🇧United Kingdom newaytech

I am hoping to install the Shopify PHP library for a microservices project - but get an issue with Guzzle versions:

- Root composer.json requires shopify/shopify-api ^4.2 -> satisfiable by shopify/shopify-api[v4.2.0].
- shopify/shopify-api v4.2.0 requires guzzlehttp/guzzle ^7.0 -> found guzzlehttp/guzzle[dev-master, 7.0.0-beta.1, ..., 7.5.x-dev (alias of dev-master)] but the package is fixed to 6.5.8 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

It would be great if we could get some guidance as to how to migrate safely toward Guzzle 7...

🇬🇧United Kingdom newaytech

Thanks for the patch #151 - this applied for me on Drupal 9.5 - and I was able to change the offline page within a minimal theme I have created just for offline pages across all my multisites.

The issues I cannot fathom - is how to elegantly alter the response code of the error page. If we have a database issue - I need a 504 - such that my upstream proxy serves an interim cached site page - any thoughts around this? Previously, we could achieve that using a preprocess hook - but as we're bypassing the drupal ecosystem and going direct via twig - I can't see how to alter the response code.

Production build 0.69.0 2024