🇺🇸United States @rondog469

Account created on 18 March 2016, about 9 years ago
#

Recent comments

🇺🇸United States rondog469

@adamps, can you expand on your answer? How do I change the weight? I am trying to set a variable inside HOOK_mailer_post_render but am getting an error saying "setVariable function is only valid in phases 0-1, called in 3.". I'm sure I also need to change post_render, but I cant find what to change it to.

🇺🇸United States rondog469

This seems to be a duplicate of this one 💬 Search api autocomplete not working Postponed: needs info . OP claims you cannot add a "fulltext search" field to the view which is where my problem is. I did not see a solution in there. I also found this thread 📌 Field for autocomplete filter not exists in view VIEW_NAME, display VIEW_DISPLAY_NAME Closed: cannot reproduce which someone suggests adding the "fulltext search" field to the view but that is just not possible when using fulltext search

🇺🇸United States rondog469

Our team noticed that if we uncheck "Download uploaded files", we do get all the submissions. Our forms have file upload fields and we need them included in the download so unchecking that is not really an option.

🇺🇸United States rondog469

I created a patch that will expose the datetime field plus include its operator

🇺🇸United States rondog469

@mahde unfortunately, no. They weren't very helpful. If it has to do with load balancing, I tried to set the tmp dir using this guide but no luck. https://docs.pantheon.io/guides/filesystem/tmp I linked them to this thread and they told me to ask @jrockowitz because of his comment in #7. The link jrockowitz shared is for acquia, but I think the first one I linked to is trying to achieve the same thing.

🇺🇸United States rondog469

I think I am running into this issue as well. I have 350 submissions. When I download all of them, it downloads them in chunks of 10, skips 10, grabs 10, skips 10 etc so I end up with half. This particular site is on pantheon. It works fine on my local, but once on pantheon it does this behavior. Sometimes it'll grab the opposite half. That may point to a load balancing issue which I have tried remeding by specifying the tmp path but no luck so far. I ended up opening a ticket with pantheon. If I try and grab the latest 30, it only returns 10 for me. If I choose Latest and specify anything <= 10 it returns 0...very strange

🇺🇸United States rondog469

Looking at line 1382 of CommerceWebformOrderHandler.php

foreach (['uuid', 'id', 'sku'] as $key) {
  $entity_keys[] = $entity_type->getKey($key);
}

'sku' is always false as that key does not exist.

I think I managed to fix this for my case though. When setting up the webform handler, for "Purchasable entity" I've been using a hidden input field that contains the SKU. That is what was working on 2.x. I have since changed it to "Reference one..." and manually added my two products via the autocomplete field that appears when choose reference one.

This is by no means the correct solution. I only have 2 products so this was easy. There is definitely something wrong with the way the $prepared_data['purchasable_entity'] is set in 3.x

🇺🇸United States rondog469

@ckng as I find myself back in this same spot, did you come up with a solution? Our round for security updates are upon us again. If not I am going to look into that loadEntityValue you found and see if I can come up with a patch

🇺🇸United States rondog469

@ccjjmartin I think we're trying to move away from "donutdan4114/shopify" in favor of Shopify's official API.

🇺🇸United States rondog469

one more thing to add to @rpayanm's list was to be sure to set the new DSN transport to default. Mine was the "Sendmail" one that was there when I installed the module. I didn't realize I had to set the default.

🇺🇸United States rondog469

For someone who simply needs to watch and compile scss to css gulp is pretty straight forward. Someone mentioned Vite, but it sounds overkill for what I would need. Do you have any suggestions @VladimirAus?

🇺🇸United States rondog469

I did not find a solution and I did try updating all the dependencies in my package.json. Just for reference, here are the contents of my deps. The entire file contains a lot more custom rules for linting so I wont include that.

...
  "devDependencies": {
    "@babel/core": "^7.16.12",
    "@babel/eslint-parser": "^7.16.5",
    "@babel/preset-env": "^7.16.11",
    "autoprefixer": "^10.4.2",
    "babel-loader": "^9.0.0",
    "browser-sync": "^2.27.7",
    "cross-env": "^7.0.3",
    "dotenv": "^14.3.2",
    "eslint": "^8.8.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "eslint-plugin-yml": "^1.0.0",
    "gulp": "^4.0.2",
    "gulp-babel": "^8.0.0",
    "gulp-plumber": "^1.2.1",
    "gulp-postcss": "^9.0.1",
    "gulp-rename": "^2.0.0",
    "gulp-sass": "^5.1.0",
    "gulp-sourcemaps": "^3.0.0",
    "gulp-tap": "^2.0.0",
    "husky": "^8.0.0",
    "lint-staged": "^14.0.0",
    "postcss-scss": "^4.0.3",
    "sass": "^1.49.0",
    "stylefmt": "^6.0.3",
    "stylelint": "^15.0.0",
    "stylelint-config-standard-scss": "^11.0.0",
    "webpack-stream": "^7.0.0"
  },
...

Our custom gulpfile. This just watches js and scss files inside themes/custom as well as modules/custom and outputs them to a compiled dist/style.css and dist/app.js

require('dotenv').config()
const { watch, parallel, series, src, dest } = require('gulp')
const fs = require('fs')
const path = require('path')
const rename = require('gulp-rename')
const tap = require('gulp-tap')
const babel = require('gulp-babel')
const plumber = require('gulp-plumber')
const sass = require('gulp-sass')(require('sass'))
const autoprefixer = require('autoprefixer')
const postcss = require('gulp-postcss')
const sourcemaps = require('gulp-sourcemaps')
const browsersync = require('browser-sync').create()
const webpack = require('webpack-stream')
const cp = require('child_process')

// Covers pantheon and acquia environments.
let rootPath = './web'
if (fs.existsSync('./docroot')) {
  rootPath = './docroot'
}
let originalPath
function javascript() {
  return src([rootPath + '/themes/custom/**/js/*.js'])
    .pipe(plumber())
    .pipe(tap(function (file) {
      //  Webpack was removing original file path so couldn't set dirname properly.
      originalPath = path.join(path.dirname(file.dirname), 'dist')
    }))
    .pipe(webpack({
      mode: 'production',
      devtool: false,
      output: {
        filename: 'app.js',
      },
      module: {
        rules: [{
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env']
            }
          }
        }]
      }
    }))
    .pipe(rename(function (file) {
      // Generates a "themename/dist" string.
      const dist = path.parse(originalPath)
      const theme = path.parse(dist.dir)
      file.dirname = theme.base + '/' + dist.base
    }))
    .pipe(dest(rootPath + '/themes/custom/'))
    .pipe(browsersync.stream())
}

function css() {
  return src([rootPath + '/themes/custom/**/scss/style.scss'])
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass({ outputStyle: 'expanded' }))
    .pipe(postcss([autoprefixer()]))
    .pipe(sourcemaps.write())
    .pipe(rename(function (file) {
      // Generates a "themename/dist" string.
      file.dirname = path.join(path.dirname(file.dirname), 'dist');
    }))
    .pipe(dest(rootPath + '/themes/custom/'))
    .pipe(browsersync.stream())
}

function moduleCss() {
  return src([rootPath + '/modules/custom/**/scss/style.scss'])
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass({ outputStyle: 'expanded' }))
    .pipe(postcss([autoprefixer()]))
    .pipe(sourcemaps.write())
    .pipe(rename(function (file) {
      // Generates a "themename/dist" string.
      file.dirname = path.join(path.dirname(file.dirname), 'dist');
    }))
    .pipe(dest(rootPath + '/modules/custom/'))
    .pipe(browsersync.stream())
}

function browserSync() {
  browsersync.init({
    open: 'external',
  })
}

function browserSyncReload() {
  browsersync.reload()
}

function clearCache(cb) {
  return cp.spawn('drush', ['cache-rebuild'], { stdio: 'inherit' })
    .on('close', cb)
}

exports.build = parallel(javascript, css)
exports.default = function () {
  browserSync()
  watch(rootPath + '/themes/custom/**/templates/**/*.twig', series(clearCache, browserSyncReload))
  watch([rootPath + '/themes/custom/**/**/*.scss'], css)
  watch([rootPath + '/modules/custom/**/**/*.scss'], moduleCss)
  watch([rootPath + '/themes/custom/**/**/*.js', '!' + rootPath + '/themes/custom/**/dist/app.js'], javascript)
}
🇺🇸United States rondog469

I am also having this issue unfortunately. Running it my local I have a different error than what it gives me on pantheon

My local shows this:

PHPStan command failed:
/Applications/MAMP/bin/php/php8.1.13/bin/php-cgi /Users/ronnieswietek/Sites/xxx/xxxt/vendor/bin/phpstan analyse --memory-limit=1500M --error-format=json --configuration=/Applications/MAMP/tmp/php/upgrade_status/deprecation_testing.neon /Users/ronnieswietek/Sites/xxx/xxx/web/modules/custom/my_custom_module

Command output:
X-Powered-By: PHP/8.1.13 Cache-Control: must-revalidate, no-cache, private Date: Mon, 02 Oct 2023 18:16:06 GMT Content-Type: application/json X-UA-Compatible: IE=edge Content-language: en X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Expires: Sun, 19 Nov 1978 05:00:00 GMT X-Generator: Drupal 9 (https://www.drupal.org) {"message":"Scanned my_custom_module"}

Command error:
Empty.

When I run it on pantheon, I get the error shown in the OP

🇺🇸United States rondog469

Hi @facine that is indeed the entity type It is set to. I didn't change anything from before. Here is the yml from the webform export

handlers:
  commerce_webform_order_handler:
    id: commerce_webform_order
    handler_id: commerce_webform_order_handler
    label: 'Commerce Webform Order Handler'
    notes: ''
    status: true
    conditions: {  }
    weight: -49
    settings:
      store:
        store_entity: 7d425a50-ed52-4e92-810a-e3957d083cd8
        bypass_access: false
      order_item:
        order_item_id: ''
        purchasable_entity_type: commerce_product_variation
        purchasable_entity: ':input[name="sku"]'
        title: ''
        overwrite_price: false
        amount: ''
        currency: ''
        quantity: ':input[name="number_of_guests"]'
        order_item_bundle: default
        fields: {  }
      checkout:
        new_cart: false
        empty_cart: true
        combine_cart: true
        owner: ':input[name="email"]'
        owner_id: ''
        billing_profile_id: ''
        billing_profile_bypass_access: false
        payment_gateway_id: ''
        payment_method_id: ''
        cancel_url: ''
        hide_add_to_cart_message: true
        redirect: true
        order_state: ''
        order_data: ''
      sync: false
      webform_states:
        - completed
      order_states:
        - _new_order_
        - 'order_default:draft'
      prevent_update: false
      debug: false

In the handler settings, I have "Purchasable entity type" set to "Product Variation" and that appears to be setting it to that "commerce_product_variation" value.

Also looking at the form on prod (2.0.0-beta2) and my local (3.0.0-beta5), "Purchasable Entity Type" is not available in version 2.

I am posting pics of my form settings. Basically the hidden SKU field on my webform contains the commerce product value. I onlyhave two products, "public_tour" and "private_tour".

🇺🇸United States rondog469

thank you @Dom! Yeah I am not too sure what I did with that first patch. I think I uploaded the wrong version at the time because it indeed does not work. Yours look good to me

🇺🇸United States rondog469

Sure, but as I said before I dont think this is super flexible for all cases. I wrote this for our specific needs. It could be a good starting point though.

/**
 * Implements hook_preprocess_office_hours().
 *
 * A normal week with no exceptions is 7 items long, Sunday-Saturday.
 * If there is an exception this array will be longer. Let's figure out
 * which day of the week needs to be overridden. See template for integration.
 *
 * @TODO Array length might not be reliable especially if a day of the week is
 * consistently closed. Perhaps search for the exception label instead.
 */
function HOOK_preprocess_office_hours(&$vars) {
  $hourLength = count($vars['office_hours']);
  $keys = array_keys($vars['office_hours']);
  if ($hourLength > 7) {
    for ($i = 8; $i < $hourLength; $i++) {
      $key = $keys[$i];
      $dayOverrideKey = date('w', $vars['office_hours'][$key]['day']);
      $vars['items'][$dayOverrideKey]['exception'] = $vars['items'][$i];
    }
  }
}

That code outputs something like this. You can see I have an exception for Tuesday july 4th

^ array:9 [▼
  0 => array:4 [▼
    "label" => "Sunday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  1 => array:4 [▼
    "label" => "Monday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  2 => array:5 [▼
    "label" => "Tuesday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
    "exception" => array:4 [▼
      "label" => "Tuesday, July 4, 2023: "
      "slots" => array:2 [▼
        "#type" => "markup"
        "#markup" => "10:00 am-3:00 pm"
      ]
      "comments" => array:2 [▼
        "#type" => "markup"
        "#markup" => "Closing early for July 4th"
      ]
      "suffix" => "<br />"
    ]
  ]
  3 => array:4 [▼
    "label" => "Wednesday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  4 => array:4 [▼
    "label" => "Thursday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  5 => array:4 [▼
    "label" => "Friday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  6 => array:4 [▼
    "label" => "Saturday: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  7 => array:4 [▼
    "label" => "Exception hours"
    "slots" => array:2 [▶]
    "comments" => array:2 [▶]
    "suffix" => "<br />"
  ]
  8 => array:4 [▼
    "label" => "Tuesday, July 4, 2023: "
    "slots" => array:2 [▶]
    "comments" => array:2 [▼
      "#type" => "markup"
      "#markup" => "Closing early for July 4th"
    ]
    "suffix" => "<br />"
  ]
]

Here is our modified twig template. Aside from showing the exception hours I also change the current day label to read as TODAY

{% set classes = "office-hours office-hours-status--" ~ (is_open ? "open" : "closed") %}
<div{{ attributes.addClass(classes) }} id="{{ id }}">
  {% set today =  'now'|date('w') %}
  {% for key, item in items %}
    {% set currentClass = '' %}
    {% if today == key %}
      {% set currentClass = 'current' %}
    {% endif %}
    <div class="office-hours__item {{ currentClass }}">
      {% if item.label %}
        <span class="office-hours__item-label" style="width: {{ label_length * 0.60 }}em;">
          {% if today == key %}
            Today:
          {% else %}
            {{ item.label }}
          {% endif %}
        </span>
      {% endif %}
      {% if item.slots['#markup'] is not empty %}
        <span class="office-hours__item-slots">
          {% if item.exception %}
            {{ item.exception.slots }}
          {% else %}
            {{ item.slots }}
          {% endif %}
        </span>
      {% endif %}
      {% if item.comments['#markup'] is not empty %}
        <span class="office-hours__item-comments">{{ item.comments }}</span>
      {% endif %}
      {% if item.exception.comments['#markup'] is not empty %}
        <span class="office-hours__item-comments">{{ item.exception.comments }}</span>
      {% endif %}
      <span>{{ item_separator | raw }}</span>
    </div>
  {% endfor %}
</div>
🇺🇸United States rondog469

Yes that sounds similar. I ended up doing a hook_preprocess_office_hours and modified the twig template. Basically the gist was in the preprocess, check if an exception exists. If it does, find which day the exception is for and add an exception property to that day of the weeks render array. In the twig file I check if that property exists and if it does display that instead of the normal time slot

{% if item.slots['#markup'] is not empty %}
  <span class="office-hours__item-slots">
    {% if item.exception %}
      {{ item.exception.slots }}
    {% else %}
      {{ item.slots }}
    {% endif %}
  </span>
{% endif %}
🇺🇸United States rondog469

This shouldn't be closed. This patch no longer works so I am attaching an updated patch that works with the latest version, 3.0.0. It would not successfully apply because the composer.json had different version numbers.

🇺🇸United States rondog469

@smutgrave, I dont know the exact scenario, but this happened when viewing the user profile picture field after migrating a drupal 7 site to drupal 9. On the d7 site the field in question did not have a size set. After migrating the size value of the field was set to just "KB", no number prepended to it.

🇺🇸United States rondog469

@mondrake Yup I just did and I linked back to this one for reference purposes https://www.drupal.org/project/drupal/issues/3352728 🐛 \Drupal\Component\Utility\Bytes::toNumber() - $size must be a number in PHP 8+ Needs work

🇺🇸United States rondog469

looking more into this issue, with this patch I can now edit my user picture field and this problem has to stem from migrating. The file size value set on this field is just "KB". The is incorrect. Even though the display value on the field's file size limit is just "KB", when I output `$size` its "1024".

Again, this issue must stem from migrating, but I also think $size should still be casted as a number anyway.

🇺🇸United States rondog469

apologies, this issue was for Bytes::toInt which is now deprecated. My issue is with the Bytes::toNumber function albeit it still applies.

🇺🇸United States rondog469

This patch should have probably included a fix for the line above the else:

return round($size * pow(self::KILOBYTE, stripos('bkmgtpezy', $unit[0]))); is returning the same error.

🇺🇸United States rondog469

@hudri thank you! You saved me a lot of time on debugging probably.

Production build 0.71.5 2024