Commerce – How to prevent caching of programmatically created blocks

I've been working with Drupal 7 for a few years, but I do not know Drupal 8 yet and I'm just starting to build custom modules.

What I have built is a module that modifies Drupal Commerce to make it more fluid for child sponsorship (so that you do not have the impression of buying from children).

That's two things:
1. If you add a second product to the cart, your old cart will be deleted.
2. After clicking add to cart, it redirects you to an information page.
3. This page contains a block generated by the module with a "Continue" button that takes the customer to the cashier.

The problem I have is that the code that generates the payment button block is cached and retrieves an old order ID number, which no longer exists.

Is there a way to prevent block caching or a better way to programmatically configure a custom block?

Here is my code:

src Plugin Block ContinueCheckoutBlock.php

id ();
$ connection =  Drupal :: database ();
$ user_ip =  Drupal :: request () -> getClientIp ();
$ query = $ connection-> query ("select * from commerce_order_item join commerce_order on commerce_order_item.order_id = commerce_order.order_id where uid =: user and state = & # 39; draft & # 39; and commerce_order.ip_address =: user_ip order by trade_order .changed asc limit 1 ", [':user' => $user, ':user_ip' => $user_ip])
$ result = $ query-> fetchAll ();
$ order_id = $ result[0]-> order_id;
drupal_set_message ($ order_id);

return a table (
& # 39; # type & # 39; => & # 39; markup & # 39 ;,
& # 39; # markup & # 39; => & # 39;Carry on& # 39 ;,
& # 39; # Cache & # 39; => array (& # 39; max_age> => 0),
)
}
}

commerce_custom.module

id ();
$ connection =  Drupal :: database ();
$ user_ip =  Drupal :: request () -> getClientIp ();
$ query = $ connection-> query ("select * from commerce_order_item join commerce_order on commerce_order_item.order_id = commerce_order.order_id where uid =: user and state = & # 39; draft & trade_order.ip_address =: user_ip command by trade_order .changed desc limit 1 ", [':user' => $user, ':user_ip' => $user_ip])
$ result = $ query-> fetchAll ();

$ cart_count = $ result[0]-> quantity;
$ order_id = $ result[0]-> order_id;

if ($ cart_count> 0 && $ order_id) {
$ order =  Drupal :: entityTypeManager () -> getStorage (& # 39; commerce_order & # 39;) -> load ($ order_id);
$ items = $ order-> getItems ();
$ order-> delete ();
}
}

function commerce_custom_cart_alter_redirect (& $ form, FormStateInterface $ form_state) {
$ response = new RedirectResponse (& # 39; / how-it-works & # 39;);
$ responce-> send ();
}

Since the Christian God can not prevent "Satan" from doing evil, how can he be given the word "omnipotent"?

I really think that they do not understand the implications of the infinite abilities that they attribute to their divinity.

If God can stop the devil, but do not do it, then the devil is only another hand of God – Satan can only do what God allows, and therefore really wants.

Satan is the ultimate type in fall

Anonymous says that we are all tested. Why does a deity who knows everything need to test us? He already knows what will happen.

Do not expect mythology to make sense.

.

How to prevent MediaWiki from wrapping indented content in HTML tag?

How to prevent MediaWiki from wrapping the indented content in an HTML tag?

I need a way to disable this behavior. Do you know one?

ios – How to prevent the iPhone from performing a specific autocorrection?

My iPhone almost always replace the word make (lowercase) with the word Male (yes, with a capital letter M).

I think this has been going on for about 3-4 months. I wonder if I lose my head. Almost every time I type the word make (including right there, I type this on my phone) it magically changes to Maleand I have to select the word and retype it manually.

I have checked in the application Settings → General → Keyboard → Text Replacement, and no such replacement has been set.

So, it seems that my iPhone comes from learned do that, but I can not think of a time when I would have done this substitution myself.

Question: How can I fix this problem (without globally disabling AutoCorrect)?

Bonus points for curiosity: Why did my iPhone start doing it? I do not see how he could learn to replace a very common word with a much less common word (with non-standard capitalization, anyway). It sounds like a kind of broken machine learning algorithm stuck in a strange loop of self-assertion. But if so, why would this bug only manifest in one persistent unwanted substitution? (My iPhone seems to have reluctantly agreed that I rarely wanted to type dodgeso clearly he can learn.)

How to prevent Blogger from overwriting your custom HTML code?

Blogger crashed my html!

Blogger replaces the custom HTML code with its own default HTML code whenever a publication is opened in "composition" mode.

This means that, if you use the compose option of a message in "html" mode, and then go back and edit the page in "composition" mode, Blogger overwrites your HTML code with its own default html code.

This does not just mean that it spoils the way you have spaced / indented the code.

It seems to insert
breaks where there was none, and removed

blocks that I used as the primary way to block my text elements.

If Blogger offers users to create their own HTML code, should not it leave it intact once they've done it?

Worse, Blogger sometimes seems to open a publication in "composition" mode by default when you decide to edit an already published publication. Therefore, if you write an article with your own HTML code, and then come back later to edit it, Blogger opens the page in composition mode and overwrites your own HTML code.

How do you prevent Blogger from doing it?

hold – How to use Catch correctly[] prevent my program from giving up?

I receive an error describing an untrimmed throw, with the accompanying code returned:

hold[Throw[$Failed, CURLLink`Utilities`Exception]]

I managed to find the function from which the error comes by saving the part of the code running when the program fails, and I am now trying to use it Capture[] to solve the error. However, the error persists despite my body wrap Capture[] around the part of the code that I believe is responsible. Is there a limit to what can fit inside the Capture[]?

Regarding my understanding of Capture[] go, I thought this would automatically capture all the error messages returned and prevent the program from shutting down. Is my basic assumption about this function incorrect?

In recent weeks, I have done a lot of research on my spare time trying to fix this bug, including browsing the publications on this site, but the understanding of the error correction has alluded to. I appreciate the help.

Here's a screenshot of the code, which extracts some emails from my account:
enter the description of the image here

seo – Does the use of x-Robots-Tag on a 302 advertising redirect URL will prevent penalties imposed by Google when the publisher does not support nofollow links?

Usually, we buy banner ads on some websites (not with a SEO goal) and we use this approach:

publisher-website.example
->
banner
->
short-link.example / 1234 /

On this domain, we have configured a 302 redirect to our website and a directive: always defined header X-Robots-Tag "noindex, nofollow"
so something like that

redirection 302/1234 / ourwebsite.example

Is it safe? Is it to avoid the penalties related to SEO, because we do not buy a link for SEO purposes? Unfortunately, the publisher does not support our request to add no following directly on the link.

If it is not sure, is there an alternative?

How to prevent the notification of an application from getting updated when the screen is off?

I have a bootleggers ROM (Android 9 mag) installed on a Motorola Moto E 2015 phone. I have a setting enabled in the Adaptive Display settings that allows the screen to be displayed. 39; turn on when a new notification is received. This is a good feature, but my music player (AIMP) updates its notification each time a new song starts to be played, which often forces the display to appear again. turn on (pulse) and use an extra battery. I could avoid this by completely disabling the notifications for AIMP, but I want to see the notification when the screen is turned on.

Is it possible to prevent the notification from getting updated when the screen is off?

Another solution is to disable notifications for AIMP when the screen is off, and then turn them back on when the screen is turned on (using tasker, for example). But the disadvantage of this approach is that once activated, the notification appears only in the next song. It is therefore impossible to see the current song in the notification this way.

dnd 5th – Does the antimagic field suppress or prevent the petrification of a creature ability?

It only removes / prevents if the creature's ability is magic

Some of the abilities of these monsters are considered magical, others not. To define whether something is magic or not, the Sage Advice Compendium offers us a short questionnaire:

  • Is it a magic object?
  • Is it a spell? Or does it allow you to create the effects of a spell mentioned in its description?
  • Is it a spell attack?
  • Is it powered by the use of slot machines?
  • Does his description say it's magic?

If you answer yes to any of these questions, the ability is considered magic and is therefore removed by a antimagic field.

Now, between spectator and the medusaonly the spectator's eye rays are magical. Let's take a look at the viewer's eye ray description (that's me pointing out):

The viewer draws three of the following magical Random Eye Rays (repeat duplicates), choosing one to three targets visible within 120 feet: […]

In addition, the description of the antimagic cone's function indicates that it acts against the rays of the viewer's own eye (see below), thus removing the petrifying effect for a target creature. If the target makes saving rolls against petrification and enters an anti-aggression area, it stops saving as long as it stays in that area and continues to roll back the saving rolls after leaving the field.

The central eye of the viewer creates an antimagic zone, as in antimagic field fate, in a cone of 150 feet. At the beginning of each of its turns, the viewer decides in which direction the cone faces and if the cone is active. The region works against the own rays of the viewer's gaze.

The jellyfish (including the jellyfish under the city introduced in Ravnica) petrifying look, however, answer all the questions of the "is this magic?" questionnaire above with a no, so a creature petrified by it remains petrified under the effect of a antimagic field.

Antimagic field also suppress the petrification of both basil and basil abilities, respectively (that's me highlighting):

Basil:
basil can force the creature to make a DC 12 build save roll if basil is not unfit. In case of failure of the backup, the creature magically begins to turn into stone and is restrained.

Basil:
[…] and the target must succeed on a backup roll DC 11 Constitution against being magically petrified.

If you automatically delete a table / column, the views are dropped – how to prevent it instead?

If I have a view that uses a column and I delete that column / table, the view is deleted automatically.

Is there a parameter that I can modify to prevent the column / table from being deleted, warning that it has dependencies?