protected function merge( $items, $mergeAdded = false )
    {
        $itemObjects = array();
        foreach ( $items as $item )
        {
            $oid = $item['object_id'];
            $itemObjects[$oid] = new eZPageBlockItem( $item, false );
        }

        if ( isset( $this->attributes['items'] ) && $this->attributes['items'] )
        {
            foreach ( $this->attributes['items'] as $item )
            {
                $oid = $item->attribute( 'object_id' );
                if ( $item->toBeRemoved() )
                {
                    unset( $itemObjects[$oid] );
                }
                if ( $mergeAdded && $item->toBeAdded() )
                {
                    $itemObjects[$oid] = $item;
                }
                if ( $item->toBeModified() )
                {
                    if ( isset( $itemObjects[$oid] ) )
                    {
                        //modify an item in history to be visible
                        //if item from db is hidden, visible=0 and the item from draft is not, delete it from db queue
                        //this is the case when requesting the history items and valid item
                        if( $item->attribute( 'ts_hidden' ) == 0 && $item->attribute( 'ts_visible' ) == 0 )
                        {
                            if( !$mergeAdded )
                            {
                                unset( $itemObjects[$oid] );
                            }
                        }
                        else
                        {
                            //this is the case when fetching valid items
                            $itemObjects[$oid]->setAttribute( 'ts_publication', $item->attribute( 'ts_publication' ) );
                            $itemObjects[$oid]->setAttribute( 'priority', $item->attribute( 'priority' ) );
                        }
                    }
                    else
                    {
                        //modify an item in history to be visible
                        //if the items from db don't have the item
                        //and modified item is not hidden, add it to the item list.
                        //this is the case when requesting the queue
                        if( $item->attribute( 'ts_hidden' ) == 0 && $item->attribute( 'ts_visible' ) == 0)
                        {
                            if( $mergeAdded )
                            {
                                $itemObjects[$oid] = $item;
                            }
                        }
                    }
                }
            }
        }

        return $itemObjects;
    }