Closed (fixed)
Project:
Drupal.org Testing
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
8 Mar 2008 at 16:22 UTC
Updated:
26 Oct 2008 at 18:53 UTC
Jump to comment: Most recent file
Comments
Comment #1
aclight commentedHere's a start on this. This currently just generates a few releases for the Drupal project itself. The code if quite hackish because I couldn't get it to work any other way. I really hate drupal_execute().
Still to do:
1. Make this less hackish (if possible).
2. Generate more releases for more projects. Also create some snapshot releases.
3. Figure out a way to deal with files. Right now, I've manually created files in my /files/project directory for each of the files mentioned in the release nodes. It would be much better if this was handled automatically.
4. Once we get this working, we'll probably want to revisit the automatic creation of project issues and start assigning those issues and comments to actual versions so that we have project issue and project releases working together in this respect.
Any suggestions on how to accomplish any of the above would be appreciated.
Comment #2
aclight commentedOk, with these two patches we're pretty close to nirvana as far as automatically generating project releases is concerned.
Let me explain what these patches do.
First of all, two new files are added:
* drupalorg_testing_build_releases.php: This is a script that is not designed to be run from within Drupal, but instead from the command line. It takes a list of projects and releases (hard coded into the script) that are used in the drupalorg_testing profile and contacts updates.drupal.org to get information about each release on d.o for each project and API term pair. Included in this information is the size, path, and hash of each release file. This script takes all of this information and dumps it (in the form of a serialized array) into another file
* drupalorg_testing_releases.inc: Contains a single function that contains a serialized array written by the file above. This file is included by the drupalorg_testing.profile file. It's pretty large, but it's designed to store data more than be code. Once in a while someone can run the file above on their machine to get new releases information, and then we can commit the changes in this file back to the project. When reviewing this patch, you can pretty much ignore this file--it's almost all data.
The other patch attached here is for the project issue module. It needs to be committed at the same time as or after this patch is committed or I think it'll break functionality in the project issues generation module. It basically just assigns issues and comments that are automatically generated to an appropriate revision. I also noticed a bug in the project_issue_generate_issue_comments() function. When the project was changed in a comment, a new array of categories needs to be created to make sure that a valid category is being used. I'm not sure that we've added any categories in any of the project nodes beyond the default categories, so this bug might not have actually shown up.
One thing I'd still like to do is to use the output of the XML data retrieved from updates.drupal.org and add that to {project_release_supported_versions}. Right now there is data written to that table, but it's not necessarily the same information that's on drupal.org.
Comment #3
aclight commentedAttached patch now generates rows in {project_release_supported_versions} as on d.o, with the exception that the snapshot column is set to 1 for all rows because I couldn't think of a way to pull this information from the XML data from updates.drupal.org.
One other thing, in case anyone is curious. I thought it's best to have this (rather large) data file that's created by the script included in this patch instead of fetching this data each time the profile is used so that it's possible to use the profile when offline. I suppose we could have it fetch fresh data if the user is online and otherwise fall back to the data file, but that's probably not worth the trouble.
I think this is working pretty well now, so I'm setting to CNR. This patch should be very useful when working on views conversion of project*.
Comment #4
dwwI guess I'm somehow not down with committing the auto-generated data file to CVS. I guess the rest of this profile is already a bunch of hard-coded data which could be auto-generated using similar means, so I don't know what my problem is. ;) But, something strikes me as very weird about this approach. That's my main hesitation. Otherwise, this all sounds good (though I haven't had time to look closely at the patches). Thanks for working on this, and yeah, it'll definitely be a huge help when it's done.
Comment #5
aclight commentedYeah, it does feel wrong to commit this big data file, but I can't think of any way around this unless we are ok with this profile being useless without internet connectivity (which I'm not). At least I didn't try to included the release node bodies as well :)
If it's the size of the data file that worries you I can probably figure out a way to compress it more, at the expense of readability. Storing a big array as a serialized string is obviously not that space efficient, but at least it keeps the data file somewhat readable.
If you can suggest another way to do this I'm willing to take a look.
Comment #6
hunmonk commentedwhat i'd like to see is:
ok, the .inc file may be a bit large, but it's totally readable, it's done as a regular .inc file, and it's periodically updatable via the script.
Comment #7
aclight commentedAttached patch prints the $releases and $supported_releases in a pretty format instead of serialized.
I've also added a check to the script that generates the drupalorg_testing_build_releases.php file that checks to make sure that the SimpleXML extension is available. It's included in PHP 5 and greater by default.
Comment #8
aclight commentedThis might need to be modified to not try to add release files and such if touch() is not permitted due to file system settings.
Comment #9
aclight commentedFixed a bug where the script that generates the data file would fail if SimpleXML *was* present, not if it was absent.
Also, a comment is now added at the top of the data file with the date and time it was generated.
Comment #10
hunmonk commentedcouple of things:
$releases = array_merge(dot_get_releases($project, $api_term, $supported_releases), $releases);-- would it be cleaner to do both $releases and $supported_releases by reference?Comment #11
aclight commentedre #10
1:
Are you talking about the code following this comment?
Since I don't typically sigh in my comments, I think that came from somewhere else in the profile, but I don't recall if I tested that the comment is still true.
2:
Yeah, it looks like parse_url(), possibly in combination with basename(), should do the trick.
Comment #12
dwwMy crusty memory (and thankfully, cvs annotate) says that comment was from webchick:
Furthermore, I think we've since figured out the problem with why drupal_execute() wasn't working for taxonomy stuff. And thanks to the joys of searchable issue history, we have an answer:
#151976-2: auto-generate some of the non-CVS/non-release projects, too
Comment #13
aclight commented@dww: By my reading of the issue you linked to, it sounds like, at the moment, this hack would still be necessary, right? Or has this been fixed in the project module and I'm not aware of it?
Comment #14
dwwI don't believe we've yet fixed that problem, no. Checking the code and/or CVS archeology could confirm, but for now, I'd just leave those in place.
Comment #15
aclight commentedFirst, I want to point out here that before this code can be committed, #267313: Allow .inc files in contributions/profiles needs to be addressed, because otherwise the .inc file created by this patch won't be allowed to be committed to the repository.
Regarding hunmonk's comments in #10:
1. I added a code comment with a link to the issue dww pulled up in #12 to explain why the manual queries are still necessary.
2. Fixed.
3. Casting does work, but it's not quite that simple since $terms is a SimpleXML object that contains nested SimpleXML objects, so the casting to array has to be done several times. However, it's quite a bit less code than it was with the object_to_array() function there.
4. Good point. Fixed. By passing these by reference, the projects and releases are handled in a different order than they were previously, so the .inc files from before I made the change and the new one included in the patch will not be identical, however as far as I can tell the data for each release is the same, just the order is different.
I also fixed a few other things in this patch:
a) Improved handling of release nodes on d.o that have no file information in the downloaded XML (old releases from the Drupal project). Now, no value for the file path will be stored to the database, whereas before the function was storing the path without the file name.
b) Improved code in _drupalorg_testing_create_content_project_release() so that the /files and /files/project directories are created. If this isn't successful, then the function doesn't attempt to create the empty files associated with releases, and also doesn't add information about the files to {project_release_nodes}, because doing so would cause PHP errors when releases are viewed but the file associated with the release doesn't exist. This also takes care of my concern from comment #8 above.
Comment #16
dwwJust went over this closely with aclight in IRC. I only have relatively minor gripes at this point:
A) I'm glad the // CHEESY HACK comments now link to the actual answer, but they still tell lies about bootstrapping, etc. We should fix those comments to summarize the real reason, instead of spreading confusion about bootstrapping.
B) It'd be nicer if we could specify the version stuff for the drupal_execute(), instead of doing that manually, since it's a lot of duplicated goo. But, if drupal_execute() is failing us again, I'm fine leaving this as-is.
C) "drupalorg_testing_build_releases.php" -- that's not really what the script does. How about "drupalorg_testing_build_release_info.php" or something? Then, the .inc file could be "drupalorg_testing_release_info.inc"...
D) How about moving the $error_message stuff inside the failure case?
Maybe using wordwrap() is cleaner here, too.
E) It'd be nice to cross reference this comment:
We should add the same reminder over at _drupalorg_testing_create_content_project().
F) It'd be nice if the script to generate the .inc file added a comment above each array it appends to the file. I totally missed the $supported_releases array in there since there was almost nothing to break it up visually as you scan the file.
Comment #17
dwwNew patch
A) Fixed.
B) I tried (briefly) and failed to get drupal_execute() to do the right thing. Not worth it -- what you have works, ship it! ;)
C) I wanted to leave that up to you before I just decided unilaterally, since you were already gone from IRC when I thought of this.
D) Fixed, wordwrap() indeed seems a lot better.
E) Fixed.
F) Fixed, along with some other pedantic spacing, style and comment issues.
In addition to the "// Generated on:" comment in the .inc file, I also added a "// Generated by:" since the @file comment references "a script" but doesn't name it.
So, other than (C), my only other concern is when I run the generation script, I get a bunch of PHP notices:
G) 2 of these:
H) dozens of these:
It all seems to work, so I don't care that much, but perhaps this can be resolved?
@aclight: Given I want your input on (C), and perhaps (G) and (H), I'm not going to commit this now. However, if you either resolve those or won't fix them, feel free to commit this.
Oh, and THIS TOTALLY ROCKS!!! ;) Wow. The profile is about 100 times more useful now. Very, very excellent.
Comment #18
aclight commented@dww: Good idea in (c) about changing the names of these two files. I agree that the names you proposed are better.
I also fixed the notices you reported in (g) and (h) above.
In addition, I modified a few of the comments very slightly.
I've attached the final patch, as well as a diff of your patch vs. my patch, so it's easy to see what I changed.
I also (briefly) tried again to get drupal_execute() to work in the places it's failing and had no success. I agree that it's not worth spending more time trying to get that fixed, since this patch makes the profile much more useful.
I'll be committing this soon.
Comment #19
aclight commentedCommitted to HEAD
http://drupal.org/cvs?commit=145958
Thanks for the reviews on this.
I've created an issue in the project_issue queue at #320278: Assign automatically created issues version information to get the patch from comment #2 committed there.
Comment #20
dwwYay, excellent! Thanks for all your work on this!!
Comment #21
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.