Jump to content

Page clone - Incorrect integer value: '' for column 'data_max' at row 1


Raymond Geerts
 Share

Recommended Posts

Im making a module to clone a pre defined page tree. This module is called CustomerStructureCloner.

I have to fill in a new customer name that will be used as page title and page name.

But im having dificulties with some error i dont understand: It clones the first page but not the children. It also doent rename the first page. But instead i get the following error message: Incorrect integer value: '' for column 'data_max' at row 1

Im using the following code inside the module:

public function ___execute() {

    $error = $this->_("Unable to load page");
    $id = 1005; // ID of /structure/customer/
    if(!$id) throw new WireException("$error A");
    $customer = $this->pages->get($id);

    $form = $this->modules->get("InputfieldForm");
    $form->attr('action', './add/');
    $form->attr('method', 'post');
    $form->description = 'Vul hieronder de naam van de klant in.'; // Form description/headline

    $n = 1;
    $root = $this->pages->get('/');
    while(count($root->children("include=all, name={'klantnaam'}-$n"))) $n++;

    $field = $this->modules->get("InputfieldPageTitle");
    $field->attr('name', 'clone_page_title');
    $field->attr('value', 'Klantnaam ' . sprintf($this->_n("(copy)", "(copy %d)", $n), $n)); // Phrase added to page title to make it unique
    $field->label = $this->_("Naam van de klant"); // Label for title field
    $description  = "Vul hier een unieke klantnaam in. Deze klantnaam mag niet al bestaan. ";
    $description .= "Vervolgens wordt er een één-op-één copie gemaakt van de pagina %s en alle onderliggende pagina's";
    $field->description = sprintf($this->_($description), $customer->path); // Form description/headline

    $form->add($field);

    $field = $this->modules->get("InputfieldSubmit");
    $field->attr('name', 'submit_clone');
    $form->add($field);

    return $form->render();    
}    

/**
 * Called when the URL is this module's page URL + "/add/"
 *
 */
public function ___executeAdd() {

    $input = $this->input;

    // add a breadcrumb that returns to our main page
    $this->breadcrumbs->add(new Breadcrumb('../', 'Nieuwe klant toevoegen'));

    $error = $this->_("Unable to load page");
    $id = 1005; // ID of /structure/customer/
    if(!$id) throw new WireException("$error A");
    $customer = $this->pages->get($id);

    $root = $this->pages->get('/');
    $pageName = $this->sanitizer->pageName($input->post->clone_page_title);
    $nameTaken = count($root->children("name=$pageName, include=all")) > 0;

    $clone = $this->pages->clone($customer, $root);

    if(!$clone->id) throw new WireException(sprintf($this->_("Unable to clone page %s"), $customer->path));

    if(strlen($pageName)) {
        if($nameTaken) $this->error(sprintf($this->_("The name '%s' was already taken, so one was automatically assigned."), $pageName));
            else $clone->name = $pageName;
        $clone->title = $input->post->clone_page_title;
        $clone->save();
        $this->message(sprintf($this->_('Cloned page "%1$s" to "%2$s"'), $customer->name, $clone->name));
    }

    //$this->session->redirect($this->config->urls->admin . 'page/list/?open=' . $clone->id);
}
 

What could be the problem that it doesnt clone its children too and doesnt rename the page?
 

Edit:

A little update, All the pages templates to be cloned have the right "Family" settings, so they are allowed to be eachothers parent and/or children.

Link to comment
Share on other sites

Thanks Soma for looking in to this and finding this.

Yes the first page in the tree has a range slider on the template.

I have removed the range slider from the template and now it clones the whole tree as expected.

note: when i removed the range slider field from the template it also gave the error: Incorrect integer value: '' for column 'data_max' at row 1

Is this a bug in the range slider module or could it be i have to set some field in the configuration of the field?

Link to comment
Share on other sites

The values of the field logo_height of the type RangeSlider that was assigned to the template of the first page in the tree to be cloned

Range: [unchecked]

Slider width: 100

Default value: 100

Minimum Allowed Value: 50

Maximum Allowed Value: 200

Step: 1

Counter Prefix: [empty]

Counter Suffix: px.

The field was placed between a FieldsetTabOpen and FieldsetClose

Link to comment
Share on other sites

I have no idea. It doesn't matter where it is on the template, and no matter what settings, I can't reproduce. I think it has more to do with versions PW, PHP, MySQL ... something with that page? Can you create a new page and try cloning that with simple API call?

Link to comment
Share on other sites

I have tried cloning it manualy from the home template

$clone = $pages->clone($pages->get('/test1/'));

$clone->title = 'Test1 Clone';
$clone->name = 'test1-clone';
$clone->save();
 

But this also generated the following error:

Error: Exception: Incorrect integer value: '' for column 'data_max' at row 1 (in /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Database.php line 118)

#0 /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Fieldtype.php(537): Database->query('INSERT INTO `fi...')
#1 [internal function]: Fieldtype->___savePageField(Object(Page), Object(Field))
#2 /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Wire.php(271): call_user_func_array(Array, Array)
#3 /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Wire.php(229): Wire->runHooks('savePageField', Array)
#4 /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Pages.php(576): Wire->__call('savePageField', Array)
#5 /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Pages.php(576): FieldtypeRangeSlider->savePageField(Object(Page), Object(Field))
#6 [internal function]: Pages->___save(Object(Page), Array)
#7 /Users/user/Sites/www_domains/test/htdocs/klanten/wire/core/Wire.php(271): c

This error message was shown because you are logged in as a Superuser. Error has been logged.

As for now i wil replace the RangeSlider field with something else, that will do the job.

Could be my localhost is the problem, i will try when its finished how it does on the server it will be hosted on.

Link to comment
Share on other sites

I can't reproduce and I don't have Database.php #118 (empty line) What is the PW version and PHP, MySQL ?

The error states that it tried to set a string on the integer field, and there's nothing wrong with RangeSlider.

(BTW, your code would need a $clone->of(false), or it will throw an error)

$clone = $pages->clone($pages->get('/test1/'));
$clone->of(false);
$clone->title = 'Test1 Clone';
$clone->name = 'test1-clone';
$clone->save();
Link to comment
Share on other sites

Maybe can you try to change soemthing in RangeSlider?

FieldtypeRangeSlider.module 

in the ___sleepValue method

This: 

$sleepValue = array(
    'data' => $range->min,
    'data_max' => $range->max
);
to this:
 
$sleepValue = array(
    'data' => (int) $range->min,
    'data_max' => (int) $range->max
);
  • Like 1
Link to comment
Share on other sites

Im running Apache localy on a MacBook Pro for development.

  • ProcessWire 2.3.0
  • System Darwin MAC-0010.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
  • Server API Apache 2.0 Handler
  • Apache Version Apache/2.2.22 (Unix) PHP/5.3.23
  • Loaded Modules core
    prefork http_core mod_so mod_authn_file mod_authz_host mod_cache
    mod_disk_cache mod_dumpio mod_reqtimeout mod_ext_filter mod_include
    mod_filter mod_substitute mod_deflate mod_log_config mod_log_forensic
    mod_logio mod_env mod_cern_meta mod_expires mod_headers mod_ident
    mod_usertrack mod_setenvif mod_version mod_proxy mod_proxy_http
    mod_proxy_balancer mod_mime mod_autoindex mod_asis mod_info mod_cgi
    mod_vhost_alias mod_negotiation mod_dir mod_imagemap mod_actions
    mod_speling mod_alias mod_rewrite mod_hfs_apple2 mod_userdir_apple
    mod_mem_cache mod_status mod_php5
  • MySQL Support Client API version mysqlnd 5.0.8-dev - 20102224 - $Id: 731e5b87ba42146a687c29995d2dfd8b4e40b325 $
  • User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:21.0) Gecko/20100101 Firefox/21.0
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...