June 3, 2021

drupal fresh install no css Layout was forced before the page was fully loaded

The problem with the fresh install of Drupal 9 on Firefox and Chrome:
Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content
The site looks like the CSS doesn't work. The solution: go to the Appearance settings (https://example.com/admin/appearance) and simply switch to a different theme. As is turns out, this no CSS thing is the expected behaviour:
Stark 9.1.9 An intentionally plain theme with no styling to demonstrate default Drupal’s HTML and CSS.

June 2, 2021

wordpress network multisite app password invalid user id

I have a Wordpress Multisite set up as a Network. When I try to add an App Password for a user, I'm getting a cryptic Invalid User ID error.

The problem: when on a network setup, the user must be added to all sites. The error was being caused by this check:

if ( is_multisite() && ! is_user_member_of_blog( $user->ID ) ) {

Solution:

  • go to /wp-admin/network/sites.php

  • for every site, go to Users and add the required user

  • as soon as you get it right, the app passwords area will start saying something similar to:

    Application passwords grant access to all 2 blogs in this installation that you have permissions on.

https://wordpress.stackexchange.com/questions/261319/wp-api-v2-returning-invalid-user-id/

May 25, 2021

quickpay opencart 3d secure

  • Go to Settings → Acquirers → Swedbank (or any other acquirer) → View Advanced Settings → Enable SecurePay
  • Create a Fraud Filter having:
    • Metric=Transaction Type, Operator=in, Transaction Type=Card,Payment
    • Do=Enforce 3-D Secure
  • In the Opencart admin go to Extensions → Payment → QuickPay Creditcard → Cardtypelock 3d-creditcard
  • Alternatively, go to Settings → Integration → Default payment settings → Default payment methods → set 3d-creditcard

May 17, 2021

resizing swap /dev /sda virtualbox

This is a draft.
  1. lsblk:
    root@debian:~# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0    8G  0 disk 
    ├─sda1   8:1    0    4G  0 part /
    ├─sda2   8:2    0    1K  0 part 
    └─sda5   8:5    0    4G  0 part [SWAP]
    sr0     11:0    1 57.8M  0 rom  
  2. vi /etc/fstab and comment out the UUID line where type=swap
  3. reboot
  4. apt-get install --no-install-recommends parted
  5. ??

May 6, 2021

Google Search Console showing "Sitemap could not be read" and "Couldn't fetch"

The issue

  1. We run an Opencart website which has a built-in, default sitemap available at http://example.com/index.php?route=extension/feed/google_sitemap
  2. This sitemap has been submitted to Google Search Console → Sitemaps for years
  3. Google has stopped fetching it about a year ago, and any attempts to re-submit it under the same URL (or it's http/https and www/non-www variations) resulted in Couldn't fetch displayed in the list, as well as Sitemap could not be read on the drill-down page.

The confusion

  1. This support thread Sitemap could not be read in new GSC says it's a known bug:
    That the new console says 'couldnt fetch' is a bug in the console. Pending is the real status! Alas there is no real way (that I know of!) to tell between them. But can try using the URL Inspection on the sitemap url. it SHOULD say not indexed (it's a sitemap not a page, so shouldn't be indexed!), but can use the Live Test, to check if Googlebot CAN fetch it! Again as its a sitemap, NOT a page, DON'T use the 'Request Indexing' button! If Google can fetch it, it's most likely just Pending, which case just wait.
  2. The above has kept me from experimenting with our sitemap, but after keeping an eye on this for a few months, the status hasn't changed, so I decided to revisit

The solution

  1. Make your sitemap avalilable under /sitemap.xml. I have used the following Nginx rule: rewrite ^/sitemap.xml$ /index.php?route=extension/feed/google_sitemap break;
  2. Explicitly link to it using the robots.txt directive: Sitemap: https://www.example.com/sitemap.xml
  3. If you have a multistore (several domain names served by the same Opencart copy), you may have to have a dynamic robots.txt that replies with e.g. Sitemap: http<?=isset($_SERVER['HTTPS'])?'s':''?>://<?=$_SERVER['HTTP_HOST']?>/sitemap.xml. Make sure it's accessible under the default robots.txt name: rewrite ^/robots.txt$ /robots.php break;.
  4. The newly submitted Sitemap (essentially the same built-in Opencart sitemap submitted under a different URL) got fetched and showed Status=Success in just a few minutes, so there was no need to actually wait.

April 3, 2021

Call to undefined method Cake\Mailer\AbstractTransport::_headersToString()

Upgrading CakePHP3 to CakePHP4, getting this error:
Call to undefined method Cake\Mailer\AbstractTransport::_headersToString()
The method was moved to src/Mailer/Message.php in ce8c7e8. Instead, call getHeadersString() providing an array of headers you need.
$headerNames = [
    'bcc',
    'cc',
    'from',
    'readReceipt',
    'replyTo',
    'returnPath',
    'sender',
    'subject',
    'to',
];
// get all the headers
$headers = $email->getHeadersString($headerNames);

April 1, 2021

upgrade cakephp 3 to 4 using rector

The website you're upgrading must be on the latest CakePHP3. In your composer.json make sure you have "cakephp/cakephp": "^3" and run php composer.phar upgrade. You will also need to have a compatible phpunit installed: php composer.phar require --dev phpunit/phpunit:"^5.7|^6.0" Next, unlock your composer.json requirements:
    "require": {

        "cakephp/authentication": ">1.2",
        "cakephp/cakephp": "^3",
        "cakephp/migrations": ">3.0",
        "cakephp/plugin-installer": ">1.0",
        "friendsofcake/bootstrap-ui": ">1.0",
        "friendsofcake/crud": ">5.0",
        "friendsofcake/crud-view": ">0.14.0",
    },
    "require-dev": {
        "cakephp/bake": ">1",
        "cakephp/cakephp-codesniffer": ">3",
        "cakephp/debug_kit": ">3",
    },
This will let composer pick the right dependency versions as it upgrades without giving you numerous errors such as below.
Problem 1 - cakephp/authentication is locked to version 1.4.2 and an update of this package was not requested Problem 2 - friendsofcake/bootstrap-ui is locked to version 1.4.3 and an update of this package was not requested. - cakephp/migrations is locked to version dev-cake3 and an update of this package was not requested. - Conclusion: don't install cakephp/cakephp 4.0.0 (conflict analysis result) etc.
And here's how to actually upgrade.
cd /var/www
git clone git://github.com/cakephp/upgrade
cd /var/www/upgrade
git checkout master
php ../composer.phar install --no-dev
bin/cake upgrade file_rename locales /var/www/app3
bin/cake upgrade file_rename templates /var/www/app3
bin/cake upgrade rector --rules phpunit80 /var/www/app3/tests
bin/cake upgrade rector --rules cakephp40 /var/www/app3/src
cd /var/www/app3
php ../composer.phar require --dev --update-with-dependencies "phpunit/phpunit:^8.0"
php ../composer.phar require --update-with-dependencies "cakephp/cakephp:4.0.*"
php ../composer.phar require --dev cakephp/debug_kit:"^4.0"
You are likely to run into errors such as below:
PHP Deprecated: Use Cake\Error\ConsoleErrorHandler instead of Cake\Console\ConsoleErrorHandler. - /var/www/app3/vendor/composer/ClassLoader.php, line: 478 Deprecated: Use Cake\Error\ConsoleErrorHandler instead of Cake\Console\ConsoleErrorHandler. - /var/www/app3/vendor/composer/ClassLoader.php, line: 478
As well as…
The view for UsersController::login() was not found. Template file `Users/login.php` could not be found. The following paths were searched: - `/var/www/app3/src/Template/Users/login.php` - `/var/www/app3/vendor/cakephp/cakephp/templates/Users/login.php`
Update your config/ files remaining from CakePHP3 using their latest CakePHP4 counterparts.
PHP Fatal error: Declaration of App\Shell\ConsoleShell::getOptionParser() must be compatible with Cake\Console\Shell::getOptionParser(): Cake\Console\ConsoleOptionParser in /var/www/app3/src/Shell/ConsoleShell.php on line 25
An error message like the above actually guides you on what needs to be updated. If you need to see the full namespaced path of the class it wants, just search the CakePHP CookBook.
A route matching "array ( 'prefix' => 'profile', 'controller' => 'settings', 'action' => 'index', 'plugin' => NULL, '_ext' => NULL, )" could not be found.
If using $this->Html->link, make sure your prefix and controller names start with an uppercase/capital letter.