User can select a node type and its filefield containing gpx data, and the module renames the waypoints in it to YYYY-MM-DD-number format.

Project page:

https://drupal.org/project/2163381/

Git repository:

https://drupal.org/project/2163381/git-instructions
Use: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/balagan/2163381.git gpx_rename

Code review: http://pareview.sh/pareview/httpgitdrupalorgsandboxbalagan2163381git

Added a sample gpx file (with .txt extension) for testing purposes.

Reviews of other projects

https://www.drupal.org/node/2335827#comment-9142631
https://www.drupal.org/node/2333083#comment-9143373
https://www.drupal.org/node/2129127#comment-9316717

CommentFileSizeAuthor
teszt5.txt5.03 KBbalagan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PA robot’s picture

Status: Active » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxbalagan2163381git

We 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.

balagan’s picture

Status: Needs work » Needs review
keopx’s picture

Issue summary: View changes
Status: Needs review » Needs work

Hi,

You a have some error in your code and you need remove master branch.

Please see this link: http://pareview.sh/pareview/httpgitdrupalorgsandboxbalagan2163381git

balagan’s picture

Issue summary: View changes
Status: Needs work » Needs review
balagan’s picture

Issue summary: View changes
balagan’s picture

Issue summary: View changes
balagan’s picture

Issue summary: View changes

Thanks,
Yes, indeed, the master branch was still an older version. I have deleted that now, and renamed 7.x.1.x to 7.x-1.x.
Nevertheless the git instructions were for the correct, default branch. Now only 1 branch remains.

keopx’s picture

Status: Needs review » Needs work
balagan’s picture

Ok, thanks, I will take a look at these 2 warnings tonight.

balagan’s picture

Status: Needs work » Needs review

Broke long comment into two lines, and removed unnecessary unset in ajax form.

maris.abols’s picture

Status: Needs review » Reviewed & tested by the community

Code auto testing now seems fine.

I also installed module on fresh Drupal. Everything works as expected, but some short documentation is needed. Because only with third attempt I got waypoint names renamed. The right workflow that could be written in documentation:

1. Create file field for node.
2. Go to admin/config/gpx/gpx_rename and choose and save settings for this field.
3. Clear cache.
4. Create new node and upload test file.

balagan’s picture

Ahh, good idea, I was too busy with coding :)
Thanks for the advice.

balagan’s picture

Issue summary: View changes
balagan’s picture

Issue summary: View changes
balagan’s picture

Issue summary: View changes
keopx’s picture

Status: Reviewed & tested by the community » Needs work

Hi @balagan

You've some errors, please review this: http://pareview.sh/pareview/httpgitdrupalorgsandboxbalagan2163381git

balagan’s picture

Thanks for pointing out the errors, I have fixed them.

balagan’s picture

Status: Needs work » Needs review
er.pushpinderrana’s picture

Status: Needs review » Needs work

@balagan, thankyou for your contribution.

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. None.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and fragmentation. However GPX field module exist there but looks different from this one.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
(*) No: Follows the guidelines for in-project documentation and the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes. If "no", list security issues identified.
Coding style & Drupal API usage
  1. (*) gpx_rename_rename_gpx(): It producing following warnings and notices because of unorganized code in this function.
    Notice: Undefined variable: cmt in gpx_rename_rename_gpx() (line 96 of E:\xampp\htdocs\drupal730\sites\all\modules\2163381\gpx_rename.module).
    
    Warning: date_timestamp_get() expects parameter 1 to be DateTimeInterface, boolean given in gpx_rename_rename_gpx() (line 97 of E:\xampp\htdocs\drupal730\sites\all\modules\2163381\gpx_rename.module).
    
    Warning: date_timestamp_get() expects parameter 1 to be DateTimeInterface, boolean given in gpx_rename_rename_gpx() (line 97 of E:\xampp\htdocs\drupal730\sites\all\modules\2163381\gpx_rename.module).
    

    In this code, $cmt variable value is set that not declared outside this if condition and you are using this variable outside this if statement that completely break the logic of script.

    if (isset($wpt_item->getElementsByTagName('cmt')->item(0)->nodeValue)) {
                $cmt = $wpt_item->getElementsByTagName('cmt')->item(0)->nodeValue;
              }
              else {
                drupal_set_message(t('Time is not set in the cmt element of a waypoint'));
              }

    Similar thing applied for $o variable, also variable names not convincing, you should use some meaningful name otherwise it is difficult to understand like array_multisort($t, $n, $o);. You should go through https://www.drupal.org/node/299070 again. I am unsure how PAreview can skip these.

    Personally I would suggest, you should report drupal_set_message(t('Time is not set in the cmt element of a waypoint')); these message in Drupal logs instead directly printing on screen.

    Also you are checking for valid file (File is not a valid gpx file) at later stage after $doc = new DOMDocument('1.0'); that producing following warning, if invalid file uploaded there.

    Warning: DOMDocument::load(): I/O warning : failed to load external entity "public://test%20Commands%20Useful%20for%20drupal.docx" in gpx_rename_rename_gpx() (line 80 of E:\xampp\htdocs\drupal730\sites\all\modules\2163381\gpx_rename.module).

    You should check file type first and skip further process, if file format is invalid.

  2. date_create_from_format(): Why this function is required in your case, please add your comment on this, also read http://stackoverflow.com/questions/2621433/date-create-from-format-equiv... once.
  3. hook_help() is missing in your module.
  4. gpx_rename_install(): do not juggle with module weights as this is not reliable. Is it really required in your case, please add your comment on this.
  5. gpx_rename_menu(): The administration menu callback should probably use "administer site configuration" - which implies the user can change something - rather than "access administration pages" which is about viewing but not changing configurations. A separate permission would be good, too.
  6. (+) Instead of using date, better to use format_date().
  7. (+) gpx_rename_rename_batch(): You are using count($nids) 3 times in this function, can't you store count once and use that variable further, same for count($n) in gpx_rename_rename_gpx().
  8. (+) gpx_rename_add_field_form(): t() missing in at number of places like at line number 20 and 23 etc that need to be fix.
  9. (+) gpx_rename_add_field_form(): Wrong html tags in following code like <P> and </div etc.
    $form['gpx_rename_settings'] = array(
        '#prefix' => '<div id="gpx_rename_settings"><P><B>' . $message . '</b></p><P>',
        '#markup' => $string,
        '#suffix' => '</p></div',
      );
  10. Project Page: Extend this little bit more, better to go through https://www.drupal.org/node/997024 again.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

Nice to see, you are doing manual reviews, getting review bonus will help speed up review process for this application :)

Thanks again for your hard work.

balagan’s picture

Thanks for the review, my answers will follow shortly!

balagan’s picture

I have changed the README.txt.
1. Fixed those issues, but still printing errors on screen, I think it is better to inform the user straight ahead, than to let them search for the cause of errors.
2. date_create_from_format was very comfortable, I have got rid of it.
3. Added hook_help() to display the README.txt.
4. This module actually will be part of a bunch of modules. It's hooks has to run before all other modules, because they actually change the file, the other modules parse and use this file. There was already a short comment about it in code.
5. As far as I know, it was already fixed. Maybe just locally? I don't know how you see this, maybe you did not pull the newest commit, or I forgot to push it. Now it should be fine.
6. Ok, using format_date now.
7. Fixed this, thanks for pointing this out.
8. Added missing t() functions.
9. Changed HTML tags to lowercase. I hope that is the way to go.
10. Edited project page.

Really thanks for pointing me out my mistakes! Actually the variable naming caused me some headaches too, when after a while I tried to touch my code. You seem to have a good eye to catch errors! Thanks a lot!

balagan’s picture

Status: Needs work » Needs review
balagan’s picture

Priority: Normal » Critical
Issue summary: View changes
Issue tags: +PAreview: review bonus

Changed status, since the project application has been waiting over a month for review.

hawkeye.twolf’s picture

Status: Needs review » Needs work

Major issues

  • gpx_rename.admin.inc:34 Variable name should be gpx_rename_path not gpx_rename_settings.
  • When a filefield instance gets deleted, its entry in gpx_rename_settings variable does not get removed.
  • gpx_rename.module:238,355 Missing t() around message text "item processed."
  • Incorrect function signature for gpx_rename_form_field_ui_field_edit_form_alter(). It implements hook_form_FORM_ID() and therefore does not take the third $form_id parameter. This will cause PHP notices.

Minor issues

  • gpx_rename.module:117,169 These calls to drupal_set_message() should probably have "error" as the second parameter.
  • Missing space after lines gpx_rename.module:178,283
  • Missing @param (and some @return) documentation on gpx_rename_rename_gpx(), gpx_rename_get_nodes(), gpx_rename_rename_fields_batch(), and gpx_rename_rename_files_batch().
  • Incorrect docblock comment on gpx_rename_form_field_ui_field_edit_form_alter(). Should say, "Implements hook_form_FORMID_alter()."
  • Almost all functions have incorrect docblock comments; they must start with an active, present-tense third person verb. E.g., "Queries for and returns the nodes with filefields in the given bundle." instead of "EntityFieldQuery to return the nodes with filefields in the given bundle."
  • Fix HTML markup of "known issues" section on the project page: Move "Known problems and limitations" out of the list markup and create separate unordered list items for each known issue.
  • Consider creating an appropriate git repo tag. See What are alpha, beta releases and release candidates?.

Setting status to "needs work" only because the configuration page does not work correctly.

balagan’s picture

Thanks for the review Derek!
As for the hook_form_FORM_ID_alter(), according to the API its signature is right.
Nice catch with the instance deletion.
I hope to have fixed all issues (except git repo tag), and also added code to rename track names.

balagan’s picture

Status: Needs work » Needs review
klausi’s picture

Assigned: Unassigned » heddn
Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  1. gpx_rename_install(): as already said before: do not juggle with module weights, use hook_module_implements_alter() if you need to run before/after a specific hook implementation. Also the comment is confusing, what is gpx_parser? Is that a function or a hook implementation? The function does not exist in your module?
  2. gpx_rename_node_presave(): so this module only works for nodes? Then please add a comment to the README that it does not work for other entity types that might have GPX file fields. Why can't you implement some field level hook that would apply to any file field on any entity? hook_field_attach_presave() for example?

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to heddn as he might have time to take a final look at this.

balagan’s picture

I will follow your advice and make it work for entities in general.
gpx_parser is another module by me, and it has different submodules, one of it will be gpx_rename. Gpx rename works independently, so I choose this for project application for easier reviewing. I will check hook_module_implements_alter().
Thanks for reviewing.

heddn’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

Manual review:

  1. There are spelling errors in the README. i.e. rame, modul, etc.
  2. Known problems: might I suggest transliteration module? I'm not sure if it will resolve all the problems, but it supposed to fix those types of issues.
  3. (+) The hook_install still messes with module weights. Plus it defines variable values in variable_set(). Use hook_module_implements_alter() instead and provide default values in your variable_get() instead.
  4. (+) admin.inc: Don't use extra whitespace in t() calls. It makes translation difficult. The newline should disappear.
        '#description' => t('The path can be relative, for example public://gpx or it can be
        an absolute system path, for example f:\xampp\htdocs\drupal\sites\default\files\gpx'),
  5. hook_help: Instead of simply printing out the README.txt, I'd suggest using the suggestion @ https://www.drupal.org/node/161085 and convert the README to markdown format. It will make the formatting easier to read.
  6. hook_menu: If this module is the beggining of several modules, might I suggest a new permission is in order?
  7. A note about only supporting nodes is in order... but that feedback was already given.
  8. (*) The current implementation of this module uses a hard coded LANGUAGE_NONE. This means it won't work on any multi-lingual site. Either place a dependency on entity.module, or use field_language(), or somehow dynamically figure out the appropriate field language. I also see calls to $node->type to get the bundle. If you make this support all entities, then I would highly suggest you depend on entity. Most sites use it, so its not a huge change. And then you can can call getBundle(). See https://www.drupal.org/documentation/entity-metadata-wrappers.
  9. gpx_rename_form_field_ui_field_edit_form_alter: The "Implements" name should be FORM_ID, not FORMID. See https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...
  10. Are you sure you want to use field_read_field instead of field_info_field in gpx_rename_field_delete_instance()? The info function is more performant.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

klausi’s picture

Status: Needs work » Reviewed & tested by the community

I think that your only (*) item about field language does not warrant setting this back to needs work, since file fields are rarely translated this problem should not be a critical application blocker. Back to RTBC I guess?

heddn’s picture

Status: Reviewed & tested by the community » Fixed

RTBC again. I was able to confirm that file fields are almost always LANGUAGE_NONE, even when content translation is enabled. A pretty specific set configuration is required to make a file translatable. However, a note should be added into module documentation mentioning the i18n limitation.

And since that was the last blocker...

Thanks for your contribution, Nagy Zsolt!

I updated 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!

Thanks, 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 to the dedicated reviewer(s) as well.

balagan’s picture

Responding to heddn's notes in comment 29:
1. I could not find "rame" in the README file, but corrected "modul".
2. I will try that, my gpx parser module requires that anyway.
3. I am planning to do that.
4. Ok, I have fixed that. When I did this, I was just keeping the 80 character/row limit in mind. The coding standards say in general lines should not be longer than 80 chars. What is the best practice for long translatable strings?
5. Ok, I will look into that.
6. Ok.
7. Yes, I will try to implement general entity support.
8. I saw in other modules that it is quite common to use LANGUAGE_NONE. In my case I think it does not really make sense to have different gpx filefields for different langauges, so I would skip it if possible. I see you guys also agreed already.
9. You are right. I have fixed that.
10. + I will definitely change it then. I have copied it from the image module. The image module only uses it for the same purpose, is there a reason why they chose field_read_field()? Is it worth opening an issue?

Thank you all for your help and effort, I appreciate it!

heddn’s picture

#32.2: 80 characters applies to comments. Code itself can be longer than 80 characters. In general translatable strings should be logical chunks of data. Single words don't make sense, but neither does pages of text in one long t(). I tend to recommend a paragraph is the max length.
#32.8: Using entity module will resolve the issue as well.
#32.10: Depending on how that code is run, it might need an uncached copy of field info. I'm not sure in this case if it is necessary or not.

Status: Fixed » Closed (fixed)

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