Introduction
This module is meant for individual field data manipulation from commandline to add, delete or modify values in fields. It uses Drush commandline interface. Aim is to be able add, delete, modify and list data in all core field types and most contributed field types.
I'm not aware of any similar projects.
I have 20 years of programming experience and 5 year with Drupal and have one active community site. I have built dozens Drupal sites and dozens modules for my own use.
Examples:
Add a file to a file field:
drush fields-file-add node 1 field_myfilefield --file=/tmp/icon-flag.pdf
Delete an element from file field:
drush fields-file-del node 1 field_myfilefield 1
Project page:
https://drupal.org/sandbox/ragnarkurm/2274189
Direct git repository:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/ragnarkurm/2274189.git drush_fields
cd drush_fields
PAReview
http://pareview.sh/pareview/httpgitdrupalorgsandboxragnarkurm2274189git
Note that it gives false positives Variable $xxx is undefined. since it cannot understand extract().
Reviews of other projects
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | pareview_results.txt | 13.61 KB | mpdonadio |
Comments
Comment #1
ragnarkurm commentedComment #2
ragnarkurm commentedComment #3
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #4
ragnarkurm commentedComment #5
dbcollies commentedIn the files in drush/fields, I believe that you should be wrapping the argument help text in calls to dt().
Otherwise, looks really good to me.
Comment #6
ragnarkurm commentedBelief or fact?
Can you be more specific, where?
If you mean content of extensions of
hook_drush_command(), namelydrush_fields_file_cmd()anddrush_fields_node_title_cmd()then it has to be untranslated. You can check from drush installation that drush itself hashook_drupal_command()untranslated. For example in:drush/commands/core/archive.drush.inc. If you have any source to quote or reference for translatinghook_drush_command()then it would be helpful.The reason is that drush caches command info and if it caches translated stuff and then drush command results gets funny (mixed language). Sometimes when you install a module and all its strings get into database in translated form and later no matter what, you cannot get admin interface into English anymore.
If there is any other string you see untranslated, then please point out. As I live in non-English environment I always write translatable code. So I have been quite careful making all possible strings translatable. The only exception in this code is
hook_drush_command()extension functions.So currently there is nothing to do about the translations.
Comment #7
mpdonadioFor reference, total disregard for using t() and dt() is a blocking issue (falls under the Major API issue category). A few missing strings when good faith has been made to catch them should be pointed out, but does not warrant going back to Needs Work.
Comment #8
dbcollies commentedGiven the followup comments, I rescind my earlier objection, and, rather than pushing this to the bottom of the queue for my mistake, I'll go ahead and mark it as RTBC.
Comment #9
ragnarkurm commentedComment #10
mpdonadioUpdated git link to public one.
Comment #11
mpdonadioIf that fails for whatever reason please get back to us and set this back to "needs review".
Comment #12
ragnarkurm commentedThank you for refering Drush Entity project, which went unnoticed for me.
My project is not duplication, but it is closely related.
Drupal Entity is around reporting Entity metadata.
My project is around changing (and reading) specific field data.
Just for the record, here is project merge issue:
https://www.drupal.org/node/2290005
Comment #13
mpdonadioThis is currently Postponed, but here is my review.
Automated Review
There is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732
Review of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Fix the long lines. Unused variables seem to be accounted for via the comments before the extract().
Manual Review
(+) Get rid of the master branch from the repo.
README has private git link. Use the public one.
How would a module that implements a entity_metadata_wrapper() field go about making it compatible with this module?
The chown() / chmod() / chgrp() will require elevated permissions on the server, and have these been tested on Windows? May need to
document this behavior.
(+) In general, db_select() against the node table should have the node_access() tag. This is an interesting case. In a module, this
would be a security problem. With a drush command, you bypass just about all security. However, if you run
drush with the -u option (to get it to run as a user), you may end up in a weird situation where a hook_node_update() runs
on a node that the user doesn't really have access to. I would add the tag, and document some of the weirdness that may result
because of hooks / rules running as the user that drush is run as (which defaults to the anonymous user). Some of the same
general concerns pop up in drush_fields_target(). Maybe an explicit entity_access() instead? Maybe warn/prompt users in drush_fields_target()
when the drush user don't have update access to the entity?
I concur about the dt() usage in hook_drush_command entries. I am not seeing any in the code drush files.
Can't drush_fields_target() just use entity_load() instead of building up the load funciton name?
This is just a note to myself and other reviewers that drush_exit() got removed a while ago. However, I am not 100% certain
that calling exit() is appropriate. Double check this.
I think drush_fields_file_add() will need 'description' set on the file object for it to work properly with entity_metadata_wrapper() (I have had
problems with this in the past).
Comments about files also apply to images.
Not a huge fan of extract(), but I think you documented it well enough.
Will the file add work with remote files? Look into system_retrieve_file(), this may work with local files, too.
Seems to me that some refactoring could be used to share / simplify things, eg float / int / text share a lot in common, other than validaton.
You may want to look into whether using field_attach_update() is an option rather than a full blown save.
There is a way to package drush-only "modules". I am pretty sure you get rid of the .module file and the core= from the .info file.
Look at drush_extras to see how it works.
Do the file/image functions work when File Entity is enabled? I can't recall if entity_metadata_wrapper() behaves differenly when
they are.
I'm seeing escaped text when I do a 'drush fields-text-add'.
I think that these operations should be logged via watchdog(), as normal content updates are.
(+) I also think that these should propmt the user before updating, unless the -y option is present.
A couple of these are fairly big (the + ones), but I am not seeing any blocking issues (other than the duplication issue mentioned above).
If this gets committed to drush_entity, and other admins concur, I don't see a problem giving vetted access based on this code.
Whether or not this gets folded into drush_entity, I see this as a very useful addition to the module space. I have a lot of
one-off drush scr scripts for altering data, and this would simplify my life.
Comment #14
mpdonadioGrrr.
Comment #15
ragnarkurm commentedThank you for review!
Asking for help on removing master branch. I just get:
! [remote rejected] master (deletion of the current branch prohibited)EDIT: solved.
Comment #16
ragnarkurm commentedFixed first portion of things.
Need help doing it. See #15.
Long lines fixed.
extract() removed.
Fixed.
Didnt get it, can you rephrase?
Added relevant notices to drush commandline command and option descriptions.
Added permission checking and documented it.
Users 0 and 1 can do all operations for practical reasons.
Other users are checked properly against system access settings.
Done.
Removed all exit() functions. Drush commands actually return FALSE rather then exit().
Comment #17
ragnarkurm commentedDescription element and respective commandline argument added.
Can you be more specific?
Images use alt and title, file use description.
This is drush problem and I cannot do much about it, except bug report. You can verify by typing
drush cache-setand see what happens.Comment #18
ragnarkurm commentedGood idea! Feature request implemented. Files/Images can now be added by url directly.
Comment #19
ragnarkurm commentedDone.
Why? Only reason using it is to optimize for speed - if there are a lot changes. Currently the module works one entity change per execution. Also, field_attach_update() would prevent Rules and save hooks etc not to be run. If there is a use-case which needs field_attach_update() then it will b implemented.
Comment #20
mpdonadioThe field_attach_update() was just a suggestion to investigate. You are correct that a proper node_save() will invoke hooks so things like Rules run, which is best. I frequently run into situations where I need to do touchup on data (esp after a import) where I don't necessarily want the Rules to run.
Comment #21
ragnarkurm commentedDone.
Done.
Seems that drush-only modules download-only.
No manual/automated updating?
It works. File Entity adds to retrieved array ($wrapper->field_file->value()) only few additional (possibly autogenerated) elements. Otherwise the format and functionality seems to be same.
Done.
Done.
Fair enough. Added option to choose saving method. The field_attach_update() method involves entity cache clearing.
Now, all points in review are corrected.
Comment #22
helmo commentedOne quick remark:
You have a lot of create_function calls, about which the php.net documentation warns ...
Comment #23
clemens.tolboomI would opt for a duplicate project which is motivated below.
---
Drush core has a command set field
Drush Entity project has a command set entity. It can read entity type and CRUD on entities. It's update can filter on (list of) field(s).
As an example let's update node/53 only it's title (starts default editor)
Or even through STDIN
@ragnarkurm Sorry for the long delay :-/
I'll review the code through the sandbox issue queue.
I will update the project page https://www.drupal.org/project/drush_entity with these example.
Next process issue #2290005: Merge Drush Fields into Drush Entities?
Comment #24
mpdonadio@clemens.tolboom, I'm confused. Do you want to merge this into Drush Entities or do you think this should stay a separate project?
Comment #25
clemens.tolboom@mpdonadio sorry for the confusing text.
I think the project is a duplicate (Closed (duplicate)) of drush_entity only different in drush commands and arguments.
I've invited @ragnarkurm to join drush_entity per #2290005-5: Merge Drush Fields into Drush Entities?
Hope that helps.
Comment #26
ragnarkurm commentedClosing this application as duplicate.
Working towards merge with Drush Entity.
Comment #27
ragnarkurm commentedIs it possible to use this sandbox project to earn "Create Full Projects" permission?
Despite that is merged into Drupal Entity.
(Though the process is called Project Application, but should be titled as Status Application, hence the confusion).
I have learned all basic rules for creating a project and went through this months-long trial,
not sure if I would like to go through this barrier again or keep future developments to my own.
Comment #28
mpdonadioYes, we can do that. We just need to determine what the review will be against. Is the patch against Drupal Entity mostly standalone that we could evaluate that? Or, is the sandbox version essentially what got committed?
Comment #29
ragnarkurm commentedMy suggestion is to currently evaluate sandbox version.
There are two branches of code: sandbox and merge.
Sandbox version is constantly refined, polished, doc added, new features added, bugfixed etc. It is stable and consistent. As Drush Entity owner did code review in separate issue, it is not directly visible here. All points are answered / corrected.
I dont have any permissions in Drush Entity, I upload (possibly unstable) tarballs to merge issue. It is too early to evaluate anything there yet. Currently seems that merge is going to be slow process.
Comment #30
ragnarkurm commentedComment #31
klausiSince you don't have any other sandboxes to promote currently I think that we can wait until your changes to drush_entity land.
You should start to provide smaller patches against drush_entity so that it is easier for the maintainers to accept them. Once there is enough of your stuff in drush_entity let's review that and proceed here. I think it would be a waste of time to review the sandbox code now which will soon be obsolete. Thank you for your yonsideration and your contribution!
Comment #32
clemens.tolboomSo I guess I must work harder on drush_entity besides oter projects :-p
Comment #33
PA robot commentedClosing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #34
ragnarkurm commentedApparently the merge does not happen.
Lack of interest.
In Changes to the project application review process it is said:
So, is there anything else blocking?
Comment #35
ragnarkurm commentedComment #36
avpadernoThe user who is applying should not set the status to Reviewed & tested by the community.
Comment #37
ragnarkurm commentedSorry, I have probably missed or forgot something during years of the application, but the question still stands.
In Changes to the project application review process it is said:
So, is there anything else blocking?
Comment #38
avpadernoI will update your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thank you, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks go the dedicated reviewer(s) as well.