Posts

Create a branch in bitbucket cloud using curl

 Example: curl -X POST \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{       "name": "feature/mynewbranch",       "target": {           "hash": "master"       }     }' \ "https://api.bitbucket.org/2.0/repositories/gopiworkspace/gopirepo/refs/branches" <access_token> is generated in the repository where you want to create the branch. https://bitbucket.org/gopiworkspace/gopirepo/admin/access-tokens  Ref: https://community.atlassian.com/t5/Bitbucket-discussions/Create-branch-BitBucket-REST-API-Support/td-p/610927 

Debugging

 devel_kint_extras disable minifyhtml module to take any kind of devel modules take effect.

ClamAV in MAC

Install ClamAV in MAC  > b rew install clamav  >  cp /usr/local/etc/clamav/clamd.conf.sample usr/local/etc/clamav/clamd.conf Uncomment  below TCPSocket 3310 TCPAddr localhost > cp /usr/local/etc/clamav/clamd.conf.sample/ freshclam.conf.sample  /usr/local/etc/clamav/ freshclam.conf .conf Comment below Example > brew services restart clamav   Starting and Verifying ClamAV Start clamd : Start the ClamAV daemon manually to ensure it’s running: sudo clamd Check Status : Verify that clamd is running and listening on the correct port: sudo lsof -i -P -n | grep clamd Start freshclam : Start the FreshClam updater to update the virus definitions: sudo freshclam

Semmai

  சீரக நீà®°ில் சித்தரத்தை: à®’à®°ு பானை நீà®°ினை நன்à®±ாகக் கொத்திக்க விட்டு, சிà®±ு தேக்கரண்டி அளவு சீரகம், எட்டு à®®ிளகுகள், சிà®±ிதளவு சித்தரத்தை ஆகியவற்à®±ைப் போட்டு à®®ூடிவிட வேண்டுà®®். இரவு இவ்வாà®±ு செய்துவிடுà®™்கள். மறுநாள் காலை à®®ுதல் இந்நீà®°ைக் குடிநீà®°ாகப் பருகலாà®®். ஆறிப்போனாலுà®®் சூடேà®±்றத் தேவையில்லை. சீரகம், à®®ிளகு, சித்தரத்தை ஆகியவற்à®±ை குà®±ிப்பிட்டுள்ள அளவில் மட்டுà®®் பயன்படுத்துà®™்கள். அளவு à®®ிக வேண்டாà®®். சித்தரத்தை என்பது கிà®´à®™்குவகையைச் சேà®°்ந்த சிறந்த à®®ூலிகை. நாட்டு மருந்துக் கடைகளில் கிடைக்குà®®். பூண்டு பாகு நாட்டு சர்க்கரை à®’à®°ு டம்பளர் + பூண்டு நாலு பள்ளு தோலுடன் நசுக்கி

Error with duplicated entry in webform issue in Drupal

Issue:   Drupal\Core\Database\IntegrityConstraintViolationException : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'my_form-2' for key 'PRIMARY': UPDATE "webform" SET "next_serial"=:db_update_placeholder_0 WHERE "webform_id" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 2 [:db_condition_placeholder_0] => my_form ) in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 45 of core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php ). Fix: Delete from webform where webform_id='my_form' and next_serial=1

SSO

1.  IDP (Identity provider) Azure AD 2. SP (service provider) Any of your applications like Joomla, Moodle, Drupal 3. Authentication can be done via OAuth, SAML etc.. between IDP and SP. 4. Microsoft Office 365 uses Azure AD to authenticate users. 5.  OpenID Connect is an identity layer built on top of OAuth 2.0, providing authentication capabilities.

Deployment failure in Drupal

 In case, a config import error is coming because the new module is not installed then we can do the following function somemodule_update_10001() {   if (!\Drupal::service('module_handler')->moduleExists('new_module')) {     \Drupal::service('module_installer')->install(['new_module']);   } }

File upload security in Drupal

  finfo_file  https://www.drupal.org/project/file_upload_secure_validator/

Drupal example using migrate module, migrations, drush import, revert import

 https://www.drupal.org/project/path_redirect_import

Nginx config for redirect map

 Using 'Map' for redirects map_hash_bucket_size 128; map $uri $new_uri { /test-to-rewrite /test-rewritten; /test2-to-rewrite /test2-rewritten; } server { server_name example.com ; if ($new_uri) { return 301 $new_uri; } #... }         Source: https://www.dogsbody.com/blog/nginx-optimising-redirects/ Another example for using query strings: http {      map_hash_bucket_size 128;     map $uri$is_args$args $new_uri {         # /hello?123     /hello123?345;         include /my-location/redirect.tsv;         default         $uri$is_args$args;   # Default to the original URI if not matched     }    server {    location / {       if ($new_uri != $uri$is_args$args) {          return 302 $new_uri;       }     } } File...

Drupal caching

 Use case1: You return data as a JSON API via an endpoint. Ex: /api/mydata. This data is fetched from a config form. Now, we have to cache the JSON API response and refresh it when the config form is updated. Code: $config = $this->config(MySettingsForm::my_config_name); $cacheMeta = new CacheableMetadata(); $cacheMeta->addCacheTags($config->getCacheTags()); $data = ['key' => 'value']; $response = new CacheableJsonResponse(json_encode([$data], JSON_UNESCAPED_SLASHES), 200, [], TRUE); $response->addCacheableDependency($cacheMeta); return $response; When this code is added to the controller, Drupal stores following cache id (cid) in cache_config table when the response is created for the first time. For subsequent requests the cached data is returned. When the config form is updated the cached data is refreshed using the cache id (cid) cache id: config:my_module.my_config_name 

Upgrade from D9 to D10

 Ngnix change: Change from: location @rewrite {     rewrite ^/(.*)$ /index.php?q=$1; } To: location @rewrite {     rewrite ^ /index.php; # For Drupal >= 7   }

Setting up SSH keys, Git to contribute to Drupal.org

SSH Keys:  https://www.drupal.org/drupalorg/docs/user-accounts/git-authentication-for-drupalorg-projects cd ~/.ssh ssh-keygen -t ed25519 -b 4096 -C " drupalcode.org " Enter the filename. Ex:  id_ed25519_drupalcode_org ssh-add ~/.ssh/ id_ed25519_drupalcode_org vim  id_ed25519_drupalcode_org.pub copy the contents and create a new key at  https://git.drupalcode.org/-/profile/keys Test:  ssh -T git@git.drupal.org You can also add ssh config file  vim ~/.ssh/config Save the below contents Host git.drupal.org   AddKeysToAgent yes   IdentityFile ~/.ssh/id_ed25519_drupal_org Configuring Git: https://www.drupal.org/docs/develop/git/setting-up-git-for-drupal/configuring-git-for-drupal Note: Configure your name and email address https://www.drupal.org/user/<your-id>/git Committing: Make sure username and email are correct in the folder you are committing > git config --list   credential.helper=osxkeychain init.defaultbranch=main user.email= gop...

PHP Ngnix Mysql in OSX with multiple PHP Versions

 https://kevdees.com/macos-11-big-sur-nginx-setup-multiple-php-versions/ https://github.com/shivammathur/homebrew-php == Upgrade PHP version from 8.2 to 8.3 1. Take the backup of PHP 8.2 ini file from /usr/local/etc/php/8.2/php.ini /usr/local/etc/php/php.ini 2. Remove PHP 8.2 brew uninstall shivammathur/php/php@8.1 3. Install PHP 8.3 # Add the PHP and PHP Extension taps brew tap shivammathur/php brew tap shivammathur/extensions # Install PHP 8.3 brew install shivammathur/php/php@8.3 # Link PHP 8.3 CLI executable as `php` brew link --overwrite --force shivammathur/php/php@8.3 # Test installation php -v 4. Restart sudo killall php-fpm sudo service php-fpm restart 5. Edit config file vim /usr/local/etc/php/8.3/php-fpm.d/www.conf # default user = _www group = _www listen = 127.0.0.1:9000 # change to user = <your_username> group = staff listen = 127.0.0.1:9074 brew services restart php@8.3 Other tools Xdebug in shivammathur/homebrew-php brew install shivammathur/extensions/xdebug@...

Online semver checker - Useful while using composer

 https://jubianchi.github.io/semver-check/#/

Redirect issue with the URL alias in D8/D9

 Sometimes the redirect from a node to the destination might not work. It might not work because of the URL alias of the source node. The solution is to delete the URL alias of the source node. Then the redirect will work. https://www.drupal.org/project/redirect/issues/2821158 Example: node/11 exists without URL alias. Create a redirect from /hello to sitey.com => redirect works Add a URL alias to node/11 as /hello Now check the redirect from /hello to sitey.com => Don't work Delete the URL alias of the node/11 => now the redirect works.

Regex Lib

 https://regexlib.com/Search.aspx?k=password&AspxAutoDetectCookieSupport=1

Git cherry pick

git checkout <branch_where_you_want_new_commits> git fetch origin <branch_from_which_you_want_commits> git cherry-pick <commit-hash> Note: You can get the commit hashes from "git log" on the source branch

Regex to humar readable

 http://xenon.stanford.edu/~xusch/regexp/ 

http exception Drupal8

  HttpExceptionSubscriberBase - Drupal 8 - W3cubDocs