Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary entities can break the settings form for XMLsitemap module #42

Closed
jenlampton opened this issue Sep 4, 2017 · 5 comments
Closed
Labels
Milestone

Comments

@jenlampton
Copy link
Member

jenlampton commented Sep 4, 2017

I know it seems unlikely, but I'm getting a multifield related db error on the xmlsitemap settings form:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'multifield.id' in 'where clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {multifield} multifield WHERE (multifield.id > :db_condition_placeholder_0) AND (multifield.type = :db_condition_placeholder_1) ) subquery; Array ( [:db_condition_placeholder_0] => 0 [:db_condition_placeholder_1] => field_list_items ) in xmlsitemap_get_link_type_indexed_status() (line 962 of backdrop/modules/contrib/xmlsitemap/xmlsitemap.module).

However, disabling the multifield module brought the XMLsitemap admin form back to life.

See related: backdrop-contrib/multifield#12

@jenlampton
Copy link
Member Author

jenlampton commented Mar 30, 2018

I've noticed that there are a lot of entities appearing on the xmlsitemap settings form that do not have URLs, and should not have settings for xmlsitemap.

Is there a way to tell if an entity has a path, url, or uri, and exclude it if not? I've got both Flaggings and Multifields showing here now (though multifield is the only one causing this problem).

Some light reading:

@alexfinnarn
Copy link
Contributor

I'm not entirely sure I know where you are talking about, but if it is...
screen shot 2018-04-06 at 3 08 55 pm

then https://github.com/backdrop-contrib/xmlsitemap/blob/1.x-1.x/xmlsitemap.module#L920 seems like you can alter away any entities you didn't want to have sitemap links for. If you look on line #901 they already explicitly disabled some entities, but I'd hope the alter hook can get you where you need to go.

As far as the URI callback, I don't see it mentioned in https://api.backdropcms.org/api/backdrop/core%21modules%21entity%21entity.api.php/function/hook_entity_info/1 as it is in https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_info/7.x. With that URI info, I would think you could ping something to determine if it was a public 200 response and exclude if not.

That's about all I can think of for now.

jenlampton pushed a commit to jenlampton/backdrop-xml-sitemap that referenced this issue May 23, 2018
@jenlampton
Copy link
Member Author

jenlampton commented May 23, 2018

Okay, how about this: Instead of blindly adding XMLsitemap support for any arbitrary entity, we specifically include those we know are safe. Any contrib module that adds an entity can also add XMLsitemap support for it by implementing hook_xmlsitemap_link_info(). I think this is a much safer default than assuming all entities will have URIs, and will need XMLsitemap support.

I've filed a PR at #48 for review.

@jenlampton jenlampton changed the title Multifield module breaks the settings form for XMLsitemap module Arbitrary entities can break the settings form for XMLsitemap module May 23, 2018
@jenlampton jenlampton added the bug label May 23, 2018
jenlampton pushed a commit to jenlampton/backdrop-xml-sitemap that referenced this issue May 23, 2018
jenlampton pushed a commit to jenlampton/backdrop-xml-sitemap that referenced this issue May 23, 2018
@alexfinnarn
Copy link
Contributor

@jenlampton I took a look at this, and it makes sense and seems to function the same as the 1.x branch.

The only question I have is about hook_xmlsitemap_link_info(). In the API file, it lists a lot of keys in the returned array when the PR only has whatever entity_get_info() returns. That might be enough information, but I doubt it has the XMLSitemap specific parts...not sure.

It looks like xmlsitemap_get_link_info() is the only function that calls hook_xmlsitemap_link_info() and it adds defaults for the link types if they don't exist. Right?

I don't use this module currently, so I thought you might know more...thoughts?

alexfinnarn pushed a commit that referenced this issue Jul 20, 2018
Issue #42: Prevent broken settings page by any arbitrary entity.
@alexfinnarn
Copy link
Contributor

I merged this in, but I will add a note on the next release. If someone included content of a module that didn't have hook_xmlsitemap_link_info() but had a URI, they would lose the inclusion once they updated the module.

That can be mitigated by adding a small custom module that implemented hook_xmlsitemap_link_info().

@alexfinnarn alexfinnarn added this to the 1.0.4 milestone Jul 23, 2018
This was referenced Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants