CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#12498] Page Copy in ContentManager enforces Default Values (overwriting actual values)

avatar
Created By: Ludger Merkens (lume)
Date Submitted: Wed Nov 24 06:10:46 -0500 2021

Assigned To:
Version: None
CMSMS Version: 2.2.16
Severity: Minor
Resolution: Awaiting Response
State: Open
Summary:
Page Copy in ContentManager enforces Default Values (overwriting actual values)
Detailed Description:
Scenario is as follows:

you have a page template, which has a content_block with an explicit
default_value. You create a page, change this default_value and save the page.
You then copy this page and voila the copy of the page looses this change and
the default_value is in the page. I first stumbled upon this behaviour with ECB2
Checkbox fields, where I had lots of default_value=0 fields, to have sane
checkbox fields.

e.g.

{content_module module="ECB2" field="checkbox" block="SitemapExclude"
assign="sitemapexclude" label="Seite und evtl. Unterseiten nicht in sitemap.xml
aufnehmen" tab='SEO' default_value=0}

I almost blamed ECB2 for badly handling the copy situation. But after a closer
look into the copy process the culprit seems to be:

 line 82 $to_obj->SetDefaultContent(0) from action.admin_copycontent.php.

The fix might be as simple, as removing this line. But I still ponder, what the
reason for this Initialization initially was.

best regards - any ideas?

Ludger Merkens


History

Comments
avatar
Date: 2021-11-25 23:09
Posted By: tom (tomphantoo)

->SetDefaultContent(0) (or actually, ->SetDefaultContent(false)) in
ContentManager-module action.admin_copycontent.php etc merely ensures that the
newly cloned content-object is not considered to be part of the (site) default
page (if indeed the cloned page is capable of being the default).

Are you able to post here a report on what is actually stored in the database
after you save a page including a changed default value?

There might be a cache-related problem.




      
avatar
Date: 2021-11-26 04:57
Posted By: Ludger Merkens (lume)

I'll try to do some more specific testing. I checked with CMSMS 2.2.12 running
on php 7.3 - there the problem doesn't occur. The problematic platform is 2.2.15
running on php 7.4. (both use apache with php-fpm)

I'm doing some more setup work now - to get a minimal scenario.


      
avatar
Date: 2022-02-16 05:17
Posted By: Ludger Merkens (lume)

Ok, sorry for the long pause... 
I now can elimitate any circumstances besides the cmsms upgrade. I moved a
working cmsms 2.2.12 instance to the new server hardware (and thus to the new
software environment)
Copy mechanism works fine.
Upgrade to 2.2.16 (thus incorporating the changes from 2.2.14) - Problem occurs.

I have access to the database. Can you elaborate which data you need to
investigate the supposed cache problem?
      
avatar
Date: 2022-02-16 06:09
Posted By: Ludger Merkens (lume)

Ok - I checked on database level.

content_id 4 is the original, content_id 3614 is the copy.

I have different ECB_2 fields in the template:

{content_module module='ECB2' block='previewmode' assign='previewmode'
field="dropdown" label='Blockgröße' values='Volle Zeile=t1,Zwei Drittel
Zeile=t23,Halbe Zeile=t2,Drittel Zeile=t3,Viertel Zeile=t4' default_value="t1"}
{content_module module='ECB2' block='hidetitle' assign='hidetitle'
field='checkbox' label='Überschrift nicht automatisch einbeziehen'
default_value="0"}

the ecb_field "previewmode" which is a dropdown changes its value from t2 to t1
(which is the default given in the template above)

the ecb fiel "hidetitle"  a checkbox field changes its value from 1 to empty
wich again might be the default_value of "0".

those are the results after the copy process is completed. (not during copy)


      
avatar
Date: 2022-02-16 06:12
Posted By: Ludger Merkens (lume)

bug occurs in 2.2.15 as well as in 2.2.16
      
avatar
Date: 2022-04-24 22:26
Posted By: tom (tomphantoo)

Suggestion 1: from ecb2_tools::get_checkbox() remove
  // a hack for if $adding not being set correctly by Content Manager (2.2.14)
if ( !$this->adding && empty($_REQUEST['m1_content_id']) &&
empty($this->value) && isset($this->default) ) {
     $this->value = $this->default;
  }
and instead add into ECB2::GetContentBlockFieldInput()
// workaround $adding not set in ContentManager v1.0 action admin_editcontent
if (!$adding && version_compare(CMS_VERSION, '2.1') < 0 && $content_obj->Id()
== 0) {
      $adding = true;
   }

Suggestion 2: given that ecb2_tools includes
  if ( $adding==true ) $this->value = $this->default; 

in CMSContentManager action.admin_copycontent.php, we might try
  $this->Redirect($id,'admin_editcontent','',array('content_id'=>-1));
instead of
  $this->Redirect($id,'admin_editcontent','',array('content_id'=>'copy'));

and in CMSContentManager action.admin_editcontent.php
   if( isset($_SESSION['__cms_copy_obj__']) ) {
instead of
   if( $content_id === 0 && isset($_SESSION['__cms_copy_obj__']) ) {

Are you able to check whether the above fix the problem you reported?

      
avatar
Date: 2022-04-25 02:58
Posted By: Ludger Merkens (lume)

I will give it a try, but it will take a week or two, since I'm under a
deadline.
      
avatar
Date: 2022-04-25 03:11
Posted By: Chris Taylor (chrisbt)

I'll keep an eye on this thread and gladly update ECB2 with whatever is
necessary to get this to work correctly. I'll wait until you confirm the fix
before I make another change. Thanks for both your work investigating this.

Chris
      
Updates

Updated: 2022-02-16 06:12
cmsms_version_id: 31740 => 31780

Updated: 2021-12-12 12:21
resolution_id: 5 => 10

Updated: 2021-11-25 23:09
resolution_id: => 5