filterByAttribute does not accept attribute "author"

I’m on my Dev Concrete CMS v8.5.13 system, and I tried to use ->filterByAttribute on an “new Concrete\Core\Express\EntryList” type Object, but with the declared Attribute ‘author’ (single quotes, lower case).

The error given is:

So reading through the documentation for Concrete\Core\Express\EntryList : Concrete\Core\Express\EntryList | ConcreteCMS API

I find that there’s a function filterByAuthorUserID, which does not seem to be documented anywhere else, and I only seem to find Japanese examples.

This other method SEEMS to work, but why is it exactly that filterByAttribute cannot handle the built-in attribute “Author” exactly? That seems very out of place.

I don’t believe “author” is an actual “attribute”. I think the following should get you in the right direction…

$pageList->filterByUserID($page->getCollectionUserID())

Edit: For pages anyway. Not certain in regards to express…

Yeah I’m talking about Express Objects here, sorry I should have been more clear on that. @andrew can you clarify on this aspect? I was of the understanding Author (and a few other built-in ones) behaved in the same way as other Express Attributes.

According to the documentation:

This is an instance of the Concrete\Core\Search\ItemList\Database\AttributedItemList class. You can use all the same methods you use to filter pages and files here

You can see in this commit that the method was specifically added to allow filtering by author.

The reason why it doesn’t automatically like other attributes is that the database table field isn’t author, it’s uID. For attributes added to the Express object, a matching field is added matching the attribute name. uID is the convention for storing user IDs throughout the codebase, so it would be an exception to do otherwise.

However, you can always make a PR to add a convenience function that would convert a filter request for the author attribute to filterByAuthorUserID() if you think that there’s a use case for it. I doubt anyone would object.