Rasmus Vind
Well-known member
When you find yourself using WebDav in a sub theme and you delete a template which has not been modified in said theme, it will be deleted from the parent too. This may be expected behavior in some cases, I don't know.
In my case, it has caused me lots of pain and troubleshooting.
I have a WebDav client, which allows me to edit files directly. It's called Transmit and is for the Mac. It's a really great application.
When you edit a file and hit save. It saves a file with another name, then deletes the original file and renames the saved file. This is quite a good way of doing things as the site is up while the new file is being downloaded when working with SFTP or FTP, but with WebDav and xenForo it gives you some unexpected behavior.
You see when my WebDav client deletes the unmodified template file to replace it with a new version, it actually deletes that template from all other themes, which is horrible.
You don't expect files in other folders to be deleted because you delete a file which happens to be just a link to a file that exists in another folder. The only really good solution to this problem is to not do anything at all when you delete an unmodified template.
Therefore I suggest this change:
It prevents the deletion of the template, if this style does not have a custom version of it.
In my case, it has caused me lots of pain and troubleshooting.
I have a WebDav client, which allows me to edit files directly. It's called Transmit and is for the Mac. It's a really great application.
When you edit a file and hit save. It saves a file with another name, then deletes the original file and renames the saved file. This is quite a good way of doing things as the site is up while the new file is being downloaded when working with SFTP or FTP, but with WebDav and xenForo it gives you some unexpected behavior.
You see when my WebDav client deletes the unmodified template file to replace it with a new version, it actually deletes that template from all other themes, which is horrible.
You don't expect files in other folders to be deleted because you delete a file which happens to be just a link to a file that exists in another folder. The only really good solution to this problem is to not do anything at all when you delete an unmodified template.
Therefore I suggest this change:
Code:
--- a/library/XenForo/SabreDav/File/Template.php
+++ b/library/XenForo/SabreDav/File/Template.php
@@ -157,7 +157,7 @@ class XenForo_SabreDav_File_Template extends Sabre_DAV_File
public function delete()
{
- if ($this->_template)
+ if ($this->_template && $this->_template['style_id'] == $this->_style['style_id'])
{
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Template');
$dw->setExistingData($this->_template);