Originally suggested by moshe over at #652566-25: Support multiple download files per release in release history XML. Yes, adding an alter hook invoked whenever project-release-create-history.php is generating the release history XML for a given project would be a better solution to the d.o-centric hacks in that issue for the <variant> tag (which is totally specific to our distribution packaging stuff). However, that's a big change, since it means the whole script would have to be re-written to generate the XML in a SimpleXML resource instead of just printing it, and then we'd need to pass this reference around in the alter hook. Plus, we'd need to add a hook implementation to drupalorg_project.module to actually handle the variant tag, etc.

Since #652566 is a blocker for the urgent task of getting .zip packaging deployed ASAP, there's a working hack we can use for now that doesn't involve this major change, and this stuff could easily be done later by anyone who's inspired to work on it, I'm splitting this out into a separate issue so it doesn't block or derail #652566...

Comments

dww’s picture

Status: Active » Postponed

Should definitely look at #715582: Use DOM to create release history feeds again with a fresh pair of eyes before doing anything else here. That might already be most of what we need to make this happen.

Xano’s picture

Here are the suggestions I posted in #1549000: Convert XML generation to an API:
1) Move the update XML generation to a separate project to improve maintainability (in case a new Drupal version changes the XML specification) and to make it easier for people to set up their own update server.
2) When doing so, make sure the XML generation code is a true API: it should work with passed on arguments only and not depend on the database for getting update information. This allows the code to work with information from other sources than Project.module releases. Generating the data structure and the XML should happen in two separate functions, to allow the data to be output in another format as well, e.g. JSON.

Some more suggestions based on this issue:
3) The alter hook is a great idea. However, don't pass on SimpleXML objects. Instead, standardize the data using classes and pass the object structure on to alter implementations, because they shouldn't care about the XML. The built and altered data structure can then be rendered through a different function (see suggestion 2).

Summarized: Separate update data generation project & separate update data generation and render functions.

dww’s picture

Yeah, since I last posted here, I came to the conclusion this definitely should *NOT* be SimpleXML and all that, but instead passing around a PHP array that can be altered and then finally output in various formats (XML, JSON, etc).

However, I'm not sure about making this a totally separate project, since it's really just a question of an external API for viewing release info. It's not clear to me what a feed of release history means without releases. ;) Sure, you might not like project_release to represent your releases, but that's not the responsibility of the project_release module to care about. It's not immediately obvious what a generic API for release history is supposed to look like. If it's generic enough to handle project_release and anything else you might want, I don't know what this "API" is actually going to do beyond "populate an array with arbitrary data and then export it to XML or JSON" and that doesn't sound very useful as an abstraction over raw PHP. ;) I'm probably being too narrow-minded. Please help me see the light.

Thanks,
-Derek

Xano’s picture

With "[update] feed", I meant the XML output that contains project information according to the format used for Drupal (is there a DTD for this? There should be!)

The current code that generates this feed is specific to how project_release.module stores its project data: in {project_release}. However, there may be people who want to provide an update feed that pulls its data from another source: different DB tables, or perhaps files stored on disk. This is why I suggest to rewrite the feed generation code to use content from function arguments and not from any other external source. The DB may be used, but for configuration and not for loading feed content (unless by an external function that calls the update feed API). This will add abstraction, but not to the level where the code just renders an array to XML. I don't think using arrays to store data is a DX-proof way. I'd suggest to use objects for this. They will be easier to document and understand, and the code handling them will be easier to read.
Also, instead of setting human-readable names (which is wrong enough in itself), we should pass on objects as well (term objects instead of term names, for instance). This will provide the alter hook with more context.

I hope that the above paragraph does a better job at explaining my suggestions than my previous post. I also hope that it shows why we might want to move the feed code to a separate project: if it no longer depends on project_release's data, why should it still be part of the project? It may be a lot more useful if we give it a place of its own.

drumm’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » drumm
Issue summary: View changes
Status: Postponed » Active
Related issues: +#2853696: Add security advisory coverage to update status XML

This is needed for #2853696: Add security advisory coverage to update status XML.

Around the D6 deprecation, we had a need for altering the XML, and SimpleXMLElement and an alter hook has been working well. The release-specific bits are still string concatenation.

  • drumm committed 1e1e8b1 on 7.x-2.x
    Issue #1003764: Replace Drupal.org-specific code with a hook in update...
  • drumm committed 8c60c6d on 7.x-2.x
    Issue #1003764: Refactor release XML rendering for update status
    
  • drumm committed d39027b on 7.x-2.x
    Issue #1003764: Refactor release information gathering for update status...
drumm’s picture

Status: Active » Fixed

  • drumm committed 623d008 on 7.x-2.x
    Issue #1003764: Rolling back bad refactoring
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.