Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank page created when duplicating a page in 3.1 beta 3 #689

Closed
ipalette opened this issue Apr 29, 2013 · 13 comments
Closed

Blank page created when duplicating a page in 3.1 beta 3 #689

ipalette opened this issue Apr 29, 2013 · 13 comments

Comments

@ipalette
Copy link

In beta 3 of 3.1 and were excited to see the duplicate feature back. One problem we see though is that when we duplicate a page is creates a ghost page that we see after we refresh.

Browser: Firefox 20 and Safari 6.03

chillu referenced this issue Apr 30, 2013
… in 2.4 See ticket #7602

Conflicts:
	javascript/CMSMain.Tree.js
	templates/Includes/CMSMain_TreeView.ss
@yunusaslam
Copy link

Duplicating the page creates a blank duplicate also exists in the latest release SS 3.1.0 Beta3. Also the duplicate this and sub pages do not duplicate the sub pages....

@fvue
Copy link

fvue commented May 29, 2013

I can confirm the problem in SilverStripe-3.1.x-dev

Steps to reproduce the problem:

  1. Goto admin/pages
  2. Right-click page "Home" and select { Duplicate | This page only }
  3. You're redirected to an edit page. Add "?flush" to the url, e.g. "admin/pages/edit/show/nn?flush".
  4. Within the tree pane you see that besides the duplicate, an additional blank page is created

What did you expect?

Besides the duplicate, no additional (blank) page should've been created.

@fvue
Copy link

fvue commented May 29, 2013

I think the patch underneath fixes the problem of the additional blank page:

framework$ git diff
diff --git a/model/DataObject.php b/model/DataObject.php
index fc5fb6b..9b54d95 100644
--- a/model/DataObject.php
+++ b/model/DataObject.php
@@ -491,7 +491,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
                                        }
                                }
                        } else {    //one-to-one relation
-                               $destinationObject->$name = $relations;
+                               // Is this the Page.Parent relation to the SiteTree-root?
+                               // NOTE: This conditional prevents creation of blank page when
+                               //       duplicating page under root (GitHub issue #689)
+                               if (! ($name == 'Parent' && $sourceObject instanceOf Page && $relations instanceOf SiteTree)) {
+                                       // No, this is not the Page.Parent-relation to the SiteTree-root;
+                                       // Duplicate relation
+                                       $destinationObject->$name = $relations;
+                               }
                        }
                }
        }

@yunusaslam
Copy link

Thanks a lot this is working perfect.. Thanks a looootttt... But have issue with Duplicate this page and subpage also..
When i try to Duplicate this page and subpages I get error... The sserrors have the following
"Duplicate entry '341' for key 'PRIMARY' (http://www.hf-dev.com/admin/pages/duplicatewithchildren/2?SecurityID=3e210281f91775846bc5fe7a0bf220f762e39538)"
The Page and its subpage get duplicated but the subpage get duplicated under the parent page which i choose to duplicate..

For ex :
-->Home /// Say this is parent page
|__>TestPage /// This is subpage

Now when i choose to duplicate this page and its subpages ite generates the above error and the page goes blank.. When i refresh to admin/pages the page duplicated in the below given manner

-->Home /// The main parent page which was chosen to create duplicate
|> TestPage
|
> TestPage /// ############# Subpage gets duplicated here.. Which is wrong must be below...

-->Home /// Duplicated Parent created

Your help is really needed.. I am trying this since past few weeks but didnt get the issue... Thanks in advance...

@fvue
Copy link

fvue commented May 29, 2013

I can't reproduce the problem. I don't get an error. I get a messagebox saying "Duplicated 'Home' and children succesfully". I have tested using plain SilverStripe-3.1.x-dev branch using these steps:

  1. Right-click "Home" and select { Add new page here | Page }. Change Page name to "TestPage" and click "Save & Publish"
  2. Right-click "Home" and select { Duplicate | This page and subpages }

The output is as I expected:

I'm redirected to an edit page of the duplicated Home. Only bug is that I need to refresh or flush to see the duplicated subpage in the hierarchy. After duplicating and refresh/flush my tree looks like this:

Home
|- TestPage
About Us
Contact Us
Page not found
Server error
Home DRAFT   # Duplicated page
|- TestPage DRAFT   # Duplicated subpage

The url you sent needs a login/password? The error you sent makes me think your database primary key sequence is out of sync with the real ID's stored in the database table. Can you give it a try with a clean database?

@yunusaslam
Copy link

Actually that is the URL which is generated when i click on the Duplicate this and its sub pages and all page goes blank.. Sserrors.txt have the above mentioned error. I tried emptying the database but i don't exactly know which tables to truncate.. So that rest of the things wont get affected.. If i empty the whole db and then dev/build.. And when i try to run the pages there is an error "Error While Connecting to Db".. Can u please tell me few particular tables which are related with the above errors..

@fvue
Copy link

fvue commented May 30, 2013

I think these tables are used concerning the SiteTree:

  • SiteTree
  • SiteTree_Live
  • SiteTree_versions
  • Page
  • Page_Live
  • Page_versions

Maybe you can try doing a manual sql INSERT on the tables to see if the primary keys work.

@yunusaslam
Copy link

Thanks for your such a great support.. I tried truncating the tables which u mentioned above.. This time i got a different error in the sserrors.. I got something like this :
"Error at framework/core/Object.php line 633: Uncaught Exception: Object->__call(): the method 'setvalue' does not exist on 'Image'".. This one is completely different than the previous one... May be primary key is working fine...
So what is your suggestion about this error ??

@fvue
Copy link

fvue commented Jun 3, 2013

Can you try if you get the same error with a clean checkout of SilverStripe-3.1, the latest beta? Then we know if the error is in your project code or in SilverStripe. If the error is in your code we should continue this thread elsewhere I think, maybe in the forum.

@yunusaslam
Copy link

No i am not getting this on a new installation of SilverStripe-3.1.. I tried this before opening this thread.. Still i am unable to figure this one out.. I know that helping this way would become quite difficult. Coz u wont get exactly what the issue is.. Is there any other way to figure out this.. One more better option is that i upgrade my system, but if i upgrade i will loose all my changes and will have to do them back.. Thanks...

@chillu
Copy link
Member

chillu commented Jun 3, 2013

I've singled out the issue with subpages not appearing until a hard refresh into issue #763. The original "ghost page" issue has been fixed a while ago. On the primary key error, this seems to be an issue with your specific database which is impossible for us to track down, so I'm closing this. If you can single out how the inconsistent state in your database was created in the first place (and SS is the culprit), feel free to open another more specific issue.

@chillu chillu closed this as completed Jun 3, 2013
@fvue
Copy link

fvue commented Jun 3, 2013

If the "ghost page" issue has been fixed a while ago, how come I experienced the problem in the latest SilverStripe-3.1.x-dev checkout?

@chillu
Copy link
Member

chillu commented Jun 3, 2013

You're correct, I've confused this with a different fix (silverstripe/silverstripe-framework@67d1327). Submitted a pull request to fix the ghost page behaviour with silverstripe/silverstripe-framework#2054

sekjal pushed a commit to sekjal/sapphire that referenced this issue Nov 15, 2013
This caused problems when duplicate() was used in the CMS UI
to duplicate a SiteTree object. Since every object of this type
has a ParentID relation, it copied this empty relation into
new "ghost page".

See silverstripe/silverstripe-cms#689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants