Tuesday, January 29, 2013

Bootstrap Modal Double Backdrop

I recently had an issue where I was getting the modal-backdrop class applied twice, so I ended up with two overlays.


Upon calling .modal(), I ended up with a very dark background overlay. Dismissing the modal cause the overlay to lighten but remain. Clicking somewhere on the page or pressing ESC caused the overlay to vanish.


This was occurring whenever I loaded the entire content of the modal with AJAX. Something like:

function makeModal(html) {
        var $modal = $(html);

The problem is that html had a script tag present, so $modal.modal(); was actually being applied to the modal div and the script tag.

The Fix

You need to make sure you only apply modal() to the modal  div, like this:

function makeModal(html) {
        var $modal = $(html);

I found the answer to this problem via landon's post on this github issue: https://github.com/twitter/bootstrap/issues/679

Friday, January 25, 2013

Confluence: Failed to create the user X. Check your server logs for more information.

I recently received this error when trying to create a new user.

The error was occurring because of the order of my Group Directories.

I have both Confluence Internal Directory and Microsoft Active Directory enabled. The order is important here. Microsoft Active Directory was listed first, so when I was trying to create a new user it was trying to do so in AD.

In my case, I wanted the user to be created in the internal directory, not my AD.

The Fix

  1. Browse -> Confluence Admin
  2. User Directories
  3. Use the green arrows to make it so the Internal directory is first in the list.

You should now be able to create your user!

Tuesday, January 22, 2013

Get a Stack Trace on the Symfony2 Command line (console)

If you run a command via the Symfony 2 Console component and receive an exception, you aren't presented with much more information than the exception name and message.

To see a full stack trace, append -v to your command.

For example:

php app/console doctrine:schema:update --force -v

This will provide a full stack trace. You probably need to have Xdebug installed.

Friday, December 7, 2012

Symfony 2 cache and log permissions on Ubuntu

Using the ACL, run the following in your project home directory:

sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs

More info at http://symfony.com/doc/current/book/installation.html

Tuesday, November 27, 2012

CSS, Sublime Text 2, Colon, Vintage Mode

Can't use ':w' to save CSS/LESS files in ST2 in Vintage mode because it keeps just inserting the colon? The problem is actually with ZenCoding keybindings.

Quick Fix

Add the following to your User Confirmation file, found via Preferences -> Key Bindings (User)

{ "keys": [":"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": ":"},
        "context": [{"key": "setting.command_mode"}]

Note: The above should be inserted inside of the square brackets ([]).

What's going on?

ZenCoding has a default key binding for ':' that doesn't really respect Vintage mode. You can see these bindings in Preferences->Package Settings->ZenCoding->Bindings->Key Bindings (Default).

The binding mentioned in the Quick Fix is a copy/paste from the Vintage package key bindings. What we're doing here is putting it into our User key binding file, effectively over-ridding the one from ZenCoding.

Sunday, November 11, 2012

Using services.yml instead of services.xml in Symfony 2

In my application's bundle, I recently wanted to switch from using an XML file to register my services to a YML file. There's more information about services here: http://symfony.com/doc/current/book/service_container.html

Here's how to do it.

Create the services.yml file in your bundle, probably in something like /src/Acme/DemoBundle/Resources/config/services.yml

Next, edit the bundle's extension file and change which services file gets loaded:

// src/Acme/DemoBundle/DependencyInjection/AcmeDemoExtension.php

namespace Acme\DemoBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;

class AcmeDemoExtension extends Extension
    public function load(array $configs, ContainerBuilder $container)
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

    public function getAlias()
        return 'acme_demo';

The main changes are:

  1. switching the XmlFileLoader to YamlFileLoader in line 14
  2. canging the file to services.yml in line 15

Saturday, November 10, 2012

Symfony 2: Drop, Create, and Update Database

The Problem

This is regarding symfony 2.1 CLI tasks. When trying to add a task that dropped, created, and updated my database, I received the following:

An exception occurred while executing 'SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'':  
SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected                           
SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected

The problem, it turns out, was that doctrine was using the same connection that it used to drop the database as it was to update the database. After the drop, doctrine lost it's awareness to your database and did not re-establish it upon create.

The Fix

You need to close the connection after calling doctrine:database:drop and before doctrine:database:update --force

$connection = $this->getApplication()->getKernel()->getContainer()->get('doctrine')->getConnection();

  if ($connection->isConnected()) {

And just for reference:

Drop, Create, and Update database in Symfony 2 CLI Task

  $drop = $this->getApplication()->find('doctrine:database:drop');
  $drop_args = array(

  $drop->run(new ArrayInput($drop_args), $output);

  //Make sure we close the original connection because it lost the reference to the database
  $connection = $this->getApplication()->getKernel()->getContainer()->get('doctrine')->getConnection();

  if ($connection->isConnected()) {

  $create = $this->getApplication()->find('doctrine:database:create');
  $created_args = array(

  $create->run(new ArrayInput($created_args), $output);

  $update = $this->getApplication()->find('doctrine:schema:update');

  $update_args = array(

  $update->run(new ArrayInput($update_args), $output);