In order for Views to function properly the core Block Module needs to be enabled. While the entire site works properly without the Block Module which I assume is a performance boost, Views tries to update the Block database table. Independent of changing the block name, cache settings and machine name of blocks created in Views, Views functions correctly without the Block Module enabled.
I enabled the Block Module, changed the settings then disabled and uninstalled the Block Module. It maintained the settings change. I don't know if the cache settings are still respected.
This is an image of the error. http://imgur.com/6ZDLN
Comments
Comment #1
Adam S commentedSince I only need to change the machine name of the View, I added a condition of the Block module existing to protect against trying to write to the block table. I figure the machine names will all be created by the time I upgrade or if the case is that I need the Block Module installed it will work just the same. Here is the patch.
Comment #2
merlinofchaos commentedMaybe the check should be inside the update_block_bid() function so that it's safer to call from other locations should that need to happen for some other reason.
Comment #3
Adam S commentedWhen changing Block name or Block caching, Views also tries to write to the block table. Should these options not appear when the Block module is disabled? Or, should they be struck through with a warning, perhaps, that the Block module has been disabled?
Comment #4
merlinofchaos commentedShould the entire block display be dependent upon block module? I mean, can you do anything with it without block module?
Comment #5
Adam S commentedI'm using the Context module with Blocks disabled. **ducks and hides
Comment #6
dawehnerYeah it's indeed a plugin that block module is both api and ui and api's in drupal are hooks which are indepedent from modules.
Comment #7
merlinofchaos commentedYeah, it's just that the presence of the block table seems more tied to the API than the UI.
Anyway, if the block table isn't there when block.module is uninstalled then yes we have to guard our references to it.
Comment #8
Adam S commentedHere is a patch to hide the block name/description and block level caching options.
Comment #9
dawehnerThis was part of your previous patch not views itself.
Comment #10
merlinofchaos commentedI don't think I would hide these options. Some other block interface might still use that data, if it's using block APIs.
Comment #11
Adam S commentedSorry about that.
Comment #12
merlinofchaos commentedAnother issue: block.module could be enabled, creating a block table. Then disabled. The table will still exist until block.module is uninstalled. If you change something, and block table does not get updated, then when block.module is re-enabled the data will be out of sync.
I think we actually need to use something like
Comment #13
Adam S commentedOh, I see. This information is exposed to the API through views_block_info() and views_block_view(). Therefore, the only point of saving it to the blocks table is if the Blocks UI is enabled to be overridden on the blocks configuration page.
Comment #14
merlinofchaos commentedRight but what about, say, CTools content types? They use the same data even though block module may be disabled. Ok not the block caching, but it *could* use it. Certainly the block description.
Comment #15
Adam S commentedIt shouldn't matter if the Block module is enabled or not because if the Block module is enabled and the block table doesn't exist the site wouldn't work. So for brevity sake the module_exists('block') condition might safely be left out.
In views_block_info(), the info and cache properties were set by Views based on the description and block cache settings in the View while the Block module was disabled and uninstalled.
Comment #16
merlinofchaos commentedFor brevity yes.
But for performance reasons, no: module_exists() is a fast check. db_table_exists() is slow.
module_exists() guarantees db_table_exists. Therefore we increase performance by checking the module first.
Comment #17
dawehnerThis shouldn't be part of the patch.
Comment #18
dawehnerSo here is a real review: If module_exists than the table exists as well, so it would be enough to check for the db_table_exists
Comment #19
dawehnerOkay commtied the idea from #18