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
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
http://localhost:8888/vanilla/settings.php?PostBackAction=Category&btnSave=Create+a+new+category\
to
http://localhost:8888/vanilla/settings.php
I my opinion The url should remain the same cause then if your doing this
the code will break on error cause the url has been changed and it no longer contains the PostBackAction
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
http://localhost:8888/vanilla/settings.php?PostBackAction=Category&btnSave=Create+a+new+category\
to
http://localhost:8888/vanilla/settings.php
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
0
This discussion has been closed.
Comments
line 58 their is an if statement that redirects if no error is detected, but doesn't do anything if errors are detected.
Lets assume your changing the stylesheet of the calendar form. if the error occurs the style sheet vanishes
<?php /* Extension Name: Fancy CategoryForm Extension Url: http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=297 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>'); } ?>
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); }
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.
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: http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=297 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>'); } ?>