summaryrefslogtreecommitdiff
path: root/modules/php/php.install
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-03 15:33:42 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-03 15:33:42 +0000
commitd1a2de607e23da467c1366aca04ac5f61328a37a (patch)
treecbaca2bea89c96d310b1dabbf99d5b134c809f23 /modules/php/php.install
parentf43ee59e056e3d769545f90a3ab26244fb229b00 (diff)
downloadbrdo-d1a2de607e23da467c1366aca04ac5f61328a37a.tar.gz
brdo-d1a2de607e23da467c1366aca04ac5f61328a37a.tar.bz2
- Patch #626024 by sun, catch: fixed filter_list_format() hits database too often / filter_format_save() doesn't save all filters.
Diffstat (limited to 'modules/php/php.install')
-rw-r--r--modules/php/php.install39
1 files changed, 19 insertions, 20 deletions
diff --git a/modules/php/php.install b/modules/php/php.install
index c010fc738..a8ac75ce7 100644
--- a/modules/php/php.install
+++ b/modules/php/php.install
@@ -7,34 +7,33 @@
*/
/**
- * Implement hook_install().
+ * Implements hook_enable().
*/
-function php_install() {
+function php_enable() {
$format_exists = (bool) db_query_range('SELECT 1 FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'PHP code'))->fetchField();
// Add a PHP code text format, if it does not exist. Do this only for the
// first install (or if the format has been manually deleted) as there is no
// reliable method to identify the format in an uninstall hook or in
// subsequent clean installs.
if (!$format_exists) {
- $format = db_insert('filter_format')
- ->fields(array(
- 'name' => 'PHP code',
- 'cache' => 0,
- ))
- ->execute();
+ $php_format = array(
+ 'name' => 'PHP code',
+ // 'Plain text' format is installed with a weight of 10 by default. Use a
+ // higher weight here to ensure that this format will not be the default
+ // format for anyone.
+ 'weight' => 11,
+ 'filters' => array(
+ // Enable the PHP evaluator filter.
+ 'php_code' => array(
+ 'weight' => 0,
+ 'status' => 1,
+ ),
+ ),
+ );
+ $php_format = (object) $php_format;
+ filter_format_save($php_format);
- // Enable the PHP evaluator filter.
- db_insert('filter')
- ->fields(array(
- 'format' => $format,
- 'module' => 'php',
- 'name' => 'php_code',
- 'weight' => 0,
- 'status' => 1,
- ))
- ->execute();
-
- drupal_set_message(t('A !php-code text format has been created.', array('!php-code' => l('PHP code', 'admin/config/content/formats/' . $format))));
+ drupal_set_message(t('A !php-code text format has been created.', array('!php-code' => l('PHP code', 'admin/config/content/formats/' . $php_format->format))));
}
}