ENHANCEMENT Allowing to skip linktracking sync in Filesystem::sync() (useful for large bulk updates) (AIR-28)

This commit is contained in:
Ingo Schommer 2011-09-27 14:02:35 +02:00
parent e3cceb6038
commit d6c050c6ce

View File

@ -123,8 +123,13 @@ class Filesystem extends Object {
* back to the equivalent filesystem record. * back to the equivalent filesystem record.
* *
* @param int $folderID Folder ID to sync along with all it's children * @param int $folderID Folder ID to sync along with all it's children
* @param Boolean $syncLinkTracking Determines if the link tracking data should also
* be updated via {@link SiteTree->syncLinkTracking()}. Setting this to FALSE
* means that broken links inside page content are not noticed, at least until the next
* call to {@link SiteTree->write()} on this page.
* @return string Localized status message
*/ */
static function sync($folderID = null) { static function sync($folderID = null, $syncLinkTracking = true) {
$folder = DataObject::get_by_id('Folder', (int) $folderID); $folder = DataObject::get_by_id('Folder', (int) $folderID);
if(!($folder && $folder->exists())) $folder = singleton('Folder'); if(!($folder && $folder->exists())) $folder = singleton('Folder');
@ -145,15 +150,17 @@ class Filesystem extends Object {
} }
// Update the image tracking of all pages // Update the image tracking of all pages
if(class_exists('SiteTree')) { if($syncLinkTracking) {
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter; if(class_exists('SiteTree')) {
if(class_exists('Subsite')) Subsite::$disable_subsite_filter = true; $origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
foreach(DataObject::get("SiteTree") as $page) { if(class_exists('Subsite')) Subsite::$disable_subsite_filter = true;
// syncLinkTracking is called by SiteTree::onBeforeWrite(). foreach(DataObject::get("SiteTree") as $page) {
// Call it without affecting the page version, as this is an internal change. // syncLinkTracking is called by SiteTree::onBeforeWrite().
$page->writeWithoutVersion(); // Call it without affecting the page version, as this is an internal change.
$page->writeWithoutVersion();
}
if(class_exists('Subsite')) Subsite::disable_subsite_filter($origDisableSubsiteFilter);
} }
if(class_exists('Subsite')) Subsite::disable_subsite_filter($origDisableSubsiteFilter);
} }
return _t( return _t(