Planet Drupal

Syndicate content
Drupal.org - aggregated feeds in category Planet Drupal
Updated: 16 min 25 sec ago

There is a module for that!: Printing debugging info for forms

Sun, 11/30/2014 - 22:23
pDuring development, it's useful to quickly find information about form elements. Quickly is the key word here, and adding a codedpm/code in a codehook_form_alter/code then removing it becomes tedious./p pHere's a very simple module to add debug information to the codetitle/code attribute of all form elements: script src=https://gist.github.com/infojunkie/c0195f034a5eaa420ad2.js/script/p

Liran Tal's Enginx: Drupal Performance Tip – replace views blocks with vanilla blocks

Sat, 11/29/2014 - 19:57
div class=seriesmetaThis entry is part 2 of 2 in the series a href=http://enginx.com/series/drupal-performance-tuning-for-better-database-utilization/ class=series-54 title=Drupal Performance Tuning for Better Database UtilizationDrupal Performance Tuning for Better Database Utilization/a/divpIn the spirit of the computer video game a href=http://doom.wikia.com/wiki/Doom target=_blankDoom /aand its a href=http://doom.wikia.com/wiki/Skill_level target=_blankskill levels/a, we#8217;ll review a few ways you can improve your a href=http://drupal.org target=_blankDrupal /aspeed performance and optimize for better results and server response time. These tips that we#8217;ll cover may be at times specific to Drupal 6 versions, although you can always learn the best practices from these examples and apply them on your own code base. img class=alignleft src=http://adamatomic.com/pics/blog/doom/doom2.jpg alt=Doom width=298 height=212 / Doom skill  levels: (easiest first) 1.strong I#8217;m too young to die/strong 2. Hey, not too rough 3. Hurt me plenty 4. Ultra-violence 5. Nightmare! strong  This post is rated #8220;I#8217;m too young too die#8221; difficulty level/strong.   When we start out building a href=https://www.drupal.org/ target=_blankDrupal /awebsites, we gradually build functionality and a common use case is creating a view, then you might want to create some blocks, very much related to the view, so you create a block view using the a href=https://www.drupal.org/project/views target=_blankViews /amodule. Then you maybe combine it with a href=https://www.drupal.org/project/panels target=_blankPanels /aor a href=https://www.drupal.org/project/context target=_blankContext/a, it doesn#8217;t really matter, but essentially you#8217;ve been using the UI tools which are for ease of use, and the overhead for that lies in quite a bit of abstraction layer which later may cost in performance. Replacing the quicklinks and help and support blocks that were used in our theme#8217;s sidebar from being a view based block to a simple programmatiaclly created block implementation proved to reduce a sizzling amount of ~200ms to ~2ms of server time spent on doing the same operation. That accounted for about ~200ms of page load time redduction for each page load, as this item was featured in many pages consistently on our theme./p pre class=commit_message style=color: black;/pre pa href=http://enginx.com/wp-content/uploads/2014/11/drupal_perf-3.pngimg class=aligncenter size-full wp-image-506 src=http://enginx.com/wp-content/uploads/2014/11/drupal_perf-3.png alt=drupal_perf-3 width=420 height=113 //a/p !-- Easy AdSense V7.43 -- !-- [leadout: 1 urCount: 1 urMax: 0] -- div class=ezAdsense adsense adsense-leadout style=text-align:center;margin:12px; script async src=//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js/script !-- enginx-blog-wide-post -- ins class=adsbygoogle style=display:inline-block;width:728px;height:90px data-ad-client=ca-pub-9677997565991773 data-ad-slot=6746030703/ins script (adsbygoogle = window.adsbygoogle || []).push({}); /script/div !-- Easy AdSense V7.43 -- pThe post a rel=nofollow href=http://enginx.com/blog/drupal-performance-tip-replace-views-blocks-vanilla-blocks/Drupal Performance Tip #8211; replace views blocks with vanilla blocks/a appeared first on a rel=nofollow href=http://enginx.comLiran Tal#039;s Enginx/a./p

Drupal core announcements: This Month in Drupal Documentation - November 2014

Sat, 11/29/2014 - 05:00
pHere's an update from the a href=https://drupal.org/governance/doc-working-groupDocumentation Working Group (DocWG)/a on what has been happening in Drupal Documentation in the last month or so. Sorry... because this is posted in the Core group as well as Documentation, comments are disabled./p pIf you have comments or suggestions, please see the a href=https://drupal.org/governance/doc-working-groupDocWG home page/a for how to contact us. Thanks!/p h3Notable Documentation Updates/h3 pWork continues to progress on the a href=http://drupal.org/theme-guide/8Drupal 8 Theming Guide/a, and providing better documentation of the release policies for Drupal 8 and future versions of Drupal has been a topic of much discussion recently. In general, documentation for Drupal 8 continues to get better as more and more people start making use of the current beta version and are ironing out the details./p pIf you're interested in helping out with documentation now is a great opportunity to install Drupal 8 and walk through the documentation related to various tasks and verify that it's clear, concise and accurate./p pThere was also a considerable amount of work put into updating various handbook pages for the Chart module, the Charts module, and various other Drupal charting solutions. This demonstrates one of my favorite ways to get involved with documentation. When you're working on a project that requires you to do some research into a module you've never used before take some time to jot down a few notes about what you've learned, or to help improve existing documentation. It doesn't take long to do and if nothing else your future self will probably thank you for the work you did next time you come across this same problem./p pSee the a href=https://drupal.org/governance/doc-working-groupDocWG home page/a for how to contact us, if you'd like to be listed here in our next post!/p h3Thanks for contributing!/h3 pSince Oct. 28th, 2014 (a href=https://groups.drupal.org/node/447693our previous TMIDD post/a), 260 contributors have made 1135 total Drupal.org documentation page revisions, including 6 people that made more than 30 edits (Pierre.Vriens, kreynen, tvn, annagaz, peterx, and ashish_nirmohi) -- thanks everyone!/p pIn addition, there were many many commits to Drupal Core and contributed projects that improved documentation -- these are hard to count, because many commits combine code and documentation -- but they are greatly appreciated too!/p h3Documentation Priorities/h3 pThe a href=https://www.drupal.org/documentation/prioritiesCurrent documentation priorities page/a is always a good place to look to figure out what to work on, and has been updated recently./p pIf you're new to contributing to documentation, these projects may seem a bit overwhelming -- so why not try out a a href=https://drupal.org/contributor-tasks/writersNew contributor task/a to get started?/p h3Upcoming Events/h3 ul lia href=https://groups.drupal.org/node/447258Global Sprint Weekend/a is coming up soon, and if you haven't done so already now would be a great time to find some other people that are interested in sprinting on documentation issues and make plans to get together./li liAlthough we don't have anything specific lined up at the moment DrupalCon Bogotà (Feb. 10-12) and DrupalCon LA (May 11-15) are both coming up soon and there will undoubtably be talk about documentation at both. /lili /liliGot any events you know about that we should add to this list? Let us know!/li /ul h3Report from the Working Group/h3 pAt our last meeting on Oct. 28th, the Documentation Working Group discussed possible options for curated documentation on Drupal.org and what it would take to make that happen, as well as what the potential downsides might be. In general, we're in favor of the idea but realize that doing so will require putting a lot of thought into making it sustainable. We'll continue to discuss this in future meetings and are open to suggestions. We also discussed options for a href=https://www.drupal.org/node/2206371better handling of SPAM documentation pages/a, and a somewhat mysterious a href=https://www.drupal.org/node/944332documentation search block/a that shows up on a few pages and how to proceed with that./p pRight now, figuring out how to best proceed with hook_help() and getting it updated for Drupal 8 are on our radar and likely to be a topic of conversation at our next meeting./p pFinally, our next meeting will be December 17th. We normally meet using Google Hangouts; if you'd like to join us, a href=https://groups.drupal.org/user/6005contact Boris (batigolix)/a./p

Metal Toad: Migrating Content into Drupal 8

Sat, 11/29/2014 - 03:04
span class=field field-node--title field-name-title field-type-string field-label-hidden data-quickedit-field-id=node/911/title/en/rssMigrating Content into Drupal 8/span span class=field field-node--created field-name-created field-type-created field-label-hidden data-quickedit-field-id=node/911/created/en/rssNovember 28th, 2014/span span class=field field-node--uid field-name-uid field-type-entity-reference field-label-hidden data-quickedit-field-id=node/911/uid/en/rssa title=View user profile. href=/people/keithdechant lang= about=/people/keithdechant typeof=schema:Person property=schema:name datatype= class=usernameKeith Dechant /a/span div class=field field-node--body field-name-body field-type-text-with-summary field-label-hidden data-quickedit-field-id=node/911/body/en/rss div class=field-items div class=field-itempDrupal 8 includes a powerful built-in migration system for importing content into your site. It is designed to handle data from Drupal 6 or 7, and much more. It is built around a plugin-based architecture, which allows importing of data from any external data source if you write your own source plugin./p h3History/h3 pWhen Drupal 7 was released, it came with an upgrade script that would convert a Drupal 6 database into a Drupal 7 database. For Drupal 8, the core team decided against this approach, in favor of creating a more flexible migration module./p pAlso, Drupal 7 has the Migrate and Migrate D2D contrib modules, used for importing data into a Drupal 7 database. This effort has been moved into Core in Drupal 8./p pThe team developing the Migrate modules maintains a group on Drupal.org. For more information about the status of these modules, visit the a href=https://groups.drupal.org/imp target=_blankIMP project on Drupal.org/a./p h3Migrations in Core/h3 pDrupal 8 includes two core modules:/p pstrongMigrate/strong - A base module for creating your own custom migrations. This module provides the core migration architecture, but does not define any usable migrations itself./p pstrongMigrate Drupal/strong, a module containing migration definitions and source plugins for migrating content from Drupal 6 to Drupal 8. This will eventually support Drupal 7 as well./p h3Other components/h3 pThe Migrate and Migrate Drupal modules do not currently provide a UI for running migrations. You will need an external component to run migrations./p pstrongDrush/strong You can create a migration manifest (a YAML file) and execute it using the drush migrate-manifest command. Drush 7 is required./p pNote: The previous Drush command, drush migrate-import, used with the Drupal 7 Migrate module, has been removed from Drupal 8./p pAlso note: As of Drupal 8 beta 2, the drush migrate-manifest command does not work with managed files, because it does not yet have a parameter for specifying the source directory where the files should be copied from./p pstronga href=https://www.drupal.org/project/migrate_upgradeMigrate Upgrade/a/strong - A contrib module which provides a user interface for migrations. As of this writing, the module is still under development./p h3Migrating from Drupal 6/h3 pThe Migrate Drupal module is being built to help with migrating from Drupal 6/7 to Drupal 8. Its aim is to import many components of Drupal like content types, fields, users, nodes, and more./p pMigrate Drupal comes out-of-the-box with many of these migrations already built. It can even query CCK to determine the list of available fields to use when importing field data. To run these built-in migrations, you simply need to define a migration manifest. The following example would import Drupal 6 users and taxonomies:/p div class=geshifilter div class=text geshifilter-text style=font-family:monospace; pre style=font-family: monospace; font-weight: normal; font-style: normal- d6_user - d6_taxonomy_vocabulary - d6_taxonomy_term/pre/div /div pTo run the migration, open a command prompt and run the following command:/p pspan class=geshifiltercode class=text geshifilter-textdrush migrate-manifest manifest.yml --legacy-db-url=mysql://{dbuser}:{dbpass}@localhost/{dbname}/code/span/p pReplace {dbuser}, {dbpass}, and {dbname} with the MySQL username, password, and database name for your Drupal 6 database./p h4Migrating from Drupal 7/h4 pThe Migrate Drupal module in Drupal 8 beta 3 does not yet include support for migrating from Drupal 7. Developers migrating from Drupal 7 to 8 will need to write their own custom migration scripts or pursue other options./p pAt the 2014 Pacific Northwest Drupal Summit, several presenters and participants mentioned that the Drupal 7-8 migration path is not expected to be completed by the release of Drupal 8.0.0. It is expected that this will be completed in a future core release./p pFor an example of writing a custom migration from Drupal 7 to Drupal 8, see the next installment in this series, a href=/blog/migrating-users-drupal-7-to-drupal-8Migrating Users from Drupal 7/a./p /div /div /div

Wunderkraut blog: Ref debug, an alternative for dpm

Fri, 11/28/2014 - 20:34
p class=field-ns-blog-post-lead I looked for a simple debugger to use in the fronted, and discovered PHP-ref. /p div class=field-ns-blog-post-body clearfix div class=field-item even divI like to keep things simple and clean. I like devel when using simple debugging on the frontend (for more advance debugging I am using xdebug), put devel adds a lot of overhead - like many drupal modules it tries to cover a lot of issues, and therefore it adds a lot of things you maybe not need. So I tested some of the debuggers you could use with php in the frontend, and I really like PHP-ref - simple and clean, just the way I liked it./divdiv /divdivSo now I have wrapped it out to a moudle - Ref debug. With it you could do debugging on entities and direct in code as an replacement for devels dpm() - instead you use r(), and to that you could add functions, variables, classes etc./divdiv /divdivYou could check it out over att a href=https://www.drupal.org/project/ref_debugdrupal.org/a./divdiv /divdiv /divdiv /div /div /div

Code Enigma: Better UX in your forms, the easy way

Fri, 11/28/2014 - 12:19
Entity References are cool. Prepopulating them is even cooler. You#039;ve seen it already, but if you are not working with Field API, you#039;re on your own... until now, at least.

Deeson: Extending EntityDrupalWrapper

Fri, 11/28/2014 - 10:33
p dir=ltr id=docs-internal-guid-267d043d-e8e1-13ce-a8dc-d44dd92a27c3We'd all like to be writing better OO code with Drupal 7, wouldn't we?/p p dir=ltrIt's always been a a href=https://www.deeson.co.uk/labs/programatically-access-field-data-using-entitymetadatawrapper-drupalbest practice of ours/a to use the entity_metadata_wrapper() function when programming the additional logic that inevitably comes when constructing complex content types. But a pain point of this is that the code usually ends up in one hook_ implementation or another and any shared code tends to get arranged into functions in the .module file./p p dir=ltrIn an ideal world, Drupal would have provided us with entity classes that we could extend at the bundle level to allow us to add feature-specific functionality. I had a bit of a eureka moment the other day, when I realised that we’re already quite close to this, and that it's actually quite trivial to extend the EntityDrupalWrapper class provided by entity_metadata_wrapper() with functionality specific to each entity type./p p dir=ltrIndeed, as I think about it, I'm wondering if this should be a new best practice?/p h3 dir=ltrAn overly simple example/h3 p dir=ltrLet’s imagine that we have a content type that is tied up with Organic Groups and that we use it as a way of grouping members into different organisations on our site. We’ll call it “company”./p p dir=ltrLet’s also imagine that we would like to send an email to each of the members of a company whenever one of them posts a comment./p p dir=ltrFor the convenience of this example, let's forget that Rules exist for a moment!/p h3Firstly, a quick note about autoloading/h3 pDrupal 8 takes advantage of the wonderful PSR-4 autoloading standard so that we no longer have to define includes in our module's .info file. The brilliant a href=https://www.drupal.org/project/xautoloadX Autoload/a module provides just the same functionality for Drupal 7. Since we’re going to be writing a lot more classes from now on, I’d recommend using it, especially as what we’re doing supports PHP 5.3 namespaces. My example below assumes that you're using it./p h3 dir=ltrThe old way/h3 p dir=ltrSo you’d probably start with a hook_comment_insert, and in there you’d probably grab the user, load the company that they belong to and start looping./p p dir=ltrThe problem with this approach is that everything is inside of the hook implementation and if you take it out of the hook implementation, you’ll just be littering the code base with API-like functions. Your modules are soon going to get messy. Additionally, if you need to do something else non-related in hook_comment_insert() things are going to get even more messy./p h3 dir=ltrThe new way(?)/h3 p dir=ltrWhat if in your hook_comment_insert, instead you just called a function on an entity wrapper?/p pre $author_wrapper = new UserWrapper($comment-gt;uid); $author_wrapper-gt;emailColleagues([...]);/prepThen, in my_module/src/EntityWrapper/User/UserWrapper.php (Drupal\my_module\EntityWrapper\User\UserWrapper.php) you’d make your class:/p pre class=syntax lt;?php /** * @file * Firm Profile wrapper class. */ namespace Drupal\my_module\EntityWrapper\User; use \EntityDrupalWrapper; use Drupal\my_module\EntityWrapper\Node\CompanyWrapper; /** * Wraps nodes of type firm_profile with additional functionality. */ class UserWrapper extends EntityDrupalWrapper { /** * Wrap a user object. * * @param int|object $data * A uid or user object. */ public function __construct($data) { parent::__construct(#039;user#039;, $data); } /** * Send an email to all colleagues of this user. * * @param mixed $some_args * Whatever is needed here. */ public function emailColleagues($some_args) { foreach ($this-gt;getColleagues() as $colleague) { $colleague-gt;email($some_args); } } /** * Send an email to this user. * * @param mixed $some_args * Whatever is needed here. */ public function email($some_args) { // Call something like drupal_mail() here; } /** * Get a list of colleagues in the same company as this user. * * @return UserWrapper[] * An array UserWrappers. */ public function getColleagues() { $colleagues = array(); foreach ($this-gt;getCompany()-gt;getEmployees() as $employee) { if ($employee-gt;getIdentifier() !== $this-gt;getIdentifier()) { $colleagues[] = $employee; } } return $colleagues; } /** * Get the company for this user. * * Note that we can cleanly wrap relationships between entities. * * @return CompanyWrapper * A company wrapper object. Check it with -gt;value() if you * need to make sure it has data. */ public function getCompany() { return new CompanyWrapper($this-gt;field_company-gt;raw()); } } /pre /pre pHow simple is that?! Look at all those reusable functions that we've placed directly against the relevant class. You’ll call getCompany() all the time and if you add functionality to the CompanyWrapper class then that will be ready to use as well./p pI’m quite convinced that my code is going to start looking very different from now on!/p

Flocon de toile | Freelance Drupal: Drupal SA-CORE-2014-005, perspective and lessons

Fri, 11/28/2014 - 10:28
div class=field field-name-field-image field-type-image field-label-hiddendiv class=field-itemsdiv class=field-item evenimg typeof=foaf:Image src=http://flocondetoile.fr/sites/default/files/public/styles/blog_teaser_custom_user_wide_1x/public/images/dark-clouds-hills-lighthouse-367.jpg?itok=D6gPnfnT width=800 height=300 alt=photo d#039;un phare //div/div/divdiv class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedp On Wednesday, October 15, 2014, the Drupal Security Team published an highly critical security advisory (reference SA-CORE-2014-005 (CVE-2014-3704)) in regard of a vulnerability discovered in the database abstraction API that allows to automatically sanitize the parameters of an SQL query and, therefore,prevent SQL injection attacks. In short, this vulnerability allows an anonymous attacker to compromise any Drupal 7 site by a SQL injection attack. Let's go back on the chronology of the event and try to learn some lesson from the discovery and the management of this security breach. /p /div/div/divdiv class=field field-name-field-theme field-type-taxonomy-term-reference field-label-abovediv class=field-labelThèmenbsp;/divdiv class=field-itemsdiv class=field-item evenDrupal planet/div/div/div

Lullabot: Drupal Community Leadership

Fri, 11/28/2014 - 10:05
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item evenpIn this week's episode, a href=https://www.lullabot.com/who-we-are/addison-berryAddison Berry/a is joined by Larry Garfield (a href=https://www.drupal.org/u/crellCrell/a), Greg Dunlap (a href=https://www.drupal.org/u/heyrockerheyrocker/a), and Gábor Hojsty (a href=https://www.drupal.org/u/g%C3%A1bor-hojtsyGábor Hojsty/a) to discuss the ongoing public conversation about Drupal's Community Leadership pains./p/div/div/div ul class=field field-name-field-show-notes field-type-link-field field-label-hidden li a href=https://amsterdam2014.drupal.org/session/managing-complexityLarry's Managing Complexity presentation/a /li li a href=http://hojtsy.hu/blog/2014-oct-17/authority-drupal-andor-open-source-generalGábor's On Authority blog post/a /li li a href=https://medium.com/@heyrocker/this-article-was-originally-a-keynote-presentation-at-the-pacific-northwest-drupal-summit-in-5e7c7f93131bGreg's Stay for the Community blog post/a /li li a href=http://www.garfieldtech.com/drupal/leadershipLarry's collection of the discussion to date/a /li li a href=http://portland2013.drupal.org/session/d8-lessons-learned-and-how-we-can-make-d9-better.htmlShannon Vettes’ D8 Lessons Learned presentation/a /li li a href=https://amsterdam2014.drupal.org/keynote-dries-buytaertDries’ DrupalCon Amsterdam keynote/a /li li a href=https://prague2013.drupal.org/keynote/lisa-welchmanLisa Welchman keynote, The Paradox of Open Growth/a /li li a href=https://www.drupal.org/governance/community-working-groupDrupal Community Working Group/a /li li a href=http://denver2012.drupal.org/program/sessions/painting-bikeshed-lessons-drupal-8-initiative-ownerGreg: Painting The Bikeshed: Lessons From A Drupal 8 Initiative Owner presentation/a /li li a href=http://portland2013.drupal.org/session/making-core-development-sustainable.htmlGreg: Making Core Development More Sustainable presentation/a /li /ul

Flocon de toile | Freelance Drupal: Create a Drupal 8 block in seconds

Fri, 11/28/2014 - 08:59
div class=field field-name-field-image field-type-image field-label-hiddendiv class=field-itemsdiv class=field-item evenimg typeof=foaf:Image src=http://flocondetoile.fr/sites/default/files/public/styles/blog_teaser_custom_user_wide_1x/public/images/bloc_pierre.jpg?itok=EmpH3Lk8 width=800 height=300 alt=Blocs de pierres empilées //div/div/divdiv class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedp We continue to explore the possibilities offered by the Console module and will discover how to build a Drupal 8 block in a very little time, and then customize it to our needs. /p /div/div/divdiv class=field field-name-field-theme field-type-taxonomy-term-reference field-label-abovediv class=field-labelThèmenbsp;/divdiv class=field-itemsdiv class=field-item evenDrupal planet/div/div/div

Code Drop: Getting Started Testing Drush Commands

Fri, 11/28/2014 - 07:53
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedpI've recently been rewriting the Drush Migrate Manifest command for Drupal 8 and it was my first introduction to writing tests for Drush commands. The process was more painless than I had initially imagined it would be, but not without a few caveats along the way./p h2Background/h2 pDrush tests use PHPUnit as the test runner and testing framework which offers a kind familiarity to many developers, especially anyone involved in Drupal 8. Drush uses the name Unish for its testing namespace and base test classes. I’ve no idea where Unish comes from but here’s a a href=http://en.wikipedia.org/wiki/Unishdefinition/a?/p h2Test Skeleton/h2 pCreate your test within the tests folder using Lower Camel Case for the naming of both the file and the class name./p p /p/div/div/div

KnackForge: Android app integration with Drupal for OAuth

Fri, 11/28/2014 - 07:40
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedpWhen you build Android app for an existing Drupal website which allows it's users to login using their social media account, it is important to include such features in your app as well. Instead of using app specific APIs, we can use WebView to achieve the login mechanism. Let me explain the method that I followed,/p p1) Setup Drupal menu paths for social login(s)./p p2) From android app, use webview that can call Drupal path for social login./p p3) Drupal side completes the authentication and sends back an identification token to Android./p p4) Android app uses the token to make further calls to Drupal site. Drupal side authenticates user by this token./p pstrongDrupal side /strong/p pFirst we need to define entry point for social login,/p/div/div/div

.VDMi/Blog: I went to Drupal 7.33 and all I got was a slow site

Thu, 11/27/2014 - 22:29
div class=field field-name-field-afbeelding field-type-image field-label-hiddendiv class=field-itemsdiv class=field-item evena href=/blog/i-went-drupal-733-and-all-i-got-was-slow-siteimg style=max-width: 40%; height: auto; float: left; margin-right: 1em; align=left hspace=10 src=http://www.vdmi.nl/sites/vdmisite.s1.aegirhost.nl/files/styles/200_max_width/public/sad_drupal_icon_0.jpg?itok=i-FMq2_0 width=110 height=110 alt=I went to Drupal 7.33 and all I got was a slow site //a/div/div/divdiv class=field field-name-field-samenvatting1 field-type-text-long field-label-hiddendiv class=field-itemsdiv class=field-item evenSo, you just upgraded your site(s) to Drupal gt;= 7.33, everything seemed fine in your tests. You deployed the new release and after a while you notice that your site isn#039;t as fast as before. It#039;s actually slowing down everything on your server. You started Googling and ended up on this blogpost. Sounds like your story? Read on!/div/div/divdiv class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item evenpI spent the last 2 hours figuring this out, I decided it would be best to write it up right away while it's fresh in my memory. TLDR; at the bottom of this post./p pWe did an upgrade to Drupal 7.34 recently, we thought everything was fine. Release went over 3 different environments before deploying to live and no actual issues were found./p pAfter deployment to live, we got some reports that the site was responding slow. We didn't directly link it to the upgrade to 7.34, I actually did a diff between 7.32 and 7.34 to see what changed after these reports and did not see anything suspicious that could cause this./p pWe had to investigate after a while as there was no sign of improvement, the CPU of the server was hitting 100% 24/7. New Relic monitoring told us about many calls to the file_scan_directory function of Drupal. When I actually logged the calls with the following snippet:/p p/pprecodestatic $count;br / if (!isset($count)) {br /   $count = 0;br / }br / $count++;br / drupal_debug($count . PHP_EOL);/code/pre pThe count actually went up to 700 for every request (It's quite a large project, plus the file_scan_directory is recursive).br /When I printed the debug_backtrace, I saw that this call was coming from drupal_get_filename.br /Looking at the function arguments, Drupal was looking for a imagecache_actions file, why?! And why on every request? Doesn't it cache these records in the registry?!/p pYes it does! It appeared the imagecache_actions module had a typo in it (patch a href=https://www.drupal.org/node/2166715here/a):br //p precodemodule_load_include('inc', 'imagcache_actions', 'image_overlay.inc');/code/pre pThis should be:br //p precodemodule_load_include('inc', 'imagecache_actions', 'image_overlay.inc');/code/pre pThis would not have been an issue previously, 7.33 introduced a a href=https://www.drupal.org/node/2228825change/a though.br /Pre 7.33:br //p precode$file = db_query(SELECT filename FROM {system} WHERE name = :name AND type = :type, array(':name' =gt; $name, ':type' =gt; $type))-gt;fetchField();br / if (file_exists(DRUPAL_ROOT . '/' . $file)) {br /   $files[$type][$name] = $file;br / }/code/pre p7.33 or higher:br //p precode$file = db_query(SELECT filename FROM {system} WHERE name = :name AND type = :type, array(':name' =gt; $name, ':type' =gt; $type))-gt;fetchField();br / if ($file !== FALSE amp;amp; file_exists(DRUPAL_ROOT . '/' . $file)) {br /   $files[$type][$name] = $file;br / }/code/pre pBefore 7.33, Drupal would try to find the record in the system table, it wouldn't find it and the $file would be NULL. The resulting string would be DRUPAL_ROOT . '/' . $file, as $file is NULL, you can also see it as DRUPAL_ROOT . '/'. Obviously the DRUPAL_ROOT exists, so it returns TRUE. It would put the record in the $files array and continue with what it was doing./p pBecause 7.33 and higher does a NULL-check on $file, it will not add any record to the $files array. This causes it to go into the file discovery routine:br //p precodeif (!isset($files[$type][$name])) {br /   // ... Some codebr /   $matches = drupal_system_listing(/^ . DRUPAL_PHP_FUNCTION_PATTERN . \.$extension$/, $dir, 'name', 0);br /   foreach ($matches as $matched_name =gt; $file) {br /     $files[$type][$matched_name] = $file-gt;uri;br /   }br / }/code/pre pThis code will try to scan your Drupal installation for the given file. It will not find the file and continue eventually, but it will execute the file search in EVERY request that you execute the module_load_include./p pWhile our issue was in the imagecache_actions module, your issue might be in any module (even custom) which does a wrong module_load_include.br /It's very hard to find this out yourself. You can edit includes/bootstrap.inc on line 866 to write some info away to /tmp/drupal_debug.txt:br /Add the following code after line 866:br //p precodeelse {br /   drupal_debug('Missing file ' . $type . ' ' . $name . ' ' . DRUPAL_ROOT . '/' . $file . PHP_EOL);br / }/code/pre pTLDR; an issue in imagecache_actions combined with an upgrade to Drupal gt;= 7.33 killed the performance of our site. Patch for imagecache_actions a href=https://www.drupal.org/node/2166715here/a. Causing issue/patch a href=https://www.drupal.org/node/2228825here/a./p /div/div/div

Blair Wadman: Eleven tips to keep Drupal up to date with security releases

Thu, 11/27/2014 - 21:36
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedpKeeping your Drupal site up to date has always been of critical importance to ensure it remains secure. Last month's announcement of a a href=https://www.drupal.org/SA-CORE-2014-005SQL Injection vulnerability/a and subsequent announcement of a href=https://www.drupal.org/PSA-2014-003automated attacks within 7 hours/a caused wide spread panic across much of the Drupal community./p/div/div/divdiv class=field field-name-field-tags field-type-taxonomy-term-reference field-label-abovediv class=field-labelTags:nbsp;/divdiv class=field-itemsdiv class=field-item even rel=dc:subjecta href=/drupal/all typeof=skos:Concept property=rdfs:label skos:prefLabel datatype=Drupal/a/divdiv class=field-item odd rel=dc:subjecta href=/drupal/planet typeof=skos:Concept property=rdfs:label skos:prefLabel datatype=Planet Drupal/a/div/div/div

Appnovation Technologies: Searching and attaching images to content

Thu, 11/27/2014 - 18:00
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedpBecause of its ability to extend the core platform, Drupal has become a popular CMS/Framework for many large media and publishing companies./p/div/div/divdiv class=field field-name-field-blog-header-image field-type-image field-label-hiddendiv class=field-itemsdiv class=field-item evena href=/blog/searching-and-attaching-images-contentimg typeof=foaf:Image src=http://www.appnovation.com/sites/default/files/styles/blog_listing_page_header/public/searchingimages.jpg?itok=zi27xJcn width=680 height=200 alt= //a/div/div/divdiv class=sharethis-buttonsdiv class=sharethis-wrapperspan st_url=http://www.appnovation.com/blog/searching-and-attaching-images-content st_title=Searching and attaching images to content class=st_facebook/span span st_url=http://www.appnovation.com/blog/searching-and-attaching-images-content st_title=Searching and attaching images to content class=st_twitter/span span st_url=http://www.appnovation.com/blog/searching-and-attaching-images-content st_title=Searching and attaching images to content class=st_sharethis/span script type='text/javascript'var switchTo5x = false;/scriptscript type='text/javascript' src='http://w.sharethis.com/button/buttons.js'/scriptscript type='text/javascript'stLight.options({publisher:dr-75626d0b-d9b4-2fdb-6d29-1a20f61d683});/script/div/div

Oliver Davies: Include environment-specific settings files on Pantheon

Thu, 11/27/2014 - 17:24
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item evenpI was recently doing some work on a site hosted on a href=http://getpantheon.comPantheon/a and came across an issue, for which part of the suggested fix was to ensure that the code$base_url/code variable was explicitly defined within settings.php (this is also best practice on all Drupal sites)./p pThe way that was recommended was by using a codeswitch()/code function based on Pantheon's environment variable. For example:/p/div/div/divdiv class=field field-name-field-tags field-type-taxonomy-term-reference field-label-above clearfixh3 class=field-labelTags: /h3ul class=linksli class=taxonomy-term-reference-0a href=/blog/tags/drupal-planetDrupal Planet/a/lili class=taxonomy-term-reference-1a href=/blog/tags/pantheonPantheon/a/lili class=taxonomy-term-reference-2a href=/blog/tags/settingsphpsettings.php/a/lili class=taxonomy-term-reference-3a href=/blog/tags/drupalDrupal/a/li/ul/div

Cheppers blog: Acquia Certified Developer exam - passed!

Thu, 11/27/2014 - 13:21
div class=field field-name-field-front-image field-type-image field-label-hiddendiv class=field-itemsdiv class=field-item even rel=schema:image resource=http://cheppers.com/sites/default/files/styles/blog_promoted-image/public/blog_2.jpg?itok=cmTCmpL6a href=/blog/acquia-certified-developer-exam-passedimg typeof=foaf:Image src=http://cheppers.com/sites/default/files/styles/blog_promoted-image/public/blog_2.jpg?itok=cmTCmpL6 width=350 height=210 alt= //a/div/div/divdiv class=field field-name-field-lead field-type-text-long field-label-hiddendiv class=field-itemsdiv class=field-item even property=schema:headlinepWe are proud to announce that Cheppers has now three Acquia Certified Developers!br / This Monday Mau, Attila and Andor have all passed the exam held by Acquia, and we are very proud of them./p /div/div/divspan rel=schema:url resource=/blog/acquia-certified-developer-exam-passed class=rdf-meta/spanspan property=schema:name content=Acquia Certified Developer exam - passed! class=rdf-meta/span

Kristian Polso: Crawling the top 15,000 Drupal websites

Thu, 11/27/2014 - 11:01
So I crawled the top 1,000,000 websites from Alexa, looking for all of the Drupal websites (and other popular CMS's). Here are the results.

Joachim's blog: A git-based patch workflow for drupal.org (with interdiffs for free!)

Thu, 11/27/2014 - 09:39
div class=field field-name-body field-type-text-with-summary field-label-hiddendiv class=field-itemsdiv class=field-item even property=content:encodedpThere's been a lot of discussion about how we need github-like features on d.org. Will we get them? There's definitely many improvements in the pipeline to the way our issue queues work. Whether we actually need to replicate github is another debate (and my take on it is that I don't think we do)./p pIn the meantime, I think that it's possible to have a good collaborative workflow with what we have right now on drupal.org, with just the issue queue and patches, and git local branches. Here's what I've gradually refined over the years. It's fast, it helps you keep track of things, and it makes the most of git's strengths./p h2A word on local branches/h2 pGit's killer feature, in my opinion, is local branches. Local branches allow you to keep work on different issues separate, and they allow you to experiment and backtrack. To get the most out of git, you should be making small, frequent commits./p pWhenever I do a presentation on git, I ask for a show of hands of who's ever had to bounce on CMD-Z in their text editor because they broke something that was working five minutes ago. Commit often, and never have that problem again: my rule of thumb is to commit any time that your work has reached a state where if subsequent changes broke it, you'd be dismayed to lose it./p h2Starting work on an issue/h2 pMy first step when I'm working on an issue is obviously:/p pdiv class=codeblockcodenbsp; git pull/code/div/p pThis gets the current branch (e.g. 7.x, 7.x-2.x) up to date. Then it's a good idea to reload your site and check it's all okay. If you've not worked on core or the contrib project in question in a while, then you might need to run update.php, in case new commits have added updates./p pNow start a new local branch for the issue:/p pdiv class=codeblockcodenbsp; git checkout -b 123456-foobar-is-broken/code/div/p pI like to prefix my branch name with the issue number, so I can always find the issue for a branch, and find my work in progress for an issue. A description after that is nice, and as git has bash autocompletion for branch names, it doesn't get in the way. Using the issue number also means that it's easy to see later on which branches I can delete to unclutter my local git checkout: if the issue has been fixed, the branch can be deleted!/p pSo now I can go ahead and start making commits. Because a local branch is private to me, I can feel free to commit code that's a total mess. So something like:/p pdiv class=codeblockcodenbsp; dpm($some_variable_I_needed_to_examine);br /nbsp; /*br /nbsp; // Commented-out earlier approach that didn't quite work right.br /nbsp; $foo += $bar;br /nbsp; */br /nbsp; // Badly-formatted code that will need to be cleaned up.br /nbsp; if($badly-formatted_code) { $arg++; }/code/div/p pThat last bit illustrates an important point: commit code before cleaning up. I've lost count of the number of times that I've got it working, and cleaned up, and then broken it because I've accidentally removed an important that was lost among the cruft. So as soon as code is working, I make a commit, usually whose message is something like 'TOUCH NOTHING IT WORKS!'. Then, start cleaning up: remove the commented-out bits, the false starts, the stray code that doesn't do anything. (This is where you find it actually does, and breaks everything: but that doesn't matter, because you can just revert to a previous commit, or even use git bisect.)/p h2Keeping up to date/h2 pCore (or the module you're working on) doesn't stay still. By the time you're ready to make a patch, it's likely that there'll be new commits on the main development branch (with core it's almost certain). And prior to that, there may be commits that affect your work in some way: API changes, bug fixes that you no longer need to work around, and so on./p pOnce you've made sure there's no work currently uncommitted (either use git stash, or just commit it!), do:/p pdiv class=codeblockcodegit fetchbr /git rebase BRANCH/code/div/p pwhere BRANCH is the main development branch that is being committed to on drupal.org, such as 8.0.x, 7.x-2.x-dev, and so on./p p(This is arguably one case where a local branch is easier to work with than a github-style forked repository.)/p pThere's lots to read about rebasing elsewhere on the web, and some will say that rebasing is a terrible thing. It's not, when used correctly. It can cause merge conflicts, it's true. But here's another place where small, regular commits help you: small commits mean small conflicts, that shouldn't be too hard to resolve./p h2Making a patch/h2 pAt some point, I'll have code I'm happy with (and I'll have made a bunch of commits whose log messages are 'clean-up' and 'formatting'), and I want to make a patch to post to the issue:/p pdiv class=codeblockcodenbsp; git diff 7.x-1.x gt; 123456.PROJECT.foobar-is-broken.patch/code/div/p pAgain, I use the issue number in the name of the patch. Tastes differ on this. I like the issue number to come first. This means it's easy to use autocomplete, and all patches are grouped together in my file manager and the sidebar of my text editor./p h2Reviewing and improving on a patch/h2 pNow support Alice comes along, reviews my patch, and wants to improve it. She should make her own local branch:/p pdiv class=codeblockcodenbsp; git checkout -b 123456-foobar-is-broken/code/div/p pand download and apply my patch:/p pdiv class=codeblockcodenbsp; wget PATCHURLbr /nbsp; patch -p1 lt; 123456.PROJECT.foobar-is-broken.patch/code/div/p p(Though I would hope she has a bash alias for 'patch -p1' like I do. The other thing to say about the above is that while wget is working at downloading the patch, there's usually enough time to double-click the name of the patch in its progress output and copy it to the clipboard so you don't have to type it at all.)/p pAnd finally commit it to her branch. I would suggest she uses a commit message that describes it thus:/p pdiv class=codeblockcodenbsp; git commit -m joachim's patch at comment #1/code/div/p p(Though again, I would hope she uses a GUI for git, as it makes this sort of thing much easier.)/p pAlice can now make further commits in her local branch, and when she's happy with her work, make a patch the same way I did. She can also make an interdiff very easily, by doing a git diff against the commit that represents my patch./p h2Incorporating other people's changes to ongoing work/h2 pAll simple so far. But now suppose I want to fix something else (patches can often bounce around like this, as it's great to have someone else to spot your mistakes and to take turns with). My branch looks like it did at my patch. Alice's patch is against the main branch (for the purposes of this example, 7.x-1.x)./p pWhat I want is a new commit on the tip of my local branch that says 'Alice's changes from comment #2'. What I need is for git to believe it's on my local branch, but for the project files to look like the 7.x-1.x branch. With git, there's nearly always a way:/p pdiv class=codeblockcodenbsp; git checkout 7.x-1.x ./code/div/p pNote the dot at the end. This is the filename parameter to the checkout command, which tells git that rather than switch branches, you want to checkout just the given file(s) while staying on your current branch. And that the filename is a dot means we're doing that for the entire project. The branch remains unchanged, but all the files from 7.x-1.x are checked out./p pI can now apply Alice's patch:/p pdiv class=codeblockcodenbsp; wget PATCHURLbr /nbsp; patch -p1 lt; 123456.2.PROJECT.foobar-is-broken.patch/code/div/p p(Alice has put the comment ID after the issue ID in the patch filename.)/p pWhen I make a commit, the new commit goes on the tip of my local branch. The commit diff won't look like Alice's patch: it'll look like the difference between my patch and Alice's patch: effectively, an interdiff./p pdiv class=codeblockcodenbsp; git commit -m Alice's patch at comment #2/code/div/p pI can now do a diff as before, post a patch, and work on the issue advances to another iteration./p pHere's an example of my local branch for an issue on Migrate I've been working on recently. You can see where I made a bunch of commits to clean up the documentation to get ready to make a patch. Following that is a commit for the patch the module maintainer posted in response to mine. And following that are a few further tweaks that I made on top of the maintainer's patch, which I then of course posted as another patch./p pimg src=http://www.noreiko.com/sites/default/files/article/image/git-local-branch-issue-workflow.png width=457 height=257 alt=A screenshot of a git GUI showing the tip of a local branch, with a commit for a patch from another user. //p h2Improving on our tools/h2 pWhere next? I'm pretty happy with this workflow as it stands, though I think there's plenty of scope for making it easier with some git or bash aliases. In particular, applying Alice's patch is a little tricky. (Though the stumbling block there is that you need to know the name of the main development branch. Maybe pass the script the comment URL, and let it ask d.org what the branch of that issue is?)/p pBeyond that, I wonder if any changes can be made to the way git works on d.org. A sandbox per issue would replace the passing around of patch files: you'd still have your local branch, and merge in and push instead of posting a patch. But would we have one single branch for the issue's development, which then runs the risk of commit clashes, or start a new branch each time someone wants to share something, which adds complexity to merging? And finally, sandboxes with public branches mean that rebasing against the main project's development can't be done (or at least, not without everyone know how to handle the consequences). The alternative would be merging in, which isn't perfect either./p pThe key thing, for me, is to preserve (and improve) the way that so often on d.org, issues are not worked on by just one person. They're a ball that we take turns pushing forward (snowball, Sisyphean rock, take your pick depending on the issue!). That's our real strength as a community, and whatever changes we make to our toolset have to be made with the goal of supporting that./p /div/div/divul class=links inlineli class=comment-add first lasta href=/comment/reply/33#comment-form title=Share your thoughts and opinions related to this posting.Add new comment/a/li /ul

PreviousNext: Lightning talk - Drupal 8's Third Party Settings Interface

Thu, 11/27/2014 - 03:22
pDuring this weeks developers' meeting our lightning talk was all about Drupal 8's ThirdPartySettingsInterface./p pHere's the video introduction to this powerful new feature in Drupal./p span property=dc:title content=Lightning talk - Drupal 8#039;s Third Party Settings Interface class=rdf-meta element-hidden/span