news aggregator

NEWMEDIA: DrupalCamp Colorado 2014: Large Scale Drupal

Planet Drupal - Fri, 25/07/2014 - 2:26pm
DrupalCamp Colorado 2014: Large Scale DrupalWith less than a week until the camp, here is a preview of what to expect from our team!

Everyone here at NEWMEDIA is extremely enthusiastic about this year's DrupalCamp Colorado, which will be held on August 1st-3rd in Denver. This year’s theme for the camp is “Large Scale Drupal” where the focus is on how  larger organizations can become more collaborative with the Drupal community by pooling ideas and resources together to solve common issues they are facing. There will be a wide variety sessions this year, six of which will be presented by members of NEWMEDIA. We are also very excited about being a Platinum sponsor.

Drupal 8 Module Development: Just the Basics

Start off this years DrupalCamp Colorado right and jump into Drupal 8 module development.  Brandon Williams  will cover the basics of Symphony and the Drupal 8 module , including a review of what has replaced some of the most common hooks from D7. Brandon is an advocate for learning and change and in the technological world we experience that invariably. While Drupal 7 will be the best option for the short-term, it is never too early to dive in to D8 as he describes in why I love D8!

Jenkins 101: A Drupal Perspective

Want to know more about Jenkins from a Drupal perspective and have a better understanding on how Jenkins can be applied to multiple processes? Then you should join Brandon in his second session that will introduce Jenkins from a Drupal perspective and how it has been proven to be beneficial within NEWMEDIA. As a community we can take this knowledge and continue the conversation to help emerge the tools to permit everyone to become more effective.

Securing customers credit card data

Security for your clients credit cards is now a necessity in today's growing eCommerce market. Rick Manelius  will review all of the parts of the standard that apply to Drupal along with providing efficient advice on how to best reduce one's risk when processing credit cards. As the amount of eCommerce transactions continues to rise it becomes even more critical to support every part in the system. If you would like more information on PCI compliance for Drupal  visit DrupalPCICompliance.org you can also download the free, community sponsored white paper.

The SCSSy Wild West: Partial Organization for a Complete Site

Take a look at Tim’s blog Partial to Partials: BoF Recap for a recap of last years session about the organization of partials.This year Tim Whitney  will go over a partial layout strategy for all scales of Drupal and non Drupal. Going over common pain points of SCSS partials and how to alleviate them while including approaches to help make life a little easier for everyone.

Integration Testing with KitchenCI & Multiple Provisioners

“Works on my machine” is no longer an acceptable reason for a Drupal site to not perform as expected across multiple environment (i.e. production, staging, development, and local development). This is particularly important as projects become larger, more complex, and have stringent requirements on performance, uptime, and security. Kevin Bridge's presentation will start with the basics of “Infrastructure as Code” and then quickly ramp up to review how to use provisioning tools and integration tests to ensure your infrastructure is achieving the desired state.

Intro to Frontend Ops

Discover the tools that help frontend developers stay consistent as they develop their drupal themes. This discussion from Ryan McVeigh will focus on gruntjs and bower and will also discuss Gulp JS, Phantomjs, PageSpeed, and Slimer JS. You will be able to watch some of his pre-recorded demos of the tools in action. Come and join in on the  discussion and see how the use of these various tools can contribute to your routine work day.

Come Join Us!

There is still time to sign up for this weekend and better yet it is free with the option to donate.  Any registration contributions beyond DrupalCamp Colorado’s  budget target will be donated to 3 charities: The Ada Initiative, Code.org, and Electronic Frontier Foundation.  This weekend has a  great full-day Training Day on August 1st and will be offering three separate classes you can pay and sign up for.

Categories: Drupal News

Another Drop in the Drupal Sea: Ways to shoot yourself in the foot: element validation

Planet Drupal - Fri, 25/07/2014 - 2:21pm

I needed to do some custom validation of fields on a form. So, I decided to use #element_validate. One of the fields I was validating appeared a bit strange to me, though. When I displayed its $form_state['values']['field_face_palm'] information I saw that it looked like:

$field_face_palm['und'] = 'you_knucklehead'

instead of like:

$field_face_palm['und'][0]['value'] = 'you_knucklehead'

read more

Categories: Drupal News

Drupal.org frontpage posts for the Drupal planet: Drupal 7.30 released

Planet Drupal - Fri, 25/07/2014 - 9:12am

Drupal 7.30, a maintenance release with several bug fixes (no security fixes), including a fix for regressions introduced in Drupal 7.29, is now available for download. See the Drupal 7.30 release notes for a full listing.

Download Drupal 7.30

Upgrading your existing Drupal 7 sites is recommended. There are no new features in this release. For more information about the Drupal 7.x release series, consult the Drupal 7.0 release announcement.

Security information

We have a security announcement mailing list and a history of all security advisories, as well as an RSS feed with the most recent security advisories. We strongly advise Drupal administrators to sign up for the list.

Drupal 7 includes the built-in Update Manager module, which informs you about important updates to your modules and themes.

There are no security fixes in this release of Drupal core.

Bug reports

Drupal 7.x is being maintained, so given enough bug fixes (not just bug reports), more maintenance releases will be made available, according to our monthly release cycle.

Changelog

Drupal 7.30 is a bug fix only release. The full list of changes between the 7.29 and 7.30 releases can be found by reading the 7.30 release notes. A complete list of all bug fixes in the stable 7.x branch can be found in the git commit log.

Update notes

See the 7.30 release notes for details on important changes in this release.

Known issues

None.

Front page news: Planet DrupalDrupal version: Drupal 7.x
Categories: Drupal News

Mediacurrent: Code Review for Non-Technical Folks

Planet Drupal - Fri, 25/07/2014 - 8:07am

Andrew Riley leads us through a high level walkthrough of what Code Reviews are and why we need them. In this talk he covers what we check for at Mediacurrent (syntax, security, efficiency etc) and why code reviews are important for our customers and any company that writes their own code.

Additional Resources

Drupal 8 In Pictures (for Users) | Mediacurrent Blog

Categories: Drupal News

Forum One: Drupal 8 Code Sprint at the Jersey Shore

Planet Drupal - Fri, 25/07/2014 - 5:52am

On the heels of our own Drupal 8 code sprint in DC, I spent the last weekend with the New Jersey Drupal group who organized a Drupal 8 code sprint in Asbury Park, NJ – and although I was never greeted by The Boss, I was pleased to participate thanks to the generosity of the event organizers.

Issue-Focused

I worked on the MenuLink NG part 1 issue extensively with Peter Wolanin and YesCT. This issue is part of the [Meta] New plan, Phase 2 issue which proposed performance improvement and UI improvement in Drupal 8. This issue originally had a 600KB patch, but to make it more reviewable/committable the issue was split into five child issues.

Three of us spent a solid two days and more than 30 hours addressing every single point that had been raised by reviewers – and which had been holding up the process of adding this to Core.

Image courtesy of Blink Reaction

About this Issue (a high level overview)

A site builder or developer can create menu links in Drupal via configuration by changing the weight, position, creating links in menu, or in code. All these different types of menu links need to be rendered together in menus, so that they present the same in the API to developers. The developer experience on this issue needs to be easy, as almost everything depends on menu items.

While we toiled on this issue, other sprinters worked on DrupalCon Austin’s Consensus Banana, testing the migration path from Drupal 6 to Drupal 7, along with some other issues.

Results and Commits

The sprint was a very productive one, and resulted in Menu part 1 and Menu part 2 being committed to Core, which was a beta-blocker issue. As of this sprint there were seven beta-blocker issues, but solving the Menu issue helps to put us one step closer to the Drupal 8 Beta release!

For those interested, here are the commits for part 1 and part 2. And for those needing a chuckle, Alex “The Situation” Pott – who thankfully preferred DCC (Drupal Core Commits) over GTL (Gym, Tan, Laundry) – drew this goaty looking lama to celebrate his commit

Image courtesy of Blink Reaction

It was very rewarding to work for a weekend with this group of talented developers, and I think we all left the shore content in the knowledge that we’d made strides toward bringing Drupal 8 that much closer to completion.

Check out these other pictures taken by Peter Wolanin and DrupalCamp NJ at the event »

Categories: Drupal News

Dries Buytaert: The business behind Open Source

Planet Drupal - Fri, 25/07/2014 - 1:38am
Topic: DrupalAcquiaBusinessThe future

A few days ago, I sat down with Quentin Hardy of The New York Times to talk Open Source. We spoke mostly about the Drupal ecosystem and how Acquia makes money. As someone who spent almost his entire career in Open Source, I'm a firm believer in the fact that you can build a high-growth, high-margin business and help the community flourish. It's not an either-or proposition, and Acquia and Drupal are proof of that.

Rather than an utopian alternate reality as Quentin outlines, I believe Open Source is both a better way to build software, and a good foundation for an ecosystem of for-profit companies. Open Source software itself is very successful, and is capable of running some of the most complex enterprise systems. But failure to commercialize Open Source doesn't necessarily make it bad.

I mentioned to Quentin that I thought Open Source was Darwinian; a proprietary software company can't afford to experiment with creating 10 different implementations of an online photo album, only to pick the best one. In Open Source we can, and do. We often have competing implementations and eventually the best implementation(s) will win. One could say that Open Source is a more "wasteful" way of software development. In a pure capitalist read of On the Origin of Species, there is only one winner, but business and Darwin's theory itself is far more complex. Beyond "only the strongest survive", Darwin tells a story of interconnectedness, or the way an ecosystem can dictate how an entire species chooses to adapt.

While it's true that the Open Source "business model" has produced few large businesses (Red Hat being one notable example), we're also evolving the different Open Source business models. In the case of Acquia, we're selling a number of "as-a-service" products for Drupal, which is vastly different than just selling support like the first generation of Open Source companies did.

As a private company, Acquia doesn't disclose financial information, but I can say that we've been very busy operating a high-growth business. Acquia is North America's fastest growing private company on the Deloitte Fast 500 list. Our Q1 2014 bookings increased 55 percent year-over-year, and the majority of that is recurring subscription revenue. We've experienced 21 consecutive quarters of revenue growth, with no signs of slowing down. Acquia's business model has been both disruptive and transformative in our industry. Other Open Source companies like Hortonworks, Cloudera and MongoDB seem to be building thriving businesses too.

Society is undergoing tremendous change right now -- the sharing and collaboration practices of the internet are extending to transportation (Uber), hotels (Airbnb), financing (Kickstarter, LendingClub) and music services (Spotify). The rise of the collaborative economy, of which the Open Source community is a part of, should be a powerful message for the business community. It are the established, proprietary vendors whose business models are at risk, and not the other way around.

Hundreds of other companies, including several venture backed startups, have been born out of the Drupal community. Like Acquia, they have grown their businesses while supporting the ecosystem from which they came. That is more than a feel-good story, it's just good business.

Categories: Drupal News

drunken monkey: Updating the Search API to D8 – Part 3: Creating your own service

Planet Drupal - Thu, 24/07/2014 - 11:28pm

Even though there was somewhat of a delay since my last post in this series, it seems no-one else has really covered any of the advanced use cases of Drupal 8 in tutorials yet. So, here is the next installment in my series. I initially wanted to cover creating a new plugin type, but since that already requires creating a new servive, I thought I'd cover that smaller part first and then move on to plugin types in the next post.
I realize that now already a lot more people have started on their Drupal 8 modules, but perhaps this will make this series all the more useful.

Services in Drupal 8

First, a short overview of what a service even is. Basically it is a component (represented as a class) providing a certain, limited range of functionality. The database is a service, the entity manager (which is what you now use for loading entities) is a service, translation, configuration – everything handled by services. Getting the current user – also a service now, ridding us of the highly unclean global variable.
In general, a lot of what was previously a file in includes/ containing some functions with a common prefix is now a service (or split into multiple services).

The upsides of this is that the implementation and logic is cleanly bundled and properly encapsulated, that all these components can easily be switched out by contrib or later core updates, and that these systems can also be very well tested with unit tests. Even more, since services can be used with dependency injection, it also makes it much easier to test all other classes that use any of these services (if they can use dependency injection and do it properly).

(For reference, here is the official documentation on services.)

Dependency injection

This has been covered already in a lot of other blog posts, probably since it is both a rather central concept in Drupal 8, and a bit complicated when you first encounter it. However, before using it, I should still at least skim over the topic. Feel free to skip to the next heading if you feel you already know what dependency injection is and how it roughly works in Drupal 8.

Dependency injection is a programming technique where a class with external dependencies (e.g., a mechanism for translating) explicitly defines these dependencies (in some form) and makes the class which constructs it responsible for supplying those dependencies. That way, the class itself can be self-contained and doesn't need to know about where it can get those dependencies, or use any global functions or anything to achieve that.

Consider for example the following class:

<?php
class ExampleClass {

  public function getDefinition() {
    return array(
      'label' => t('example class'),
      'type' => 'foo',
    );
  }

}
?>

For translating the definition label, this explicitly uses the global t() function. Now, what's bad about this I, hear you ask, it worked well enough in Drupal 7, right?
The problem is that it becomes almost impossible to properly unit-test that method without bootstrapping Drupal to the point where the t() function becomes available and functional. It's also more or less impossible to switch out Drupal's translation mechanism without hacking core, since there is no way to redirect the call to t().

But if translation is done by a class with a defined interface (in other words, a service), it 's possible to do this much cleaner:

<?php
class ExampleClass {

  public function __construct(TranslationServiceInterface $translation) {
    $this->translation = $translation;
  }

  public function getDefinition() {
    return array(
      'label' => $this->translation->translate('example class'),
      'type' => 'foo',
    );
  }

}
?>

Then our example class just has to make it easily possible for code that wants to instantiate it to know how to pass its dependencies to it. In Drupal, there are two ways to do this, depending on what you are creating:

  • Services, which themselves use dependency injection to get their dependencies (as you will see in a minute) have a definition in a YAML file that exactly states which services need to be passed to the service's constructor.
  • Almost anything else (I think) uses a static create() method which just receives a container of all available services and is then responsible for passing the correct ones to the constructor.

In either case, the idea is that subclasses/replacements of ExampleClass can easily use other dependencies without any changes being necessary to code elsewhere instantiating the class.

Creating a custom service

So, when would you want to create your own service in a module? Generally, the .module file should more or less only contain hook implementations now, any general helper functions for the module should live in classes (so they can be easily grouped by functionality, and the code can be lazy-loaded when needed). The decision to make that class into a service then depends on the following questions:

  • Is there any possibility someone would want to swap out the implementation of the class?
  • Do you want to unit-test the class?
  • Relatedly, do you want dependency injection in the class?

I'm not completely sure myself about how to make these decisions, though. We're still thinking about what should and shouldn't be a service in the Search API, currently there is (apart from the ones for plugins) only one service there:

The "Server task manager" service

The "server tasks" system, which already existed in D7, basically just ensures that when any operations on a server (e.g., removing or adding an index, deleting items, …) fails for some reason (e.g., Solr is temporarily unreachable) it is regularly retried to always ensure a consistent server state. While in D7 the system consisted of just a few functions, in D8 it was decided to encapsulate the functionality in a dedicated service, the "Server task manager".

Defining an interface and a class for the service

The first thing you need, so the service can be properly swapped out later, is an interface specifying exactly what the service should be able to do. This completely depends on your use case for the service, nothing to keep in mind here (and also no special namespace or anything). In our case, for server tasks:

<?php
namespace Drupal\search_api\Task;

interface ServerTaskManagerInterface {

  public function execute(ServerInterface $server = NULL);

  public function add(ServerInterface $server, $type, IndexInterface $index = NULL, $data = NULL);

  public function delete(array $ids = NULL, ServerInterface $server = NULL, $index = NULL);

}
?>

(Of course, proper PhpDocs are essential here, I just skipped them for brevity's sake.)

Then, just create a class implementing the interface. Again, namespace and everything else is completely up to you. In the Search API, we opted to put interface and class (they usually should be in the same namespace) into the namespace \Drupal\search_api\Task. See here for their complete code.
For this post, the only relevant part of the class code is the constructor (the rest just implements the interface's methods):

<?php
class ServerTaskManager implements ServerTaskManagerInterface {

  public function __construct(Connection $database, EntityManagerInterface $entity_manager) {
    $this->database = $database;
    $this->entity_manager = $entity_manager;
  }

}
?>

As you can see, we require the database connection and the entity manager as dependencies, and just included them in the constructor. We then save them to properties to be able to use them later in the other methods.

Now we just need to tell Drupal about our service and its dependencies.

The services.yml file

As mentioned earlier, services need a YAML definition to work, where they also specify their dependencies. For this, each module can have a MODULE.services.yml file listing services it wants to publish.

In our case, search_api.services.yml looks like this (with the plugin services removed):

services:
  search_api.server_task_manager:
    class: Drupal\search_api\Task\ServerTaskManager
    arguments: ['@database', '@entity.manager']

As you see, it's pretty simple: we assign some ID for the service (search_api.server_task_manager – properly namespaced by having the module name as the first part), specify which class the service uses by default (which, like the other definition keys, can then be altered by other modules) and specify the arguments for its constructor (i.e., its dependencies). database and entity.manager in this example are just IDs of other services defined elsewhere (in Drupal core's core.services.yml, in this case).

There are more definition keys available here, and also more features that services support, but that's more or less the gist of it. Once you have its definition in the MODULE.services.yml file, you are ready to use your new service.

Using a service

You already know one way of using a service: you can specify it as an argument for another service (or any other dependency injection-enabled component). But what if you want to use it in a hook, or any other place where dependency injection is not available (like entities, annoyingly)?

You simply do this:

<?php
/** @var \Drupal\search_api\Task\ServerTaskManagerInterface $server_task_manager */
$server_task_manager = \Drupal::service('search_api.server_task_manager');
$server_task_manager->execute();
?>

That's it, now all our code needing server tasks functionality benefits from dependency injection and all the other Drupal 8 service goodness.

Categories: Drupal News

Pedro Rocha: OOP in Drupal 7: Cool module in practice

Planet Drupal - Thu, 24/07/2014 - 7:08pm
Hey, do you wanna know how to: reduce the amount of code needed to create modules turns the code more readable make it easier to find bugs make it easier to change business logic make it easier to improve code Sounds good, right? If you only wanna know about code, jump to here, or read about the historical background of the module ;)
Categories: Drupal News

NEWMEDIA: Avoiding the "API Integration Blues" on a Drupal Project

Planet Drupal - Thu, 24/07/2014 - 2:31pm
Avoiding the "API Integration Blues" on a Drupal ProjectAs Drupal continues to mature as a platform and gain adoption in the enterprise space, integration with one or more 3rd party systems is becoming common for medium to large scale projects. Unfortunately, it can be easy to underestimate the time and effort required to make these integrations work seamlessly. Here are lessons we've learned...

Mailchimp, Recurly, Mollom, Stripe, and on and on—It's easy to get spoiled by Drupal's extensive library of contributed modules that allow for quick, easy, and robust integration with 3rd party systems. Furthermore, if a particular integration does not yet exist, the extendability of Drupal is straightforward enough that it could be done given the usual caveats (i.e. an appropriate amount of time, resources, and effort). However, these caveats should not be taken lightly. Our own experiences have unearthed many of the same pain points again and again, which almost always result in waste. By applying this gained wisdom to all subsequent projects involving integrations, we've been much more successful in identifying and addressing these issues head on. We hope that in sharing what we've learned that you can avoid some of the more common traps.

API and Integration Gotchas Vaporware

Shocking as it may seem, there are situations where a client will assume an API exists when there isn't one to be found. Example: a client may be paying for an expensive enterprise software license that can connect to other programs within the same ecosystem, but there may not be an endpoint that can be accessed by Drupal. They key here is to ensure you have documentation up front along with a working example of a read and/or write operation written in php or through a web services call. Doing this as early as possible within the project will help prevent a nasty surprise when it's too late to change course or stop the project altogether.

Hidden Add-on Fees

An alternative to the scenario above is when an endpoint can be made available for an additional one-time or recurring fee. This can be quite an expensive surprise. It can also result in a difficult conversation with the client, particularly if it wasn't factored into the budget and now each side must determine who eats the cost. The key to preventing this is to verify (up front) if the API endpoint is included with the client's current license(s) or if it will be extra.

Limited Feature Sets

One can never assume that an entire feature set is available. Example: an enterprise resource planning (ERP) software solution may provide a significant amount of data and reporting to its end users, but it may only expose particular records (e.g. users, products, and inventory) to an API. The result: a Drupal site's scope document might include functionality that simply cannot be provided. To avoid this issue, you'll want to get your hands on any and all documentation as soon as possible. You'll also want to create an inventory of every feature that requires a read/write operation so that you can verify the documentation covers each and every item.

Documentation

Transcending the "Drupal learning cliff" was and continues to be a difficult journey for many members of the community despite the abundance of ebooks, videos, and articles on the subject matter. Consider how much more difficult building Drupal sites would be if these resources didn't exist. Now imagine trying to integrate with a systems you've never heard of using a language you're unfamiliar with and no user guide to point you in the right direction.

Sounds scary, doesn't it?

Integrating with a 3rd party application without documentation is akin to flying blind. Sure you might eventually get to the appropriate destination, but you will likely spend a significant amount of time using trial and error. Worse yet, you may simply miss certain pieces of functionality altogether.

The key here, as always, is to get documentation as soon as you can. Also, pay attention to certain red flags, such as the client not having the documentation readily available or requiring time for one of their team members to write it up. This is particularly important if the integration is a one-off that is specific to the customer versus an integration with a widely known platform (e.g. Salesforce or PayPal).

Business Logic

One of Drupal's strengths is the ability for other modules to hook in to common events. For example, a module could extend the functionality of a user saving his or her password to email a notification that a password was changed.When integrating with another system, it's equally important to understand what events may be triggered as a result of reading or writing a record. Otherwise, you may be in for a surprise to find out the external system was firing off emails or trying to charge credit card payments.

Documentation is invaluable to prevent these types of gaffs. However, in our experience it has been important to have access to a support resource that can provide warnings up front.

Support

What happens when the documentation is wrong or the software doesn't work? If support regarding the API is slow or non-existant, the project may grind to halt until this block is removed. For enterprise level solutions, there is usually some level of support that can be accessed via phone, forums, or support tickets. However, there can sometimes be a sizable fee for this service and your particular questions might not be in scope with respect to what their service provides. In those instances, it might be helpful to contract with a 3rd party vendor or contractor that has performed a similar integration in the past. This can be costly up front while saving a tremendous of time over the course of the project.

Domain Knowledge

As consultants, one of our primary objectives is to merge our expertise with that of the customer's domain knowledge in order to best achieve their goals. Therefore, it's important that we understand why the integration should work the way it does instead of just how we read and write data back and forth. A great example of this involves integrating Drupal Commerce with Quickbooks through the Web Connecter application. It's imperative to understand how the client's accounting department configures the Quickbooks application and how it manages the financial records. Otherwise a developer may make an assumption that results in an inefficient or (worse) incorrect functionality.

Similar to having a resource available for support on the API itself, it's invaluable to have access to team members on the client side that use the software on a daily basis so that nothing is missed.

Stability

Medium to large sized companies are becoming increasingly reliant on their websites to sustain and grow their businesses. Therefore, uptime is critical. And if the site depends on the uptime of a 3rd party integration to function properly, it may be useful to consider some form of redundancy or fallback solution. It is also important to make sure that support tickets can be filed with a maximum response time specified in any service licensing agreement (SLA) with the client.

Communication and Coordination

The rule of thumb here is simple: more moving parts in a project equals more communication time spent keeping everyone in sync. Additionally, it's usually wise to develop against an API endpoint specifically populated with test data so that it will not impact the client's production data. At some point, the test data will need to be cleared out and production data will need to be imported. This transition could be as simple as swapping a URL or it could involve significant amount of QA time testing and retesting full imports before making the final switch.

The best way to address these issues is simply to buffer in more communication time into the budget than a normal Drupal project.

SDKs

One gotcha that can be particularly difficult to work around is that an API may require you to use their specific software development kit (SDK) instead of a native PHP library. This may require the server to run a different OS (Windows instead of Linux) and web server (IIs instead of Apache). If you're not used to developing on these platforms, development time may be slowed down by a significant percentage. For example: a back-end developer may not be able to use the same IDE they are accustomed to (with all of their optimized configurations and memorized shortcuts). This requirement may be unavoidable in some circumstances, so the best way to deal with these situations is a simple percentage on the budgeted hours.

VMs

When possible, it is ideal for developers can work on their own machine locally with a fully replicate instance of the API they are interacting with. Example: Quickbooks connecting through their Web Connector application to read and write records from a Drupal Commerce site. To test this connection, it is extremely helpful to have a local virtual machine (VM) with Windows and Quickbooks, which a developer could then use to trigger the process. If a project involves multiple developers, they could each have their own copy to use a sandbox.

Setting up a local VM definitely adds an upfront cost to create. However, for larger projects this investment can generally be recouped many times over with respect to increased development speed and the ability to start from a consistent target.

Final Advice

By now, we hope that we've made the case that it's important to do your due diligence when taking on project involving integrations. And while this entire list of potential pain points may seem overkill, we've personally experienced the effects of every one of them at some point in our company's history. Ultimately, both you and the client want to avoid the uncomfortable conversation of a project's timeline slipping and going over budget. Therefore, it's critical to have address these issues thoroughly and as early in the project as possible. If uncertainty is especially high, it's usually beneficial to include a line item within the project statement of work to evaluate this piece separately. Finally, if you're able to effectively negotiate the terms of a contract, the budget for the integration shouldn't be set until an evaluation (even a partial one) has been completed.

Thoughts? Story to share? We'd love to get your feedback on how to improve upon this article.

Categories: Drupal News

Metal Toad: Drupal Solr Search with Domain Access filtering

Planet Drupal - Thu, 24/07/2014 - 8:34am

Metal Toad has had the privilege to work over the past two years with DC Comics. What makes this partnership even more exciting, is that the main dccomics.com site also includes sites for Vertigo Comics and Mad Magazine. Most recently Metal Toad was given the task of building the new search feature for all three sites. However, while its an awesome privilege to work with such a well known brand as DC, this does not come without a complex set of issues for the three sites when working with Apache Solr search and Drupal.

Categories: Drupal News

Gizra.com: Headless Drupal - Form API, Drupal 9

Planet Drupal - Thu, 24/07/2014 - 8:00am
Defining moment

A few months ago my DrupalCon Austin session was rejected. I was a bit upset, since presenting plays a big part in my trip to the states, and also surprised, as I mistakenly assumed my presentation repertoire would almost guarantee my session would be accepted. But the committee decided differently.

This has been an important moment for me. Two days later I told myself I don't care. I mean, I cared about the presentation, I just stopped caring that it was not selected, since I decided I was going to do it anyway. As an "unplugged" BoF.

The Gizra Way. I think this is probably the best presentation I've given so far, and quite ironically my rejected session is second only to Dries's keynote in YouTube.

You see - I had a "there is no spoon" moment. The second I realized it can be done differently, I was on my own track, perhaps even setting the path for others.

Form API, Drupal 9

I use Drupal because Form API is so great No one, ever

Continue reading…

Categories: Drupal News

Acquia: Search in Drupal 8 - Thomas Seidl & Nick Veenhof

Planet Drupal - Thu, 24/07/2014 - 2:57am

Thomas Seidl and Nick Veenhof took a few minutes out of the Drupal 8 Search API code sprint at the Drupal DevDays in Szeged, Hungary to talk with me about the state-of-play and what's coming in terms of search in Drupal: one flexible, pluggable solution for search functionality with the whole community behind it.

Categories: Drupal News

Clemens Tolboom: Interested in ReST and HAL?

Planet Drupal - Thu, 24/07/2014 - 1:42am
  1. Checkout the issue queue for HAL and ReST.
  2. Use the quickstart tool: https://github.com/build2be/drupal-rest-test.
Need HAL?
  1. Install HAL Browser on your site to see what we got till now.
  2. cd drupal-root
Categories: Drupal News

Acquia: Migration Tips and Tricks

Planet Drupal - Thu, 24/07/2014 - 12:18am

Cross-posted with permission from nerdstein

The Migrate module is, hands down, the defacto way to migrate content in Drupal. The only knock against it, is the learning curve. All good things come to those who take the time and learn it.

Categories: Drupal News

Code Karate: Drupal 7 Splashify

Planet Drupal - Wed, 23/07/2014 - 10:36pm
Episode Number: 158

In this episode we cover the Splashify module. This module is used to display splash pages or popups. There are multiple configuration options available to fit your site needs.

In this episode you will learn:

  • How to set up Splashify
  • How to configure Splashify
  • How to get Splashify to use the Mobile Detect plugin
  • How Splashify displays to the end user
  • How to be awesome
Tags: DrupalDrupal 7Drupal PlanetUI/DesignJavascriptResponsive Design
Categories: Drupal News

Drupal Association News: Building the Drupal Community in Vietnam: Seeds for Empowerment and Opportunities

Planet Drupal - Wed, 23/07/2014 - 3:38pm

With almost 90 million people, Vietnam has the 13th largest population of any nation in the world. It's home to a young generation that is very active in adopting innovative technologies, and in the last decade, the country has been steadily emerging as an attractive IT outsourcing and staffing location for many Western software companies.

Yet amidst this clear trend, Drupal has emerged very slowly in Vietnam and all of Asia as a leading, enterprise-ready Framework (CMF). However, this is changing as one Drupalista works hard to grow the regional user base.

How it all started

Tom Tran, a German with Hanoian roots, discovered Drupal in 2008. He was overwhelmed by the technological power and flexibility that makes Drupal such a highly competitive platform, and was amazed by the friendliness and vibrancy of the global community. He realized that introducing the framework and the Drupal community to Vietnam would help local people the opportunity to access the following three benefits:

  • Steady Income: Drupal won’t make you an overnight millionaire, however if you become a Drupal expert and commit to helping clients to achieve their goals, you will never be short of work. Quality Drupal specialists are in huge demand across the world and this demand won’t stop any time soon as Drupal adoption grows.
  • Better Lifestyle: You are free and able to design a work/lifestyle balance on your terms. You can work from home or contribute remotely while traveling, as long as you continue to deliver sustainable value to your client. Many professionals in less developed countries like Vietnam have never imagined this opportunity-- and learning about this lifestyle can be very empowering and inspirational.
  • Cross Cultural Friendships: In spite of national borders and cultural differences, Tom has established fruitful partnerships between his development team from Vietnam and clients from across the globe. Whether clients are based in California, Berlin, Melbourne or Tokyo, his team has successfully collaborated on many projects and often became good friends beyond just project mates. These relationships can only grow thanks to the open Drupal community spirit and the way it connects peoples from all regions and cultures from around the world.

Tom started by organizing a Drupal 7 release party in Hanoi in January 2011. Afterwards, he reached out to Drupal enthusiasts in the region and organized informal coffee sessions, which have contributed to the growth of a solid, cohesive community in Vietnam.

Drupal Vietnam College Tour

With help from a Community Cultivation Grant, Tom put on workshops every three months at Vietnamese universities and colleges in 2012. By showcasing the big brands and institutions using Drupal, a diverse series of use cases demonstrate that the demand for Drupal is high, and that the Drupal industry is a great place to be. A three hour hands-on session walks students through the basics of sitebuilding with Drupal-- and it's at this point that most students get hooked.

March 2012
First ever Drupal Hanoi Conference at VTC Academy, with 120 visitors (facebook gallery)

June 2012
Hello Drupal workshop @ Tech University Danang (gallery)

 

July 2012
Drupal Workshop @ FTP-Aptech (fb gallery, fpt aptech news)

 

September 2012
Drupal Workshop @ NUCE (gallery, Nuce news)

 

November 2012
Drupal Workshop @ FTP University (gallery)

 

December 2012
Drupal Workshop @ Aiti-Aptech (gallery)

 

December 2012
Drupal talk & sponsorship for PHPDay.vn 2012 (local images 2x)

The results was an overall increase in members and growing everyday. Stats in 2014:

What’s next?

Tom is currently planning to organize the first DrupalCamp in Hanoi / Vietnam in late 2014. Today Drupal Vietnam has only roughly 1300 members, (less than LA DUG) but with a growing pool of software engineers graduating each year, this country is set to become a relevant resource of highly skilled developers, provided high quality training is affordable and access to jobs can be facilitated. Things look very bright in Vietnam!

Supporters About

Tom is founder of Geekpolis, a software company with a development center based in Hanoi, Vietnam. Geekpolis focuses on high-quality managed Drupal development services for bigger consultancy agencies. Currently the team is comprised of 25 engineers.

To get involved, contact Tom at:
Categories: Drupal News

Drupal core announcements: Drupal 7.30 release this week to fix regressions in the Drupal 7.29 security release

Planet Drupal - Wed, 23/07/2014 - 3:06pm
Start:  2014-07-23 (All day) - 2014-07-25 (All day) America/New_York Sprint Organizers:  David_Rothstein

The Drupal 7.29 security release contained a security fix to the File module which caused some regressions in Drupal's file handling, particularly for files or images attached to taxonomy terms.

I am planning to release Drupal 7.30 this week to fix as many of these regressions as possible and allow more sites to upgrade past Drupal 7.28. The release could come as early as today (Wednesday July 23).

However, to do this we need more testing and reviews of the proposed patches to make sure they are solid. Please see #2305017: Regression: Files or images attached to certain core and non-core entities are lost when the entity is edited and saved for more details and for the patches to test, and leave a comment on that issue if you have reviewed or tested them.

Thank you!

Categories: Drupal News

Mediacurrent: Understanding the Role of the Enterprise in Drupal

Planet Drupal - Wed, 23/07/2014 - 12:53pm

There is a trending topic I am seeing being discussed a lot more in the open-source software and Drupal community. The point of conversation focuses on what the role should be of enterprise organizations?  Especially, those that are or have already adopted Drupal as their web platform of choice.

Categories: Drupal News

Greater Los Angeles Drupal (GLAD): Drupal Migrate using xml 0 to 35

Planet Drupal - Wed, 23/07/2014 - 5:55am

Using Drupal Migrate is a great way to move you content into Drupal. Unfortunately the documentation for xml import can be obscure. This comes about when those that developed the module try to communicate how they did what they did to someone that did not do the work. Things that seem obvious to them are not to someone else.

I have spent some time recently importing content using xml. In no way am I an expert that is speeding down the fast lane, something more in the cruising around town at a comfortable 35 mph.

To use Drupal Migrate you need to define your own class. A class is php code that is used in Object Oriented Programming that defines your data and defines how you can manipulate your data. Most of the actual migration work is done with the classes provide by the migrate module, you simply have to define the details of your migration.

Constructor - The constructor modifies the migration modules classes to define your specific data. I was able to follow the SourceList method, this provides one xml (file or feed) that contains the ID number for all the content you want to import, and a second (file or feed) that contains the content. The wine example migrate has this but understanding what it really wants is more difficult to understand.

Below is my class file explained:
=====================
<?php

/**
* @file
* Vision Article migration.
*/

/**
* Vision Article migration class.
*/
class VisionArticleMigration extends XMLMigration {
public function __construct() {
parent::__construct();
$this->description = t('XML feed of Ektron Articles.');

---------------
So far pretty easy. You need to name your class, extend from the proper migration. and give it an extension.

-----------------

// There isn't a consistent way to automatically identify appropriate
// "fields" from an XML feed, so we pass an explicit list of source fields.
$fields = array(
'id' => t('ID'),
'lang_type' => t('Language'),
'type' => t('Type'),
'image' => t('Image'),
'authors' => t('Authors'),
'article_category' => t('Article Category'),
'article_series_title' => t('Article Series Title'),
'article_part_no' => t('Article Series Part Number'),
'article_title' => t('Article Title'),
'article_date' => t('Article Date'),
'article_display_date' => t('Article Display Date'),
'article_dropheader' => t('Article Dropheader'),
'article_body' => t('Article Body'),
'article_author_name' => t('Article Author Name'),
'article_author_url' => t('Article Author Email Address'),
'article_authors' => t('Article Additional Authors'),
'article_postscript' => t('Article Postscript'),
'article_link_text' => t('Article Link text'),
'article_link' => t('Article Link'),
'article_image' => t('Article Image'),
'article_image_folder' => t('Article Image Folder'),
'article_image_alt' => t('Article Image Alt'),
'article_image_title' => t('Article Image Title'),
'article_image_caption' => t('Article Image Caption'),
'article_image_credit' => t('Article Image Credit'),
'article_sidebar_element' => t('Article Side Bar Content'),
'article_sidebar_element_margin' => t('Article Margin between Sidebar Content'),
'article_archived_html_content' => t('Article HTML Content from old system'),
'article_video_id' => t('Article ID of Associated Video Article'),
'metadata_title' => t('Metadata Title'),
'metadata_description' => t('Metadata Description'),
'metadata_keywords' => t('Metadata Keywords'),
'metadata_google_sitemap_priority' => t('Metadata Google Sitemap Priority'),
'metadata_google_sitemap_change_frequency' => t('Metadata Google Sitemap Change Freequency'),
'metadata_collection_number' => t('Metadata Collection Number'),
'title' => t('Title'),
'teaser' => t('Teaser'),
'alias' => t('Alias from old system'),
'taxonomy' => t('Taxonomy'),
'created_date' => t('Date Created')
);

-------------------
So what doe this mean?
You will need a field name below. It has nothing to do with your xml file, you will need a field for each thing you want to import. Such as article_image_alt is the alt text for the image. Later you will define the xpath to load this variable. This will start to come together below, just remember each unique piece of information needs a variable.

---------------------

// The source ID here is the one retrieved from the XML listing URL, and
// used to identify the specific item's URL.
$this->map = new MigrateSQLMap($this->machineName,
array(
'ID' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Source ID',
)
),
MigrateDestinationNode::getKeySchema()
);

---------------------
This has to do with setting up the migration table in the database. This has to do with the input database, the Source ID is the field in the input file that has the pointer to the data record. My source file looks like:

567
1054

So we need a table with a field for the id which an integer.

-----------------------

// Source list URL.
$list_url = 'http://www.vision.org/visionmedia/generateexportlist.aspx';
// Each ID retrieved from the list URL will be plugged into :id in the
// item URL to fetch the specific objects.
// @todo: Add langtype for importing translated content.
$item_url = 'http://www.vision.org/visionmedia/generatecontentxml.aspx?id=:id';

// We use the MigrateSourceList class for any source where we obtain the
// list of IDs to process separately from the data for each item. The
// listing and item are represented by separate classes, so for example we
// could replace the XML listing with a file directory listing, or the XML
// item with a JSON item.
$this->source = new MigrateSourceList(new MigrateListXML($list_url),
new MigrateItemXML($item_url), $fields);

$this->destination = new MigrateDestinationNode('vision_article');

-----------------

Now we are setting up the magic. We setup a list url that contains the ID's of all the content to import, then another one that uses this ID to fetch the details for this ID. Then you tell Migrate to use the MigrateListXML to find the items to import with MigrateItemXML. Then finally in the MigrateDestinationNode to tell Migrate which content type to use. This means we need a separate migration class for each content type to import. I have been creating each class in it's own inc file and adding this to the files section in the info file.

-----------------

// TIP: Note that for XML sources, in addition to the source field passed to
// addFieldMapping (the name under which it will be saved in the data row
// passed through the migration process) we specify the Xpath used to retrieve
// the value from the XML.
$this->addFieldMapping('created', 'created_date')
->xpath('/content/CreateDate');

------------------
Now we map the source field with the destination field. Created is the field name in the content type (vision_article), created_date is from our fields section above. Remember I said we needed a definiation for each part of the content we want to import. The xpath then points to the data in the xml feed. So this says take the content of the /contnet/CreateDate in the xml file and load this into the source variable created_date, then store this in the created field in a new vision_article content item. I say this in this way because if you do like me and cut and paste and forget to change the source varable, the source varable will contain the bottom data from xpath.

------------------

$this->addFieldMapping('field_category', 'article_category')
->defaultValue(1)
->xpath('/content/html/root/article/Category');

-------------------

You can set a default value in case the xml does not contain any data

----------

$this->addFieldMapping('field_series_title', 'article_series_title')
->xpath('/content/html/root/article/ArticleSeriesTitle');
$this->addFieldMapping('field_part_number', 'article_part_no')
->xpath('/content/html/root/article/ArticlePartNo');
$this->addFieldMapping('field_h1_title', 'article_title')
->arguments(array('format' => 'filtered_html'))
->xpath('/content/html/root/article/Title');
$this->addFieldMapping('field_display_date', 'article_display_date')
->xpath('/content/html/root/article/DisplayDate');
$this->addFieldMapping('field_drophead', 'article_dropheader')
->arguments(array('format' => 'filtered_html'))
->xpath('/content/Taxonomy');

-------------

Another field argument, the default content type is plain text, so if your content contains HTML you need to set the correct format here.

---------------

$this->addFieldMapping('body', 'article_body')
->arguments(array('format' => 'filtered_html'))
->xpath('/content/html/root/article/Body');
$this->addFieldMapping('body:summary', 'teaser')
->arguments(array('format' => 'filtered_html'))
->xpath('/content/Teaser');

-----------

Note you can set the teaser as a part of the body. One of the drush migrate commands make is easy to discover the additional parts of your content field, drush mfd (Migrate Field Destinations). This will display all the destination fields and their options.

------------

$this->addFieldMapping('field_author', 'article_author_email')
->xpath('/content/html/root/article/AuthorURL');
$this->addFieldMapping('field_author:title', 'article_author_name')
->xpath('/content/html/root/article/AuthorName');
$this->addFieldMapping('field_ext_reference_title', 'article_postscript')
->arguments(array('format' => 'filtered_html'))
->xpath('/content/html/root/article/Postscript');

---------
see explanation below
--------
$this->addFieldMapping('field_article_image:file_replace')
->defaultValue(MigrateFile::FILE_EXISTS_REUSE); //FILE_EXISTS_REUSE is in the MigrateFile class
$this->addFieldMapping('field_article_images', 'article_image')
->xpath('/content/html/root/article/Image/File/img/file_name');
$this->addFieldMapping('field_article_images:source_dir', 'article_image_folder')
->xpath('/content/html/root/article/Image/File/img/file_path');
$this->addFieldMapping('field_article_images:alt', 'article_image_alt')
->xpath('/content/html/root/article/Image/File/img/@alt');
$this->addFieldMapping('field_article_images:title', 'article_image_title')
->xpath('/content/html/root/article/Image/File/img/@alt');

--------------

This section gets tricky. You are importing an Image or other file. The default migration for a file is MigrateFileUrl. You can migrate all your files ahead of time or as I am doing do it inline. The main components for this is the main field, which is the file name, and the source_dir for the path to this image. Drual 7 has a database table for the files is uses with the url to the file. MigrateFile then uploads this file to the public folder and creates an entry into the files_,amaged table to indicate the url. What I did was copy all the images to a public location on S3 storage so I did not want Migrate to create a new file but use the existing file. Thus the file_replace setting to the constant MigrateFile::FILE_EXISTS_REUSE. This tells migrate to use the existing file and make an entry in the file_managed table for this file.

Later in the PrepareRow method I will show how we separate this and add it to the xml.

------------

$this->addFieldMapping('field_archive', 'article_archived_html_content')
->xpath('/content/archive_html');
$this->addFieldMapping('field_ektron_id', 'id')
->xpath('/content/ID');
$this->addFieldMapping('field_ektron_alias', 'alias')
->xpath('/content/html/Alias');
$this->addFieldMapping('field_sidebar', 'article_sidebar_element')
->arguments(array('format' => 'filtered_html'))
->xpath('/content/html/root/article/SidebarElement/SidebarElementInformation');
$this->addFieldMapping('field_slider_image:file_replace')
->defaultValue(MigrateFile::FILE_EXISTS_REUSE); //FILE_EXISTS_REUSE is in the MigrateFile class
$this->addFieldMapping('field_slider_image', 'image')
->xpath('/content/Image/file_name');
$this->addFieldMapping('field_slider_image:source_dir', 'image_folder')
->xpath('/content/Image/file_path');
$this->addFieldMapping('field_slider_image:alt', 'image_alt')
->xpath('/content/Title');
$this->addFieldMapping('field_slider_image:title', 'image_title')
->xpath('/content/Title');
$this->addFieldMapping('title', 'title')
->xpath('/content/Title');
$this->addFieldMapping('title_field', 'title')
->xpath('/content/Title');

// Declare unmapped source fields.
$unmapped_sources = array(
'article_author_url',
'article_authors',
'article_sidebar_element_margin',
'article_video_id',
'metadata_title',
'metadata_description',
'metadata_keywords',
'metadata_google_sitemap_priority',
'metadata_google_sitemap_change_frequency',
'metadata_collection_number',

);

-------------

If you are not using a source field, best practices state that you declare it in the unmapped sources

------------

$this->addUnmigratedSources($unmapped_sources);

// Declare unmapped destination fields.
$unmapped_destinations = array(
'revision_uid',
'changed',
'status',
'promote',
'sticky',
'revision',
'log',
'language',
'tnid',
'is_new',
'body:language',
);

----------------------

If you are not using a destination field best practices state that you declare in the unmaped destinations array. Note if you later use this field you need to remove it from the unused array.

---------------------

$this->addUnmigratedDestinations($unmapped_destinations);

if (module_exists('path')) {
$this->addFieldMapping('path')
->issueGroup(t('DNM'));
if (module_exists('pathauto')) {
$this->addFieldMapping('pathauto')
->issueGroup(t('DNM'));
}
}
if (module_exists('statistics')) {
$this->addUnmigratedDestinations(array('totalcount', 'daycount', 'timestamp'));
}
}

------------

The rest of the constructor is from the example. Did not cause me a problem so did not worry about it.

------------
/**
* {@inheritdoc}
*/

---------------

Now we can add our own magic. We can effect the data from the content item before it is saved in to the content item.

-----------------

public function prepareRow($row) {
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
$ctype = (string)$row->xml->Type;
//set variable for return code
$ret = FALSE;
//dpm($row);

------------

You will see these scattered through the prepareRow function. These are the devel command to print to the screen for debuging. They should be commented out but you can see the process I went through to debug my particular prepareRow. Also note this is a great use of the Migrate UI, these print statment only help you in the web interface, if you use Drush you will not see these diagnostic prints.

---------------

if ($ctype == '12'){

---------------

This is specific to my migrate. The following code is only applicable to a content type of 12. The other content types have a different data structure. If prepareRow returns False the row will be skipped.

------------------

// Map the article_postscript source field to the new destination fields.
//if((string)$row->xml->root->article->Title == ''){
// $row->xml->root->article->Title = $row->xml->root->Title;
//}
$postscript = $row->xml->html->root->article->Postscript->asXML();
$postscript = str_replace('','',$postscript);
$postscript = str_replace('','',$postscript);
$row->xml->html->root->article->Postscript = $postscript;

-------------------

Again this is something unique to my migrate. The content structure is contained in xml so the HTML is recognized by SimpleXML as xml. So the asXML() function returns a string containing the xml of the node. Now I can save this string to the node and it becomes a string node and is back to straight html. So I need to do this for all the nodes that contain html. Most of the time you will be able to pass the html string as a node and will not have to do this transform.

-------------------

//converts html nodes to string so they will load.
$body = $row->xml->html->root->article->Body->asXML();
$body = str_replace('','',$body);
$body = str_replace('','',$body);
$row->xml->html->root->article->Body = $body;
$title = $row->xml->html->root->article->Title->asXML();
$title = str_replace('','',$title);
$title = str_replace('','',$title);
$row->xml->html->root->article->Title = $title;
$drophead = $row->xml->html->root->article->Dropheader->asXML();
$drophead = str_replace('','',$drophead);
$drophead = str_replace('','',$drophead);
//If Dropheader is empty
$drophead = str_replace('','',$drophead);
$row->xml->html->root->article->Dropheader = $drophead;
//Array to allow conversion of Category text to IS
$cat_tax = array(
'Science and Environment' => 1,
'History' => 2,
'Social Issues' => 3,
'Family and Relationships' => 4,
'Life and Health' => 5,
'Religion and Spirituality' => 6,
'Biography' => 7,
'Ethics and Morality'=> 8,
'Society and Culture' => 9,
'Current Events and Politics' => 10,
'Philosophy and Ideas' => 11,
'Personal Development' => 12,
'Reviews' => 13,
'From the Publisher' => 14,
'Interviews' => 17,
);
//Convert additional taxonomies to tags
//$tax_id_in = (string)$row->xml->Taxonomy;
//$tax_id_array = explode(',',$tax_id_in);
//$tax_in_array = array();
//foreach($tax_id_array as $tax){
// If(is_null($cat_tax[tax]))
// $tax_in_array[] = $cat_tax[$tax];
//}
//$new_tax = implode(',',$tax_in_array);
//dpm($new_tax);
//dpm($row);
//$row->xml->Taxomomy = $new_tax;
// Change category text to ID
$category = (string)$row->xml->html->root->article->Category;
//Specify unknown category if we do not recognize the category
//This allows the migrate and allow us to fix later.
$tax_cat = $cat_tax[trim($category)];
//dpm($category);
if(is_null($tax_cat)) {$tax_cat = 18;}
//dpm($tax_cat);
$row->xml->html->root->article->Category = $tax_cat;

-------------

The category field in the source is a text field. The categories are a entity reference to a taxonomy field, which requires an id rather than text. I manually setup the categories ahead of time so I created an array that has the text as the key and the is as the content. Then you can use this to quickly look up the id for the text in he category field. Then we can replace the text in Category with the id. This works, another way to do this is migrate the categories first then use this migration to translate this for you. This is a feature built into migrate. The explanation of this will come later.

----------------

//modify the image file node.
//dpm((string)$row->xml->ID);
if((string)$row->xml->html->root->article->Image->File->asXML() != ''){
//dpm((string)$row->xml->html->root->article->Image->File->asXML());
$src = (string)$row->xml->html->root->article->Image->File->img->attributes()->src;
$src_new = str_replace('/visionmedia/uploadedImages/','http://assets.vision.org/uploadedimages/',$src);
$row->xml->html->root->article->Image->File->img->attributes()->src = $src_new;
$file_name = basename($src_new);
$file_path = rtrim(str_replace($file_name,'', $src_new), '/');;
$row->xml->html->root->article->Image->File->img->addChild('file_name',$file_name);
$row->xml->html->root->article->Image->File->img->addChild('file_path',$file_path);
}

--------------

There is alot of stuff here. Remember for the MigrateFile you need to present the file name and source directory. The Image/File node contains an img tag. So we need to get the scr attribute and extract the file name and source directory. So why the if? Migrate will import a null node as null, but this is php code running on the row. If you try to get the src attribute on a null node it will throw an error. So the if statement checks to see if the File node is empty (only contains /File) and skips this tranformation, Migrate will simply import a null or empty field.

The src is the relative path to the website, so the first thing we do is change this to full url to the s3 content storage. The path is basically the same except in the uploadedimages the i in the database is uppercase. This was a Windows server so it did not make a difference but the s3 url is case sensitive. We then use base name to extract the file name and use this to remove the file from the path for the file path and create a new child in the xml row to store these. I did not point this out but this is the xpath use in the field mapping above.

--------------

$email = (string)$row->xml->html->root->article->AuthorURL;
if (!empty($email)){
$email = 'mailto:'.$email;
$row->xml->html->root->article->AuthorURL = $email;
}

-------------

The author url is the email to the author of the article. We turn this into a mailto link so that it will generate a link to send the author an email.

---------------

$archive_html = (string)$row->xml->html->asXML();
$row->xml->addChild('archive_html',$archive_html);
$sidebar_element = (string)$row->xml->html->root->article->SidebarElement->SidebarElementInformation->asXML();
$row->xml->html->root->article->SidebarElement->SidebarElementInformation = $sidebar_element;
$slider_src = (string)$row->xml->Image;
$slider_src_new = str_replace('/visionmedia/uploadedImages/','http://assets.vision.org/uploadedimages/',$slider_src);
$row->xml->Image = $slider_src_new;
$slider_file_name = basename($slider_src_new);
$slider_file_path = rtrim(str_replace($slider_file_name,'', $slider_src_new), '/');;
$row->xml->Image->addChild('file_name',$slider_file_name);
$row->xml->Image->addChild('file_path',$slider_file_path);
//dpm($row);

---------------

The rest is repitition of the above techniques. Note that we return TRUE if we want to process the row and false if we do not want to process the row.

-----------------

$ret=TRUE;
//dpm($src);
}
//Need to add processing for other Article Content types especially 0 (HTML content)
//dpm($row);
return $ret;
}

}

----------

This is the class I use for one of the imports. I told you that I would show the use of another migrate in the field mappings. Below is a snippet of code from the issues migration. The issue contains entity reference to vision_articles that were imported from above.

-------------

$this->addFieldMapping('field_articles', 'article_id')
->sourceMigration('VisionArticle')
->xpath('/item/articles/article/ID');

--------------

So this says use the VisionArticle (I will show you were to find this next), it knows to look up the source ID and relate it to the DestinationID and store this in the field_articles field.

---------------

Migrate has been around for a while. Initially they said that the class would automaticall be registed and you could manually register them if needed. Then they changed to say that they will not manually register and you should register your classes. So you should have as part of your migration module the following that will register your classes. Note the name of the array element is the name used above.

----------------

function vision_migrate_migrate_api() {
$api = array(
'api' => 2,
// Give the group a human readable title.
'groups' => array(
'vision' => array(
'title' => t('Vision'),
),
),
'migrations' => array(
'VisionArticle' => array('class_name' => 'VisionArticleMigration'),
'VisionIssue' => array('class_name' => 'VisionIssueMigration'),
'VisionVideoArticle' => array('class_name' => 'VisionVideoArticleMigration'),
'VisionFrontpage' => array('class_name' => 'VisionFrontpageMigration'),
),
);

return $api;
}

----------------

I hope this makes things a little easier to understand. You will need some basic module building skills, knowing the file names and things like that, but this should help you through the more obscure parts of creating your migration class.

Tags: Planet Drupal
Categories: Drupal News

Drupal Association News: Why we moved Drupal.org to a CDN

Planet Drupal - Wed, 23/07/2014 - 4:54am

As of a little after 19:00 UTC on 2 July 2014, Drupal.org is now delivering as many sites as possible via our EdgeCast CDN.

Why a CDN?

We are primarily concerned with the network level security that a CDN will provide Drupal.org.

The CDN enables us to restrict access to our origin servers and disallow directly connecting to origin web nodes (which is currently possible). The two big advantages are:

  1. Accelerate cacheable content (static assets, static pages, etc).
  2. Allow us to easily manage network access and have a very large network in front of ours to absorb some levels of attacks.

Here are some examples of how the CDN helps Drupal.org:

  • We were having issues with a .js file on Drupal.org. The network was having routing issues to Europe and people were complaining about Drupal.org stalling on page loads. There was basically nothing we could do but wait for the route to get better. This should never be a problem again with EdgeCast's global network.
  • We constantly have reports of updates.drupal.org because blacklisted because it serves a ton of traffic coming in and out of a small number of IP addresses. This should also not happen again because the traffic is distributed through EdgeCast's network.
  • A few months ago we were under consistent attack from a group of IPs that was sub-HTTP and was saturating the origin network's bandwidth. We now have EdgeCast's large network in front of us that can 'take the beating'.
updates.drupal.org

By enabling EdgeCast's raw logs, rsync, and caching features, we were able to offload roughly 25 Mbps of traffic from our origin servers to EdgeCast. This change resulted in a drastic drop in origin network traffic, which freed up resources for Drupal.org. The use of rsync and the raw log features of EdgeCast enabled us to continue using our current project usage statistics tools. We do this by syncing the access logs from EdgeCast to Drupal.org’s utility server that processes project usage statistics.

Drupal.org

Minutes after switching www.drupal.org to use the CDN, there were multiple reports of faster page load times from Europe and North America.

A quick check from France / webpagetest.org:
Pre-CDN results: first page load=4.387s. repeat view=2.155s
Post-CDN results: first page load=3.779s, repeat view=1.285s

Why was the www.drupal.org rename required?

Our CDN uses a combination of Anycast IP addresses and DNS trickery. Each region (Asia, North America, Europe, etc.) has an Anycast IP address associated with it. For example cs73.wac.edgecastcdn.net might resolve to 72.21.91.99 in North America, and 117.18.237.99 in Japan.

Since 72.21.91.99, 117.18.237.99, etc. are Anycast IPs, generally their routes are as short as possible, and the IP will route to whatever POP is closest. This improves network performance globally.

Why can't drupal.org be a CNAME?

The DNS trickery above works by using a CNAME DNS record. Drupal.org must be an A record because the root domain cannot be a CNAME. MX records and any other records are not allowed by the RFC on CNAME records. To work around this DNS limitation, Drupal.org URLs are now redirected to www.drupal.org.

 

 

Related issues
https://www.drupal.org/node/2087411
https://www.drupal.org/node/2238131

Categories: Drupal News

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer