All modules inside nodewords module should internally named like the base module. Otherwise the module may easily run in name conflicts with other modules. The rule is normally to name the module [modulename]_[submodulename] (like "xmlsitemap_node" - but not "basic_metatags". One exception I can think of may be "metatags_basic" if the base module is going to be moved to the new and better name "metatags" in future.

I'm not sure if this has been written yet into stone somewhere for the reason that it's known to be "best practice" and the only "save" way to make sure there is no name conflict. Please re-think the submodule names and better change - shouldn't be a big problem if the base module name is kept for the reason that it can be used in the upgrade process to change all stuff for now...

Comments

avpaderno’s picture

I have marked #595394: Module name conflict as duplicate of this report.

avpaderno’s picture

Status: Active » Postponed (maintainer needs more info)

I will change the modules name to the correct names; I will also add code to change the information contained in the database table used by Drupal.

Are there any further steps that need to be taken, to be sure the modules status is kept, after they are renamed?

hass’s picture

Hm - don't forget to rename all variables/functions and prefix them in the same way...

dave reid’s picture

Subscribing

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Active
avpaderno’s picture

Status: Active » Fixed

The last committed code changed the name of the modules, and this morning I removed the SQL query that was trying to update the module data contained in the system table.

hass’s picture

Why are you not fixing the system table and provide a working update path? I don't like re-enabling modules... we know all and update hooks will work as expected. If you are not changing the system table all update hooks in the submodules may become broken.

hass’s picture

Status: Fixed » Needs work

Translation files need to be moved and renamed.

avpaderno’s picture

Status: Needs work » Fixed

The translation templates, and the translation files need to be updated, as their content is not synchronized with the code developed until now; it's not just a question of file names.

That is a different issue, anyway.

hass’s picture

Status: Fixed » Needs work

#7?

avpaderno’s picture

Status: Needs work » Fixed

I have already tried that, but the code failed because Drupal was creating table rows for the new modules; that is why I dropped that code.

hass’s picture

Status: Fixed » Needs work

You mean the new modules rows exists inside the system table if the update is executed? It shouldn't be a problem - the most important information you need to carry over is the schema_ version, throttle and maybe the weight. Select this data from the old module names, update the new rows with the old data and than use http://api.drupal.org/api/function/module_enable/6 to enable the new modules - if the appropriate old one was active ({system}.status=1).

Leave the outdated entries in the system table... no problem at all. This make sure the upgrade works like a charm.

avpaderno’s picture

What I mean is that I implemented the code to update the existing rows in the table system (the first implementation contained a syntax error in the SQL query, so it didn't updated the data), but the update functions failed because a duplicate rows error.

The code should then update the information Drupal grabs from the file .info.

I will check about this part of the code, but at the actual state nothing is being lost.

hass’s picture

Nothing "lost" is not my point here. Users updating the modules do not expect the modules are going to be disabled. This may be solvable and should be solved. Duplicate row issues cannot happen if UPDATE is used.

avpaderno’s picture

Status: Needs work » Fixed

I can change the status of this report, as the code has been already changed.

hass’s picture

Title: Submodule names not prefixed with base module name » Upgrade path for new submodule names broken
Priority: Normal » Critical
Status: Fixed » Needs work

Upgrade path does not work at all. Tested from 1.2 to DEV.

1. All nodewords modules are enabled in 1.2
2. Run update.php gives you:

The following queries were executed
nodewords module
Update #6128

    * DELETE FROM {nodewords} WHERE type = 'offline'

Update #6129

    * UPDATE MENUS

Update #6130

    * CLEAR DRUPAL CACHE

Update #6131

    * DELETE FROM {variable} WHERE name IN ('nodewords', 'nodewords-repeat', 'nodewords-use_front')

Update #6133

    * No queries

No queries is already a clear statement here and proves the update have failed.

Listing SELECT * FROM system WHERE filename LIKE 'sites/all/modules/nodewords/%' ORDER BY weight shows that the new module names do not have the schema version, status and weight of the old modules. Old modules are marked as disabled, but the new modules are not active.

hass’s picture

Looks like the step from "update.php" to "update.php?op=info" kills the status=1... this is really bad... so no chance to upgrade cleanly... but schema_version and weight can and need to be upgraded. The update hook needs a drupal_set_message() to people re-enabling the submodules manually is required.

avpaderno’s picture

The update hook needs a drupal_set_message() to people re-enabling the submodules manually is required.

Which is what the code I before implemented did, but somebody (without to say exactly who is) suggested that it was the wrong method, and that he didn't want to manually enable the new module (I am still not saying who this person is).

To notice that nodewords.module has code to verify if there are any modules implementing meta tags, and in hook_requirements() it emits an error message if there are not such modules; schema version, and module weight are automatically set once the new modules have been enabled (the modules are really being installed, and there are no wonders such metadata are updated).

avpaderno’s picture

Status: Needs work » Fixed
hass’s picture

Status: Fixed » Needs work

Nevermind, I have never changed a module name myself for the reason that I know the naming rules.

If the submodules are installed "from scratch" there will never be any update hook in this submodule executed. Why are the upgrade hooks still in the code of the new modules?

nodewords_basic_update_6104() is not executed inside hook_install... not sure if this needs to be executed, but it may need to be or all this stuff is never changed. Not sure - but above still needs work.

avpaderno’s picture

I have never changed a module name myself for the reason that I know the naming rules.

I remember also that you were trying to pass plain text, not handled as HTML through check_plain(). We are not talking of what you know, so let's move on that topic.

nodewords_basic_update_6104() is not executed inside hook_install.

That is perfectly normal; as that is an update function, it doesn't need to be executed during installation phase.

hass’s picture

That is perfectly normal; as that is an update function, it doesn't need to be executed during installation phase.

So on - this obsolete code needs to be removed. Maybe there is more code in the other modules. Aside DELETING something from tables is DATA LOSS if there is no upgrade path.

@db_query("DELETE FROM $table WHERE type = 'robots'");

avpaderno’s picture

So on - this obsolete code needs to be removed.

See what reported in http://api.drupal.org/api/function/hook_update_N/6:

A good rule of thumb is to remove updates older than two major releases of Drupal.

hass’s picture

You are mixing things up! This rule is for a clean upgrade path that should work for 2 major *Drupal* versions. It's not for a "new" module that do not have a history as the name "nodewords_basic" was never ever used before.

avpaderno’s picture

Title: Upgrade path for new submodule names broken » Upgrade path for new submodule names is broken
hass’s picture

For the reason that the system.status column is killed... how about guessing if a submodule was used in past? For example lookup the nodewords tables and settings if there are tags that needs a specific submodule. Than enable all submodules that manage the tags found in the database... what do you think?

avpaderno’s picture

That makes sense.
The code would call module_enable() for all the modules that handle the meta tags found in the database; the function would enable only the modules that are not already enabled, and that would help in simplifying the code, which doesn't need to verify if the module is already enabled, or not.
It could be possible to do it only for the modules of the Nodewords project, but that would be enough.

I am just wondering if it would work; if we cannot rely on the field status, how can we rely on code that checks the value of that field?

avpaderno’s picture

Status: Needs work » Postponed (maintainer needs more info)
hass’s picture

I thought you have implemented some basic meta tags with the nodewords_basic module. So if this tags are inside nodewords table, enable nodewords_basic - that's all!? This logic will not rely on system table...

avpaderno’s picture

This logic will not rely on system table

As the module enables a module, it needs to call module_enable(), which in turn checks the table system.

function module_enable($module_list) {
  $invoke_modules = array();
  foreach ($module_list as $module) {
    $existing = db_fetch_object(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s'", 'module', $module));
    if ($existing->status == 0) {
      module_load_install($module);
      db_query("UPDATE {system} SET status = %d, throttle = %d WHERE type = '%s' AND name = '%s'", 1, 0, 'module', $module);
      drupal_load('module', $module);
      $invoke_modules[] = $module;
    }
  }
  // ...
}

If you are suggesting that the code should not call module_enable(), and not use the table system too, then I don't know how that can be accomplished.

hass’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.44 KB

Patch attached, needs review and testing.

avpaderno’s picture

I will test the code by installing nodewords 6.x-1.0, and updating it to 6.x-1.x-dev.
The code to test doesn't change the content of any tables used from the module, so it would be easy to be checked.

hass’s picture

You need to update from 1.2 to DEV... the submodules haven't existed before.

Upgrading from 1.0 to DEV will bring you into in an endless loop in update.php, see http://drupal.org/node/588990#comment-2133608

avpaderno’s picture

I have tested the update from 6.x-1.0, and I have not seen any problem, probably because the test site I used didn't have a lot of nodes with meta tags (but then, I tested it after I removed the update functions that were used for intra-development updates -- see the latest commits).

I will try both the updates.

avpaderno’s picture

I have tested the proposed code, but it doesn't work.
The update function finds the meta tags, and enables the modules; when I visit the modules page, the modules that handle those meta tags are still disabled.

avpaderno’s picture

The code correctly detects the meta tags, and enables the correct module; the problem it's another one.

I would set the report as fixed; so far, we have tried different solutions, but none of them works. It would have been better if the modules had the correct name from the beginning; in this way, there would not be any worries to find a way to automatically enable those modules that handle the currently saved meta tags.

hass’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.48 KB

* Damn* - module_enable() expects an array... now it works.

hass’s picture

Re #34 - nodewords table is wiped on update from 1.0, but the endless loop is gone.

avpaderno’s picture

I thought I passed an array to module_enable(), but I could be wrong.

If I don't have time in the next 30 minutes to commit the code, then I will commit it when I return from a short trip (that means on Monday).

dave reid’s picture

Looking forward to the next official release with this. I'm still getting support requests for site_verify.module wondering why the interface isn't showing up when they've in face only enabled the Meta tags 'Site verification' module. Arg.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

The code has been changed, and committed in CVS.

hass’s picture

Status: Fixed » Needs work

Code has been made unperformant. Do a COUNT(1) only - or this statement returns a result set of many hundred thousands of entries.

foreach ($tags as $module => $module_tags) {
635 	     db_drop_table($ret, 'cache_nodewords'); 	     $bool = (
636 	  	       db_result(
637 	  	         db_query(
638 	  	           "SELECT 1 FROM {nodewords} WHERE name IN (" . db_placeholders($module_tags, 'varchar') . ")",
639 	  	           $module_tags
640 	  	         )
641 	  	       )
642 	  	     );

You have issued a API call and the update should tell the users the module has been enabled. Don't show them SQL statements. Show them the message as I've done it, please.

UPDATE {system} SET status = 1 WHERE type = 'module' AND name = '$module'"
dave reid’s picture

If you're going to do a SELECT 1 query, make sure you use db_result(db_query_range("SELECT 1 FROM ...", $module_tags 0, 1));

avpaderno’s picture

Status: Needs work » Fixed

If you're going to do a SELECT 1 query, make sure you use db_result(db_query_range("SELECT 1 FROM ...", $module_tags 0, 1));

That is right; differently the query is going to return a row for each meta tag found, which could be a lot of rows.
I have already changed the query to use COUNT(1), which surely returns a single row.

I am not going to change the string used as query from the update function because it is supposed to be a SQL string; I prefer to use a SQL query, or a pseudo SQL query.

Status: Fixed » Closed (fixed)

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

ClearXS’s picture

Component: Code » Documentation
Priority: Critical » Normal
Status: Closed (fixed) » Needs review

Hi, I have site_verify module and after installing the most recent dev nodewords (first time, but I see now its dangerous on future updating), this gave a conflict:

Site verification meta tags Disable one of the modules in modules pageArray
You have enabled two modules with similar purpose: site_verify.module and nodewords_verification_tags.module.

This problem was not there and site_verification existed first, before this conflicting feature was incorporated into the nodewords module:
http://drupal.org/node/607744

So resolving this; in .../admin/build/modules ticking off the:
Site verification meta tags 6.x-1.x-dev
Define site verification meta tags required by some web sites (mainly from search engines) to verify a web site. Depends on: Nodewords (enabled)

I suppose this is the favorite way of doing so? Anyway: I just made this change. And site_verification is better than this feature under nodewords? Are there motives for getting rid of site_verification and use nodewords_verification? When and when not?

Then this explanation about the conflict and what to do lacks on the modules page of both modules (what gave reason why I had to research it through 3 different issues and posted this)

Then the naming is pretty confusing; in my modules list of .../admin/build/modules it is not grouped under the modules name Node Words, but under Meta tags. OK, I´m getting pretty experienced in finding submodules in a haystack (over 200 real modules installed), but fear this might be a problem to instruct other people in future who have to run these systems I'm building, about how to find a 'hidden' submodule.

P.S.: I'm sorry; changing the overall status; maybe change it back after reviewing, so this issue keeps archived correctly under the proper/old issue?

avpaderno’s picture

Component: Documentation » Code
Status: Needs review » Closed (fixed)

The module nodewords_verification_tags.module is enabled only if you already set verification meta tags through Nodewords, which is not something I would have suggested to do, if you had already a module to handle such meta tags. If you prefer to use the other module that is fine, but you should disable nodewords_verification_tags.module in that case.

All Nodewords modules are listed under the category Meta tags, without any exception.

The name of the project was not the best choice, but the module names cannot be changed without to cause more confusion; the name of the directory containing the project files cannot be modified, and looking for a module called metatags.module inside a directory nodewords is not something that would make many users happy.

The topic of this issue is the upgrade path for new submodule names, which was already fixed. Reopening this issue could make somebody think that the issue has not been resolved, which is not true.

avpaderno’s picture

Priority: Normal » Critical

I am restoring the original priority.