16. Aug 2022 |

Ubuntu 22.04.1 LTS – Chrome is crashing, external drives don’t mount

I updated from the previous Ubuntu to the latest 22.04.1 LTS (Jammy Jellyfish). Having some issues now.

Chrome is crashing on Ubuntu 22.04.1 LTS

Chrome browser is crashing very often. Window just becomes non-responsive. I can close the window and open new ones but not use the current one.

External drives do not mount

Problem with mounting Windows partition and external harddrive.

Unable to access location. Error mounting [..] wrong fs type, bad option, bad superblock on [..], missing codepage or helper program, or other error.”

11. Aug 2022 |

Weird stuff in Laravel

Laravel migrations run in the alphabetical order of their file name

“General error: 1005 Can’t create table [..] Foreign key constraint is incorrectly formed”

This happened when the migration of my in-between table ran before the table its FKs were linked to. First I thought I can not use Laravel’s foreign key constraints but at some point I figured it out. Renaming the migration file helped.

3. Aug 2022 |

Laravel and php notes

Updated Laravel 8 to 9. Had to install php 8.0 with extensions (below) and switch php version.

Installing php. apt installs php to /etc/php

Find ini file – php -i | grep php.ini or php --ini

Install dependencies

sudo apt install php8.0-curl php8.0-xml php8.0-mbstring php8.0-mysql php8.0-intl – installs two extensions.

Call to undefined function… See if all necessary extensions are installed

21. Jul 2022 |

Eestiblogid.eu uuendus

Kirjutasin eestiblogid.eu lehe ümber Laraveli raamistikule. Kasutajaliidese jaoks hetkel kasutusel blade mallid (hea mugav kasutada). Väga suurt äriloogikat ei teinud aga vähemalt viewmodelid püüdsin ikka kasutusele võtta.

Reader (ehk see tükk, mis blogisid loeb) on Laravelist eraldi. Endiselt lihtsakoeline php rakendus (index.php, functions.php ja kaks mudelit) aga püüdsin valmisteeke kasutada seekord. Kasutusele said võetud laminas/laminas-feed, laminas/laminas-http, doctrine/dbal. DI implementeerimisest (php-di abil) kahjuks jõud üle ei käinud. Eesmärk olnuks andmebaasiühenduste kasutust viisakamaks muuta 🙂

Asub Zone serveris, minu muude asjade hulgas. Laraveli deployment sinna on väga mugav. Pmst repo fetch ja pull privaatses kaustas. Rakenduse kiirus on päris normaalne. Andmebaas on hetkel veel arendusserveris (pisike Hetzneri VPS) aga tõstan vasti Zonesse ringi.

Andmebaasi kolimisel Zone’sse läksid tähed katki.

Andmebaasi kolimisel tekkis selline viga (mida arenduskeskkonnas ei esinenud). Esialgu oli vaja kohendada Doctrine‘i ja lisada selle konfiguratsiooni charset (mille valik vajas natuke otsimist, kasutusele läks utf8mb4). Selle tulemusel sai andmebaasi kirjutamise esmapilgul korda. Seejärel läks katki Laravel. Põhjuseks see, et andmebaasitabelite collation ei olnud see, mida Laravel (enda konfuguratsioonis) kasutab. Tabeli collation’i muutmisel läks Laravel ka korda. Arendamise ajal (kuna arenduskeskkonna baasis vigu ei esinenud) ei osanud nendele asjadele tähelepanu pöörata.

7. Jul 2022 |

Composer notes

composer init – to create composer.json (not needed if you just run composer require {package}

composer dump-autoload – to regenerate namespaces in dependencies list (if composer.json is modified)

composer dump-autoload -o – generates optimised autoloading. Not actually needed in development.

Working with composer

Commit composer.lock but runcomposer update locally, composer install on server (ref).

28. Jun 2022 |

WordPress plugins

These are the plugins I install with clean install, just one command using wp cli.

Classic editors for widgets and posts (because Guttenberg is awful). One plugin against spam, plugin for opening external links in new window and Yoast SEO (because AIOSEO is garbage). You probably don’t need anything else in the beginning.

In the end I enable auto updates.

wp plugin install classic-widgets classic-editor antispam-bee open-external-links-in-a-new-window wordpress-seo --activate && wp plugin auto-updates enable --all

13. Jun 2022 |

IADB IT-süsteemide arendus – 6. semester

Kuues ehk viimane semester algas sellega, et oli vaja leida endale praktikakoht. Kuuenda semestri peakski moodustama erialapraktika (24 EAP) ja lõputöö (6 EAP). Kuna ma teadsin, mida ma tahaksin teha – PHP, e-kaubanduse ja e-äri valdkond, mõnes keerukamas raamistikus – siis kandideerisin praktikale Lumavisse. See oli minu esimene valik ja sinna ka sain. Lumavi kõrval oli siiski veel paar ettevõtet varuks.

Praktika algas minu jaoks 31. jaanuaril ja lõppes 27. mail. Praktika oli päris intensiivne õppimine ja tegi kiiresti selgeks, et 2.5 aastat ei anna tegelikult kuigi palju oskuseid ega kuigi palju arusaamist. Seega õppida on veel kõvasti.

Nüüd on teha jäänud veel vaid lõputöö, mille plaanin teha sügissemestril. Ei tahaks, et see kuidagi venima jääks.

4. Jun 2022 |

WooCommerce – add product custom field to order email

What you need, is to use a hook and a function to modify e-mail template. That is it.

First idea probably would be changing the template. In this file: wp-content/plugins/woocommerce/templates/emails/email-order-items.php

First $product = $item->get_product(); and then $key = $product->get_meta('custom_field_key'); and then this thread was helpful but this is the hook and action were what I really needed.

Also useful:

'customer_completed_order' === $email->id and order email ids that are available.

I order to test e-mails locally Sendinblue works really well as SMTP and is simpler to set up than Sendgrid.

26. May 2022 |

Docker, Linux, user

Täielik segadus 🙂 Selleks, et Linuxis saaks Dockeriga lokaalselt php arendust teha, siis peab Docker, host ja PHP õigused paika sättima.

Digital Oceani õpetus täpselt olemas.

To run docker command without sudo, you need to add your user (who has root privileges) to docker group. (ref).

See current user: echo ${UID}

Official doc: Post-installation steps for Linux

You need to run your application as the same uid inside the container as you do on the host to get file ownership to match. (ref)

Something about application and root here.

Digital Ocean tutorial – WordPress with docker compose.
Probably the thing you are looking for – Docker in Development – Docker and File Permissions