- PowerPoint PPT Presentation

About This Presentation
Title:

Description:

The Horrible Truth About Drupal - NY PHP – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 46
Provided by: nyp8
Learn more at: http://www.nyphp.org
Category:
Tags: magic | thinking

less

Transcript and Presenter's Notes

Title:


1
(No Transcript)
2
(No Transcript)
3
H o r r i b l e T r u t h 1
Drupal is written in PHP, which is uttterly
offensive to people.
4
(No Transcript)
5
H o r r i b l e T r u t h 2
Drupal loads too much code -rasmus
6
Is Drupal too Modular?

7
H o r r i b l e T r u t h 4
Drupal is basically a 404 page to which you can
add modules
8
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL)

index.php includes/bootstrap.inc - load necessary
functions drupal_page_header() starts timer, sets
up caching, module callout includes/common.inc -
utility functions such as path formatting
functions, form generation and validation, etc.
fix_gpc_magic() sets status 404 switch - case
Not Found case Access Denied drupal_page_footer()
9
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL)

drupal_load() drupal_not_found() drupal_access_de
nied() drupal_site_offline() return
menu_execute_active_handler() print
theme('page', return) drupal_page_footer()
10
What's on the menu api?

MENU_CALLBACK MENU_DEFAULT_LOCAL_TASK MENU_LOCA
L_TASK MENU_MAX_DEPTH MENU_MAX_PARTS MENU_NORMA
L_ITEM MENU_SUGGESTED_ITEM MENU_CALLBACK MENU_D
EFAULT_LOCAL_TASK MENU_LOCAL_TASK MENU_MAX_DEPTH
MENU_MAX_PARTS MENU_NORMAL_ITEM MENU_SUGGESTED
_ITEM
11
Scream API

12
H o r r i b l e T r u t h 7
The Dreaded Hooks of Torture
13
Hooks of Torture
to implement a hook, create a function that
'extends' hooks into an existing hook (hook
function) not functions but can be
overloaded call user function array used to
make dynamic function calls
14
module_invoke_all
  • lt?php
  • function module_invoke_all()
  • args func_get_args()
  • hook args0
  • unset(args0)
  • return array()
  • foreach (module_implements(hook) as module)
  • function module .'_'. hook
  • result call_user_func_array(function,
    args)
  • if (isset(result) is_array(result))
  • return array_merge_recursive(return,
    result)
  • else if (isset(result))
  • return result
  • return return

15
hook_admin
  • /
  • channels_admin
  • implements hook_admin
  • Provides channels admin form to save settings
    for the following fields
  • /
  • function channels_admin()
  • form'channels' array(
  • 'type' gt 'textfield',
  • 'title' gt t('Channel'),
  • 'default_value' gt variable_get('channels',
    ''),
  • 'size' gt 25,
  • 'maxlength' gt 128,
  • 'description' gt t("channel_theme"),
  • 'required' gt TRUE,
  • )
  • return system_settings_form(form)

16
hook_perms
  • /
  • Implements hook_perm().
  • /
  • function channels_perm()
  • return array(
  • 'access channel content',
  • 'administer channels',
  • )

17
hook_menu
  • /
  • Implements hook_menu().
  • anne/
  • function channels_menu()
  • items array()
  • items'admin/settings/channels' array(
  • 'title' gt 'channel settings',
  • 'description' gt 'select channel',
  • 'page callback' gt 'drupal_get_form',
  • 'page arguments' gt array('channels_admin'),
  • 'access arguments' gt array('administer
    channels'),
  • 'type' gt MENU_NORMAL_ITEM,
  • )
  • return items

18
hook_block
  • /
  • Implementation of hook_block().
  • /
  • function channels_block(op 'list', delta 0,
    edit array())
  • switch (op)
  • case 'list'
  • blocks0'info' t('current_channel')
  • return blocks
  • case 'view'
  • totals _channels_get_theme()
  • if (!empty(webstream))
  • content theme('channels_current_theme',
    webstream)
  • blocks'subject' t('You're What's
    On!')
  • blocks'content' content
  • return blocks

19
hook_menu_alter
  • / Implementation of hook_menu_alter(). /
  • function noaccess_menu_alter(items)
  • items'node''access arguments'
    array('access node path')
  • / Implementation of hook_perm(). /
  • function noaccess_perm()
  • return array('access node path')

20
Hook Soup
21
Does Drupal have a Learning Curve...

22
or a Learning Brick Wall ?

23
(No Transcript)
24
Community Plumbing

25
Product!
Framework!
Drupal is a Pushme - Pullyou
26
Field API
  • What's
  • a
  • Node?

27
H o r r i b l e T r u t h 9
Drupal Isn't 'Classy'?
28
H o r r i b l e T r u t h 10
Drupal isn't Object Oriented?
29
DRUPAL DESIGN PATTERN
Drupal Design Pattern
30
REALITY CHECK.
Drupal Design Pattern
31
Drupal Anti-Pattern

Load Everything then Cherry Pick What You
Need.
32
H o r r i b l e T r u t h 11
Drupal Encourages Slavery
33
Making Drupal Slave Safe!
34
Actions Triggers
(not slave safe)
35
Database TNG
36
(No Transcript)
37
Performance Scaling
  • Sample Metrics from a large Drupal site
  • 50 million page views per month
  • 6.5 million site visitors per month
  • 150,000 page views per hour
  • load tests to levels of greater than 500,000 page
    views per hour
  • Drupal.org delivers approximately 1M/day/month

38
Object Caching
  • APC
  • Advantages
  • Low latency
  • No need to serialize/unserialize items
  • Scales perfectly with more web servers
  • Disadvantages
  • No enforced consistency across multiple
    web servers
  • Cache is not shared each web server must
    generate each item
  • memcached
  • Advantages
  • Consistent across multiple web servers
  • Cache is shared across all web servers items
    only need to be generated once
  • Disadvantages
  • High latency
  • Requires serializing/unserializing items
  • Easily shards data across multiple web servers,
    but is still a big, shared cache

39
Cache Headers
40
(No Transcript)
41
drush
  • Download and enable devel module
  • drush dl devel
  • drush enable devel
  • Run cron
  • drush cron
  • Refresh modules and core updates
    informartion
  • drush refresh
  • Take a snapshot of the DB
  • drush sql dump gt mydb.sql
  • Open a mysql console for running SQL
    commands into Drupal DB
  • drush sql cli
  • Clear Drupal cache
  • drush cache clear

42
drush
43
drush_make
core "7.x" projects "drupal" projects
"acquia_connector" projectsapachesolrdownloa
dtype "cvs" projectsapachesolrdownloadmo
dule "contributions/modules/apachesolr" project
sapachesolrdownloadrevision
"DRUPAL-7--0" projectsacquia_searchtype
"module" projectsacquia_searchdownloadtype
"svn" projectsacquia_searchdownloadurl
"https//svn.acquia.com/drupal/branches/1.x-7.x/mo
dules/acquia/acquia_search/" librariesSolrPhpCli
entdownloadtype "get" librariesSolrPhpClie
ntdownloadurl "http//solr-php-client.googl
ecode.com/files/SolrPhpClient.r22.2009-11-09.tgz"
librariesSolrPhpClientdestination
"modules/apachesolr"
44
Automated Backup
  • touch /.logrotate.state /.logrotate.config
  • emacs /.logrotate.config
  • /backup/dev.sql.gz
  • rotate 7
  • daily
  • nocompress
  • nocopytruncate
  • postrotate
  • /usr/bin/drush -r /web.root.org/web/
    sql dump gzip gt /backup/dev.sql.gz
  • endscript
  • /usr/bin/drush -r /web.root.org/web/ sql dump
    gzip gt /backup/dev.sql.gz

45
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com