/* drucafe */

Tuesday, March 8, 2016

Build unminified CKEditor for Drupal 8

Drupal 8 core contains a minified version of CKEditor in core/assets/vendor/ckeditor/ckeditor.js . It's hard to debug e.g. while writing a custom plugin or widget. So on development server it may be useful to have full unminified version.

There are two methods to produce (make, build) unminified ckeditor.js in place of existing, minified version, both described in core/assets/vendor/ckeditor/build-config.js .

First method is to use CKEditor builder on page http://ckeditor.com/builder and this method didn't work for me (after build there were errors, can't remember exactly what errors but it the unminified ckeditor.js just didn't work on my site.

The other method requires to install Git locally and to clone the dev repository. The result ckeditor.js worked perfectly on my site. The build process is described here and has the following steps:

  • Check the version of your existing CKEditor version which came with the D8 install. It's in file core\assets\vendor\ckeditor\changes.md
  • Open Git console in D8 root directory
  • Make a clone of the ckeditor-dev branch from Git into local ckeditor-dev subdirectory:
    git clone https://github.com/ckeditor/ckeditor-dev.git
  • Change directory into the new one: cd ckeditor-dev
  • Upgrade the local clone to the version checked in the first step (from changes.md file). In my case it was 4.5.5, so: git checkout 4.5.5
  • The build configuration which was originally used by D8 is in file core\assets\vendor\ckeditor\build-config.js. So to prepare to make exactly the same build, copy this file to D8root\ckeditor-dev\dev\builder directory.
  • From ckeditor-dev directory, run the builder shell script with the following flags: ./dev/builder/build.sh --skip-omitted-in-build-config --leave-js-unminified
    It will create release subdirectory with unminified ckeditor version
  • Delete the original core\assets\vendor\ckeditor directory
  • Copy the D8root\ckeditor-dev\dev\builder\release\ckeditor directory into core\assets\vendor.
  • You may also copy D8root\ckeditor-dev\dev\builder\build-config.js file into core\assets\vendor\ckeditor, just in case you delete the builder dev and later need to repeat the whole process again.


Saturday, March 5, 2016

Drupal errors

Drupal 7

After restoring a "backup migrate" backup from production server to test server, I had white screen with "500 Internal Server Error". The test server is on windows so I don't have drush, so I did some things in database manually. No idea whether all steps were necessary or only the last one, but I finally got it working.

First thing I did was clear cache tables. In phpmyadmin, check tables starting with "cache_" and choose operation "Empty" at the bottom of the screen. It didn't help.

Then I changed the system paths (public, private and temp) in database. Table "variable" contains three records: "file_private_path", "file_public_path" and "file_temporary_path". See here how to change them. It didn't help.

Then I noticed (in debugger) that Drupal was complaining about being unable to delete a record from table "semaphore", so I deleted it manually (a record, not the table). It didn't help.

And then finally I noticed that the error message is in debugger is "SQLSTATE[HY000]: General error: 2006 MySQL server has gone away" and it turned out that increasing max_allowed_packet in my.ini helped, as described in this blog.

By the way, next time I have such error I'll start with deleting lines from settings.php which prevent error display on screen (makes sense in production but not on test server) so perhaps the errors will be easier to find out without using debugger.