Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Bug] in Categories form

edited November 2007 in Vanilla 1.0 Help
Go to the Categories form in your settings tab and create a new category without any name.
It will spit an error message that you need to enter a valid name for the category.
The problem is with the url. the url is changed from

I my opinion The url should remain the same cause then if your doing this
if ($Context->SelfUrl == "settings.php" && ForceIncomingString('PostBackAction', '') == 'Categories')) { // Write some stuff here }

the code will break on error cause the url has been changed and it no longer contains the PostBackAction


  • edited November 2007
    I would have to look, but I guess PostBackAction is an hidden field.
  • edited November 2007
    for a fix open up Vanilla.Control.CategoryForm.php
    line 58 their is an if statement that redirects if no error is detected, but doesn't do anything if errors are detected.
  • I noticed it cause for my calendar form I have almost the same code, and my color picker would vanish if form has errors, I'm adding the color picker by detecting the PostBackAction == Calendar.
  • If there is an error it shouldn't redirect but display the form again and let the user correct its mistake.
  • edited November 2007
    thats correct, but it should take me to the exact same form with the exact same url with the error message. its not doing that. it's changing the url and hence the code that dependents on PostBackAction.

    Lets assume your changing the stylesheet of the calendar form. if the error occurs the style sheet vanishes
  • here is the sample test case. Enable the extension. and and create a new category without any name. The extension will make the text in the category form all blue, but when an error ocurs it takes it to the default color.
    <?php /* Extension Name: Fancy CategoryForm Extension Url: Description: Bug Test for Category form Version: 0.1 Author: Ziyad (MySchizoBuddy) Saeed Author Url: N/A */ if ($Context->SelfUrl == "settings.php" && ForceIncomingString('PostBackAction', '') == 'Category') { $Head->AddString('<style type="text/css"> #Form.Account * { color:#335EB7; } </style>'); } ?>
  • edited November 2007
    I had a quick look (I can't test it or fix it right now)...
    Here is the bug (CategoryForm::Render()): if ($this->PostBackAction == 'Category') { $this->PostBackParams->Set('PostBackAction', 'ProcessCategory'); $this->CallDelegate('PreEditRender'); include(ThemeFilePath($this->Context->Configuration, 'settings_category_edit.php')); $this->CallDelegate('PostEditRender'); } elseif ($this->PostBackAction == 'CategoryRemove') { $this->PostBackParams->Set('PostBackAction', 'ProcessCategoryRemove'); $this->CategorySelect->Attributes = "onchange=\"document.location='".GetUrl($this->Context->Configuration, $this->Context->SelfUrl, '', '', '', '', 'PostBackAction=CategoryRemove')."&CategoryID='+this.options[this.selectedIndex].value;\""; $this->CategorySelect->SelectedValue = $CategoryID; $this->CallDelegate('PreRemoveRender'); include(ThemeFilePath($this->Context->Configuration, 'settings_category_remove.php')); $this->CallDelegate('PostRemoveRender'); } else { $this->PostBackParams->Set('PostBackAction', 'ProcessCategories'); $this->CallDelegate('PreListRender'); include(ThemeFilePath($this->Context->Configuration, 'settings_category_list.php')); $this->CallDelegate('PostListRender'); }

    When a ProcessCategory action fail, the PostBackAction field is not set back to 'ProcessCategory' but to 'ProcessCategories'...

    I missed this part earlier if (in_array($this->PostBackAction, array('ProcessCategory', 'ProcessCategoryRemove'))) { // Show the form again with errors $this->PostBackAction = str_replace('Process', '', $this->PostBackAction); }
  • edited November 2007
    no dinoboff that's correct.
    It should take you to ProcessCategory when you submit it.
    the bug is here line 58
    if ($this->CategoryManager->SaveCategory($this->Category)) { $this->CallDelegate('PostSaveCategory'); $RedirectUrl = GetUrl($this->Context->Configuration, $this->Context->SelfUrl, '', '', '', '','PostBackAction=Categories&Action='.$Action); }

    the if statement checks if saving was successful if ($this->CategoryManager->SaveCategory($this->Category)) and redirects you to the Categories Page
    their is no else statement that tries to keep you on the exact same page with the exact same url if error occurs. The form is reloaded but url is changed.
  • edited November 2007
    I finally could check this issue, and there is no bug. PostBackAction=whatevr is not in the url because the page is the result of a POST method. And the category page with the error message is not settings.php?PostBackAction=Category but the equivalent of settings.php?PostBackAction=ProcessCategory.

    The only find wrong here is the http response code (but Vanilla use the 200 response code for everything anyway - except for redirect).

    What do you need to change the way it works for? Your earlier example will work with <?php /* Extension Name: Fancy CategoryForm Extension Url: Description: Bug Test for Category form Version: 0.1 Author: Ziyad (MySchizoBuddy) Saeed Author Url: N/A */ if ($Context->SelfUrl == "settings.php" && in_array(ForceIncomingString('PostBackAction', ''), array('Category', 'ProcessCategory') ) { $Head->AddString('<style type="text/css"> #Form.Account * { color:#335EB7; } </style>'); } ?>
  • ok cool can you update sqlbuilder as mentioned here
This discussion has been closed.