#! code: Drupal 11: Using The Finished State In Batch Processing

This is the third article in a series of articles about the Batch API in Drupal. The Batch API is a system in Drupal that allows data to be processed in small chunks in order to prevent timeout errors or memory problems.

So far in this series we have looked at creating a batch process using a form and then creating a batch class so that batches can be run through Drush. Both of these examples used the Batch API to run a set number of items through a set number of process function callbacks. When setting up the batch run we created a list of items that we wanted to process and then split this list up into chunks, each chunk being sent to a batch process callback.

There is another way to set up the Batch API that will run the same number of operations without defining how many times we want to run them first. This is possible by using the “finished” setting in the batch context.

Let’s create a batch process that we can run and control using the finished setting.

Setting Up

First we need to create a batch process that will accept the array we want to process. This is the same array as we have processed in the last two articles, but in this case we are passing the entire array to a single callback via the addOperation() method of the BatchBuilder class.

Read more

RSpec Stubs The Object In Memory

Have you ever tested a method that pulls records out of the database and applied mocks to those records you just created in your test? Have you been surprised that the record does not appear to have the behavior you mocked out? I have an explanation of the situation for you and some options for how you can address it.

Chrome on the Mac uses less battery than Safari

It’s one of the most pervasive common wisdoms shared all over the web, no matter where you go – it’s one of those things everybody seems to universally agree on: Chrome will absolutely devastate your battery life on the Mac, and you should really be using Safari, because Apple’s special integration magic pixie dust sprinkles ensures Safari sips instead of gulps electricity. Whether you read random forum posters, Apple PR spokespeople, or Apple’s own executives on stage during events, this wisdom is hard to escape. Is it true, though? Well, Matt Birchler decided to do something entirely revolutionary and entirely unheard of: a benchmark. Back in the olden days of yore, we would run benchmarks to test the claims from companies and their PR departments, and Birchler decided to dust off this old technique and develop a routine to put the Chrome battery claims to the test. After 3 days of continuous testing on a freshly installed 14” MacBook Pro with an M2 Pro processor and 16 GB RAM running the latest stable releases of both browsers, Birchler came to some interesting conclusions. In my 3-hour tests, Safari consumed 18.67% of my battery each time on average, and Chrome averaged 17.33% battery drain. That works out to about 9% less battery drain from Chrome than Safari. Yes, you read that right, I found Chrome was easier on my battery than Safari. While I did experience some variability in each 3 hour test run, Chrome came out on top in 5 of the 6 direct comparisons. ↫ Matt Birchler His methodology seems quite sound and a good representation of what most laptop users will use their browser for: YouTube, social media, a few news websites, and editing a Google Doc, in a 20 minute loop that was repeated for three hours per test. Multiple of these three hour tests were then ran to counter variability. I highly doubt using different websites will radically change the results, but I obviously am curious to see a similar test ran on Windows and Linux, x86 and ARM, for a more complete picture that goes beyond just the Mac. Conventional wisdom is sometimes wrong, and I think we have a classic case of that here. While there may have been a time in the past where Chrome on the Mac devastated battery life, it seems Chrome and Chromium engineers have closed the gap, and in some cases even beat Safari. Now, this doesn’t mean everybody should rush and switch to Chrome, since there are countless other reasons to use Safari over Chrome other than supposed battery life advantages. With Apple PR arguing that alternative browser engines should not be allowed on iOS because Chrome would devastate iOS’ battery life, tests like these are more important than ever, and I hope we’re going to see more of them. Tech media always just seems to copy/paste whatever manufacturers and corporations claim without so much as a hint of skepticism, and this benchmark highlights the dangers of doing so, in case you didn’t already know believing corporations was a terribly idea.

وساطة إماراتية ثامنة بين روسيا وأوكرانيا

Video by via Dailymotion Source وساطة إماراتية ثامنة بين روسيا وأوكرانيااحتفالات للجنود الأوكرانيين المفرج عنهم بعد صفقة تبادل مع روسيا بوساطة إماراتية هي الثامنة من نوعها العين الإخبارية.. بوابة إخبارية عربية شاملة، تغطي أخبار العالم العربي والدولي .. تضعك دائما في قلب الحدث، لتصبح عينك على العالم برؤية مختلفة، ومحتوى متميز———————————————–‎زوروا مواقعنا الخاصة #العين_الإخباريةWebsite: https://al-ain.comX: … Read more

Akui Adanya Perundungan di PPDS Anestesi, Undip dan RSUP Kariadi Minta Maaf

Video by via Dailymotion Source SEMARANG, KOMPAS.TV – Universitas Diponegoro dan Rumah Sakit Umum Pusat Kariadi Semarang mengakui adanya perundungan di Program Pendidikan Dokter Spesialis (PPDS) anestesi. Pihak Undip dan RSUP Kariadi pun meminta maaf atas insiden ini. Awalnya, pihak Undip dan RSUP Dokter Kariadi Semarang membantah bahwa perundungan menjadi penyebab kematian dokter Aulia Risma. … Read more

Create A Responsive Tour & Travel Website Design Using HTML CSS JAVASCRIPT | Step By Step Tutorial

Video by via Dailymotion Source Watch Full Video Here:https://fb.watch/uuFO1x0xca/………………………………………………..Learn how to create a fully responsive Tour & Travel website design from scratch using HTML, CSS, and JavaScript! In this step-by-step tutorial, you’ll discover how to build a modern, user-friendly travel website that looks great on all devices. Whether you’re a beginner or an experienced developer, … Read more

شرطي بولندي يثير الجدل بحركة بهلوانية أمام فتاة

Video by via Dailymotion Source شرطي بولندي يثير الجدل بحركة بهلوانية أمام فتاة شرطي بولندي يؤدي حركة بهلوانية أمام فتاة ويثير جدلاً حول احترام الزي الرسمي العين الإخبارية.. بوابة إخبارية عربية شاملة، تغطي أخبار العالم العربي والدولي .. تضعك دائما في قلب الحدث، لتصبح عينك على العالم برؤية مختلفة، ومحتوى متميز———————————————–‎زوروا مواقعنا الخاصة #العين_الإخباريةWebsite: https://al-ain.comX: … Read more

Crested Lark Call – Experience the Wild Beauty!

Video by via Dailymotion Source The Crested Lark Call is one of the most enchanting sounds you’ll ever hear from nature. In this video, we capture the beautiful melody of the Crested Lark as it sings its heart out in the wild. The unique call of this bird has fascinated birdwatchers and nature lovers for … Read more