Content published by Unknown not returned by query

Topics: Core, General, Troubleshooting
Oct 9, 2013 at 5:30 PM

I have built a very simple test site using Orchard both from WebMatrix and Visual Studio with the following results. I'd like to know if this any of the following:
  • A mistake on my part
  • By design correct behaviour
  • A reportable issue with Orchard
My site comprises
  • A new Content type called "Proposal" with a single text field "Name"
  • A Custom form for the new "Proposal" content type added to the main menu and set to save on submit
  • Permissions for anonymous users to submit the new custom form
  • A Workflow to react to the new "Proposal" content type being created by publishing the new content
  • A query to return the all instances of the new "Proposal" content type
  • A query to return instances of the new "Proposal" content type where the name field contains a "k"
I run the site, and create a new proposal by filling in the form ensuring that the name data contains a "k" and submitting. If I check the admin dashboard I can see the new content and its state is published. The content has been published by "Unknown".

If I preview the "All Proposals" query I see the new content.
If I preview the "Proposals where name contains a k" query I see no results.

If I then un-publish the content and re-publish from the admin dashboard and re-run the "Proposals where name contains a k" query I see the content.

Any offers of information as to how I might work around this and/or fix it would be much appreciated.


Oct 10, 2013 at 3:14 PM
I have made some progress and that progress has allowed me to continue with my solution. However its not a fix for the original issue.

It turns out that the CustomForm module has two POST controller actions, one to save (submit.Save) and one to publish (submit.Publish). By using the publish action I was able to correctly publish new content and that content appears in the query preview.

Further it turns out that the save (submit.Save) action will save a draft if the content type is draftable but will publish the content if the content type is NOT draftable. Hence I am able to work around my issue by making my content type non draftable.

This is a work around for my problem but does not answer the original question.

I have also looked into the original problem where apparently published content is not returned from the query. It appears to be to do with the join to FieldIndexPartRecord in the following HQL which returns no results when the content has been published via WorkFlow.
select distinct civ.Id as Id
from Orchard.ContentManagement.Records.ContentItemVersionRecord as civ
join civ.ContentItemRecord as ci
join ci.ContentType as ct
join ci.FieldIndexPartRecord as fieldIndexPartRecord
join fieldIndexPartRecord.StringFieldIndexRecords as InsuranceProposalProposerName
where (ct.Name in ('InsuranceProposal')) AND (InsuranceProposalProposerName.PropertyName = 'InsuranceProposal.ProposerName.' and InsuranceProposalProposerName.Value like '%k%' ) AND (civ.Published = True)
order by civ.Id