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

End the ungodly racket made by PHP deprecation warnings #24

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drilldown/CargoSpecialDrilldown.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function execute( $query ) {
$this->setHeaders();
$out->addModules( 'ext.cargo.drilldown' );

$queryparts = explode( '/', $query, 1 );
$queryparts = explode( '/', $query ?? '', 1 );
$mainTable = $queryparts[0] ?? '';

// If no table was specified, go with the first table,
Expand Down
13 changes: 9 additions & 4 deletions includes/CargoSQLQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public static function newFromValues( $tablesStr, $fieldsStr, $whereStr, $joinOn
throw new MWException( "At least one table must be specified." );
}

// Needed to avoid various warnings.
if ( $whereStr === null ) {
$whereStr = '';
}

self::validateValues( $tablesStr, $fieldsStr, $whereStr, $joinOnStr, $groupByStr,
$havingStr, $orderByStr, $limitStr, $offsetStr, $allowFieldEscaping );

Expand Down Expand Up @@ -1044,11 +1049,11 @@ private function handleVirtualFields() {
$replacement = "$fieldTableAlias._value";

if ( $foundMatch1 ) {
$this->mGroupByStr = preg_replace( $pattern1, $replacement, $this->mGroupByStr );
$this->mHavingStr = preg_replace( $pattern1, $replacement, $this->mHavingStr );
$this->mGroupByStr = preg_replace( $pattern1, $replacement, $this->mGroupByStr ?? '' );
$this->mHavingStr = preg_replace( $pattern1, $replacement, $this->mHavingStr ?? '' );
} elseif ( $foundMatch2 ) {
$this->mGroupByStr = preg_replace( $pattern2, $replacement, $this->mGroupByStr );
$this->mHavingStr = preg_replace( $pattern2, $replacement, $this->mHavingStr );
$this->mGroupByStr = preg_replace( $pattern2, $replacement, $this->mGroupByStr ?? '' );
$this->mHavingStr = preg_replace( $pattern2, $replacement, $this->mHavingStr ?? '' );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/formats/CargoListFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function displayRow( $row, $fieldDescriptions ) {
if ( !array_key_exists( $fieldName, $row ) ) {
continue;
}
$fieldValue = $row[$fieldName];
$fieldValue = $row[$fieldName] ?? '';
if ( trim( $fieldValue ) == '' ) {
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions includes/formats/CargoTemplateFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ protected function displayRow( $templateName, $row, $fieldDescriptions, $namedAr
// because it's the only one that uses the
// unformatted values - the formatted values
// do this HTML-encoding on their own.
$value = $row[$fieldName] ?? '';
if ( $fieldDescription->mType == 'Wikitext' || $fieldDescription->mType == 'Wikitext string' ) {
$value = htmlspecialchars_decode( $row[$fieldName] );
} else {
$value = $row[$fieldName];
$value = htmlspecialchars_decode( $value );
}
// Escape pipes within the values so that they
// aren't interpreted as template pipes.
Expand Down
6 changes: 4 additions & 2 deletions includes/parserfunctions/CargoStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public static function storeAllData( $title, $tableName, $tableFieldValues, $tab
if ( $fieldDescription->mIsList ) {
$fieldTableName = $tableName . '__' . $fieldName;
$delimiter = $fieldDescription->getDelimiter();
$individualValues = explode( $delimiter, $tableFieldValues[$fieldName] );
$individualValues = explode( $delimiter, $tableFieldValues[$fieldName] ?? '' );
$valueNum = 1;
foreach ( $individualValues as $individualValue ) {
$individualValue = trim( $individualValue );
Expand Down Expand Up @@ -548,7 +548,9 @@ public static function doesRowAlreadyExist( $cdb, $title, $tableName, $tableFiel
$fieldSize = $fieldDescription->getFieldSize();
}

if ( $fieldValue === '' ) {
if ( $fieldValue === null ) {
// Do nothing.
} elseif ( $fieldValue === '' ) {
// Needed for correct SQL handling of blank values, for some reason.
$fieldValue = null;
} elseif ( $fieldSize != null && strlen( $fieldValue ) > $fieldSize ) {
Expand Down
Loading