Forum OpenACS Development: Error in Xowiki Upgrade

Collapse
Posted by Eduardo Santos on
Hi everibody,

I've just upgrade my XoWiki version from 0.96 to 0.106. Right now, when I use the news includelet that I already had, I see the following problem:

Error in includelet 'edit-item-button':

invalid command name "::xo::db::content_folder" while executing "$class get_instance_from_db -item_id $item_id -revision_id $revision_id" (procedure "get_instance_from_db" line 6) ::xo::db::CrClass->get_instance_from_db invoked from within "::xo::db::CrClass get_instance_from_db -item_id $parent_id" (procedure "folder_path" line 8) ::5651438 ::xowiki::Package->folder_path invoked from within "my folder_path -parent_id $parent_id" (procedure "pretty_link" line 21) ::5651438 ::xowiki::Package->pretty_link invoked from within "$package_id pretty_link -parent_id [$page parent_id] [$page name]" (procedure "render_button" line 12) ::xotcl::__#0v ::xowiki::includelet::item-button->render_button invoked from within "my render_button -page $page -method edit -package_id $package_id -title $title -alt $alt -return_url $return_url -src /resources/acs-subsite/Edit1..." (procedure "render" line 14) ::xotcl::__#0v ::xowiki::includelet::edit-item-button->render invoked from within "$includelet render"

Can somebody help me on that?

Collapse
Posted by Gustaf Neumann on
Well, this was the version from the oacs5-4 branch; the symptom is that get_instance_from_db is called with a folder_id (acs_type content folder), and for the content folder, there is no XOTcl class defined. The problem is, the news item, for which the edit-button is to be created, seems to have a folder_id as parent_id that is different to the main folder id of this xowiki instance. Can you check this?

Background: The new xowiki versions support xowiki pages having other xowiki pages as parent_ids. This is used currently primarily for embedded content, such as files/images attached to pages (e.g. xowiki::FormPages having attached uploaded files). For this included content, xowiki constructs a unix-like path for the names (using slashes as delimiters). This is implemented via the folder_path method.

I have fixed the symptoms in the oacs-5-4 branch the same way as was already in cvs head. But please, check the parent_ids for this/these items, maybe there is something else wrong....

Collapse
Posted by Eduardo Santos on
Hi Gustaf,

I order to test your hypothesis, I've used the following query:

select x.item_id,
c.name,
c.parent_id,
c2.name,
c3.folder_id,
c3.package_id
from xowiki_form_pagei x
inner join cr_items c on x.item_id = c.item_id
inner join cr_items c2 on c.parent_id = c2.item_id
inner join cr_folders c3 on c.parent_id = c3.folder_id
order by x.item_id desc;

In all the cases I could find, the xowiki_form_page parent_id is the same value as the xowiki root content_folder. The funny thing about it is that I had, a while ago, one problem where some pages where going to other folders different from the xowiki root one. Do you think these issues can be related?

I'll try to find out if there are any other xowiki pages or objects in other folders different from the package root. Maybe this is a good investigation line.

Collapse
Posted by Eduardo Santos on
Hi Gustaf,

I guess I've found the error, but I don't know how to solve it. The method that gets the folder_id is probably wrong.

In the file xowiki/tcl/includelet-procs.tcl, in line 2209, inside the render_button method, there are the following lines:

    set p_link [$package_id pretty_link -parent_id [$page parent_id] [$page name]]
    set link [$package_id make_link -link $p_link $page $method \
              return_url page_order source_item_id]

Just before this code I've inserted a log call to find the parent_id for this button object, wich looks like this:

      my log "111111111111111111111111111: [$page parent_id] | [$page item_id] | [$page name]"
    set p_link [$package_id pretty_link -parent_id [$page parent_id] [$page name]]
    set link [$package_id make_link -link $p_link $page $method \
              return_url page_order source_item_id]

My log call returned as parent_id the root folder (-100).

 111111111111111111111111111: -100 | 5898991 | pt:teste_artigos_news, ::xotcl::__#g
::xowiki::includelet::item-button->render_button (810ms, 32ms)

So, I've performed the following query in DB:

select item_id, page_id, parent_id from xowiki_form_pagex where item_id = 5898991;

 item_id | page_id | parent_id
---------+---------+-----------
 5898991 | 5898993 |   5651468
 5898991 | 5898990 |   5651468

The parent_id in the select is different from the one returned by the method. it seems like there's a problem in the cr objects attributes fetch, but I guess this is beyond my knowledgements in XoTcl. Can you tell me why this is happening?

Collapse
Posted by Gustaf Neumann on
Dear Eduardo,

the parent_id looks uninitialized to me. I have tried to recreate this situation on my machine using the news prototype page (which uses the edit-button), but this worked correctly. What do you mean by "i use the news includelet"? Is this some adp-includelet for the news package?

-gustaf neumann

Collapse
Posted by Eduardo Santos on
Hi Gustaf,

Yes, I use the news prototype page as an includelet in other page. My page has the following code:

{{news -summary 1 -page_size 1}}

The news object created has the following code:

#
  # A sample News object.
  #
  my initialize -parameter {
    {-page_size:integer 10}
    {-page_number:integer 1}
    {-summary:boolean 0}
    {-date ""}
    {-tag ""}
    {-ptag ""}
    {-entries_of en:news-item|en:announcement-talk|en:announcement-workshop}
  }

  my get_parameters
  #
  # Don't add the footer (with tags, general comments, etc.) to the
  # aggregated page, since this can be confusing..
  #
  [my info parent] set __no_footer 1

  #
  # Provide a tailored link for creating new pages in the wiki menu
  #
  set forms [::xowiki::Weblog instantiate_forms  -entries_of $entries_of  -package_id $package_id]
  set template_id [lindex $forms 0]
  set form_link [$package_id pretty_link [$template_id name]]
  set new_link  [$package_id make_link -link $form_link $template_id create-new return_url]

  [my info parent] set __link(new) $new_link

  #
  # The following definition is the default rendering per
  # news entry. This is executed in the context of every displayed page.
  #
  Class create EntryRenderer -instproc render {} {
    my instvar package_id name title creator creation_user pretty_date description publish_date
    [my set __parent] instvar weblog_obj

    set link [::xowiki::Includelet detail_link  -package_id $package_id -name $name  -instance_attributes [my get_instance_attributes]]
    regsub -all & $link "&" link
    set more [expr {[$weblog_obj summary] ?
                    " <span class='more'> \[<a href='$link'>more...</a>\]</span>" : ""}]
    #append more "<p></p>"
    set day [lc_time_fmt [my set publish_date] "%x"]
    set my_footer [my htmlFooter]

    set edit_button [my include [list edit-item-button -book_mode true]]
    if {$edit_button ne ""} {set edit_button "<div style='float: right'>$edit_button</div>"}
    append content "<DIV class='news-item' style='clear: both;'>" $edit_button  "<div class='item-header'><h2><a href='$link'>[ad_quotehtml $title]</a></h2>"  "&nbsp;<span class='date'>($day)</span></div>\n"  $description $more $my_footer \n "</DIV>"
  }

  #
  # The following definition is the renderer for the aggregated content.
  # This is executed in the context of the whole weblog object
  #
  Class create NewsRenderer -instproc render {} {
    my instvar filter_msg link name prev_page_link next_page_link title package_id

    set filter ""
    set prev ""
    set next ""

    if {[info exists filter_msg]} {
      set filter  "<div class='filter'>$filter_msg</div>"
    }
    if {[info exists prev_page_link]} {
      set prev "<a href='$prev_page_link'> <img border=0 src='/resources/acs-subsite/left.gif'  alt='Previous Page' style='float: left;  top: 0px;'></a>"
    }
    if {[info exists next_page_link]} {
      set next "<a href='$next_page_link'> <img border=0 src='/resources/acs-subsite/right.gif'  alt='Next Page' style='float: left;  top: 0px;'></a>"
    }
    #
    # Include the RSS Button
    #
    set page [my set __page]
    set rss [$page include "rss-button -title {[$page title]} -entries_of [my entries_of] -decoration none"]
    #
    # If the user has creation rights (on the first form), include the RSS Bookmarklet button
    #
    if {[my exists form_items]} {
      set can_create_news_item [$package_id make_link [lindex [my set form_items] 0] create-new return_url]
      if {$can_create_news_item ne ""} {
        append rss "Bookmarklet: " [$page include "bookmarklet-button -label {[$page title]}"]
      }
    }

    return "<div class='weblog'> $filter [next] $prev $next <br>$rss</div>"
  }

  my proc content {} {
    my get_parameters
    set page [my info parent]

    if {[$page exists __including_page]} {
      set i [$page set __including_page]
      set exclude_item_ids [$i item_id]
      $i set render_adp 0  ;# no double substitutions
      #my log "--W including page $i"
    } else {
      #my log "--W NO including page"
      set exclude_item_ids [$page item_id]
    }

    # on the news page, an edit-new should not create an object
    ::xo::cc set_parameter object_type ::xowiki::Page
    ::xo::cc set_parameter autoname 1

    # use the above defined custom renderers
    set renderer      [self]::NewsRenderer
    set entry_renderer [self]::EntryRenderer

    set w [::xowiki::Weblog new -destroy_on_cleanup  -package_id $package_id  -page_size $page_size  -page_number $page_number  -summary $summary  -date $date  -category_id [ns_queryget category_id]  -tag $tag  -ptag $ptag  -entry_label "News Articles"  -exclude_item_ids $exclude_item_ids  -entry_renderer $entry_renderer  -entry_flag __no_form_page_footer  -entries_of $entries_of  ]
    $w set __page $page
    $w mixin add $renderer
    return [$w render]
  }

Any idea on that?

Collapse
Posted by Gustaf Neumann on
Thanks, that helped. The weblog class was not fetching always the parent_id, so it defaulted to -100; it is fixed in cvs head and in oacs-5-4

best regards
-gustaf neumann

Collapse
Posted by Eduardo Santos on
Hi Gustaf,

Thank you very much for your help. It's all working now.