Hi, I have updated from 1.x to 2.x-dev.

The configurations of "Add the CSS on specific pages" and all the page URLs, went lost.

Also when i add a new CSS file I get this error:

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'rule_conditions' doesn't have a default value: INSERT INTO {css_injector_rule} (name, admin_description, css, media, preprocess, inline, page_visibility, page_visibility_pages) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => www [:db_insert_placeholder_1] => ww [:db_insert_placeholder_2] => ww [:db_insert_placeholder_3] => all [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => ) in drupal_write_record() ...

Also, when I try to re-save a CSS file with brackets in the machine name, i got this error:

Illegal characters found in the friendly name, please remove them.

but the field is disabled and i can't edit it.

Could this be all related to the one CSS file illegal characters? I have deleted it and cleared all caches, but the problems still persist.

Comments

kreynen’s picture

Can you attach an export of your css_injector table?

maustyle’s picture

I can only find this table:
css_injector_rule

kreynen’s picture

Yes. Please export that table.

bagelche’s picture

I came here today to post the same PDOException error. I've checked with a couple of others users of 2.x who report they have created new rules successfully, but I am unable to.

kreynen’s picture

Status: Active » Needs work

The issue only impacts upgraded sites. I thought the problem was in the data (or lack of data) in the rule_conditions field of a specific rule, but it's at the db level.

In the 1.x version of css_injector a value for rule_conditions was required at the table level...

http://cgit.drupalcode.org/css_injector/tree/css_injector.install?h=7.x-...

In the 2.x branch, the logic of that field is moved to page_visibility and page_visibility_pages...

http://cgit.drupalcode.org/css_injector/tree/css_injector.install?h=7.x-...

Currently the values from rule_conditions aren't migrated in an update_hook and the field remains in the table causing this error.

Expect a commit to fix this in a few minutes.

  • kreynen committed 551c1bd on 7.x-2.x
    additional update_hook for #2349327
    
kreynen’s picture

Status: Needs work » Needs review
bagelche’s picture

I just installed and did a few quick tests with kreynen's fix on my existing test environment. It has resolved this issue for me. Thank you!

maustyle’s picture

Here is my css_injector_rule (simplified):

-- phpMyAdmin SQL Dump
-- version 3.5.3
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1:33067
-- Generation Time: Oct 06, 2014 at 09:43 PM
-- Server version: 5.5.35
-- PHP Version: 5.4.15

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `w_thecngsmr_1002_1210_51`
--

-- --------------------------------------------------------

--
-- Table structure for table `css_injector_rule`
--

CREATE TABLE IF NOT EXISTS `css_injector_rule` (
  `crid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'The primary identifier for the CSS injection rule',
  `name` varchar(255) DEFAULT NULL COMMENT 'Unique ID for rules. Used to identify them programmatically.',
  `rule_type` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'The type of rule to use when determining if the CSS should be injected',
  `rule_conditions` text NOT NULL COMMENT 'The data to evaluate when determining if the CSS should be injected',
  `media` varchar(255) NOT NULL COMMENT 'The media type of the CSS file (screen, print, etc.)',
  `preprocess` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Whether the CSS file should be included by the CSS preprocessor',
  `enabled` int(10) unsigned NOT NULL DEFAULT '1' COMMENT 'Whether the rules should be enabled',
  `rule_themes` text COMMENT 'Themes that CSS rule will be applied to',
  `admin_description` varchar(255) DEFAULT NULL COMMENT 'A human readable name of a rule.',
  `css` longtext COMMENT 'The actual code.',
  `inline` int(11) NOT NULL DEFAULT '0' COMMENT 'Boolean indicating whether the rules should be inline (cannot be aggregated).',
  `page_visibility` int(11) NOT NULL DEFAULT '0' COMMENT 'Boolean indicating whether the rule has a white or black list for page visibility.',
  `page_visibility_pages` longtext COMMENT 'A list of pages to either hide or show the CSS.',
  PRIMARY KEY (`crid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;

--
-- Dumping data for table `css_injector_rule`
--

INSERT INTO `css_injector_rule` (`crid`, `name`, `rule_type`, `rule_conditions`, `media`, `preprocess`, `enabled`, `rule_themes`, `admin_description`, `css`, `inline`, `page_visibility`, `page_visibility_pages`) VALUES
(6, 'sales-pages', 1, 'events/disruptive-leadership*\r\nevents/tickets/*\r\ncourses/enrol/*\r\npromo/introductory-coaching-program*\r\nthank-you/promo/introductory-coaching-program*\r\nevents/foundations-of-coaching-success/register\r\nwebinars/how-to-become-a-successful-coach*\r\nwebinars/meta-dynamics-in-action*\r\nevents/free-information-night*\r\npersonal-success-planning-session*', 'all', 0, 1, 'a:0:{}', 'sales-pages', '.html .ss_body_wrap {\r\n  position: relative;\r\n  left: -2em;\r\n}\r\n', 0, 1, 'events/tickets/*'),
(7, 'Mini Course variant', 1, 'promo/introductory-coaching-program*', 'all', 0, 1, 'a:0:{}', 'Mini Course variant', '#menuLeft,\r\n#menuRight,\r\n#contentWrapper {\r\n    background-image: url("/profiles/mm/themes/custom/ktheme/images/carousel-black.jpg");\r\n}\r\n', 0, 1, 'promo/introductory-coaching-program*');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
kreynen’s picture

Status: Needs review » Fixed

I tested the updated dev snapshot with this @maustyle's table and I was able to add a new rule after running update.php. Like @bagelche, the update fixed the issue for me.

If you are still having this issue after updating to the most recent dev snapshot, please reopen the issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.