From d61d6008da2ecef2bbc83e002ee9c0d74fd1e0ba Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 17 Nov 2014 18:00:51 +1100 Subject: [PATCH 1/2] Adds internal event for when a package is installed which gives access to the InstalledPackage instance which contains a PackageInstance reference that contains all of the files installed in the package --- .../businesslogic/Packager/Installer.cs | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/src/umbraco.cms/businesslogic/Packager/Installer.cs b/src/umbraco.cms/businesslogic/Packager/Installer.cs index 49541df9b3..dfb76d1f7c 100644 --- a/src/umbraco.cms/businesslogic/Packager/Installer.cs +++ b/src/umbraco.cms/businesslogic/Packager/Installer.cs @@ -76,7 +76,7 @@ namespace umbraco.cms.businesslogic.packager /// Indicates that the package contains legacy property editors /// public bool ContainsLegacyPropertyEditors { get; private set; } - + public bool ContainsStyleSheeConflicts { get; private set; } public IDictionary ConflictingStyleSheetNames { get { return _conflictingStyleSheetNames; } } @@ -138,7 +138,7 @@ namespace umbraco.cms.businesslogic.packager } #region Public Methods - + /// /// Imports the specified package /// @@ -175,7 +175,7 @@ namespace umbraco.cms.businesslogic.packager return tempDir; } } - + public int CreateManifest(string tempDir, string guid, string repoGuid) { //This is the new improved install rutine, which chops up the process into 3 steps, creating the manifest, moving files, and finally handling umb objects @@ -256,14 +256,16 @@ namespace umbraco.cms.businesslogic.packager } catch (Exception ex) { - LogHelper.Error("Package install error", ex); + LogHelper.Error("Package install error", ex); } } insPack.Save(); + + } } - + public void InstallBusinessLogic(int packageId, string tempDir) { using (DisposableTimer.DebugDuration( @@ -292,7 +294,7 @@ namespace umbraco.cms.businesslogic.packager #region DataTypes var dataTypeElement = rootElement.Descendants("DataTypes").FirstOrDefault(); - if(dataTypeElement != null) + if (dataTypeElement != null) { var dataTypeDefinitions = packagingService.ImportDataTypeDefinitions(dataTypeElement, currentUser.Id); foreach (var dataTypeDefinition in dataTypeDefinitions) @@ -309,7 +311,7 @@ namespace umbraco.cms.businesslogic.packager var insertedLanguages = packagingService.ImportLanguages(languageItemsElement); insPack.Data.Languages.AddRange(insertedLanguages.Select(l => l.Id.ToString())); } - + #endregion #region Dictionary items @@ -335,7 +337,7 @@ namespace umbraco.cms.businesslogic.packager //if (saveNeeded) { insPack.Save(); saveNeeded = false; } #endregion - + #region Templates var templateElement = rootElement.Descendants("Templates").FirstOrDefault(); if (templateElement != null) @@ -404,7 +406,7 @@ namespace umbraco.cms.businesslogic.packager if (alias.IsNullOrWhiteSpace() == false) { - PackageAction.RunPackageAction(insPack.Data.Name, alias, n); + PackageAction.RunPackageAction(insPack.Data.Name, alias, n); } } } @@ -416,22 +418,24 @@ namespace umbraco.cms.businesslogic.packager new ApplicationTreeRegistrar(); insPack.Save(); + + OnPackageBusinessLogicInstalled(insPack); } } - /// - /// Remove the temp installation folder - /// - /// - /// + /// + /// Remove the temp installation folder + /// + /// + /// public void InstallCleanUp(int packageId, string tempDir) { - if (Directory.Exists(tempDir)) - { - Directory.Delete(tempDir, true); - } + if (Directory.Exists(tempDir)) + { + Directory.Delete(tempDir, true); + } } - + /// /// Reads the configuration of the package from the configuration xmldocument /// @@ -466,10 +470,10 @@ namespace umbraco.cms.businesslogic.packager { badFile = true; } - + if (destPath.ToLower().Contains(IOHelper.DirSepChar + "bin")) { - badFile = true; + badFile = true; } if (destFile.ToLower().EndsWith(".dll")) @@ -514,9 +518,9 @@ namespace umbraco.cms.businesslogic.packager ContainsMacroConflict = true; if (_conflictingMacroAliases.ContainsKey(m.Name) == false) { - _conflictingMacroAliases.Add(m.Name, alias); + _conflictingMacroAliases.Add(m.Name, alias); } - } + } } } @@ -548,8 +552,8 @@ namespace umbraco.cms.businesslogic.packager ContainsStyleSheeConflicts = true; if (_conflictingStyleSheetNames.ContainsKey(s.Text) == false) { - _conflictingStyleSheetNames.Add(s.Text, alias); - } + _conflictingStyleSheetNames.Add(s.Text, alias); + } } } } @@ -566,7 +570,7 @@ namespace umbraco.cms.businesslogic.packager } catch { } } - + /// /// This uses the old method of fetching and only supports the packages.umbraco.org repository. /// @@ -586,9 +590,9 @@ namespace umbraco.cms.businesslogic.packager return "packages\\" + Package + ".umb"; } - + #endregion - + #region Private Methods /// @@ -655,7 +659,7 @@ namespace umbraco.cms.businesslogic.packager string tempDir = IOHelper.MapPath(SystemDirectories.Data) + Path.DirectorySeparatorChar + packageId.ToString(); //clear the directory if it exists if (Directory.Exists(tempDir)) Directory.Delete(tempDir, true); - Directory.CreateDirectory(tempDir); + Directory.CreateDirectory(tempDir); var s = new ZipInputStream(File.OpenRead(zipName)); @@ -697,5 +701,13 @@ namespace umbraco.cms.businesslogic.packager } #endregion + + internal static event EventHandler PackageBusinessLogicInstalled; + + private static void OnPackageBusinessLogicInstalled(InstalledPackage e) + { + EventHandler handler = PackageBusinessLogicInstalled; + if (handler != null) handler(null, e); + } } } From c47d59a25726d4b1b5ee4d7a818724c1df3d26b7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 18 Nov 2014 10:50:56 +1100 Subject: [PATCH 2/2] Fixes: U4-5820 List View showing content of complete site after deleting last page of data --- .../Persistence/Repositories/ContentRepository.cs | 5 ++++- .../views/propertyeditors/listview/listview.controller.js | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index e05ca04bdb..ac341756e3 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -694,7 +694,10 @@ namespace Umbraco.Core.Persistence.Repositories IEnumerable result; var pagedResult = Database.Page(pageNumber, pageSize, modifiedSQL, sql.Arguments); totalRecords = Convert.ToInt32(pagedResult.TotalItems); - if (totalRecords > 0) + //NOTE: We need to check the actual items returned, not the 'totalRecords', that is because if you request a page number + // that doesn't actually have any data on it, the totalRecords will still indicate there are records but there are none in + // the pageResult, then the GetAll will actually return ALL records in the db. + if (pagedResult.Items.Any()) { // Parse out node Ids and load content (we need the cast here in order to be able to call the IQueryable extension // methods OrderBy or OrderByDescending) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js index 379504cf71..0e7b7e3caa 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/listview.controller.js @@ -86,8 +86,14 @@ function listViewController($rootScope, $scope, $routeParams, $injector, notific $scope.pagination[i] = { index: i, name: i + 1 }; } + //NOTE: This might occur if we are requesting a higher page number than what is actually available, for example + // if you have more than one page and you delete all items on the last page. In this case, we need to reset to the last + // available page and then re-load again if ($scope.options.pageNumber > $scope.listViewResultSet.totalPages) { $scope.options.pageNumber = $scope.listViewResultSet.totalPages; + + //reload! + $scope.reloadView(id); } });