Author:
nickdunn
Version:
1.7
Released:
5 February 2011
Category:
Other

New#4: Unable to create new section schemas

When trying to create a new schema, I get the following error:

unlink(/Users/tonyarnold/Sites/tonyarnold.com/workspace/data-sources/data.section_schema_pages.php) [function.unlink]: No such file or directory
/Users/tonyarnold/Sites/tonyarnold.com/symphony/lib/toolkit/class.general.php line 811

806      *  true if the file is successfully unlinked, if the unlink fails and
807      *  silent is set to true then an exception is thrown. if the unlink
808      *  fails and silent is set to false then this returns false.
809      */
810     public static function deleteFile($file, $slient=true){
811         if(!@unlink($file)){
812             if($slient == false){
813                 throw new Exception(__('Unable to remove file - %s', array($file)));
814             }
815

Heya, I get the EXACT error. This happens when I select a section within the 'Section Schemas' control area and click the 'Save Changes' button. Any ideas?

I'm also getting this error, and I was able to tame it with the following solution.

First, a little context:

Section Schemas works by creating actual .php files on your server containing the datasource information. When using Section Schemas (SS), you are given a multiple select list of all the sections on your site. You select the sections you want SS to build a datasource for, or deselect the sections you want SS to remove the datasource for. When you click "Save", SS iterates through every section in the list and attempts to do the follow: delete the data.sectionschema(sectionname).php datasource file if the section isn't selected; or, create the data.sectionschema(sectionname).php if the section is selected.

The "if(!@unlink($file)){" chunk you are seeing in the error report is the code Symphony is using to try and delete data.sectionschema(section_name).php. While this is supposed to die quietly when the file doesn't exist, for some reason it's failing to check for the file before attempting to delete it.

I was able to fix this by wrapping that "if(!@unlink($file)){...}" statement in /symphony/lib/toolkit/class.general.php with another 'if' statement that explicitly checks for the existence of the file.

public static function deleteFile($file, $slient=true){
    **if (file_exists($file)) {**
        if(!@unlink($file)){
            if($slient == false){
                throw new Exception(__('Unable to remove file - %s', array($file)));
            }
            return false;
        }
    **}**
    return true;
}

Of course, the real issue here is PHP failing to run the '!@unlink($file)' statement correctly, so this only fixes the symptom, not the disease.

Yikes, I derped and botched the formatting in that post, so to clarify:

  • open symphony/lib/toolkit/class.general.php and find the deleteFile function on line 810
  • change the function to the following code:

    public static function deleteFile($file, $slient=true){ if (file_exists($file)) { if(!@unlink($file)){ if($slient == false){ throw new Exception(__('Unable to remove file - %s', array($file))); } return false; } } return true; }

Apologies for the derp double-post— had my wrists slapped when I tried to edit the first. Remember, this doesn't solve the real problem (PHP is at fault, not Symphony methinks), just works around it.

Please login to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details