I've encountered a slight problem. Quite easy to fix in my site but it could be worse.
I have a [Document Type] called "Member".
I also have a [Member Type] called "Member".
When I use the gui to create members all is well.
When I use Member.MakeNew problems occur.
I first call MemberType.GetByAlias("Member").
It seems like the member is assigned the [Document Type] and not the [Member Type].
Should it be possible retrieving a [Document Type] with the method MemberType.GetByAlias?
I assume the problem could be avoided by ensuring unique aliases by using prefixes like: "dtMember" and "mtMember", which is the way I will go, but a better way would be if there either is a:
* Strict separation of types of nodes
or
* Node aliases must be unique
The latter would be very easy to implement by just creating a unique index on the nodeAlias IF it weren't for that all and everything is stored in the same table.
Either it must be solved by the CRUD (or rather CRU) part of the umbraco API for handling nodes of different types, or by fixing MemberType.GetByAlias (and other similar functions if the problem is in more places).
I can't do either on a running platform. Had stored procedures been used it would have been possible to hotfix live quite easily.
Now it's in the code.
Current code:
Code:return new MemberType(int.Parse(SqlHelper.ExecuteScalar(CMSNode._ConnString, CommandType.Text, "select nodeid from cmsContentType where alias = '" + sqlHelper.safeString(Alias) + "'").ToString()));
This code results in taking the first found something whatever that is.
Even nodes added by the cms users can be selected which means that any time a node is added, even a media file, the bug can come alive.
I suggest something like this: (not tested, just a notepad hack)
Code:
string sql = string.Format(
@"
SELECT nodeId
FROM cmsContentType
WHERE alias = '{0}'
AND nodeObjectType = '{0}'",
sqlHelper.safeString(Alias),
_objectType); // = 9b5416fb-e72f-45a9-a07b-5a9a2709ce43
object result = SqlHelper.ExecuteScalar(CMSNode._ConnString, CommandType.Text, sql);
MemberType mt = null;
if(null != result)
{
int nodeId = (int)result;
mt = new MemberType(nodeId);
}
//Null if not found, MemberType if found.
return mt;
Also I would very much like a table with the nodeObjectTypes. It would be nice to have even it the system wouldn't need it. It would make the db quite a lot more intuitive.
I haven't looked at the other functions performing similar stuff. There might be updates needed there too.
/Carl
(Looking forward to a small update.)