fixed a missing function: search_files_variable_get_directoryrescanage()

removed a var_dump() that someone left behind in admin for submit
fixed some references to $form_values instead of $form_state

Changed "double quote" to 'single quotes' in SQL

removed backticks in SQL

changed some mysql only sql to more generic sql that'll work anywhere.

added a form_validate() function to catch attempts to add the same directory twice instead of hitting against the unique keys.

change $type in watchdog calls to be under the 16 char limit in the database schema.

Comments

cafuego’s picture

$_SERVER['DOCUMENT_ROOT'] is not reliable. For instance on Apache with mod_vhost it generally defaults to /htdocs - which is definitely not where my Drupals live.

Something like this is a workaround to find the drupal base install dirrectory on such a setup:

$docroot = substr(dirname(__FILE__), 0, -1 * (1+strlen(drupal_get_path('module', 'search_files'))));
Shiny’s picture

The line is not new in this patch . Perhaps a new issue can be raised to address that.

Shiny’s picture

StatusFileSize
new22.79 KB

rerolled patch with out whitespace changes

cafuego’s picture

Well, I don't actually use the module; just looked at the patch after you twattered and noticed it there :-)

I think maybe it'd be nice to have it available in core, I'll have a look.

Shiny’s picture

twatter? That was identi.ca!
review my patch already Cafuego.

cafuego’s picture

Status: Needs review » Reviewed & tested by the community

Doesn't break MySQL and the patched module works OK :-)

thl’s picture

Assigned: Unassigned » thl

- Undefined variable: output
fix imported from http://drupal.org/files/issues/search_files.pgsql__1.patch file search_files.module hunk at line 71
for releases past 6.x-1.6, see search_files.module revision 1.32
for releases past 6.x-2.0beta2, see search_files.module revision 1.19.2.10
Fixed.

thl’s picture

thl’s picture

- watchdog calls hitting 16 char limit
fix taken from Shiny's patch.
for releases past 6.x-2.0beta4, see search_files_directories.module revision 1.1.2.17
Fixed.

thl’s picture

- change "double quote" to 'single quotes' in SQL
has been fixed as part of commit: name space and visible text cleanup: SQL statement unification, WHERE argument bracketing, natural SQL statements using terminating semicolon and single quotes for strings, no quotes for numbers, leaving double quotes for the whole statement; cosmetics with spaces, indentation and case, put small statements in a single line, fold large statements across multiple lines; fix typos; use appropriate database table and row quoting; no functional changes., see

search_files.module revision 1.19.2.8
search_files_attachments.install revision 1.1.2.3

Fixed.

thl’s picture

- stray var_dump()
cleaned in search_files_directories.module revision 1.1.2.11
Fixed.

thl’s picture

- removed backticks in SQL
When I started contributing to the module, I found backticks around certain field names in SQL queries. Thought this is something "Drupalish" similar to the curly brackets around table names and started to consequently use them everywhere. I was wrong! This is MySQL specific stuff, see

MySQL 5.0 Reference Manual :: 8 Language Structure :: 8.2 Schema Object Names
... If an identifier contains special characters or is a reserved word, you must quote it ... The identifier quote character is the backtick ...

Pronto Forum » General Discussion » PostgreSQL support
... Is there any special case where mysql really need the backticks? ... The reason for backticks is only when using a reserved word as a column name. For example, if you have a column named "type", you have to escape it with backticks or it will result in an error.

The search_files modules use the {search_dataset} table from the "search" module and, hell, that table contains exactly a column named `type`. This fact made me hesitant removing the backticks everywhere.


Dokeos Coding conventions, Use of backticks

... Backticks are a very bad MySQL-only habit. Don't use backticks at all ...

Drupal Home » Download » Modules » Coder » Issues "Back ticks in SQL code"
... If you decide that we should be checking for non-ANSI compliant SQL, then the attached patch should help check for back tick usage in SQL statements. ...

Anyway, brave James removed them all :-)
search_files.install revision 1.10.2.10
search_files.module revision 1.19.2.16
search_files_attachments.install revision 1.1.2.8
search_files_attachments.module revision 1.1.2.19
search_files_directories.install revision 1.1.2.12
search_files_directories.module revision 1.1.2.18, revision 1.1.2.19, revision 1.1.2.22
Fixed.

jrglasgow’s picture

Search Files was my first attempt to write a contributed module, all previous coding was just for the company I was working for at the time, and we were strictly using MySQL, I had learned using the backticks around the identifiers when I learned MySQL.

It wasn't until I started working on more contributed modules that I discovered that backticks weren't standard ANSI SQL.

Anyway, you shouldn't use special characters in identifiers.

thl’s picture

- changed some mysql only sql to more generic sql that'll work anywhere.

see #559412: search_files compatibility with PostgreSQL
Fixed.

thl’s picture

- added a form_validate() function to catch attempts to add the same directory twice instead of hitting against the unique keys.

see
search_files.module revision 1.19.2.24
search_files_directories.module revision 1.1.2.32

Fixed.

thl’s picture

Status: Reviewed & tested by the community » Fixed
thl’s picture

Status: Fixed » Closed (fixed)
steveholby’s picture

Recover sql server databases thanks to programmed method I would recommend you next utility sql fix