Done -> FS#375
In the mean time I’ve investigated this a bit more...
It appears that getDocumentObject only is called from within the document parser class and furthermore it is
always called with method ’id’. In fact it makes no sense to do it with the ’alias’ method at all as far as I can see. It is entirely possible to have several pages with the same alias (although this only makes sense when using friendly alias paths). If so, getDocumentObject would always return the same pageObject. You can easily test this as follows:
Create a page with the alias ’test’ under root.
Create a page in a folder, say ’testfolder’ and also give it the alias ’test’
Now create the below snippet (call it ’textDocObject’ if you want) and place it in the body of both documents.
<?php
$pageObject = $modx->getDocumentObject("alias",$modx->documentObject['alias']);
$output = "<p>Document ID = " . $modx->documentObject['id'] . "</p>";
$output .= "<p>Page Object ID = " . $pageObject['id'] . "</p>";
return $output;
?>
Make sure you have ’friendly alias’ and ’friendly alias path’ set to ’yes’ and view both pages. You’ll see that in one case it will return identical ID’s and on the other they will differ. So , even from the point of using getDocumentObject from snippets or plugins it is not useful to call it with the ’alias’ method.
Ergo, the function could be simplified drastically without jeopardizing any existing code (I would think, because if there is code that uses it this way, eventually it would produce unwanted results) Now if the function used the modx->documentListing and was fed the whole virtual dir instead of just the alias things would be rather different. (I’d like that a lot in fact ).
Sorry if this is getting a bit lengthy...