Skip to content

Instantly share code, notes, and snippets.

View Berdir's full-sized avatar

Sascha Grossenbacher Berdir

View GitHub Profile
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index d7adb65..3996210 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -323,12 +323,10 @@ function simpletest_test_get_all() {
else {
// Select all PSR-0 classes in the Tests namespace of all modules.
$classes = array();
- $module_data = system_rebuild_module_data();
- $all_data = $module_data + system_rebuild_theme_data();
@Berdir
Berdir / settings.php
Last active December 12, 2015 10:19
enable devel xhprof for 8.x
if (!drupal_valid_test_ua()) {
$path = '/var/www';
$conf['devel.settings']['xhprof_enabled'] = 1;
$conf['devel.settings']['xhprof_directory'] = '/var/www';
$conf['devel.settings']['xhprof_url'] = 'http://localhost/xhprof_html';
include_once $path . '/xhprof_lib/utils/xhprof_lib.php';
include_once $path . '/xhprof_lib/utils/xhprof_runs.php';
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
drupal_register_shutdown_function('devel_shutdown');
}
@Berdir
Berdir / gist:4989027
Created February 19, 2013 19:28
getObjects docblock
/**
* Query across multiple Salsa objects by performing a left join.
*
* @param array $objects
* Array of the salsa objects/tables, to query
* @param array $conditions
* Array of conditions. The key is the column name, the value can be one of
* - A value: used as is, with the = operator.
* - An array of values: Imploded with , and the IN operator is used.
* - A value with a %: The LIKE operator is used.
@Berdir
Berdir / gist:5042373
Last active December 14, 2015 06:28
<?php
/**
* @file
* Definition of Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery.
*/
namespace Drupal\Core\Plugin\Discovery;
use Drupal\Component\Plugin\Discovery\AnnotatedClassDiscovery as ComponentAnnotatedClassDiscovery;
---
extension:
min: "0.0229"
max: "0.3490"
mean: "0.0805"
median: "0.0575"
95th: "0.1972"
...
---
symfony:
diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php
index e20d48f..815dca3 100644
--- a/core/modules/edit/lib/Drupal/edit/EditController.php
+++ b/core/modules/edit/lib/Drupal/edit/EditController.php
@@ -134,11 +134,12 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
*/
public function getUntransformedText(EntityInterface $entity, $field_name, $langcode, $view_mode) {
$response = new AjaxResponse();
-
- $output = field_view_field($entity, $field_name, $view_mode, $langcode);
@Berdir
Berdir / gist:5331930
Created April 7, 2013 18:54
views data cache test comments
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php
index bd47a35..b434dc7 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewsDataTest.php
@@ -133,31 +133,35 @@ public function testViewsFetchData() {
* Ensures that cache entries are only set and get when necessary.
*/
public function testCache() {
- // Request the same table 5 times.
+ // Request the same table 5 times. The caches are empty at this point, so
@Berdir
Berdir / PHP Class
Last active December 18, 2015 17:59
PHPStorm Templates
<?php
#if (${NAMESPACE})
/**
* @file
* Contains \${NAMESPACE}\${NAME}.
*/
namespace ${NAMESPACE};
<?php
$node = node_load(1);
foreach ($node as $field) {
}
$start = microtime(TRUE);
for ($i = 0; $i < 1000; $i++) {
@Berdir
Berdir / dumper.php
Created February 6, 2014 16:57
Serialize dumper
$content = file_get_contents('file_with_serialized_string.txt');
$len = strlen($content);
//$len = 10000;
$depth = 0;
for ($i = 0; $i < $len; $i++) {
$char = $content[$i];
print $char;
if ($char == '{') {
$depth++;