Mustash
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6
Back to this add-on's main page
View Other Add-ons From Mark Croxton
Database Error - exp_stash_rules group_id
Bug Report
Fuel Integrated
|
Posted: 16 July 2015 01:43 PM |
|
|
|
Hi Mark,
I’m getting this error when trying to save a cache breaking rule, Mustash 1.1.2
Incorrect integer value: 'NULL' for column 'group_id' at row 1
INSERT INTO `exp_stash_rules` (`plugin`, `hook`, `group_id`, `bundle_id`, `scope`, `pattern`, `ord`, `site_id`) VALUES ('clear_module_page', 'stash_delete', 'NULL', '5', 'site', '#^(.*){url_title}(.*)$#', 5, '1')
Filename: third_party/mustash/models/mustash_model.php
Line Number: 574
Worked fine up until I updated, this is with the custom stash_delete hook plugin thing, which doesn’t let me select a group in the UI when entering the rule info.
|
|
|
Mark Croxton
|
Posted: 16 July 2015 02:03 PM |
# 1
|
|
Developer
|
Do you have this in your custom plugin?
/** * Set groups for this object * * @access protected * @return array */ protected function set_groups() { return array(); }
|
|
|
Fuel Integrated
|
Posted: 16 July 2015 02:04 PM |
# 2
|
|
|
Yep, here’s the file:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/** * Mustash cache-breaking plugin * * @package Mustash * @author Mark Croxton */
class Stash_clear_module_page_pi extends Mustash_plugin {
/** * Name * * @var string * @access public */ public $name = 'Module pages';
/** * Version * * @var string * @access public */ public $version = '1.0.0';
/** * Extension hook priority * * @var integer * @access public */ public $priority = '10';
/** * Extension hooks and associated markers * * @var array * @access protected */ protected $hooks = array( 'stash_delete' );
/** * The 'Tags' bundle ID * * @var integer * @access protected */ protected $bundle_id = 5;
/** * Constructor * * @return void */ public function __construct() { parent::__construct(); }
/** * Set groups for this object * * @access protected * @return array */ protected function set_groups() { return array(); }
/* ================================================================ Hooks ================================================================ */
/** * Hook: stash_delete * * @access public * @param array * @return void */ public function stash_delete($data) { if ($data['bundle_id'] == $this->bundle_id) { // prep marker data $markers = array( 'url_title' => $data['key_label'] );
// flush cache $this->flush_cache(__FUNCTION__, FALSE, $markers); } } }
|
|
|
Mark Croxton
|
Posted: 16 July 2015 02:09 PM |
# 3
|
|
Developer
|
What version of EE? Have you upgraded anything recently?
|
|
|
Fuel Integrated
|
Posted: 16 July 2015 02:10 PM |
# 4
|
|
|
EE 2.9.0, updated a bunch of things :/
|
|
|
Mark Croxton
|
Posted: 16 July 2015 02:12 PM |
# 5
|
|
Developer
|
Hmm weird one. I can do some testing with your plugin tomorrow see if I can reproduce. What PHP version?
|
|
|
Fuel Integrated
|
Posted: 16 July 2015 02:13 PM |
# 6
|
|
|
Currently running PHP Version 5.5.27-1+deb.sury.org~precise+1 in vagrant
|
|
|
Mark Croxton
|
Posted: 17 July 2015 12:06 PM |
# 7
|
|
Developer
|
I can’t reproduce it no matter what I try!
It seems like NULL is not getting filtered out of the array inserted into db, for whatever reason. Try this:
around line 657 of mcp.mustash.php change this:
if ( $trigger != "NULL" )
to this
if ( $trigger != "NULL" && ! is_null($trigger) )
|
|
|
Fuel Integrated
|
Posted: 17 July 2015 12:20 PM |
# 8
|
|
|
Just tried it, and didn’t work :(
Upon saving, the same error showed up and it removes every cache rule after the last rule with a group specified.
|
|
|
Mark Croxton
|
Posted: 17 July 2015 12:31 PM |
# 9
|
|
Developer
|
OK please undo the last change and try this line 664 just a bit below:
'group_id' => $group[$index],
To:
'group_id' => ($group[$index] == "NULL" ? NULL : $group[$index]),
|
|
|
Fuel Integrated
|
Posted: 17 July 2015 12:39 PM |
# 10
|
|
|
Yep, that seems to have done it!
In previous versions, group_id was previously 0 for stash_delete, now obviously it’s being set to NULL - though I guess that will have the same falsey result anyway.
Cheers!
|
|
|
doctorlove
|
Posted: 10 August 2015 10:42 AM |
# 11
|
|
|
I had the same errors when creating cache breaking rules and leaving group, bundle and scope blank.
I have now done the same for bundle_id and scope, which results in:
'group_id' => ($group[$index] == "NULL" ? NULL : $group[$index]), 'bundle_id' => ($bundle[$index] == "NULL" ? NULL : $bundle[$index]), 'scope' => ($scope[$index] == "NULL" ? NULL : $scope[$index]),
Is this bad practice? Why isn’t this possible out of the box?
|
|
|
Mark Croxton
|
Posted: 10 August 2015 12:05 PM |
# 12
|
|
Developer
|
It is possible of course, but you and the OP seem to have an environment-specific configuration that makes it throw an error. Not sure what exactly as I’m not able to reproduce, and no one else has reported a problem.
However, as the solution above seems to work for you both, I have rolled it into the latest release which you can download now from your account. (v1.1.3)
|
|
|