- Issue created by @wxman
- πΊπΈUnited States wxman
My 'buy_amazon.views.inc' file looks like this:
function buy_amazon_views_data() { $data['node_field_data']['computed_buy_amazon'] = [ 'title' => t('Buy Amazon'), 'entity field' => 'computed_buy_amazon', 'field' => [ 'id' => 'field', ], ]; return $data; }
- π¬π§United Kingdom joachim
That looks like the error you get without the core patch -- have you applied that? It's explained in the README.
- πΊπΈUnited States wxman
I'm sorry but I can't find any links to the core patch at https://www.drupal.org/project/drupal/issues/3349739 π Automatically declare computed base fields to Views Needs work .
Could you provide a link so I can add it to my composer.json and give it a test? - Status changed to Fixed
over 1 year ago 3:28pm 12 July 2023 - π¬π§United Kingdom joachim
Argh I mixed up the issue numbers.
It's this one: https://www.drupal.org/project/drupal/issues/2981047 π Allow adding computed bundle fields in Views Fixed
I'll fix the README.
- πΊπΈUnited States wxman
I'm guessing it's #118 so I added " https://www.drupal.org/files/issues/2023-02-23/2981047-118.patch β " to my composer.json . I ran 'composer update', and 'drush cr', still getting the same error. Isn't that the correct patch for a D10 site? It didn't give me any errors when I ran update, but it also didn't say it was loading the patch.
- π¬π§United Kingdom joachim
The patch says it's for 10.1
You're better off using the diff from the MR, as that is more recent.
> It didn't give me any errors when I ran update, but it also didn't say it was loading the patch.
You mean `composer update` didn't tell you it was deleting Drupal to patch it? Then the patch has not been applied.
- πΊπΈUnited States wxman
Still getting the same PHP error. This is a new 10.1 test site so not much on it but my one test page.
Here's what I did. I ran 'composer require cweagans/composer-patches:~1.0 --update-with-dependencies'
Here is the exact lines I added to my composer.json:"patches": { "drupal/views": { "computed base fields to work in Views": "https://www.drupal.org/files/issues/2023-02-23/2981047-118.patch" } },
I ran composer update and saw:
Gathering patches for root package. Loading composer repositories with package information Updating dependencies Nothing to modify in lock file Installing dependencies from lock file (including require-dev) Nothing to install, update or remove Generating autoload files 49 packages you are using are looking for funding. Use the `composer fund` command to find out more! No security vulnerability advisories found
Maybe I'm using the wrong patch URL?
- πΊπΈUnited States wxman
I finally think I have it! I changed composer.json to:
"patches": { "drupal/core": { "computed base fields to work in Views": "https://git.drupalcode.org/project/drupal/-/merge_requests/4224.diff" } },
Not the errors are gone and the field works in Views. If anyone wants to see my simple module for an example please let me know.
- π¬π§United Kingdom joachim
Well that's applying. But like I said, you might be better off trying the diff from the MR instead.
- πΊπΈUnited States wxman
I thought https://git.drupalcode.org/project/drupal/-/merge_requests/4224.diff was the correct diff
- π¬π§United Kingdom joachim
Sorry -- cross-posted with your comment about applying the diff.
Glad to hear you got it working!
Automatically closed - issue fixed for 2 weeks with no activity.