Two improvments to libraries.module:
1- install_profile variable default value in D7 is standard not default
2- Replacing the long costly way to look for dirs. It's better than the old one, so thought of sharing it, feedback?

Comments

good_man’s picture

StatusFileSize
new1.91 KB

missing to omit the trailing slash in the previous patch.

tstoeckler’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new1005 bytes

First of all: thanks very much for the effort.

The variable default is actually correct. The other part I'll have to look into more deeply.

Attached is a patch for the defaults thing. I will commit that in a minute.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

http://drupal.org/cvs?commit=464996

Marking needs work for the other change.
@good_man: Please note that your patch does not abide by the coding standards. Pure code-style review follows:

+++ libraries.module	12 Dec 2010 08:11:34 -0000
@@ -95,17 +95,15 @@ function libraries_get_libraries() {
-  $nomask = array('CVS');
...
+  $exclude = array('CVS');

Renaming $nomask to $exclude is unnecessary.

+++ libraries.module	12 Dec 2010 08:11:34 -0000
@@ -95,17 +95,15 @@ function libraries_get_libraries() {
-  foreach ($searchdir as $dir) {
...
+  foreach ($searchdir as $search) {

Renaming $dir to $search is unnecessary.

+++ libraries.module	12 Dec 2010 08:11:34 -0000
@@ -95,17 +95,15 @@ function libraries_get_libraries() {
+    // glob and GLOB_ONLYDIR is a better way to replace old opendir and is_dir ¶
+    // checking all the time and open a stream also won't list . and ..

Comment has trailing whitespace. Also it doesn't make much sense to put in a comment referencing code that *used to be there*.

+++ libraries.module	12 Dec 2010 08:11:34 -0000
@@ -95,17 +95,15 @@ function libraries_get_libraries() {
+	$directories[$dir_name] = $dir;

Don't use tabs. Use spaces instead.

Regarding the actual code:

I hadn't heard of glob() yet, but while the PHP Documentation generally makes it look like it would be better than open_dir() / close_dir(), what makes me wonder is that this code is basically a direct copy of Drupal 7's file_scan_directory() (http://api.drupal.org/api/drupal/includes--file.inc/function/file_scan_d...), and I cannot imagine that the team of core devs would neglect to use this function for no reason.

Powered by Dreditor.

tstoeckler’s picture

Status: Needs work » Fixed

Well, just searching on drupal.org for "glob()" (http://drupal.org/search/apachesolr_multisitesearch/glob%28%29), reveals that the following two lines from the PHP documentation make this a no-go for us:

Note: This function isn't available on some systems (e.g. old Sun OS).
Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris.

Thus, marking fixed, because this issue actually had a commit.

sun’s picture

yup, if glob() would be an option, then Drupal core would use it already.

good_man’s picture

I thought it's because it's some how a hidden function, that's why they maybe didn't notice that. Anyhow, I really don't know what's going on with the tabs issue on my kate editor! will have to take a second look at it's config. Re. variables renaming, I think it's not neccessary now as we are ignoring the whole new section.

Thanks guys, appreciate your time!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

The last submitted patch, improvements.patch, failed testing.