https://bugzilla.wikimedia.org/show_bug.cgi?id=14314





--- Comment #1 from Li Ding <[EMAIL PROTECTED]>  2008-12-01 23:42:14 UTC ---
Created an attachment (id=5550)
 --> (https://bugzilla.wikimedia.org/attachment.cgi?id=5550)
AddData failed because fromHTML does not generate correct title replacement

I encountered the same problem too. In my case, my form and template share the
same name "lod.dataset", and the reported bug occurs.

<pre>
Catchable fatal error: Argument 1 passed to Article::__construct() must be an
instance of Title, null given, called in
.../extensions/SemanticForms/includes/SF_GlobalFunctions.php on line 253 and
defined in /var/www/html/tw.rpi.edu/wiki.proj/includes/Article.php on line 47
</pre>

Below is the call stack 

/includes/SF_GlobalFunctions.php  line 253      
<pre>
        $article = new Article($title);
</pre>

/include/SF_GlobalFunctions.php   line 252 
<pre>
function sffPrintRedirectForm($title, $page_contents, $edit_summary, $is_save,
$is_preview, $is_diff, $is_minor_edit, $watch_this, $start_time, $edit_time) {
</pre>


/specials/SF_AddData.php   line 168
<pre>
                        $text = sffPrintRedirectForm($target_title, $data_text,
$wgRequest->getVal('wpSummary'), $save_page, $preview_page, $diff_page,
$wgRequest->getCheck('wpMinoredit'), $wgRequest->getCheck('wpWatchthis'),
$wgRequest->getVal('wpStarttime'), $wgRequest->getVal('wpEdittime'));
</pre>

/specials/SF_AddData.php   line 22
<pre>
 function printAddForm($form_name, $target_name, $alt_forms) {
</pre>


After some investigation, I found that, in the following code,
$generated_page_name was set to empty value, and therefore  $target_title was
set to empty.

/specials/SF_AddData.php   line 127-136
<pre>
                list ($form_text, $javascript_text, $data_text,
$form_page_title, $generated_page_name) =
                        $sfgFormPrinter->formHTML($form_definition,
$form_submitted, $page_is_source, $page_contents, $page_title,
$page_name_formula);
                if ($form_submitted) {
                        if ($page_name_formula != '') {
                                // append a namespace, if one was specified
                                if ($wgRequest->getCheck('namespace')) {
                                        $target_name =
$wgRequest->getVal('namespace') . ':' . $generated_page_name;
                                } else {
                                        $target_name = $generated_page_name;
                                }
</pre>

Further investigation found the cause.

/include/SF_FormPrinter.inc   line 229-234
<pre>
          $tif->template_name = $template_name;
          $query_template_name = str_replace(' ', '_', $template_name);
          // also replace periods with underlines, since that's what
          // POST does to strings anyway
          $query_template_name = str_replace('.', '_', $query_template_name);
</pre>

/include/SF_FormPrinter.inc   line 229-234
<pre>
          $tif->template_name = $template_name;
          $query_template_name = str_replace(' ', '_', $template_name);
          // also replace periods with underlines, since that's what
          // POST does to strings anyway
          $query_template_name = str_replace('.', '_', $query_template_name);
</pre>


/include/SF_FormPrinter.inc   line 635-636
<pre>
              $true_input_name = str_replace('.', '_', $input_name);
              $generated_page_name = str_ireplace("<$true_input_name>",
$cur_value_in_template, $generated_page_name);
</pre>


Finally, there is a fix.
<pre>
              $generated_page_name = str_replace('.', '_',
$generated_page_name);
              $generated_page_name = str_replace('.', '_',
$generated_page_name);
              $generated_page_name = str_ireplace("<$input_name>",
$cur_value_in_template, $generated_page_name);
</pre>


-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to