From http://open.silverstripe.org/ticket/4892
Re googlesitemaps current build, I noticed choosing the option of "Not Indexed' did not seem to persist when reloading a page and editing something else on it.
It saves to the database correctly when first changed, but then saves incorrectly as 0 or null if one reloads the page in the admin interface and then saves and publishes again. The problem is that the DropdownField? selected value is incorrectly set to "Auto-set based on page depth" (0 or null) when generating the Google Sitemap tab, so reloading and saving the page changes this value without user intervention.
I fixed this when I noticed the code in the function getPriority() returns 0 when it reads a -1 from the database. When I removed this conditional and let it return a -1, it behaves correctly and the value of the dropdown is set to what is stored in the db and hence does not change without user intervention.
I am unsure however, if this 'bug' was intentional (the presence of this conditional raises the question), and by fixing this problem I may have broken something else that counted on that conditional returning 0 when the db yields -1.
Does that conditional serve some other purpose? If not, I suggest committing this to the svn tree.
--tim
in GoogleSitemapDecorator?.php
function getPriority() {
if(!$this->owner->getField('Priority')) {
$parentStack = $this->owner->parentStack(); $numParents = is_array($parentStack) ? count($parentStack) - 1: 0; return max(0.1, 1.0 - ($numParents / 10));
} elseif($this->owner->getField('Priority') == -1) {
return 0;
} else {
return $this->owner->getField('Priority');
}
}
was changed to
function getPriority() {
if(!$this->owner->getField('Priority')) {
$parentStack = $this->owner->parentStack(); $numParents = is_array($parentStack) ? count($parentStack) - 1: 0; return max(0.1, 1.0 - ($numParents / 10));
} else {
return $this->owner->getField('Priority');
}
}
see also my message to the dev google group at:
http://groups.google.com/group/silverstripe-dev/browse_thread/thread/2db9de143457e48a/76cebe3d0c1230f3#76cebe3d0c1230f3
See ticket: http://open.silverstripe.org/ticket/4790