Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/12786] Extend profilefield_base_migration.php class #2675

Merged
merged 10 commits into from Jul 9, 2014

Conversation

Projects
None yet
2 participants
@satanasov
Copy link
Contributor

commented Jun 29, 2014

If extensions authors will use profilefield_base_migration.php class as base class for creation of CPFs, the class need to be extended a bit.

At the moment there are two issues with it:

  • It does not create entries for PROFILE_FIELDS_LANG_TABLE (as it can't know what fields to create).
  • The migration is not "cleaning" the DBMS after purging the extension and leaves everything except the CPF column.

satanasov added some commits Jun 29, 2014

[ticket/12786] Extend profilefield_base_migration.php class
If extensions authors will use profilefield_base_migration.php
class as base class for creation of CPFs, the class need to be
extended a bit.

At the moment there are two issues with it:

It does not create entries for PROFILE_FIELDS_LANG_TABLE
(as it can't know what fields to create).

The migration is not "cleaning" the DBMS after purging
the extension and leaves everything except the CPF column.

Adding profilefield_language_data

PHPBB3-12786
[ticket/12786] Add get_custom_field_id
Adding function to get CPFs ID

PHPBB3-12786
[ticket/12786] Add create_language_entries
Add function to create entries in PROFILE_FIELDS_LANG_TABLE

PHPBB3-12786
[ticket/12786] White spaces found
Removed some white spaces

PHPBB3-12786
[ticket/12786] Add clean_cpf_db_entries
Add function to clean the cpf fields entries

PHPBB3-12786
@@ -21,6 +21,22 @@
protected $profilefield_data;
/*Language data should be in array -> each language_data in seaprte key

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor
/**
* Language ...

This comment has been minimized.

Copy link
@satanasov

satanasov Jun 29, 2014

Author Contributor

Done

* function should be called from migration
* using revert_data()
*/
public function clean_cpf_db_entries()

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

*delete
Do not use cpf

This comment has been minimized.

Copy link
@satanasov

satanasov Jun 29, 2014

Author Contributor

Done

$sql = 'DELETE FROM ' . PROFILE_FIELDS_TABLE . ' WHERE field_id = ' . $field_id;
$this->db->sql_query($sql);

//2. PPROFILE_LANG_TABLE

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

comments are unnecessary like this.
Either say in a full sentence what its about, or remove the comment

*/
public function get_custom_profile_field_id()
{
$sql = 'SELECT field_id FROM ' . PROFILE_FIELDS_TABLE . ' WHERE field_name = \'' . $this->profilefield_name . '\'';

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

multiple lines

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

use " for the outer quotes, so you dont have to escape them

This comment has been minimized.

Copy link
@satanasov

satanasov Jun 29, 2014

Author Contributor

Done with "

{
$sql = 'SELECT field_id FROM ' . PROFILE_FIELDS_TABLE . ' WHERE field_name = \'' . $this->profilefield_name . '\'';
$result = $this->db->sql_query($sql);
$field_id = (int) $this->db->sql_fetchfield('field_id');

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

missing ->sql_freeresult($result)

This comment has been minimized.

Copy link
@satanasov

satanasov Jun 29, 2014

Author Contributor

done

@@ -21,6 +21,23 @@
protected $profilefield_data;
/**
*Language data should be in array -> each language_data in seaprte key

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

space after *
typo in seaprte

[ticket/12786] Dixing a typo
Typos fixed

PHPBB3-12786
}

/**
* Clean db after purging of extension

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

Clean database when reverting the migration

*/
public function get_custom_profile_field_id()
{
$sql = "SELECT field_id

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jun 29, 2014

Contributor

Single quotes on the first part

'lang_id' => $lang_id,
'option_id' => $language_data['option_id'],
'field_type' => $language_data['field_type'],
'lang_value' => $language_data['lang_value'],

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 3, 2014

Contributor
                $insert_buffer->insert(array_merge(array(
                    'field_id'  => $field_id,
                    'lang_id'   => $lang_id,
                ), $language_data));

instead?

[ticket/12786] Some changes of the comments.
Comments and quotes

PHPBB3-12786

[ticket/12786]

PHPBB3-12786

Revert "[ticket/12786]"

This reverts commit 61a6647101731110f67689b109de953f7449b03e.
@satanasov

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2014

Don't mind the last commit ... just an error.

[ticket/12786] Array_merge instead copy array parts
nickvergessen proposed this

PHPBB3-12786
$field_id = $this->get_custom_profile_field_id();

$sql = 'DELETE FROM ' . PROFILE_FIELDS_TABLE . '
WHERE field_id = ' . $field_id;

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab

$this->db->sql_query($sql);

$sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . '
WHERE field_id = ' . $field_id;

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab

$this->db->sql_query($sql);

$sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . '
WHERE field_id = ' . $field_id;

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab

public function get_custom_profile_field_id()
{
$sql = 'SELECT field_id
FROM ' . PROFILE_FIELDS_TABLE . "

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab

{
$sql = 'SELECT field_id
FROM ' . PROFILE_FIELDS_TABLE . "
WHERE field_name = '" . $this->profilefield_name . "'";

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab

$insert_buffer->insert(array_merge(array(
'field_id' => $field_id,
'lang_id' => $lang_id,
), $language_data));

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab

* 'field_type' => value,
* 'lang_value' => value,
* ),
* )

This comment has been minimized.

Copy link
@nickvergessen

nickvergessen Jul 8, 2014

Contributor

-1 tab for all rows after the *

[ticket/12786] Correcting some tabs
Some tabs needed corection

PHPBB3-12786

nickvergessen added a commit to nickvergessen/phpbb that referenced this pull request Jul 9, 2014

Merge pull request phpbb#2675 from lucifer4o/ticket/12786
[ticket/12786] Extend profilefield_base_migration.php class

* lucifer4o/ticket/12786:
  [ticket/12786] Correcting some tabs
  [ticket/12786] Array_merge instead copy array parts
  [ticket/12786] Some changes of the comments.
  [ticket/12786] Dixing a typo
  [ticket/12786] Some minor fixes of comments and function naming
  [ticket/12786] Add clean_cpf_db_entries
  [ticket/12786] White spaces found
  [ticket/12786] Add create_language_entries
  [ticket/12786] Add get_custom_field_id
  [ticket/12786] Extend profilefield_base_migration.php class

@nickvergessen nickvergessen merged commit c468a5d into phpbb:develop-ascraeus Jul 9, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

nickvergessen added a commit that referenced this pull request Jul 9, 2014

Merge pull request #2675 from lucifer4o/ticket/12786
[ticket/12786] Extend profilefield_base_migration.php class

* lucifer4o/ticket/12786:
  [ticket/12786] Correcting some tabs
  [ticket/12786] Array_merge instead copy array parts
  [ticket/12786] Some changes of the comments.
  [ticket/12786] Dixing a typo
  [ticket/12786] Some minor fixes of comments and function naming
  [ticket/12786] Add clean_cpf_db_entries
  [ticket/12786] White spaces found
  [ticket/12786] Add create_language_entries
  [ticket/12786] Add get_custom_field_id
  [ticket/12786] Extend profilefield_base_migration.php class

@satanasov satanasov deleted the satanasov:ticket/12786 branch Jul 9, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.