Showing posts with label Open Source. Show all posts
Showing posts with label Open Source. Show all posts

Monday, June 17, 2013

Drupal 8: Understanding the reroll process

N
ow that I'm trying to work on a slightly more involved reroll task, I'm coming up with a bunch more questions and some realizations about my workflow. First of all, I need to make sure to use my own time efficiently and not spend hours and hours trying to sort things out instead of taking a break and attacking a different problem. Secondly, I need to familiarize myself further with Drupal as a CMS before I have much chance of patching, rerolling and otherwise contributing to the open source project.

Also I badly need a better notetaking system because Blogger just lost my entire two page blog-post notes I had written here. @%#&! Text files, sadly, would be an improvement. I think I likely also said something about how to prioritize my time in order to become a highly useful Drupal contributor! This probably entails becoming more familiar with Drupal generally, working with it as a CMS, poking around the file tree etc.

This is the second reroll I've looked at, but the first to really be any fuss. Apart from sorting out the reroll system and infrastructure (which I think I've mostly got now), it's being able to parse the code on my own, rewrite it if necessary (?) and in this case update a year-old patch. This should actually be really easy, but I'm just figuring it out, so bear with me.

On applying the patch to the last commit it was known to work with, and then rebasing from the current version of 8.x, I got the following output. Only one conflict, which is nice. What do the lines marked "M" and "A" here mean?
$ git rebase 8.x
First, rewinding head to replay your work on top of it...
Applying: Applying patch from https://drupal.org/node/1008402#comment-5963414
Using index info to reconstruct a base tree...
M core/lib/Drupal/Core/StreamWrapper/LocalStream.php
A core/modules/system/tests/file.test
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): core/modules/system/tests/file.test deleted in HEAD and modified in Applying patch from https://drupal.org/node/1008402#comment-5963414. Version Applying patch from https://drupal.org/node/1008402#comment-5963414 of core/modules/system/tests/file.test left in tree.
Auto-merging core/lib/Drupal/Core/StreamWrapper/LocalStream.php
Failed to merge in the changes.
Patch failed at 0001 Applying patch from https://drupal.org/node/1008402#comment-5963414
The copy of the patch that failed is found in:
   /Users/E/Sites/drupal/.git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
If something is deleted in HEAD but modified in the patch, wouldn't that mean it isn't needed any more and should also be removed from the patch? Or else that chunk of code has been moved elsewhere. I'd like to just glance at the current commit for 8.x, but Git Tower doesn't seem to want to let me do anything without committing any/all changes in my working branch. That seems rather unhelpful, so perhaps I'm missing something about branch checkout?

Why does it look like the reroll instructions are saying I need to rewrite the code in question? I don't have specific experience/context for this patch, so not confident enough to really understand what's going on with it.

Some steps to clarify for myself before I move on from this:

  • Understand output of rebase/apply above: M and A are pretty definitely "Modify" and "Apply," as I had assumed (other options were "Merge" and "Add.") "Modified" and "Added"! 
  • Is file.test still in HEAD? Looks like no? There is no file.test in HEAD, from what Git is telling me. Unfortunately, branching is still giving me issues, and now I seem to have a stray un-named branch and some commits that Git Tower is hung up on. meh. Trying again... Appropriate commit to pull, should I lose things here: git checkout -b symlinks-old fe01ab6e16a73a
  • Ah ha. Ok, so yes, file.test is no longer in core/modules/system/tests/, but it looks like tests have been sorted out a bit, so maybe that chunk of code is somewhere else. In theory, what should happen here is that I ... have 8.x to diff against, and a branch checked out for this reroll. I attempt to rebase in my working branch, and when it doesn't work, I ... add the bit of code that used to be in file.test to wherever it might be now, then git add (being careful not to add files.test back in to HEAD accidentally), then hit rebase --continue, then keep going with the reroll instructions.
  • If not, did the code in this patch move somewhere else? What I did here was an attempt at using grep to search for a line from the file.test file anywhere in the tests directory. No luck. Tested my grepping (sp?) skills by just searching "symlink" and that pulled up a lot, but not the specific line from the file this patch was attempting to modify. So, looks like that test was just deleted/moved somewhere in the last year.
  • Does that mean that the testing part of the patch is no longer relevant, or that it should be incorporated into a different testing file? This is something I'm not experienced with, so can't attack. Will add comment to this effect in a bit, once I double check that I'm not just missing something easy. The lovely mentors at office hours are great for nudging in the right direction.
  • What does comment #61 have to do with this? #61 is just updating the patch to match the changes to the D8 test files, which seem to move around a lot. I had a look at some of the previous patch versions, and my previous bullet is definitely the case. I just can't be quite sure of where to put the tests, or where they went if I'm just not finding them appropriately.

::Take break for dinner and something not-the-computer-screen. I would've succeeded with the two hour task routine if I hadn't lost my notes. Really. Hoping office hours tonight are helpful and that nothing breaks this time (last Monday I spent 75% of the office hours mopping up a broken bottle in the pantry. sigh).

Some goals for this week: brush up on PHP, play with a functional install of Drupal as a CMS so I know what I'm looking at working on the backend. Kind of excited about using Drupal.

Tuesday, June 11, 2013

An attempted re-roll and several more hurdles

A
ssignment the second! With the help of Git Tower to tidy up my git messes, it's time to try out a re-roll. Or at least, futzing around with a patch until it works. This one was assigned to me during the core mentoring office hours, which meant it was already rather late at night. I couldn't work on it for at least 10 hours, so inevitably someone else had a whack at it first. Not a problem, always good to get things done, and I kind of like the competitive aspect there.

However, the posted reroll failed the automated tests, and a subsequent comment indicated that a single element was missing from that reroll that had (presumably) been in the previous version. Hokay. So where does that leave me? If it's missing just one thing, that one thing can be inserted and then tested again, yes?

Problems: I need to make sure I'm testing accurately, refreshing my entire local repo every time. I need to figure out exactly what is missing and where it goes. Update patch file. Test again. Upload. That seems easy, right? It's the technical details of how to do all that correctly and the first time that I get hung up on and unsure about. I need a lot of practice.
  1. Actually, on this one, I'm going to take a close, side-by-side look at the two versions of the patch and see if I can isolate the missing bits, drop them in, and call it a day. This should also clue me a little more regarding patch structure. I get the concept and the diff and the +/-, but parsing all that together on read through will take some practice. Doing this manually seems to have worked, my patch applies.
  2. Also going to try doing it this way, per berdir on IRC: "one trick would be to apply the previous patch over the current one with --reject, then the file should be added but all other changes would conflict and you can ignore them" 
And said patch passed tests and was reviewed affirmatively, so I guess it's ok. Frankly I'm amazed that things don't get broken more and that so many contributors are also patient mentors. Or my sample from the IRC is skewed, but I'm definitely grateful for that patience. 

Or rather, I'll try that second option as soon as I seriously sort out how to get my branches to work. Seems like changes I make on a checked out branch are still affecting my local head? That doesn't seem quite right. And meanwhile, 8.x doesn't seem to be working with MAMP anymore and I think that's enough for one night. Really looking forward to getting more experienced with all this.

Friday, June 7, 2013

Drupal: Re-checking that last patch?

oday I went back to take a look at the patch I reviewed yesterday, and it looks like it needs a little more review. Unfortunately, by the time I got to it, I think the patch was behind HEAD again, despite a rerolling earlier in the day, but on my second attempt after re-cloning, it seemed to apply ok.

While I'm here, some notes on my updating procedure. I'd love to find some more streamlined notes on this, will have a look in a sec.
  • The method I've been using is just to git pull (super minimal instructions) changes down without examining and merging (slightly more detailed, includes "what if patch doesn't apply") as individual steps. Git pull usually resets the install... I think. Or it did every other time I used it, but not this last time. Question: what's the best way to test that I've got the latest and greatest down properly?
  • So since that usually requires a reinstall, I also have to wipe the db from phpMyAdmin in MAMP. 
  • Apply patch using curl, check with git diff
  • That seems to be it, then I just reconnect to the now empty db during the install process. Usually. I guess this update didn't change anything in that vicinity?
Supposing that I have the newest HEAD (I have gathered this is what the latest version is called) down, let me just make sure I have everything clean and fresh and double check that the patch isn't applying... wipe db, pull, patch. Nope-ity no. 

Time to learn something new! Or just muddle around and feel silly about things, we'll see. What to do if a patch doesn't apply: Applying a patch manually, copy error msg into issue, "re-rolling" and adding to issue queue. 

First I want to test if I get that error I found in my last post without the patch applied. Nice fresh copy, connect db, test. Error is still there. Question: Should I create a new issue for it, if I can't find it elsewhere? 

hm. Ok, now the patch is applying again. Maybe that was just me? And just pulling doesn't reset everything, so how do I uninstall in order to start over? Seems silly to wipe the whole thing and re-clone each time. Grah, ok, wiped sites/default/files/php and /config_*, ditched settings.php and replaced it with a fresh copy, reloaded. 

Retesting patch... only partially works. Noted as best I could on the issue, but am so uncertain about the quality of my testing environment that I don't trust my reviewing capabilities. There's got to be a better way to set up and test without having to completely wipe and re-clone, but just pulling doesn't always reset? Rather confused and going to bed. 

Thursday, June 6, 2013

First Patch for Drupal 8.x

W
hew! Now that everything is set up, I'm back to the dev env page to get my first patch down, in, tested and confirmed. Hopefully I can get this done before someone else jumps on it. I kind of wish there was a check-out system for issues– oh I see, they're assigned, got it. So, here's my first issue for patch review: Remove drupal_add_css() from book.module.

Actually, step one: blink, get glass of water. Thanks to Jesse for plucking out a nice easy issue for me to start with and being so encouraging about my progress. 
  1. Apply the patch: 
    • First, git pull in Drupal directory. Sigh, right, of course. Configure again. Argh, so now my settings.php file wont write itself. Whelp, no idea what that was about, but I fixed it by creating a new default folder. I think the permissions had gotten screwed up on the previous, probably my own doing? Ok, wiped the entire thing, re-installed, re-db'd, reconnected. 
    • Pull down latest version of the patch. Finally found more detailed instructions on where to download the patch to here, 'cause I wanted to be sure. Went for "curl http://drupal.org/files/[patch-name].patch | git apply -" Didn't get any errors, so that seems to have worked. 
    • Run git diff to see changes... shiny, looks just like the view from the issue tracker. Will have to figure out how to use git diff a bit later. Note to self: make list of things to do "a bit later."
    • hm, but if I look at the module code, I'm not seeing the second addition from the patch. ohoh, duh, because that's a deletion, not an addition. Right!
  2. Enable the book module: Well that was easy, yay. This is, I'm a little sheepish to admit, my first time looking at the inside of a Drupal install. But look, the extend tab, logically, is modules, right? And then I just click this handy checkbox... The super easy, obvious UI is making me so happy. 
  3. Put some articles into a book: Articles, or book pages? I'll do some of both. 
  4. Verify that book.theme.css is still loading: tested by a) inspecting elements with Chrome dev tools, and b) using jQuery to find specific selectors in the dev tools console. Seems to work fine. Yay!
  5. Set the issue to "Reviewed and Tested by the Community" or "RTBC": Done. Wrote a nice, hopefully brief enough comment detailing my steps and mentioning the error I got for an unrelated (I think) issue. [Any issues I work will be recorded on my Drupal.org profile (you have to have an account to see my profile, but this issue is here).]
That should be it for now. I'll have to go find another issue to work on next! Well, right after I know that last one went ok. And maybe do a little more reading on patches and contributions and things. 

Local/Drupal: complete!

O
k, picking up from where I left off yesterday - configuring and finishing the local install of Drupal. References: dev env set up page and installation/configuration instructions. Instructions focus on command line tools, so that's good. Thank goodness I had already installed Git and know a few Unix commands or I'd really be behind the curve on this.


  1. Neat, here's a handy list of best practices for CMS usage. Completely agree about backups, and definitely need to test mine for the WordPress site I'm maintaining. ...Documentation can be such a rabbit hole; if I don't stop myself I'll just keep reading for hours.
  2. First we check system requirements, which I already looked at yesterday. Double checking in more detail now. I will want to enable clean URLs on my own site later on.
    • Web Server: Apache, check. Apache Virtualhost configuration file would be httpd.conf, I think, so I change the AllowOverride to "All" there.
    • DB server: MySQL is what MAMP uses, with PHPMyAdmin, so I should be set there. Not sure how to check what rights my account has or how to change max_allowed_packet, so I'm hoping everything just works. And my PHP is obviously already connected to MySQL. 
    • Good lord I wish I knew what I was doing.
    • Might need to up my memory for my own photography site later on. Maybe by the time I do that, I'll have plenty of experience and it'll be straightforward.
    • My favorite words today: "Enabled by default." 
    • On the bright side, I feel pretty confident about my skills once I have things installed. It's just finding all the configuration files and prying out info about new systems that's challenging.
  3. Download instructions not relevant, already have the local directory and Dreamhost has its own instructions that I'll use for my site later. oop, actually I do need to drop the Drupal folder contents into my specified web root, or just redirect the web root. I "woohoo'd" when I saw this in my browser. A little soon for the woohoos, perhaps.

  4. Oh hey, Mac specific install notes regarding PHP, MAMP and other things from my last post. Whoops. Also this note on CVS repository... Question: is this relevant, and wouldn't the Git functionality supersede it? I should figure out how to keep my local version up to date. I bet that's later in the instructions... 
  5. Looks like Drupal will create its own DB, so I'm off the hook for that... Might have to adjust settings.php, but I know where to find it, so I'll come back to this step if the install script throws an error. 
  6. Checking my MAMP install against the instructions here. Hm. Well this is saying I DO need to create my DB (and here are those pesky user rights from above). hm! all these instructions overlap, so I'm just going to stick with this one, then check back on the INSTALL.txt instructions, and really everything should work fine anyway. Really appreciating the detailed instructions on this link for db creation (necessary or not). Found max_allowed_packet here, too. 
  7. Annd filling out the db info on the install page... looks like I wont need much more from the help docs at this point, though I do wonder if I should do "minimal" or "standard." Standard makes sense for testing, rather than custom, right? right.
  8. Ok, I think... I think that's done. I get the site login page, changed some settings as in the MAMP local instructions above, db works, only thing I feel stupid about is not installing in the directory I should have. Question: how could I move the entire shebang? What's connected? MAMP needs the location, but the installation script wrote a whole bunch of db links I'm not sure about. Not critical, just irritating to my file system.
And with that, I move on to the rest of the dev env instructions and start my first patch/module/test!

Wednesday, June 5, 2013

.ignore: Setting Up Local Drupal

y blog here is just going to be very dry for a little while as personal notes/documentation, apologies for that. Once I get some things set up I can filter tags/categories and have sections for tailored subscription... but right now I just need to set up a local install of Drupal 8.x (d8). There are instructions here on Drupal.org on setting up a developer environment (dev env), but I needed a few more steps along the way.

I would have very little idea what I was doing, even with all the documentation, if not for the Drupal Core Mentoring Office Hours, and particularly the very patient help of YesCT on the #Drupal IRC. I will definitely be back for the next office hours session I can get to. And... thank goodness "there are no stupid questions," 'cause boy are some of mine... non-stupid.
  1. The above link includes some requirements for the dev env, but I needed to check a few background items, like PHP, to make sure they also fit the requirements for a Drupal install. Step one, actually, was making sure I had accounts set up on Drupal.org and DrupalCoreMentoring.org. I was also pointed at issues for the d8 dev env here, just in case anything listed there would trip me up along the way. 
    • The one thing from the dev env list I was obviously missing was Drush, which isn't immediately necessary, but I figured I'd get it out of the way. The best way to install for d8 seems to be a git clone from the Drush project page, then following the instructions in the ReadMe to check that it's "using the same PHP as the web user." Question: Is that PHP version, settings, .ini file? 
    • It looks like typing "php -v" in the shell gives me info on whether it's the CLI variety or not (I'm not going to fuss about understanding that completely right now). 
    • Finally found more explicit instructions on command line install of Drush here. The video is the ultimate answer. 
    • However, got this error: The following restricted PHP modes have non-empty values: [error] magic_quotes_gpc. This configuration is incompatible with drush. Please check your configuration settings in or in your drush.ini file; see examples/example.drush.ini for details. Argh. [turns out there's an easy way to turn magic quotes off. oh well]
    • Ok, so then I go to example.drush.ini in the drush install directory and follow those instructions... Turns out my local PHP is out of date, hence magic quotes (deprecated a while ago). Installing new PHP and god-help-me configuring it. 
    • And back to the Drush ReadMe, I added an export PATH to my bash_profile specifying PHP 5.4, although MAMP is on 5.4.10 and command line PHP is 5.4.12... CL PHP ini file is at /usr/local/php5/lib/php.ini, MAMP file is at /Applications/MAMP/bin/php/php5.4.10/conf/php.ini
    • I want matching memory_limit 512M and time limit 120 seconds in both files, I think. Not sure about what this step is referring to, so hoping it's these two files, not that I should have just one .ini file. Changed memory limits to match. Question: where is the time limit? script execution or input?
  2. Not a clue where I left off... I think the next step is getting my Drupal from version control via git clone.  This really ought to be easy... downloaded just fine.
  3. Then adding the Git Deploy module. hm. Doesn't appear to be released for 8.x. Question: Do I need Git Deploy for patch work? 
  4. Checking back on the dev env page for configuration and other steps... Just need to install? Will have to do that tomorrow.
  5. Then that should probably do it, and I'll leave the rest for tomorrow. I think the next steps are finding a project, and I shouldn't need to mess much with this install until I have something to test. 


Monday, June 3, 2013

Overloaded - Journaling some progress

his will be a less coherent post than usual, just because I'm in process a lot sooner than I thought I'd be. Going back to my Grand List, the intent was that I would research several different CMS platforms (Drupal, WordPress, Joomla etc) before choosing one, or even deciding that a full fledged CMS was too heavy for my purposes. In an ideal world (I've been using "ideal" more lately. hm. Self-awareness?), I'd probably design my own database and create the whole thing from scratch. Since that would require being a db architect, it would take quite a lot longer than winging it in a CMS.

More recently, I had decided to go with WordPress, simply because I have some experience with it already and would be building on that, rather than learning yet another new skill set. I had been thinking that Drupal was the more sophisticated option, and that I could learn yet more awesome new things by installing it, but second-guessed myself into a corner. Really, WordPress has given me some pretty big headaches over the last couple of years.

This past weekend was the National Day of Civic Hacking. Within a span of four days, my whole outlook and project list merged onto a gigantic, fast-moving highway of projects, people, inspiration and busy, busy schedules. Now I find myself wrapped up in Code for DC, a project to map migration and DC school boundaries, hopefully getting further involved with Girl Develop It, and throwing myself at Drupal Core.

The big problem here is that every single thing I just listed has not just a physical group and projects, but Hackpads, Trello boards, Google Groups, Meetups, Twitter accounts, GitHub accounts, CKAN site, IRC channels, calendars, forums, websites and good lord do I have a lot of tabs open. I think I linked up with everyone from the weekend, signed up for everything I needed to... at this point I'm just hoping that anything important will ping a notification to my email, otherwise it'll be lost in the aether.

But back to Drupal. Let's just take a look at where I'm at, mostly for personal reference. I signed onto Drupal.org, and to DrupalMentoring.org. Joined the DC Drupalers meetup. Have [just] four IRC channels up in preparation for the Office Hours later tonight from the mentoring people (who I hope will be able to give me dummy points on installation and patches and link me up with an appropriately straightforward project [open issue]).

Some questions, having just read the Drupal overview here (front-end installation stuff) and nearly every other page I could find after that:

  • Why XHTML?
  • What exactly happens in terms of nodes, paths, blocks, users when a page is requested? How does the request play out?
  • Wait, so bootstrap, which isn't bootstrapping, or Bootstrap? argh. But sort of like the WordPress Loop, yes?
  • I've really got to learn PHP/more PHP. What are alternatives to PHP? How else can web pages be dynamic?
  • So there are issues listed on Drupal.org and DrupalMentoring.org... how are they related? Same thing, different interface? (oh, I see, they're linked and the Drupal.org is the main page for info comments etc)

... a bit brain-dead right now, which is unhelpful given that the mentoring office hours are in... an hour!