Menu

#368 Failure to sync source file when project is created

workingwiki
closed
None
5
2013-07-28
2013-07-27
Lee Worden
No

Lee Worden is confused, could have sworn there was a ticket for this one. Opening a duplicate, maybe. When you create a new project by introducing a source file into a fresh page and previewing, the first time it adds the file to the project and fails to make, and the next time you preview it makes correctly.

Related

Bugs: #321

Discussion

  • Lee Worden

    Lee Worden - 2013-07-27

    It adds the file in WWInterface::render_after_parsing(). That function goes in 2 passes now, in order to do the adding of new files before the syncing, and it works, except when the project is not yet created. Why should that make a difference?

    In the first pass, for each tag it loads the project and adds the file to it if needed:

    $project = WWStorage::find_project_by_name($n_projectname);
    WWInterface::$uniq_tokens[$token]['project'] = $project;
    ...
    $project->add_source_file( ... );
    WWInterface::project_is_modified( $project );
    

    In second pass, it loops through all the tags and does, for each one,

    $project = WWInterface::$uniq_tokens[$token]['project'];
    $file_html = WWInterface::display_project_file(
             $project, WWInterface::$uniq_tokens[$token]['file_content'], 
             $source, $args, $parser);
    

    So what's different about projects that don't have saved descriptions? find_project_by_name() creates an empty project if there's no description, and render_after_parsing should add to it and use it the same as any other, and project_is_modified() causes it to eventually be saved to the wiki - if it didn't we'd be adding the file again the next time we preview.

     
  • Lee Worden

    Lee Worden - 2013-07-27

    I am doing some logging, and so far:

    • Just before it does the add_source_file() it already has the tex file listed as a project file with no info attached - what's up with that?
    • Just after, it has it listed as a source file, with a page location, in the usual way.
    • After that, when it does the sync call to PE, it does include the new tex file and its contents, and PE reports back that it did sync it in the preview directory.
    • Then it calls PE again, to make the .html file, and PE reports that it failed.
    • On looking closer at the sync request, I notice that it doesn't include GNUmakefile.

    I've been assuming that it was failing to sync the tex file, but apparently that's not actually the problem.

    • When I hit preview again, sure enough, this time it syncs both the tex file and GNUmakefile.
     
  • Lee Worden

    Lee Worden - 2013-07-27

    Hmm, so WorkingWikiProjectDescription::__construct() actually has a special case:

        // if there's going to be an automatic makefile, we create a
        // special entry for it
        // (but don't do it for a project that doesn't actually exist)
        global $wwGenerateMakefile;
        if ( $wwGenerateMakefile and $this->options['use-default-makefiles']
            and (($this->project_description_page != '')
                  or count($this->project_files) > 0) )
        { #error_log("Adding GNUmakefile to project with xml:\n$xmldata,\npage $page, revision $as_of_revision\n");
          ...
    

    which seems like it must be the source of the problem. If creating an empty project and then adding a source file to it gives you a project with no GNUmakefile, but creating one with a file in it gives you one with a GNUmakefile, what purpose does this serve exactly?

    Maybe it's so that it won't add GNUmakefile and save the project description just because someone tried to look at whether the project exists?

    But initializing it with an automatic makefile wouldn't cause it to get saved to the wiki...

     
  • Lee Worden

    Lee Worden - 2013-07-27

    All the discussion I archived while I was implementing the GNUmakefile thing, at [#356], is encyclopedic and interesting, but doesn't shed any light on why I thought brand-new projects should be prevented from having a GNUmakefile.

    • What if the site makefile or something defines targets that you can make without any source files, such as to find out something about the project or the system or something? Then you would want to be able to do that in an empty project, which won't work unless it has a GNUmakefile.
    • These projects I'm dealing with in this ticket either need to to be created with a makefile, or they need to grow one when I add the first source file, so I can make stuff.

    I'm tempted to just add it, but I'm worried about not knowing whether there's a reason for not doing it. What should I test once it's added?

    • make sure the first preview works, of course.
    • do some operations on a non-existent project and see what goes wrong, I guess.
    • Look through the code for places where it might check for an empty project in a way that would break:
      • When evaluating a tag on a subpage - it loads the subpage's project to see if there's anything in it, or if it should use the parent page's project.
      • When deciding whether there's a project to list in the sidebar
      • When deciding whether a link to a project should be red
      • Search the code for the word 'empty' and for code that checks a project's $project_files array to see what's in it
     

    Related

    Bugs: #356

  • Lee Worden

    Lee Worden - 2013-07-28
    • status: open --> closed
     
  • Lee Worden

    Lee Worden - 2013-07-28

    OK I checked all those things in the code, and they seem robust to this change. So I'll make it and poke around the wiki for troubles.

    • confirmed that the first-preview bug is fixed.
    • ManageProject seems to do the right thing, i.e. displays a project with only a GNUmakefile and no project description, and doesn't create a saved description for it.
      • I want to add a notice that the file project doesn't exist. It was kind of self-explanatory to show a project with no files and no project description, but now that it has a non-empty list of source files it seems less clear.
      • added
    • introducing a source file on a subpage does right
    • sidebar links seem right

    Guess I'll leave it like this.

    Committed in r1047.

     

Anonymous
Anonymous

Add attachments
Cancel