Wednesday, February 5, 2020

ArgumentCountError: Too few arguments to function Drush\Sql\SqlBase::__construct(), 1 passed

Ever encountered Drush error while running Drush commands in your local against sites hosted in Acquia? Here is a solution.

Drush command:
drush @example.dev status

Drush version:
Drush Commandline Tool 9.6.0

Drush error:
ArgumentCountError: Too few arguments to function Drush\Sql\SqlBase::__construct(), 1 passed and exactly 2 expected in Drush\Sql\SqlBase->__construct() (line 42 of /mnt/www/html/vendor/drush/drush/src/Sql/SqlBase.php).
ArgumentCountError: Too few arguments to function Drush\Sql\SqlBase::__construct(), 1 passed and exactly 2 expected in /mnt/www/html/vendor/drush/drush/src/Sql/SqlBase.php on line 42 #0 [internal function]: Drush\Sql\SqlBase->__construct(Array)
#1 /usr/local/drush8/vendor/drush/drush/includes/drush.inc(117): ReflectionClass->newInstanceArgs(Array)
#2 /usr/local/drush8/vendor/drush/drush/commands/sql/sql.drush.inc(532): drush_get_class('Drush\\Sql\\Sql', Array, Array)
#3 /usr/local/drush8/vendor/drush/drush/commands/sql/sql.drush.inc(549): drush_sql_get_class(Array)
#4 /usr/local/drush8/vendor/drush/drush/includes/environment.inc(389): drush_sql_get_class()
#5 /usr/local/drush8/vendor/drush/drush/lib/Drush/Boot/DrupalBoot.php(462): drush_valid_db_credentials()
#6 /usr/local/drush8/vendor/drush/drush/lib/Drush/Boot/DrupalBoot8.php(109): Drush\Boot\DrupalBoot->bootstrap_drupal_database_validate()
#7 /usr/local/drush8/vendor/drush/drush/includes/bootstrap.inc(430): Drush\Boot\DrupalBoot8->bootstrap_drupal_database_validate()
#8 /usr/local/drush8/vendor/drush/drush/includes/bootstrap.inc(507): drush_bootstrap_validate(4)
#9 /usr/local/drush8/vendor/drush/drush/includes/bootstrap.inc(456): drush_bootstrap_max()
#10 /usr/local/drush8/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(59): drush_bootstrap_to_phase(-2)
#11 /usr/local/drush8/vendor/drush/drush/includes/preflight.inc(67): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 /usr/local/drush8/vendor/drush/drush/drush.php(12): drush_main()
#13 {main}
Drush command terminated abnormally due to an unrecoverable error.       [error]

Fix:

  1. Go to your /sites containing *.site.yml files. In my case /home/sastha/sites
  2. vi example.site.yml
  3. Check "paths:" variable
  4. If other aliases are running fine, then set same for your problematic alias
  5. In my case, changed below from
       paths:
          drush-script: drush

         TO

        paths:
            drush-script: drush9

Wednesday, March 20, 2019

[success] No site aliases found. drush 9

[success] No site aliases found. drush 9

Running drush sa returns below message in drush 9?

[success] No site aliases found.

Here is the solution:
NOTE: Tested with drush installed globally

Run drush debug command:
drush st --debug -vvv
 Sample output from above:

 [preflight] Config paths: /home/sastha/.composer/vendor/drush/drush/drush.yml
 [preflight] Alias paths:
 [preflight] Commandfile search paths: /home/sastha/.composer/vendor/drush/drush/src
 [bootstrap] Starting bootstrap to max [0.3 sec, 7.64 MB]
 [debug] Trying to bootstrap as far as we can [0.3 sec, 7.64 MB]
 PHP binary    : /usr/bin/php7.2
 PHP config    : /etc/php/7.2/cli/php.ini
 PHP OS        : Linux
 Drush script  : /home/sastha/.composer/vendor/drush/drush/drush
 Drush version : 9.6.0
 Drush temp    : /tmp
 Drush configs : /home/sastha/.composer/vendor/drush/drush/drush.yml


Alias Path is missing as highlighted above


Sample drush.yml content:
sastha@DESKTOP $ cat /home/sastha/.composer/vendor/drush/drush/drush.yml
#This is a Drush config file. Sites may override this config to change minimum PHP.
drush:
  php:
    minimum-version: 5.6.0
  paths:
    alias-path:
     - /home/sastha/sites

Check if alias-path is set?

sastha@DESKTOP $ drush st --debug -vvv
 [preflight] Config paths: /home/sastha/.composer/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /home/sastha/sites
 [preflight] Commandfile search paths: /home/sastha/.composer/vendor/drush/drush/src
 [bootstrap] Starting bootstrap to max [1.47 sec, 7.64 MB]
 [debug] Trying to bootstrap as far as we can [1.48 sec, 7.65 MB]
 PHP binary    : /usr/bin/php7.2
 PHP config    : /etc/php/7.2/cli/php.ini
 PHP OS        : Linux
 Drush script  : /home/sastha/.composer/vendor/drush/drush/drush
 Drush version : 9.6.0
 Drush temp    : /tmp
 Drush configs : /home/sastha/.composer/vendor/drush/drush/drush.yml

Problem solved!

Yes formatting is bad because no one is reading my blog except me :) :) :)

Friday, March 1, 2019

Drupal 8 Composer failure on Windows 7 with the message "bin\phpcs" "--config-show" "installed_paths"" failed.

Drupal 8 Composer failure with the below message on Windows 7:

 ""D:\www\mydrupalsite/vendor/bin\phpcs" "--config-show" "installed_paths"" failed.

Solution: 

Save this as phpcs.bat inside D:\www\vendor\bin:

@ECHO OFF
setlocal DISABLEDELAYEDEXPANSION
SET BIN_TARGET=%~dp0/../squizlabs/php_codesniffer/bin/phpcs
php "%BIN_TARGET%" %*

Monday, February 4, 2019

DrupalcampNJ: YouTube Channel

Drupal 8: Using Kint to print views fields

How to print fields variable of a views?

{{ kint(fields) }}

To resolve Out of memory issue:
https://www.drupal.org/project/devel/issues/2764023

Edit modules/devel/kint/kint/config.default.php and set $_kintSettings['maxLevels'] to a lower number (the default is 7)

My recommendation: Set it to 4 if you are using Windows


PHP error while enabling Drupal 8 Devel Module

Error Message:
The website encountered an unexpected error. Please try again later.Symfony\Component\Routing\Exception\RouteNotFoundException: Route "devel.execute_php" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 202 of core\lib\Drupal\Core\Routing\RouteProvider.php).

Reason:
Most probably you are installing Devel module (8.x-2.0) with Admin Toolbar installed

Fix:
https://www.drupal.org/project/admin_toolbar/issues/3009193
Upgrade to latest version of Admin Toolbar (8.x-1.26)

Monday, April 6, 2015

Acquia Certified Developer

I am a proud Acquia Certified Developer (Drupal) from today! :)


Friday, December 30, 2011

2011 & Me!!

It’s been quite a long time, since I have posted something in my blog. So I have decided to scribble few things in this borrowed space from Google, to end this year. There is no big fan following for my writing, so no worries even if I make grammatical mistakes, unnecessary punctuations or discuss worthless topics.

Survival:

Like everyone in this densely populated, extremely polluted and massively corrupted country, I relocated to the Silicon Valley of India nothing for a single reason, Food. Once Chennai knocked me out badly, survival became a tough job for me near the end of 2010. Bangalore helped for survival and a decent comeback. It’s not required I have to stick with what is written as the title of this blog! No one questioned why movies are named irrelevant to the content shown.

Truth:

I became the most loved to most hated individual. I learnt it is not required to mention why we hate someone? Never imagined about how future will be, while living this moment. May be people don’t like this attitude and definitely it’s a tough decision to think about a guy who is having no money. Finally, what is true is "Truth won’t die, but can be killed."

Career:

New Company, new people, new environment almost everything settled when New Year begin for me. I approached this year with my own philosophy, "Hard work decides what you deserve". But nothing great is achieved now.

Travel:

Every day I have to travel one and a half an hour to reach office from my shared house. Red painted overpaid Volvo buses are offering not only luxury but also showed me how people live in a High-tech city. From multi branded wardrobes, glittering shoes, imported gadgets, multi-lingual conversations to mechanical life style, worried faces etc. Volvo is my teacher, guide, companion, park and everything.

I want to make a rough calculation of how many kilometers I have travelled (to and fro) this year.

Shared house to office: 40 Km per day * 15 days per month* 12 months = 7200 Km
Bangalore to Chennai: 360 Km * 3 times per month * 12 months = 12960 Km
Bangalore to Kodaikanal: 750 Km * 1 time = 750 Km
Approximately, I have travelled 20910 Km this year!

Books:

Travel pushed me to read. Books I have read Shall we tell the president?, 2 States, Bad luck & Trouble (still in progress),The Alchemist and Revolution 2020. Good to have few collections in my hand and mind.

Thanks:

Mid 2011 presented me unforgettable people and unforgettable moments. I feel happy for that. But I couldn’t relocate my mother along with me, for which I should scold myself as 'Stupid'.

Hope the New Year 2012 will bring more surprises. I still believe, Truth alone triumphs!

Thanks to God.

Wednesday, April 28, 2010

Drupal Interview questions PHP, MySQL, Javascript and CSS

This is the list of interview questions asked to me in various interviews I have attended so far, answers will be updated soon.

PHP & MySQL questions:
-----------------------

  1. Mysql & mysqli difference

  2. Second highest salary

  3. Breadcumb handling

  4. Diff JSON & XML. Which will be best? Reason for that?

  5. Which is the best one for RIA?

  6. Calling pages from other server

  7. How you find Version of Drupal?

  8. serialize and unserialize in php?

  9. echo and print difference

  10. exif? usage?

  11. sort, asort, ksort? usage?

  12. require, require_once & include?

  13. how many ways PHP session ID can be retrieved?

  14. persistent cookies?

  15. How to eliminate PHPSESSID= in URL?

  16. php oop pass by value or reference?

  17. @fopen()

  18. Php HEREDOC

  19. myd, myi, frm?

  20. single command to import .csv file into DB

  21. find date difference?

  22. optimizing mysql queries

  23. mysql_fetch_row(), mysql_fetch_object(), mysql_fetch_array()


General:
-------

  1. Tell me about your company.

  2. Summarize your work experience.



Drupal:
-------

  1. What are the necessary files for creating a new module?

  2. What will happen when there is no tpl files inside your custom themes folder?

  3. How you set an subdomain sites with your existing drupal installation?

  4. Use of AHAHA module?

  5. Have you every worked with any properitory drupal products like Acquia?

  6. What you know that Drupal template engines?

  7. Views? Views 2?

  8. MySQL replication

  9. How you do Drupal Performance tuning?

  10. memcached?

  11. Why we use jQuery?


Client-side language interview questions:
--------------------------------

  1. It's a simple list of client-side language interview questions.



CSS:
---

  1. What's the difference between display: none and visibility: hidden?

  2. What are the ways we can include stylesheets in a HTML file?

  3. List the possible Values of 'Position' property. Which one is the default value?

  4. What is the use of '!important'?

  5. Tell the priority level of external, inline & internal stylesheets.

  6. Can we use a class name more than once in a HTML file?

  7. Which one will have the higher priority, ID or CLASS?

  8. What is the purpose of 'Block'?

  9. How do we override a class property in css?


JS :
--

  1. On page load, i want to hide a

    tag. How to do that?

  2. What is the syntax for addListener?

  3. What is a Lightbox?


HTML:
----

  1. List the attributes of anchor tag.

Wednesday, December 23, 2009

svn: PROPFIND request failed on 403 forbidden error - Tortoise SVN

At instances when we try to update our source code from CMD prompt or PUTTY using the following command in Tortoise SVN,

# svn update
or
# svn up

We may come across the following error

svn: PROPFIND request failed on '/svn/repos/yourfolder'
svn: PROPFIND of '/svn/repos/yourfolder': 403 Forbidden (https://yourdomainname.com


The solution for this error is:

svn update --username your_user_name


where,
'your_user_name' is your SVN user name

Once you type this command it ask your password
Authentication realm:
Authorization Realm Password for 'your_user_name':


After this type your password. This will resolve this problem and your source code will get updated.

If not please try some other procedures.

Sunday, December 13, 2009

The URI you submitted has disallowed characters. Code Igniter

While deploying your Code Igniter application in the production server, you may come across with the following error message.

The URI you submitted has disallowed characters.

The problem can be solved with one of the following:

  1. mod_rewrite problem: The mod_rewrite might be the problem for this. Get help form your hosting provider to enable mod_rewrite. In my case, our hosting provider is networksolutions.com. The server environment is FastCGI. They informed us that by default the mod_rewrite will be enabled. In order to use in your application, we need to add
    RewriteBase URL-path
    in our .htaccess file.

    RewriteEngine on
    # If your application is in the home directory
    RewriteBase /
    #Followed by your application specific rules

    In case of deploying in a sub-directories the .htaccess file should have

    RewriteEngine on
    # If your application is in the sub-directory
    RewriteBase /myfolder



  2. The $config['permitted_uri_chars'] configuration variable problem. To resolve this check this url.

Tuesday, November 10, 2009

Paa The movie

Amitabhji - One of the versatile and finest actors of Indian cinema. He always amaze people with his experimental acting. I was shocked by his new look in the upcoming movie 'Paa'(to be released on December).



Surprising to see real father & son combo in a son-father relation in reel world. Amitabhji constantly rocks Indian cinema with his stunning performances. I wish him all the best for 'Paa'.

Will the senior actors of Tamil cinema ready for an experimentation like Amitabhji?

Monday, October 12, 2009

Its PEAR's turn to kick my PUT (BUTT) :)

We had a peculiar requirement, in which all the API requests should be sent using PUT method. I never heard of this 'PUT' HTTP method before.

By the way here is my development environment details:

OS : WINDOWS
Framework : Code Igniter (PHP)
DB: MySQL

After vigorous goggling, we found that JQUERY (AJAX) can send HTTP requests by PUT method. Here is the sample link.
Cross-domain issue: There came the 'Cross-domain' issue in Mozilla Firefox when I tried to send HTTP requests to our API. IE 6 will not have this problem. But fixing this cross-domain issue in Mozilla Firefox 3.0 is not as simple as in Firefox 2.x. Changing configuration in pref.js file didn't helped me.

I realized that this not a easy task as i thought.

What about REST? Yaa!! REST can send requests to send HTTP requests in PUT method. We started trying things in a new direction.

Will REST help us????

The fact is even though there are wonderful PHP libraries to send HTTP requests in PUT method, the API provided to us rejected everything. WTF!

Here is the PHP REST servers and clients :
REST PHP class client
REST PHP class server

Again we started our search for the solution. My Tech Lead - Palani gave me the idea of sending the requests in PUT using ROR (Ruby on Rails), this will help us to check whether the API is really accepting PUT method?

I consulted with our ROR team and they gave me a new buzz word 'mechanize' gem.
Here is the code which i used
require "rubygems"
require "mechanize"
require "net/https"
agent = WWW::Mechanize.new
agent.keep_alive = false # true causes TypeError
STDERR #if $DEBUG
agent.put("http://ourapi.com", {"param1" => "0"}, :headers => {"Content-Length" => 50})

Our cute API rejected that too! "What the hell you want me to do?". I shouted.

Again we started our search for the solution. Suddenly I came across PEAR HTTP REQUEST.

HTTP REQUEST is a PHP PEAR package to perform HTTP requests. This package supports all the four HTTP methods to send requests (GET, POST, PUT, DELETE).

This looked promising! I was overjoyed.

At the very next moment, downloaded and integrated it in Code Igniter with the help of this wonderful posting, PEAR integration.

Hurray!! We completed the coding

$this->load->library('Pearloader');
$req3 = $this->pearloader->load('HTTP', 'Request');
$params = 'state=0';
$url = 'http://ourapi.com';
$req3->setURL($url);
$req3->setMethod(HTTP_REQUEST_METHOD_PUT);
$req3->setBody($params);
$req3->sendRequest();
$response3 = $req3->getResponseBody();
echo $response3;
echo '
--------------------------
';

Wait...wait man. We have a twist in the tale. :(

Yes, this code worked charmingly in WINDOWS. But in Linux!!! This thrown the following error..

"Fatal error: Call to undefined method HTTP_Request::setBody() in"

For god's sake, What I did to this LINUX?, I wondered!

Finally, I fixed the issue by changing the line

$req3->setBody($params);

with

$req3->addRawPostData($params);

The funniest thing is, Request.php documentation says, "addRawPostData() is deprecated since 1.3.0, method setBody() should be used instead"

:)

This code worked fine in LINUX also. My problem was solved. Now we can send HTTP Requests in PUT method using PEAR package.

THE END :)

Thanks for reading

DOM PDF sucked me!

DOM PDF is an excellent HTML to PDF converter for PHP. It gives us the flexibility to design our PDF output in HTML format and use that file to generate the required PDF. Looks cool, huh! I never knew the danger behind it when i started using it.

Yes, i have developed my PDF generation requirement using the DOM PDF in my Windows box and the project was about to be delivered. But once i ported it in Linux Box, i was terrified!

In Linux, DOM PDF is not generating the PDF properly. I was clueless. It worked charmingly in Windows. What i observed is that, if the contents (number of pages) exceed more than one page, it doesn't generate the PDF. It was shocked! We (along with my Tech Lead) tried our level best to fix it up. But DOM PDF sucked us. We couldn't arrive at a solution to fix this issue.

At last we gave up DOM PDF and continued our development with FPDF (the savior) and completed the project.

It's a very good lesson for me about the platform specific issues of free codes. I admit that i never posted anything related to this issue in DOM PDF. I have to do it soon.

Thanks for reading this.

Friday, September 18, 2009

Monday, July 14, 2008

IRC for Online help (in my case its Drupal)..


Another day of struggle in learning Drupal (CMS) ,a Content Management System for website development. Although, i worked in it a long way back.Now,i need to learn its coding. I have been instructed to learn new things for the past 2 weeks like Plone(Python),Code Igniter and now Drupal.

Whenever, i start learning a new technology. I do the following things (Everybody will do the same isn't it?)
1.First i search for its official site and download the application.
2.Then,I install it in my local system and try out few sample codes.
3.The next step would be the search for a free ebook.
4. The final step would be the new thing, i started doing these days. ONLINE HELP!
Here comes the explanation for that last step. Getting "Online support" will be the best possible way, to quickly learn a new technology . There should be a way to get this support isn't it? Yes,here comes IRC(Internet Relay Chat) to help us.
IRC ,a very old concept started way back in 80's. To know more about its history, visit http://en.wikipedia.org/wiki/Internet_Relay_Chat.
This environment will help you to get connected to 1000's of experts in various technologies. Talking about my experience for Drupal, i searched web for a Drupal online support. I landed up with this fantastic environment IRC. To set up this environment in Windows,
1. I installed "Microsoft Chat" which is a free download from http://www.tucows.com/preview/193891 . or you can download XCHAT from www.xchat.org/.
2. Connect to the specific host,in my case its "irc.freenode.net"
3. Join the room from the list of rooms available.For Drupal rooms like "#drupal,#drupal-support" will be the opt.
4. Get connected and learn the technology from experts.
All these geeks will amaze you in answering your queries,providing us with reference URL's,suggestions,best coding practices and more.

"WHAT ELSE YOU NEED TO LEARN A TECHNOLOGY"

A Sample IRC Chat environment:




I don't know how many of u guys reading this, will know it already.But my objective is to share my knowledge. That's it :)

As a conclusion,always remember the basic etiquettes to be followed in IRC chat.
GET CONNECTED TO LEARN.

Thanks,
Sastha L

Tuesday, February 5, 2008

A good day to start my blog.

"Blogging seems to be an personal diary, openly written".
Me too join this open culture from today.
Support me.
Thanks
Sastha L