I've found interesting issue with file_check_directory() in Drupal. It generates errors like:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /.../public_html/includes/module.inc on line 245
With back trace like:
30.06424656960 file_check_directory( )../mycustom-script.php:90
40.06434657840 t( )../file.inc:114
50.06434659648 theme( )../common.inc:972
60.06434660552 init_theme( )../theme.inc:619
70.06624884760 _init_theme( )../theme.inc:71
80.06654901784 call_user_func ( )../theme.inc:172
90.06654902024 phptemplate_init( )../theme.inc:172
100.06674928608 include_once( 'sites/all/themes/zen/template.php' )../phptemplate.engine:14
110.06674928688 theme_get_setting( )../template.php:15
120.06674929200 theme_get_settings( )../theme.inc:1021
130.06674932440 module_exists( )../theme.inc:981
140.06674932880 array_key_exists ( )../module.inc:245
I'm not sure if this should be reported as a bug for Drupal guys and still do not have a time for experiments and to reproduce it on fresh Drupal installation.
Anyway want to note that I was using the lowest possibly Drupal bootstrap level:
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
Issue occurs due to message displayed by file_check_directory() function after new directory was created. Message becomes localized with t() function and then themed - which starts theme initialization that results in reading modules related information. As on DRUPAL_BOOTSTRAP_DATABASE level no modules are loaded - uninitialized variable is passed to foreach() loop and then array_key_exists function resulting in such a issue.
IMHO it would be better to avoid displaying any output in filesystem related functions.
But to avoid any core hacks - my quick and dirty workaround for this issue was to rise the bootstrap level and load modules right before using the file_check_directory() function, like:
// trying to bootstrap modules in order to resolve issue with
// "file_check_directory()" producing errors when modules are not loaded
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// So we are ready to work with our directories
$path = file_directory_path();
file_check_directory($path, FILE_CREATE_DIRECTORY);
file_check_directory($path . "/test1", FILE_CREATE_DIRECTORY);
file_check_directory($path . "/test2", FILE_CREATE_DIRECTORY);
file_check_directory($path . "/test3", FILE_CREATE_DIRECTORY);
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /.../public_html/includes/module.inc on line 245
With back trace like:
30.06424656960 file_check_directory( )../mycustom-script.php:90
40.06434657840 t( )../file.inc:114
50.06434659648 theme( )../common.inc:972
60.06434660552 init_theme( )../theme.inc:619
70.06624884760 _init_theme( )../theme.inc:71
80.06654901784 call_user_func ( )../theme.inc:172
90.06654902024 phptemplate_init( )../theme.inc:172
100.06674928608 include_once( 'sites/all/themes/zen/template.php' )../phptemplate.engine:14
110.06674928688 theme_get_setting( )../template.php:15
120.06674929200 theme_get_settings( )../theme.inc:1021
130.06674932440 module_exists( )../theme.inc:981
140.06674932880 array_key_exists ( )../module.inc:245
I'm not sure if this should be reported as a bug for Drupal guys and still do not have a time for experiments and to reproduce it on fresh Drupal installation.
Anyway want to note that I was using the lowest possibly Drupal bootstrap level:
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
Issue occurs due to message displayed by file_check_directory() function after new directory was created. Message becomes localized with t() function and then themed - which starts theme initialization that results in reading modules related information. As on DRUPAL_BOOTSTRAP_DATABASE level no modules are loaded - uninitialized variable is passed to foreach() loop and then array_key_exists function resulting in such a issue.
IMHO it would be better to avoid displaying any output in filesystem related functions.
But to avoid any core hacks - my quick and dirty workaround for this issue was to rise the bootstrap level and load modules right before using the file_check_directory() function, like:
// trying to bootstrap modules in order to resolve issue with
// "file_check_directory()" producing errors when modules are not loaded
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// So we are ready to work with our directories
$path = file_directory_path();
file_check_directory($path, FILE_CREATE_DIRECTORY);
file_check_directory($path . "/test1", FILE_CREATE_DIRECTORY);
file_check_directory($path . "/test2", FILE_CREATE_DIRECTORY);
file_check_directory($path . "/test3", FILE_CREATE_DIRECTORY);
I have been intelligent for hours and I haven't gone through such awesome stuff.
ReplyDeleteWeb Development
our Drupal professionals are popular for creating Drupal programs in relatively fast develop time and also for its powerful characteristics of the sites developed on this structure. DCKAP’s Drupal Developers now work from the new completely outfitted growth middle and also on customer website as needed.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIs Drupal better from Joomla for big news site?
ReplyDeleteWeb developer blog
Well Elpak, my personal preference is Joomla. I've used Drupal and found Joomla to be straight forward. I've heard from other web designers that Drupal is better for clients.
ReplyDeleteHire an ASP.NET Developer
Several Abu Dhabi Website Design use whitespace as their design tool to direct users' attention towards the main content.
ReplyDeleteExceptional post I enjoy the article; appreciate and the choice of explained as much as possible, what you are doing a terrific task lots of other people just like you by means of in which form of educational websites offer understanding to us all linked to many points. My partner and i read various other exciting sites through your websites in addition to I'm so much interested using your blogs abilities, We additionally started to generate document and this also variety talk truly help myself out there. My partner and i witout a doubt book-marked the site as well as shared your internet websites to our acquaintances not simply me personally nevertheless these just like your current blogging and site-building skills, hope people compose a lot more fascinating weblogs this way just one in addition to enjoy on your long term blogs.
ReplyDeleteJimmy Wilson-N7 Leather Jacket Mass Effect
Drupal is an open source also provide source for host developers as well as offering documents. With help of opensource codes we easily solve the problems or errors. There are millions of websites running by drupal platforms.
ReplyDeleteProfessional Website Design Company Bangalore
This is a nice article..Its very easy to understand ..And this article is using to learn something about it..
ReplyDeleteby MGT 521 Week 1 provider
Choosing a Content Management System is extremely important I advocate Drupal. Because Seeing that the top Ivy League schools use Durpal, I picked them For Drupal hosting I build on Pantheon with core updates on the dashboard What platform is your favorite?
ReplyDeleteDrupal Git
It was very well authored and very simple to understand. Unlike additional blogs..
ReplyDeleteby LAW 421 Entire Course provider
Drupal Vs Wodpress which is best for Home Design blog?
ReplyDeleteStandard vacationers call for discounts and other cheap small business routes. The reason being they will journey over a day-to-day foundation. Several air routes firms contemplate these vacationers although many do not.discount travel
ReplyDeleteThank You! Very useful tip that I've been looking to implement for days.
ReplyDeleteIt is also useful to know that you overwrite results in the tips info field (step 2 in your tutorial) and add in whatever text. You can also add in any fields above that tip field (i.e. [date]).
One thing I have not yet been able to do is add any html tags into the rewrite of tips field. The caption bubble just shows the html as raw data along with the text.
I actually had to check the strip the HTML tags box in order to get only text of my date field. However, I'm trying to figure out a way to include the HTML possibly to make it clickable. Not sure if this will be possible
drupal
world-wide-web design negotiations by the location associated with designing a great site AS WELL AS on the long operate updating ALONG WITH maintaining. with the online world boom, every company wants to obtain a great on the web footprint IN ADDITION TO a great internet site can be Tips on how to showcase one's skills IN ADDITION TO company ALONG WITH kindle ones curiosity associated with potential customers.
ReplyDeleteCMS for web designers
Informative blog.My partner and i read various other exciting sites through your websites in addition to I'm so much interested using your blogs abilities, We additionally started to generate document and this also variety talk truly help myself out there.One thing I have not yet been able to do is add any html tags into the rewrite of tips field.
ReplyDeletevisit us
Ways & Works Consulting is an ISO 9001:2015 certified HR Consulting Firm, Manpower Recruitment and Practical Training firm career with an aim to provide value aided service to employersTop Manpower Recruitement company in india . with an in-depth understanding of their requirements. We are working as a perfect bridge between the employer and employee to fulfil their needs by placing the best suitable at place.
ReplyDelete