Drupal cache clear enables module - drupal-7

Have 3 modules
module_a.info
dependencies[] = module_b
module_b.info
dependencies[] = module_c
Need to disable module_c now
When doing drush dis module_c it will ask to disable dependents as well, which is not required
So used an hook_update_N to disable module_c
module_disable(['module_c'], FALSE);
Now when running drush updb does not disable this module.
Upon checking noticed that the module_disable function is disabling the module, but when cache-clear happens the module is enabled back again
or if we try the below query it works
db_update('system')
->fields(array(
'status' => 0,
))
->condition('type', 'module')
->condition('name', 'module_c')
->execute();
but as soon as we execute cache clear, the module_c again gets enabled automatically
How can we disable module_c alone?

Related

How do I disable caching completely in cakephp 3.x

What is the best practice to disable caching in local development enviroments?
You might use \Cake\Cache\Cache::disable() in your bootstrap.php. I'm unaware of this being cited as 'best practise', however.
For CakePHP 4 you can do the following
in src/Application.php
use Cake\Cache\Cache;
...
public function bootstrap(): void
{
parent::bootstrap();
if (Configure::read('debug')) {
Cache::disable();
}
to disable cache completely
Also you can selectively disable only database metadata cache replacing Cache::disable(); to
$connection = ConnectionManager::get('default');
$connection->cacheMetadata(false);
Instead of default you can select your configured datasources
Do not forget to use Cake\Datasource\ConnectionManager;
And then you just need to enable debugging either in app_local.php using 'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN) or in .env setting DEBUG=true (or APP_DEBUG, look carefully in your config) if you are using dotenv. So you will not have uncommitted changes in your local files.

Chrome browser not caching js files while debugging extjs application

So far i was able to set
'disableCaching: false'
in Ext.Loader.config(in app.js) and debug extjs applications on chrome browser.
But now, on inspecting the source, i see that the files have filename.js?dc=1123123 and every time the files are fetched from remote and not cached. So i am unable to set breakpoints and debug run-time on browser.
Please note that this scenario is when i do a browser refresh.
Plz let me know how i can resolve this issue.
Set disableCacheing to false in app.js before Ext.application({...
Ext.Loader.setConfig({
disableCaching: false
});
This will remove _dc cache param from requests that are getting files.
For disabling _dc on XHR Ext.Ajax requests use
Ext.Ajax.disableCaching = false;
And for proxy communication with server use noCache property on Ext.data.proxy.Server class.
noCache: true
You can also set cache config in app.json file.
"loader": {
// This property controls how the loader manages caching for requests:
//
// - true: allows requests to receive cached responses
// - false: disable cached responses by adding a random "cache buster"
// - other: a string (such as the build.timestamp shown here) to allow
// requests to be cached for this build.
//
"cache": "${build.timestamp}",
// When "cache" is not true, this value is the request parameter used
// to control caching.
//
"cacheParam": "_dc"
}
Also if using Chrome Dev Tools for debugging take a look at disableCache on Networks tab and if using FF use CTRL + F5 insted F5 to reload page
Add ?cache=false to the end of your URL to temporarily disable caching on a per-request basis.
Setting Ext.Loader configuration is one thing. There is also something called Ext.Boot which is used before loader is up and running. Boot has his own disableCaching setting. It defaults to something like this:
disableCaching: (/[?&](?:cache|disableCacheBuster)\b/i.test(location.search) ||
!(/http[s]?\:/i.test(location.href)) ||
/(^|[ ;])ext-cache=1/.test(doc.cookie)) ? false :
true,
Probably files with dc appended to url are loaded by Boot. If you want to disable it permanently just replace this code and set it to false.
app.json:
"loader": {"cache": true},
then:
sencha app refresh
it may seem confusing, but the _dc parameter then won't be present anymore - at all.

CakePHP ini_set on Shared Host

I'm on a shared host and ini_set function is disabled for security reasons. I'm trying to deploy CakePHP 2.4.1 on this host. Fresh cake installation results in a blank page, with no errors shown, instead if I comment these lines:
\lib\Cake\Model\Datasource\CakeSession.php
if (empty($_SESSION)) {
if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) {
foreach ($sessionConfig['ini'] as $setting => $value) {
if (ini_set($setting, $value) === false) {
throw new CakeSessionException(__d('cake_dev', 'Unable to configure the session, setting %s failed.', $setting));
}
}
}
}
Everything seems to works fine. Now, I'm asking what is the downside of keeping that snippets commented (in other word, what is that code responsible for)?
As the exception message, the method name and the rest of the code indicates, it configures the session settings, session name, cookie lifetime, save handler, etc...
Your code may run fine, and you should be able to use the PHP session_*() functions instead to configure the settings (the best place for that would probably your bootstrap.php). Also writing a dummy value into $_SESSION seems to prevent the CakeSession::_configureSession() to use ini_set(), so you don't have to modify it.
So this might work, but it shouldn't be necessary to jump through such hoops. There's no need to disable ini_set() in a properly set up shared hosting environment, and personally I'd change the hoster in case they are unable to change this behaviour.

CakePHP 2.x change debug level for a session

I want to be able to set debug level for one session. That is, click somewhere in an admin page and store the new debug level so that core.php reads that and sets the debug level from that varialbe or sets itself to the default value.
It seems the session component is not ready at the time core.php sets the debug level.
How may I do this, maybe in some other way?
Do I really have to set up a DB table???
I tried this:
if(isset($_SESSION['debug'])) {
Configure::write('debug', $_SESSION['debug']);
}
but it doesn't work,
Thanks!
I use this in my bootstrap.php only on my dev server (just to get rid of DebugKit and other debug stuff to see what the page looks like without them and page speed):
if (isset($_GET['debug']) && $_GET['debug'] === 'off') {
Configure::write('debug', 0);
}
Which I know works. So you can adapt that to what you have, but try it in bootstrap.php:
if (isset($_SESSION['debug'])) {
Configure::write('debug', $_SESSION['debug']);
}

CakePHP 2.1 Asset Compress Plugin not creating cached files

I'm using the CakePHP Plugin AssetCompress (v 0.7) which works fine, except that it doesn't cache any files in the directory. This is my asset_compress.ini setup:
[General]
writeCache = true
cacheConfig = false
alwaysEnableController = true
debug = false
[js]
timestamp = true
paths[] = WEBROOT/js/
cachePath = WEBROOT/cache_js/
[speedtest.min.js]
files[] = speedtest/speedtest.js
Additional notes:
I set debug to "0" in core.php
the cache_js folder is writeable (777)
also I'm using MemCache as a caching engine (not sure if this might cause the issue)
Has anybody experienced the same issue with the Asset Compress plugin?
Update: This is what I use for the CSS/Less part, works pretty well: https://github.com/Hyra/less
If I understand well this Github's wiki page you should change cacheConfig = false to cacheConfig = true to take advantage of MemCache.
You have to generate the files using the shell script. The files are not automatically generated.
https://github.com/markstory/asset_compress/wiki/Shell
To generate and store static assets defined in the asset_compress.ini config or through the AssetCompress helper on the fly. This is to save you having to manually run the console script everytime you change you css or js files.
This is what some will define as a "nasty" hack, I call it a working solution. It simply runs the console script via the php exec() method every time the AppController beforeFilter() runs and the debug level is greater than 0. So in production where your debug level should be 0, the exec() won't be run.
Add the following to your /app/Controller/AppController.php beforeFilter() function.
if(Configure::read('debug') > 0){
exec(APP.'Console'.DS.'cake -app '.APP.' AssetCompress.asset_compress build -f');
}
This is assuming that you can run the normal AssetCompress from the console (linux) or cmd prompt (windows)

Resources