Completion of first bug

Tomorrow our team’s first complete bug report is due. Our team met this past Saturday and looked at some bugs in Drupal, while I continued to complete the bug from our last team report. I managed to create a solid solution to the bug and made a team report to accompany our other solved bug. Here is a transcript of this report.

Bug 1425138
– node/[id]/Edit (with capital e) renders edit form in default theme (despite admin theme)

About the Bug:

Once we felt comfortable with the process of implementing a fix, we moved on to find a bug that we could fix ourselves and submit to the Drupal project. The following is the bug description:

“When I visit /node/42/edit the node edit form is displayed with the administration theme.
When I visit /node/42/Edit the node edit form is displayed with the default theme.
Happens also if you use eDiT or some other combination. Is also the case for /revisions, /translate etc.”

Solution:

After reviewing the Drupal API, we found that the admin paths are set higher in the class hierarchy. This method, as described by the api, matches the paths in Drupal using patterns (defined as $patterns). In the previous report the creation of these patterns was seen and the bug fix was attempted on that function. The problem is that this method was to clunky to use because one would have to define every single way to capitalize a class path, which creating hundreds of instances. How this function is supposed to be used is to just make a one array to be used in making a map in a higher function. Drupal makes this array of acceptable administrative class paths, then creates a map within the method below in order to avoid creating multiple arrays, saving time and space.

Code from /includes/path.inc, line 489
API source
/**

* Determine whether a path is in the administrative section of the site.

*
* By default, paths are considered to be non-administrative. If a path does not

* match any of the patterns in path_get_admin_paths(), or if it matches both
* administrative and non-administrative patterns, it is considered
* non-administrative.

*
* @param $path

* A Drupal path.

*
* @return

* TRUE if the path is administrative, FALSE otherwise.

*
* @see path_get_admin_paths()

* @see hook_admin_paths()
* @see hook_admin_paths_alter()

*/
function path_is_admin($path) {
$path_map = &drupal_static(FUNCTION);
if (!isset($path_map[‘admin’][$path])) {
$patterns = path_get_admin_paths();
$path_map[‘admin’][$path] = drupal_match_path($path, $patterns[‘admin’]);
$path_map[‘non_admin’][$path] = drupal_match_path($path, $patterns[‘non_admin’]);
}
return $path_map[‘admin’][$path] && !$path_map[‘non_admin’][$path];
}

To fix this bug all that has to be done is apply a strtolower function to the $path input variable. Here is a copy of the posted patch file to reflect the change:

— drupal/includes/path.inc 2012-02-01 17:03:14.000000000 -0500
+++ path.inc 2012-02-13 00:01:15.443036067 -0500
@@ -487,6 +487,7 @@

* @see hook_admin_paths_alter()

*/
function path_is_admin($path) {
+ $path = strtolower($path);
$path_map = &drupal_static(FUNCTION);
if (!isset($path_map[‘admin’][$path])) {
$patterns = path_get_admin_paths();

Results:
The bug was successfully fixed and tested on our team’s basic test cases.

Conclusion

The second patch above has been submitted for peer review on the drupal site here and is now in the testing queue. These bug fixes brought some great experience to our team. It was a good chance to get familiar with the tools available to us. These tools included the community in the form of development mailing lists and MIRC. It also included community documentation such as the api references. These first bugs were also an opportunity to just play around with Drupal. We saw several of its features and how they operate and interact with each other in the code. With this better understanding of Drupal function our team is better at discerning bugs we can fix and how well we can fix them, and most importantly, how long it will take to make a clean fix.

Next week our team will produce a full schedule of planned bug fixes for the rest of the semester. See you all then!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s