Revision 390

Date:
2013/10/29 12:08:15
Author:
ahitrov
Revision Log:
Safe store() mode for (light => 1)
Delete attachments as default during $object->delete()
Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/lib/Contenido/Object.pm

     
    154 154 $func_end_encode = ', Encode::FB_HTMLCREF)';
    155 155 }
    156 156
    157 my @funct_default_fields = ("class=>'$class'", "keeper=>\$keeper");
    157 my @funct_default_fields = ("class=>'$class'", "keeper=>\$keeper", "__light=>\$light");
    158 158 my @funct_exra_fields = ();
    159 159
    160 160 #те вещи которые надо заранее подсчитать при инициализации класса
     
    539 539 }
    540 540
    541 541 #если использется toast то загоняется за 1 sql запрос и extra тоже
    542 if (($self->keeper->store_method() eq 'toast') and $self->class_table->have_extra) {
    542 if (($self->keeper->store_method() eq 'toast') and $self->class_table->have_extra and !$self->{__light}) {
    543 543 push @fields, 'data';
    544 544 push @values, $self->_create_extra_dump();
    545 545 }
     
    569 569 }
    570 570 $sth->finish();
    571 571
    572 if (($self->keeper->store_method() ne 'toast') and $self->class_table->have_extra) {
    572 if (($self->keeper->store_method() ne 'toast') and $self->class_table->have_extra and !$self->{__light}) {
    573 573 $self->store_extras(mode => $mode) || return $self->t_abort();
    574 574 }
    575 575
     
    600 600 $self->id($id);
    601 601 return $self->t_abort("Документу присвоен неверный идентификатор") if (! defined($self->{id}) || ($self->{id} <= 0));
    602 602
    603 if (($self->keeper->store_method() ne 'toast') and $self->class_table->have_extra) {
    603 if (($self->keeper->store_method() ne 'toast') and $self->class_table->have_extra and !$self->{__light}) {
    604 604 $self->store_extras(mode => $mode) || return $self->t_abort();
    605 605 }
    606 606
     
    638 638 my $keeper = $self->keeper;
    639 639 do { $log->error("В объекте документа не определена ссылка на базу данных"); die } unless ref($keeper);
    640 640
    641 if ( exists $opts{attachments} && $opts{attachments} ) {
    641 my $delete_attachments = exists $opts{attachments} ? $opts{attachments} : 1;
    642 if ( $delete_attachments ) {
    642 643 my @props = $self->structure();
    643 644 if ( @props ) {
    644 645 @props = grep { $_->{type} =~ /^(image|images|multimedia_new|multimedia_multi)$/ } @props;