PHP strict warnings when running tests

c960657 - December 17, 2008 - 23:54
Project:Drupal
Version:7.x-dev
Component:other
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Almost all tests pass with E_STRICT warnings enabled. This patch fixes the test. There may be more E_STRICT violations in Drupal, but if there is, these aren't covered by tests.

AttachmentSizeStatusTest resultOperations
strict-1.patch4.37 KBIdleFailed: Failed to apply patch.View details | Re-test

#1

Damien Tournoud - December 18, 2008 - 00:29
Status:needs review» needs work

<?php
-    $default = array_shift(array_keys($languages));
+    list(
$default) = array_keys($languages);
   }
   else {
    
$languages = array(
      
t('Already added languages') => $names,
      
t('Languages not yet added') => _locale_prepare_predefined_list()
     );
-   
$default = array_shift(array_keys($names));
+    list(
$default) = array_keys($names);
   }
?>

Those looks like a wicked way of doing $default = key($languages);

<?php
+      $node->taxonomy[arg(3)] = new stdClass();
      
$node->taxonomy[arg(3)]->vid = $vid;
      
$node->taxonomy[arg(3)]->tid = arg(3);
?>

Would be better as:

<?php
$node
->taxonomy[arg(3)] = (object) array(
 
'vid' => $vid,
 
'tid' => arg(3),
);
?>

And

<?php
+          $current = new stdClass();
          
$current->tid = $tids[0];
?>

better as:

<?php
  $current
= (object) array(
   
'tid' => $tids[0],
  );
?>

#2

Dave Reid - December 18, 2008 - 00:52

Also see #325827: Avoid PHP strict timezone warnings by calling date_default_timezone_set in bootstrap to fix strict errors with date functions. I've run into those several times in tests.

#3

c960657 - December 18, 2008 - 18:45
Status:needs work» needs review

This fixes the points raised in #1. Thanks for your prompt review.

AttachmentSizeStatusTest resultOperations
strict-2.patch4.53 KBIdleFailed: Failed to apply patch.View details | Re-test

#4

Dries - December 19, 2008 - 03:50
Status:needs review» needs work

By default, the tests run with 0 errors and 0 exceptions. So, I modified _drupal_error_handler in common.inc to report E_ALL and E_STRICT errors. I think we should set the error handler to E_STRICT during the development cycle. That should probably be part of this patch. Unfortunately, setting it to E_STRICT results in additional errors not covered by this patch.

#5

Dave Reid - December 19, 2008 - 19:11
Priority:normal» critical

This patch was accidentally committed along with #323528: UPDATE queries should not use aliases. http://drupal.org/cvs?commit=159769

#6

Damien Tournoud - December 20, 2008 - 13:54
Status:needs work» fixed

It doesn't really matter. Let's mark this one as fixed for now. Thanks for the patch, Christian.

#7

c960657 - December 23, 2008 - 15:01

So, I modified _drupal_error_handler in common.inc to report E_ALL and E_STRICT errors. [...] Unfortunately, setting it to E_STRICT results in additional errors not covered by this patch.

Not that you cannot simply replace if ($error_level & error_reporting()) with if ($error_level & (E_ALL | E_STRICT)) in _drupal_error_handler() – that would cause errors muted with @ to pop up which is probably not intended.

With this patch and error_reporting set to E_ALL | E_STRICT in .htaccess, I don't see any strict errors when running the test suite.

WRT using E_STRICT during the development cycle I created #350543: Use E_STRICT error reporting.

#8

cdale - December 24, 2008 - 01:17

I get a "Creating default object from empty value" From the aggregator module when running tests. This patch fixes that warning.

AttachmentSizeStatusTest resultOperations
aggregator-e-strict.patch764 bytesIdleFailed: Failed to apply patch.View details | Re-test

#9

cdale - December 24, 2008 - 01:18
Status:fixed» needs review

#10

Dave Reid - December 24, 2008 - 14:24

Could you also throw a 'stdClass' type hint on that parameter while you're there as well?
function aggregator_form_feed(&$form_state, stdClass $feed = NULL) {

#11

cdale - December 24, 2008 - 20:08

Done.

AttachmentSizeStatusTest resultOperations
aggregator-e-strict-11.patch919 bytesIdleFailed: Failed to apply patch.View details | Re-test

#12

Damien Tournoud - December 30, 2008 - 01:58
Priority:critical» normal
Status:needs review» needs work

In that case, it would looks better with a !isset() instead of the empty().

#13

c960657 - January 10, 2009 - 23:24
Status:needs work» needs review

Changed to isset(), and fixed prepareQuery() in sqlite that caused a strict error during install.

AttachmentSizeStatusTest resultOperations
strict-3.patch2.37 KBIdleFailed: Failed to apply patch.View details | Re-test

#14

Dries - January 11, 2009 - 08:36
Status:needs review» fixed

Committed to CVS HEAD. Thanks.

#15

c960657 - January 13, 2009 - 20:54
Status:fixed» needs review

Fix for more strict warnings introduced with #348201: Multiple load files, #341910: file_space_used() not checking properly checking bitmapped status value (adds unit tests) and #8: Let users cancel their accounts. With this patch, the whole suite again runs without strict warnings.

AttachmentSizeStatusTest resultOperations
strict-4.patch6.77 KBIdleFailed: Failed to apply patch.View details | Re-test

#17

c960657 - February 1, 2009 - 17:33

Updated with some fixes for the drupal_render(node_build($node)) pattern.

AttachmentSizeStatusTest resultOperations
strict-5.patch13.51 KBIdleFailed: Failed to apply patch.View details | Re-test

#18

Dries - February 3, 2009 - 12:31

How can we configure the test framework so that strict warnings always show up? :)

#19

c960657 - February 3, 2009 - 12:44

When #325827: Avoid PHP strict timezone warnings by calling date_default_timezone_set in bootstrap is fixed, we can enable E_STRICT permanently in #350543: Use E_STRICT error reporting, and then the test framework will automatically detect strict errors.

In the meantime I guess it is possible to enable E_STRICT error reporting on the testbot machines using php.ini.

#20

Dries - February 3, 2009 - 13:07

I seems our efforts are best spent getting these patches in then, instead of repeatedly chasing HEAD to be E_STRICT compliant. At least, that is my take on this situation.

#21

System Message - February 3, 2009 - 21:35
Status:needs review» needs work

The last submitted patch failed testing.

#22

mfb - June 26, 2009 - 02:19
Status:needs work» needs review

Rerolled including fixes for lots more strict notices.

AttachmentSizeStatusTest resultOperations
strict.patch20.52 KBIdleFailed: Failed to apply patch.View details | Re-test

#23

System Message - June 27, 2009 - 19:17
Status:needs review» needs work

The last submitted patch failed testing.

#24

mfb - June 28, 2009 - 01:25
Status:needs work» needs review

chasing HEAD.

AttachmentSizeStatusTest resultOperations
strict.patch19.82 KBIgnoredNoneNone

#25

mfb - June 28, 2009 - 01:28

Hmm that was weird my comment didn't show up.

AttachmentSizeStatusTest resultOperations
strict.patch19.82 KBIgnoredNoneNone

#26

mfb - July 24, 2009 - 00:13

chasing HEAD

AttachmentSizeStatusTest resultOperations
strict.patch22.1 KBIgnoredNoneNone

#27

mfb - July 24, 2009 - 06:27

Found a few more strict errors.

AttachmentSizeStatusTest resultOperations
strict.patch24.4 KBIgnoredNoneNone

#28

mfb - August 11, 2009 - 20:54

fix another strict notice in image module

AttachmentSizeStatusTest resultOperations
strict.patch22.23 KBIgnoredNoneNone

#29

mfb - August 29, 2009 - 01:17

chasing HEAD

AttachmentSizeStatusTest resultOperations
strict.patch24.37 KBIdleFailed: Failed to apply patch.View details | Re-test

#30

mfb - August 29, 2009 - 03:22

Missed one strict notice

AttachmentSizeStatusTest resultOperations
strict.patch24.63 KBIdleFailed: Failed to apply patch.View details | Re-test

#31

System Message - September 6, 2009 - 05:40
Status:needs review» needs work

The last submitted patch failed testing.

#32

mfb - September 9, 2009 - 20:52
Status:needs work» needs review

Re-roll and fix some non-static functions that should be static.

AttachmentSizeStatusTest resultOperations
strict.patch22.07 KBIdleFailed: Failed to apply patch.View details | Re-test

#33

mfb - September 9, 2009 - 20:54

Re-roll and fix some non-static functions that should be static.

AttachmentSizeStatusTest resultOperations
strict.patch24.62 KBIdleFailed: Failed to apply patch.View details | Re-test

#34

mfb - September 10, 2009 - 02:09

Found a few more strict notices.

AttachmentSizeStatusTest resultOperations
strict.patch28.41 KBIdleFailed: Invalid PHP syntax in update.php.View details | Re-test

#35

System Message - September 19, 2009 - 08:00
Status:needs review» needs work

The last submitted patch failed testing.

#36

mfb - September 19, 2009 - 17:02
Category:task» bug report
Status:needs work» needs review

fixed yet another drupal_render() issue, in book.module

AttachmentSizeStatusTest resultOperations
strict.patch29.03 KBIdleFailed: Failed to apply patch.View details | Re-test

#37

System Message - September 21, 2009 - 17:45
Status:needs review» needs work

The last submitted patch failed testing.

#38

mfb - September 22, 2009 - 03:29
Status:needs work» needs review

reroll

AttachmentSizeStatusTest resultOperations
strict.patch25.82 KBIdleFailed: Invalid PHP syntax in update.php.View details | Re-test

#39

mfb - September 29, 2009 - 05:07

Add a tweak from #561624: Strict error due to function signature incompatibility of TaxonomyTermController::cacheGet() -- pass $conditions thru to parent::cacheGet()

AttachmentSizeStatusTest resultOperations
strict.patch25.9 KBIdleFailed: Failed to apply patch.View details | Re-test

#40

System Message - October 9, 2009 - 18:40
Status:needs review» needs work

The last submitted patch failed testing.

#41

mfb - October 12, 2009 - 05:30
Status:needs work» needs review

Reroll

AttachmentSizeStatusTest resultOperations
strict.patch24.98 KBIdleFailed: Failed to apply patch.View details | Re-test

#42

webchick - October 12, 2009 - 05:37

Thanks for these clean-ups. However, I don't see anything in here that will keep the test bot running in E_STRICT mode and prevent you from having to re-roll this patch another 100,000 times throughout the development cycle.

In other words, can we fix #325827: Avoid PHP strict timezone warnings by calling date_default_timezone_set in bootstrap and #350543: Use E_STRICT error reporting as part of this patch?

#43

mfb - October 12, 2009 - 07:14

Here I enabled E_STRICT reporting in .htaccess so it can catch compile-time strict warnings; calling error_reporting() at runtime doesn't have the same effect. Will mark #350543: Use E_STRICT error reporting as a duplicate. The only issue with .htaccess is we cannot use PHP constants E_ALL | E_STRICT. This page suggests using a large number since new error levels will be added over time: http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-repor...

I also tweaked _drupal_log_error() to not display strict warnings if the error level is set to ERROR_REPORTING_DISPLAY_SOME (whereas before it only avoided displaying notices).

There may be some other strict warnings that test bot finds so let's see if this works...

AttachmentSizeStatusTest resultOperations
strict.patch28.79 KBIdleFailed: 13764 passes, 3 fails, 19611 exceptionsView details | Re-test

#44

System Message - October 12, 2009 - 07:30
Status:needs review» needs work

The last submitted patch failed testing.

#45

mfb - October 12, 2009 - 17:01
Status:needs work» needs review

Well that was spectacular. Looks like the test server doesn't have a time zone configured so I also have to merge in #325827: Avoid PHP strict timezone warnings by calling date_default_timezone_set in bootstrap

Note that unlike the rest of this patch, #325827: Avoid PHP strict timezone warnings by calling date_default_timezone_set in bootstrap results in a major functional change: any 3rd-party code that calls date/time functions will use a different time zone depending on the current user.

AttachmentSizeStatusTest resultOperations
strict.patch34.89 KBIdleFailed: Failed to apply patch.View details | Re-test

#46

mfb - October 12, 2009 - 17:32

#47

System Message - October 13, 2009 - 17:53
Status:needs review» needs work

The last submitted patch failed testing.

#48

mfb - October 15, 2009 - 18:02
Status:needs work» needs review

hmm I could not reproduce this test failure

#49

System Message - November 2, 2009 - 06:00
Status:needs review» needs work

The last submitted patch failed testing.

#50

mfb - November 2, 2009 - 16:49
Status:needs work» needs review

Rerolled

AttachmentSizeStatusTest resultOperations
strict.patch39.15 KBIdleFailed: Failed to apply patch.View details | Re-test

#51

System Message - November 5, 2009 - 08:30
Status:needs review» needs work

The last submitted patch failed testing.

#52

mfb - November 12, 2009 - 07:07
Status:needs work» needs review

rerolled

AttachmentSizeStatusTest resultOperations
strict.patch38.99 KBIdlePassed: 14766 passes, 0 fails, 0 exceptionsView details | Re-test
 
 

Drupal is a registered trademark of Dries Buytaert.