User:Chris Key/Sandbox/MetadataFormCR: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Jess Key
No edit summary
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{AccountNotLive}}
==Integrating MetadataForm into refactoring work==
==Integrating MetadataForm into refactoring work==


One of the most important tickets in Bugzilla is the CZ refactoring work
<font color=green>One of the most important tickets in Bugzilla is the CZ refactoring work
(see http://reid.citizendium.org/bugzilla/show_bug.cgi?id=5). Recently,
(see http://reid.citizendium.org/bugzilla/show_bug.cgi?id=5). Recently,
I have been red-lined fighting fires, e.g., trying to get the servers
I have been red-lined fighting fires, e.g., trying to get the servers
Line 19: Line 20:
However, some of your instructions in the README and the text in
However, some of your instructions in the README and the text in
MetadataForm output if Metatdataform.php is executed stand-alone will
MetadataForm output if Metatdataform.php is executed stand-alone will
require modification.
require modification.</font>


: Code integrated into CZ extension by Dan. Modified the couple of places required to make this done. --[[User:Chris Key|Chris Key]] 19:05, 7 May 2010 (UTC)
: Code integrated into CZ extension by Dan. Modified the couple of places required to make this done. --[[User:Chris Key|Chris Key]] 19:05, 7 May 2010 (UTC)
Line 27: Line 28:
===General Comments===
===General Comments===


1. If you look at most of the code written for MW, much of the text is formated so
<font color=green>1. If you look at most of the code written for MW, much of the text is formated so
it fits into 72 columns. Many of your code files extend lines well
it fits into 72 columns. Many of your code files extend lines well
beyond this limit. This makes it hard to read when using some editors,
beyond this limit. This makes it hard to read when using some editors,
e.g., vim. I suggest you use linebreaks appropriately so it can be read
e.g., vim. I suggest you use linebreaks appropriately so it can be read
without the editor forcing a soft line wrap, making the text difficult to
without the editor forcing a soft line wrap, making the text difficult to
read.
read.</font>
: Done --[[User:Chris Key|Chris Key]] 19:04, 7 May 2010 (UTC)
: Done --[[User:Chris Key|Chris Key]] 19:04, 7 May 2010 (UTC)


2. I am not the techncial lead, but I feel strongly that when we add code, we need to
<font color=red>2. I am not the techncial lead, but I feel strongly that when we add code, we need to
provide some unit tests that can be integrated later into a CZ regression test suite.
provide some unit tests that can be integrated later into a CZ regression test suite.
There are a number of reasons for such tests. One is as we refactor the CZ code, we
There are a number of reasons for such tests. One is as we refactor the CZ code, we
Line 49: Line 50:


In any case, you should write the MetadataForm unit tests so they are adaptable to a
In any case, you should write the MetadataForm unit tests so they are adaptable to a
regression test harness.
regression test harness.</font>


===README===
===README===


Is there some reason to make $wgMetadataFormWorkgroups a global variable rather
<font color=green>Is there some reason to make $wgMetadataFormWorkgroups a global variable rather
a MetadataForm class attribute? Is there somewhere that this variable has to
a MetadataForm class attribute? Is there somewhere that this variable has to
be accessed other than in association with the MetadataForm class? If not, then
be accessed other than in association with the MetadataForm class? If not, then
Line 61: Line 62:
If so, we need to centralize its definition. Also, to improve readability, I suggest putting
If so, we need to centralize its definition. Also, to improve readability, I suggest putting
each value of the $wgMetadataFormWorkgroups array on a single line (perhaps prefixed by
each value of the $wgMetadataFormWorkgroups array on a single line (perhaps prefixed by
a tab to make the data stand out).
a tab to make the data stand out).</font>
 
: Renamed $wgCitizendiumWorkgroups, reformatted for readability, kept as global as agreed in reply. Done. --[[User:Chris Key|Chris Key]] 19:05, 7 May 2010 (UTC)


===MetadataForm.php===
===MetadataForm.php===


There is no MW standard text to echo in case an extension is executed
<font color=green>There is no MW standard text to echo in case an extension is executed
stand-alone. However, I suggest you prefix the text you have supplied
stand-alone. However, I suggest you prefix the text you have supplied
with a simple statement, such as, "This is the MetadataForm extension."
with a simple statement, such as, "This is the MetadataForm extension."</font>
 
: Done --[[User:Chris Key|Chris Key]] 19:06, 7 May 2010 (UTC)


===MetadataForm_body.php===
===MetadataForm_body.php===


1. You probably should use isLoggedIn() rather than isAllowed('edit') to
<font color=green>1. You probably should use isLoggedIn() rather than isAllowed('edit') to
determine whether the user is logged in.
determine whether the user is logged in.
:OK. But in that case you should change the error message to stipulate the
user doesn't have the edit right. Dan.</font>
:: Done. --[[User:Chris Key|Chris Key]] 19:09, 7 May 2010 (UTC)
<font color=red>: Also, you should put the text into the
internationalization messages file (there are a couple of other places where
you need to do that). Dan.</font>


2. Comment at line 33 "# POST is to create an article" probably should
<font color=green>2. Comment at line 33 "# POST is to create an article" probably should
be "# POST is to create metadata". Also, doesn't the extension support
be "# POST is to create metadata". Also, doesn't the extension support
editing existing metatdata? If so, then the comment should be "# POST is
editing existing metatdata? If so, then the comment should be "# POST is
to create or modify metadata".
to create or modify metadata".</font>
: Comment modified. Done --[[User:Chris Key|Chris Key]] 19:07, 7 May 2010 (UTC)
 


3. At line 80 you use the operator "and" rather than "&&". This is
<font color=green>3. At line 80 you use the operator "and" rather than "&&". This is
obviously for precedence purposes. Personally, I find the precedence
obviously for precedence purposes. Personally, I find the precedence
differences between 'and' and '&&' to be a source of confusing code. If
differences between 'and' and '&&' to be a source of confusing code. If
you must use it, you should format the expression so the 'and' stands
you must use it, you should format the expression so the 'and' stands
out where it is obvious that it is connecting two non-parenthesized
out where it is obvious that it is connecting two non-parenthesized
expressions (e.g., on a separate line of its own).
expressions (e.g., on a separate line of its own).</font>
: Changed to &&. Done --[[User:Chris Key|Chris Key]] 19:07, 7 May 2010 (UTC)


4. Line 232 - not sure why the comment:
<font color=green>4. Line 232 - not sure why the comment:


//$wgOut->addHTML("<form action='".$self->getLocalURL()."' method='POST'>");
//$wgOut->addHTML("<form action='".$self->getLocalURL()."' method='POST'>");


is here. Is this fossil code?
is here. Is this fossil code?</font>
: Deleted. Done. --[[User:Chris Key|Chris Key]] 19:07, 7 May 2010 (UTC)

Latest revision as of 02:35, 22 November 2023


The account of this former contributor was not re-activated after the server upgrade of March 2022.


Integrating MetadataForm into refactoring work

One of the most important tickets in Bugzilla is the CZ refactoring work (see http://reid.citizendium.org/bugzilla/show_bug.cgi?id=5). Recently, I have been red-lined fighting fires, e.g., trying to get the servers stable and working without crashes and severe congestion. However, late last week, I once again started working on this ticket.

The intention is most CZ modifications to MW would exist in a single extension, which for the sake of clarity I will call the Citizendium extension. Since MetadataForm is a modification specific to CZ, it should be integrated into the Citizendium extension. As we refactor functionality out of the main code into the Citizendium extension, we need a place to put it. Probably the best approach is to have an include directory in the Citizendium extension and add modifications there. In that case, we probably should put MetadataForm in that directoy and place a require_once(include/Metatdataform) in Citizendium.php. I think most of your code will work without modification using this strategy. However, some of your instructions in the README and the text in MetadataForm output if Metatdataform.php is executed stand-alone will require modification.

Code integrated into CZ extension by Dan. Modified the couple of places required to make this done. --Chris Key 19:05, 7 May 2010 (UTC)

Code review comments

General Comments

1. If you look at most of the code written for MW, much of the text is formated so it fits into 72 columns. Many of your code files extend lines well beyond this limit. This makes it hard to read when using some editors, e.g., vim. I suggest you use linebreaks appropriately so it can be read without the editor forcing a soft line wrap, making the text difficult to read.

Done --Chris Key 19:04, 7 May 2010 (UTC)

2. I am not the techncial lead, but I feel strongly that when we add code, we need to provide some unit tests that can be integrated later into a CZ regression test suite. There are a number of reasons for such tests. One is as we refactor the CZ code, we need to ensure existing factored code continues to work correctly. Another is when we update the MW base and merge the Citizendium extension into it, we need a way to test that the extension still works.

So, I think you need to write some unit tests that exercise the extension's functions. Right now we don't have a regression test harness. The limited regression testing that comes with the MW code base is almost exclusively focused on the parser. These are written using a customized test harness that might be adapted to testing the Citizendium extension. Alternatively, we might use something like PHPUnit (http://www.phpunit.de/).

In any case, you should write the MetadataForm unit tests so they are adaptable to a regression test harness.

README

Is there some reason to make $wgMetadataFormWorkgroups a global variable rather a MetadataForm class attribute? Is there somewhere that this variable has to be accessed other than in association with the MetadataForm class? If not, then I suggest making it a class attribute.

Is the $wgMetadataFormWorkgroups data defined elsewhere, either explicitly or implicitly? If so, we need to centralize its definition. Also, to improve readability, I suggest putting each value of the $wgMetadataFormWorkgroups array on a single line (perhaps prefixed by a tab to make the data stand out).

Renamed $wgCitizendiumWorkgroups, reformatted for readability, kept as global as agreed in reply. Done. --Chris Key 19:05, 7 May 2010 (UTC)

MetadataForm.php

There is no MW standard text to echo in case an extension is executed stand-alone. However, I suggest you prefix the text you have supplied with a simple statement, such as, "This is the MetadataForm extension."

Done --Chris Key 19:06, 7 May 2010 (UTC)

MetadataForm_body.php

1. You probably should use isLoggedIn() rather than isAllowed('edit') to determine whether the user is logged in.

OK. But in that case you should change the error message to stipulate the

user doesn't have the edit right. Dan.

Done. --Chris Key 19:09, 7 May 2010 (UTC)

: Also, you should put the text into the internationalization messages file (there are a couple of other places where you need to do that). Dan.


2. Comment at line 33 "# POST is to create an article" probably should be "# POST is to create metadata". Also, doesn't the extension support editing existing metatdata? If so, then the comment should be "# POST is to create or modify metadata".

Comment modified. Done --Chris Key 19:07, 7 May 2010 (UTC)


3. At line 80 you use the operator "and" rather than "&&". This is obviously for precedence purposes. Personally, I find the precedence differences between 'and' and '&&' to be a source of confusing code. If you must use it, you should format the expression so the 'and' stands out where it is obvious that it is connecting two non-parenthesized expressions (e.g., on a separate line of its own).

Changed to &&. Done --Chris Key 19:07, 7 May 2010 (UTC)

4. Line 232 - not sure why the comment:

//$wgOut->addHTML("<form action='".$self->getLocalURL()."' method='POST'>");

is here. Is this fossil code?

Deleted. Done. --Chris Key 19:07, 7 May 2010 (UTC)