Problem/Motivation

I am trying to programmaticaly substitute values inside the "headers" field or "post_parameter" fieldset provided by this module when creating a new feed, but I can't access it.
What tokens should I use to set the values of

  • config>x-default>fetcher>headers
  • config>x-default>fetcher>post_parameter

here?
feed form config fetcher

Is it possible at all?
I guess not since I've already tried on similar fields provided by similar module feeds_fetcher_headers
(see here: https://www.drupal.org/project/eca/issues/3309212#comment-14858852)
and there are no tokens listed for [feeds:config] (it doesn't exist).

Proposed resolution

Maybe those config items need to be registered somewhere? I'm not an expert :(

Using config_inspector module I can see there is no configuration data regarding httpfetcherpost's fetcher_configuration:
feeds fetcher configuration data

Thank you 🙏🏻

Comments

kopeboy created an issue. See original summary.

kopeboy’s picture

Issue summary: View changes
kopeboy’s picture

Issue summary: View changes
StatusFileSize
new204.41 KB
kopeboy’s picture

Issue summary: View changes
kopeboy’s picture

Title: How to set the headers and post body programmaticaly in the feed form » Can't set headers and post body programmaticaly in the feed form, missing schema
Component: Documentation » Code
Category: Support request » Bug report

Config inspector is even signaling an error "missing schema" for the fetcher_configuration on any feed where I've enabled this module's fetcher.

Maybe that's the cause I can't set the values programmatically? 🤨

sleitner’s picture

Component: Code » Documentation
Category: Bug report » Support request

I'm not sure what you want to do exactly? In PHP or in the Drupal backend UI?

To change something in a Drupal/feed/Entity/Feed object, you should load the entity and use the functions of its class. Never change values directly. Maybe you can do this in the debugger, but this is not the way PHP works.

and there are no tokens listed for [feeds:config] (it doesn't exist).

Tokens are read only.

Maybe those config items need to be registered somewhere? I'm not an expert :(

These values are not in config, they are in the Feed entity object.

Using config_inspector module I can see there is no configuration data regarding httpfetcherpost's fetcher_configuration

Feed-URL, Headers, POST parameters are not part of the Feedtype configuration.

Feeds_fetcher_post module is an plugin for the Feeds module and it only uses its methods.

kopeboy’s picture

I'm trying to set the values of the headers and post parameters fields using ECA (which is a module similar to Rules).

On the feed type I have fields that hold the values I need and I'm trying to substitute them when the feed form is saved.
Just like I would do with form_alter & form_submit, but (through ECA module) in a more flexible way and without coding custom modules.

I can already substitute the feed source, but the same method is not working for the form fields provided by this module.

sleitner’s picture

Title: Can't set headers and post body programmaticaly in the feed form, missing schema » Can't set headers and post body programmaticaly in the feed form
Status: Active » Closed (works as designed)

The module reads the config from the feed through this function:
$feed_config = $feed->getConfigurationFor($this->plugin);

and writes it with this function:
$feed->setConfigurationFor($this->plugin, $feed_config);

I'm not familiar with ECA, I guess you have to ask your questions there.

kopeboy’s picture

Title: Can't set headers and post body programmaticaly in the feed form » Missing schema in fetcher_configuration
Component: Documentation » Code
Category: Support request » Bug report
Priority: Normal » Major
Status: Closed (works as designed) » Active
StatusFileSize
new27.3 KB

I'm returning here because I have issues ONLY when I use the fetcher provided by this module AND by feeds_fetcher_headers module
Your module is inspired by that, so I guess it's not a coincidence.

I repeat: even without creating any feed, just creating a feed_type with the fetcher:
- Download from URL additional POST parameters (this module)
- Download from URL additional Headers (inspiring module)
throws one error at /admin/reports/status#error
"The site's configuration does not match the associated schema."
for each of the feed_types using said fetchers.
At admin/reports/config-inspector/feeds.feed_type.MY_FEED_TYE/list you can see this:

missing schema error in Drupal Feed's fetcher_configuration

That, I think, makes me unable to target the feed.config.fetcher properties/values programmatically (with ECA).
Trying to edit the feed.config.fetcher.post_parameter creates a value in feed.config.post_parameter:MY_VALUE instead of feed.config.fetcher.post_parameter:MY_VALUE

kopeboy’s picture

kopeboy’s picture

Priority: Major » Critical

Now I'm stuck with errors, I cannot even content types that referenced to entity types that were referenced in a feed created with the fetcher from this module.

Apparently without a proper schema my past feeds were not deleted correctly, the error I get is:

RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "clear own MY_DELETED_FEED_TYPE feeds", "create MY_DELETED_FEED_TYPE feeds", "delete own MY_DELETED_FEED_TYPE feeds", "import own MY_DELETED_FEED_TYPE feeds", "schedule_import own MY_DELETED_FEED_TYPE feeds", "update own MY_DELETED_FEED_TYPE feeds", "view MY_DELETED_FEED_TYPE feeds". in Drupal\user\Entity\Role->calculateDependencies() (line 206 of /var/www/html/web/core/modules/user/src/Entity/Role.php).

Not sure if this permission issue depends on a Core bug though..

kopeboy’s picture

I leave this here in case it can help others:
I was able to fix the error by

  1. exporting my site configuration (/admin/config/development/configuration/full/export)
  2. uncompress it and search for my broken feed_type_name,
  3. deleting the lines with them in the .yml files that I found,
  4. importing back the single changed files (/admin/config/development/configuration/single/import)
  5. after selecting the right configuration type,
  6. pasting the contents of the file, in the "advanced" section setting typing the id of the entity that the file was defining,
  7. importing.
sleitner’s picture

Priority: Critical » Normal
StatusFileSize
new408 bytes

I'm not a config schema expert. Feel free to test the attached file.

sleitner’s picture

Status: Active » Fixed

File is added in 1.2.0-alpha1

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.